-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'Xilinx:main' into 1171-improve-type-constraints-for-aie…
…vecmul_elem-and-co
- Loading branch information
Showing
14 changed files
with
629 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
//===- TargetModel.h --------------------------------------------*- C++ -*-===// | ||
// | ||
// This file is licensed under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
// (c) Copyright 2024 Advanced Micro Devices, Inc. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef AIE_C_TARGETMODEL_H | ||
#define AIE_C_TARGETMODEL_H | ||
|
||
#include "mlir-c/IR.h" | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
//===----------------------------------------------------------------------===// | ||
// Opaque type declarations. | ||
// | ||
// Types are exposed to C bindings as structs containing opaque pointers. They | ||
// are not supposed to be inspected from C. This allows the underlying | ||
// representation to change without affecting the API users. The use of structs | ||
// instead of typedefs enables some type safety as structs are not implicitly | ||
// convertible to each other. | ||
// | ||
// Instances of these types may or may not own the underlying object. The | ||
// ownership semantics is defined by how an instance of the type was obtained. | ||
//===----------------------------------------------------------------------===// | ||
|
||
#define DEFINE_C_API_STRUCT(name, storage) \ | ||
struct name { \ | ||
storage d; \ | ||
}; \ | ||
typedef struct name name | ||
|
||
DEFINE_C_API_STRUCT(AieTargetModel, uint32_t); | ||
|
||
#undef DEFINE_C_API_STRUCT | ||
|
||
MLIR_CAPI_EXPORTED AieTargetModel aieGetTargetModel(uint32_t device); | ||
|
||
/// Returns the number of columns in the target model. | ||
MLIR_CAPI_EXPORTED int aieTargetModelColumns(AieTargetModel targetModel); | ||
|
||
/// Returns the number of rows in the target model. | ||
MLIR_CAPI_EXPORTED int aieTargetModelRows(AieTargetModel targetModel); | ||
|
||
/// Returns true if this is an NPU target model. | ||
MLIR_CAPI_EXPORTED bool aieTargetModelIsNPU(AieTargetModel targetModel); | ||
|
||
MLIR_CAPI_EXPORTED bool aieTargetModelIsCoreTile(AieTargetModel targetModel, | ||
int col, int row); | ||
|
||
MLIR_CAPI_EXPORTED bool aieTargetModelIsMemTile(AieTargetModel targetModel, | ||
int col, int row); | ||
|
||
MLIR_CAPI_EXPORTED bool aieTargetModelIsShimNOCTile(AieTargetModel targetModel, | ||
int col, int row); | ||
|
||
MLIR_CAPI_EXPORTED bool aieTargetModelIsShimPLTile(AieTargetModel targetModel, | ||
int col, int row); | ||
|
||
MLIR_CAPI_EXPORTED bool | ||
aieTargetModelIsShimNOCorPLTile(AieTargetModel targetModel, int col, int row); | ||
|
||
MLIR_CAPI_EXPORTED bool aieTargetModelIsInternal(AieTargetModel targetModel, | ||
int src_col, int src_row, | ||
int dst_col, int dst_row); | ||
|
||
MLIR_CAPI_EXPORTED bool aieTargetModelIsWest(AieTargetModel targetModel, | ||
int src_col, int src_row, | ||
int dst_col, int dst_row); | ||
|
||
MLIR_CAPI_EXPORTED bool aieTargetModelIsEast(AieTargetModel targetModel, | ||
int src_col, int src_row, | ||
int dst_col, int dst_row); | ||
|
||
MLIR_CAPI_EXPORTED bool aieTargetModelIsNorth(AieTargetModel targetModel, | ||
int src_col, int src_row, | ||
int dst_col, int dst_row); | ||
|
||
MLIR_CAPI_EXPORTED bool aieTargetModelIsSouth(AieTargetModel targetModel, | ||
int src_col, int src_row, | ||
int dst_col, int dst_row); | ||
|
||
MLIR_CAPI_EXPORTED bool aieTargetModelIsMemWest(AieTargetModel targetModel, | ||
int src_col, int src_row, | ||
int dst_col, int dst_row); | ||
|
||
MLIR_CAPI_EXPORTED bool aieTargetModelIsMemEast(AieTargetModel targetModel, | ||
int src_col, int src_row, | ||
int dst_col, int dst_row); | ||
|
||
MLIR_CAPI_EXPORTED bool aieTargetModelIsMemNorth(AieTargetModel targetModel, | ||
int src_col, int src_row, | ||
int dst_col, int dst_row); | ||
|
||
MLIR_CAPI_EXPORTED bool aieTargetModelIsMemSouth(AieTargetModel targetModel, | ||
int src_col, int src_row, | ||
int dst_col, int dst_row); | ||
|
||
MLIR_CAPI_EXPORTED bool | ||
aieTargetModelIsLegalMemAffinity(AieTargetModel targetModel, int src_col, | ||
int src_row, int dst_col, int dst_row); | ||
|
||
MLIR_CAPI_EXPORTED uint32_t | ||
aieTargetModelGetMemSouthBaseAddress(AieTargetModel targetModel); | ||
|
||
MLIR_CAPI_EXPORTED uint32_t | ||
aieTargetModelGetMemNorthBaseAddress(AieTargetModel targetModel); | ||
|
||
MLIR_CAPI_EXPORTED uint32_t | ||
aieTargetModelGetMemEastBaseAddress(AieTargetModel targetModel); | ||
|
||
MLIR_CAPI_EXPORTED uint32_t | ||
aieTargetModelGetMemWestBaseAddress(AieTargetModel targetModel); | ||
|
||
MLIR_CAPI_EXPORTED uint32_t | ||
aieTargetModelGetLocalMemorySize(AieTargetModel targetModel); | ||
|
||
MLIR_CAPI_EXPORTED uint32_t | ||
aieTargetModelGetNumLocks(AieTargetModel targetModel, int col, int row); | ||
|
||
MLIR_CAPI_EXPORTED uint32_t aieTargetModelGetNumBDs(AieTargetModel targetModel, | ||
int col, int row); | ||
|
||
MLIR_CAPI_EXPORTED uint32_t | ||
aieTargetModelGetNumMemTileRows(AieTargetModel targetModel); | ||
|
||
MLIR_CAPI_EXPORTED uint32_t | ||
aieTargetModelGetMemTileSize(AieTargetModel targetModel); | ||
|
||
/// Returns true if this is an NPU target model. | ||
MLIR_CAPI_EXPORTED bool aieTargetModelIsNPU(AieTargetModel targetModel); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif // AIE_C_TARGETMODEL_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
//===- XLLVMTypeConstraints.td - XLLVM type constraints. --*- tablegen -*-====// | ||
// | ||
// This file is licensed under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
// (c) Copyright 2024 Advanced Micro Devices, Inc. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
// Defines type constraints for LLVM types used in XLLVM intrinsic op | ||
// definitions. | ||
//===----------------------------------------------------------------------===// | ||
|
||
|
||
#ifndef AIE_DIALECT_XLLVM_IR_XLLVMTYPECONSTRAINTS_TD | ||
#define AIE_DIALECT_XLLVM_IR_XLLVMTYPECONSTRAINTS_TD | ||
|
||
class EnumeratedType<Type ty, int idx> { | ||
Type type = ty; | ||
int index = idx; | ||
} | ||
|
||
class EnumerateTypeListFrom<list<Type> tlist, int from = 0> { | ||
list<EnumeratedType> sequence = | ||
!if(!empty(tlist), [], | ||
!listconcat( | ||
[EnumeratedType<!head(tlist), from>], | ||
EnumerateTypeListFrom<!tail(tlist), !add(from, 1)>.sequence | ||
)); | ||
} | ||
|
||
class LLVM_StructOf<list<Type> structTypes> : | ||
Type< | ||
And<[LLVM_AnyStruct.predicate, | ||
CPred<"cast<::mlir::LLVM::LLVMStructType>($_self).getBody().size() == " # !size(structTypes)>, | ||
And<!foreach(enumTy, EnumerateTypeListFrom<structTypes>.sequence, | ||
SubstLeaves<"$_self", | ||
"cast<::mlir::LLVM::LLVMStructType>($_self).getBody()[" # enumTy.index # "]", | ||
enumTy.type.predicate> | ||
) | ||
> | ||
]>, | ||
"an LLVM struct of {" # !interleave(!foreach(ty, structTypes, ty.summary), "; ") # "}" | ||
>; | ||
|
||
#endif // AIE_DIALECT_XLLVM_IR_XLLVMTYPECONSTRAINTS_TD |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.