26 #include "llvm/ADT/TypeSwitch.h"
27 #include "llvm/AsmParser/Parser.h"
28 #include "llvm/IR/Attributes.h"
29 #include "llvm/IR/Function.h"
30 #include "llvm/IR/Type.h"
31 #include "llvm/Support/SourceMgr.h"
34 using namespace ROCDL;
36 #include "mlir/Dialect/LLVMIR/ROCDLOpsDialect.cpp.inc"
57 {i32x4Ty, int32Ty, int32Ty, int1Ty, int1Ty},
62 p <<
" " << getOperands() <<
" : " << (*this)->getResultTypes();
80 {type, i32x4Ty, int32Ty, int32Ty, int1Ty, int1Ty},
87 p <<
" " << getOperands() <<
" : " << getVdata().getType();
104 return parser.
resolveOperands(ops, {i32x4Ty, int32Ty, int32Ty, int32Ty},
109 p <<
" " << getOperands() <<
" : " << getRes().getType();
126 if (parser.
resolveOperands(ops, {type, i32x4Ty, int32Ty, int32Ty, int32Ty},
133 p <<
" " << getOperands() <<
" : " << getVdata().getType();
150 if (parser.
resolveOperands(ops, {type, i32x4Ty, int32Ty, int32Ty, int32Ty},
157 p <<
" " << getOperands() <<
" : " << getVdata().getType();
174 if (parser.
resolveOperands(ops, {type, i32x4Ty, int32Ty, int32Ty, int32Ty},
181 p <<
" " << getOperands() <<
" : " << getVdata().getType();
198 if (parser.
resolveOperands(ops, {type, i32x4Ty, int32Ty, int32Ty, int32Ty},
205 p <<
" " << getOperands() <<
" : " << getVdata().getType();
222 if (parser.
resolveOperands(ops, {type, i32x4Ty, int32Ty, int32Ty, int32Ty},
229 p <<
" " << getOperands() <<
" : " << getVdata().getType();
237 void ROCDLDialect::initialize() {
240 #include "mlir/Dialect/LLVMIR/ROCDLOps.cpp.inc"
244 #define GET_ATTRDEF_LIST
245 #include "mlir/Dialect/LLVMIR/ROCDLOpsAttributes.cpp.inc"
249 allowUnknownOperations();
250 declarePromisedInterface<gpu::TargetAttrInterface, ROCDLTargetAttr>();
256 if (kernelAttrName.getName() == attr.
getName()) {
257 if (!isa<LLVM::LLVMFuncOp>(op)) {
258 return op->
emitError() <<
"'" << kernelAttrName.getName()
259 <<
"' attribute attached to unexpected op";
270 int optLevel, StringRef triple, StringRef chip,
271 StringRef features, StringRef abiVersion,
272 DictionaryAttr flags, ArrayAttr files) {
273 if (optLevel < 0 || optLevel > 3) {
274 emitError() <<
"The optimization level must be a number between 0 and 3.";
277 if (triple.empty()) {
278 emitError() <<
"The target triple cannot be empty.";
282 emitError() <<
"The target chip cannot be empty.";
285 if (abiVersion !=
"400" && abiVersion !=
"500") {
286 emitError() <<
"Invalid ABI version, it must be either `400` or `500`.";
290 return attr && mlir::isa<StringAttr>(attr);
292 emitError() <<
"All the elements in the `link` array must be strings.";
298 #define GET_OP_CLASSES
299 #include "mlir/Dialect/LLVMIR/ROCDLOps.cpp.inc"
301 #define GET_ATTRDEF_CLASSES
302 #include "mlir/Dialect/LLVMIR/ROCDLOpsAttributes.cpp.inc"
static void print(spirv::VerCapExtAttr triple, DialectAsmPrinter &printer)
virtual Builder & getBuilder() const =0
Return a builder which provides useful access to MLIRContext, global objects like types and attribute...
MLIRContext * getContext() const
ParseResult addTypeToList(Type type, SmallVectorImpl< Type > &result)
Add the specified type to the end of the specified type list and return success.
virtual ParseResult parseColonType(Type &result)=0
Parse a colon followed by a type.
virtual SMLoc getNameLoc() const =0
Return the location of the original name token.
Attributes are known-constant values of operations.
This class represents a diagnostic that is inflight and set to be reported.
MLIRContext is the top-level object for a collection of MLIR operations.
NamedAttribute represents a combination of a name and an Attribute value.
StringAttr getName() const
Return the name of the attribute.
The OpAsmParser has methods for interacting with the asm parser: parsing things from it,...
ParseResult resolveOperands(Operands &&operands, Type type, SmallVectorImpl< Value > &result)
Resolve a list of operands to SSA values, emitting an error on failure, or appending the results to t...
virtual ParseResult parseOperandList(SmallVectorImpl< UnresolvedOperand > &result, Delimiter delimiter=Delimiter::None, bool allowResultNumber=true, int requiredOperandCount=-1)=0
Parse zero or more SSA comma-separated operand references with a specified surrounding delimiter,...
This is a pure-virtual base class that exposes the asmprinter hooks necessary to implement a custom p...
Operation is the basic unit of execution within MLIR.
InFlightDiagnostic emitError(const Twine &message={})
Emit an error about fatal conditions with this operation, reporting up to any diagnostic handlers tha...
This class represents success/failure for parsing-like operations that find it important to chain tog...
Instances of the Type class are uniqued, have an immutable identifier and an optional mutable compone...
Type getFixedVectorType(Type elementType, unsigned numElements)
Creates an LLVM dialect-compatible type with the given element type and length.
QueryRef parse(llvm::StringRef line, const QuerySession &qs)
Include the generated interface declarations.
LogicalResult failure(bool isFailure=true)
Utility function to generate a LogicalResult.
InFlightDiagnostic emitError(Location loc)
Utility method to emit an error message using this location.
LogicalResult success(bool isSuccess=true)
Utility function to generate a LogicalResult.
auto get(MLIRContext *context, Ts &&...params)
Helper method that injects context only if needed, this helps unify some of the attribute constructio...
LogicalResult verify(Operation *op, bool verifyRecursively=true)
Perform (potentially expensive) checks of invariants, used to detect compiler bugs,...
This class represents an efficient way to signal success or failure.
This represents an operation in an abstracted form, suitable for use with the builder APIs.
SmallVector< Value, 4 > operands
SmallVector< Type, 4 > types
Types of the results of this operation.