27 #include "llvm/ADT/TypeSwitch.h"
30 using namespace ROCDL;
32 #include "mlir/Dialect/LLVMIR/ROCDLOpsDialect.cpp.inc"
52 return parser.
resolveOperands(ops, {i32x4Ty, int32Ty, int32Ty, int32Ty},
57 p <<
" " << getOperands() <<
" : " << getRes().getType();
74 if (parser.
resolveOperands(ops, {type, i32x4Ty, int32Ty, int32Ty, int32Ty},
81 p <<
" " << getOperands() <<
" : " << getVdata().getType();
98 if (parser.
resolveOperands(ops, {type, i32x4Ty, int32Ty, int32Ty, int32Ty},
105 p <<
" " << getOperands() <<
" : " << getVdata().getType();
122 if (parser.
resolveOperands(ops, {type, i32x4Ty, int32Ty, int32Ty, int32Ty},
129 p <<
" " << getOperands() <<
" : " << getVdata().getType();
146 if (parser.
resolveOperands(ops, {type, i32x4Ty, int32Ty, int32Ty, int32Ty},
153 p <<
" " << getOperands() <<
" : " << getVdata().getType();
170 if (parser.
resolveOperands(ops, {type, i32x4Ty, int32Ty, int32Ty, int32Ty},
177 p <<
" " << getOperands() <<
" : " << getVdata().getType();
194 void ROCDLDialect::initialize() {
197 #include "mlir/Dialect/LLVMIR/ROCDLOps.cpp.inc"
201 #define GET_ATTRDEF_LIST
202 #include "mlir/Dialect/LLVMIR/ROCDLOpsAttributes.cpp.inc"
206 allowUnknownOperations();
207 addInterfaces<ROCDLInlinerInterface>();
208 declarePromisedInterface<gpu::TargetAttrInterface, ROCDLTargetAttr>();
211 LogicalResult ROCDLDialect::verifyOperationAttribute(
Operation *op,
214 if (kernelAttrName.getName() == attr.
getName()) {
215 if (!isa<LLVM::LLVMFuncOp>(op)) {
216 return op->
emitError() <<
"'" << kernelAttrName.getName()
217 <<
"' attribute attached to unexpected op";
228 int optLevel, StringRef triple, StringRef chip,
229 StringRef features, StringRef abiVersion,
230 DictionaryAttr flags, ArrayAttr files) {
231 if (optLevel < 0 || optLevel > 3) {
232 emitError() <<
"The optimization level must be a number between 0 and 3.";
235 if (triple.empty()) {
236 emitError() <<
"The target triple cannot be empty.";
240 emitError() <<
"The target chip cannot be empty.";
243 if (abiVersion !=
"400" && abiVersion !=
"500" && abiVersion !=
"600") {
244 emitError() <<
"Invalid ABI version, it must be `400`, `500` or '600'.";
248 return attr && mlir::isa<StringAttr>(attr);
250 emitError() <<
"All the elements in the `link` array must be strings.";
256 #define GET_OP_CLASSES
257 #include "mlir/Dialect/LLVMIR/ROCDLOps.cpp.inc"
259 #define GET_ATTRDEF_CLASSES
260 #include "mlir/Dialect/LLVMIR/ROCDLOpsAttributes.cpp.inc"
static bool isLegalToInline(InlinerInterface &interface, Region *src, Region *insertRegion, bool shouldCloneInlinedRegion, IRMapping &valueMapping)
Utility to check that all of the operations within 'src' can be inlined.
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...
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 is the interface that must be implemented by the dialects of operations to be inlined.
DialectInlinerInterface(Dialect *dialect)
This is a utility class for mapping one set of IR entities to another.
This class represents a diagnostic that is inflight and set to be reported.
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 contains a list of basic blocks and a link to the parent operation it is attached to.
Instances of the Type class are uniqued, have an immutable identifier and an optional mutable compone...
QueryRef parse(llvm::StringRef line, const QuerySession &qs)
Include the generated interface declarations.
InFlightDiagnostic emitError(Location loc)
Utility method to emit an error message using this location.
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 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.