27#include "llvm/ADT/TypeSwitch.h"
32#include "mlir/Dialect/LLVMIR/ROCDLOpsDialect.cpp.inc"
41ParseResult RawBufferLoadOp::parse(
OpAsmParser &parser,
51 auto i32x4Ty = VectorType::get({4}, int32Ty);
52 return parser.
resolveOperands(ops, {i32x4Ty, int32Ty, int32Ty, int32Ty},
57 p <<
" " << getOperands() <<
" : " << getRes().getType();
63ParseResult RawBufferStoreOp::parse(
OpAsmParser &parser,
72 auto i32x4Ty = VectorType::get({4}, int32Ty);
74 if (parser.
resolveOperands(ops, {type, i32x4Ty, int32Ty, int32Ty, int32Ty},
81 p <<
" " << getOperands() <<
" : " << getVdata().getType();
87ParseResult RawBufferAtomicFAddOp::parse(
OpAsmParser &parser,
97 auto i32x4Ty = VectorType::get({4}, int32Ty);
99 if (parser.
resolveOperands(ops, {type, i32x4Ty, int32Ty, int32Ty, int32Ty},
106 p <<
" " << getOperands() <<
" : " << getVdata().getType();
112ParseResult RawBufferAtomicFMaxOp::parse(
OpAsmParser &parser,
122 auto i32x4Ty = VectorType::get({4}, int32Ty);
124 if (parser.
resolveOperands(ops, {type, i32x4Ty, int32Ty, int32Ty, int32Ty},
131 p <<
" " << getOperands() <<
" : " << getVdata().getType();
137ParseResult RawBufferAtomicSMaxOp::parse(
OpAsmParser &parser,
147 auto i32x4Ty = VectorType::get({4}, int32Ty);
149 if (parser.
resolveOperands(ops, {type, i32x4Ty, int32Ty, int32Ty, int32Ty},
156 p <<
" " << getOperands() <<
" : " << getVdata().getType();
162ParseResult RawBufferAtomicUMinOp::parse(
OpAsmParser &parser,
172 auto i32x4Ty = VectorType::get({4}, int32Ty);
174 if (parser.
resolveOperands(ops, {type, i32x4Ty, int32Ty, int32Ty, int32Ty},
181 p <<
" " << getOperands() <<
" : " << getVdata().getType();
189struct ROCDLInlinerInterface final : DialectInlinerInterface {
190 using DialectInlinerInterface::DialectInlinerInterface;
191 bool isLegalToInline(Operation *, Region *,
bool, IRMapping &)
const final {
198void ROCDLDialect::initialize() {
201#include "mlir/Dialect/LLVMIR/ROCDLOps.cpp.inc"
205#define GET_ATTRDEF_LIST
206#include "mlir/Dialect/LLVMIR/ROCDLOpsAttributes.cpp.inc"
210 allowUnknownOperations();
211 addInterfaces<ROCDLInlinerInterface>();
212 declarePromisedInterface<gpu::TargetAttrInterface, ROCDLTargetAttr>();
215LogicalResult ROCDLDialect::verifyOperationAttribute(
Operation *op,
218 if (kernelAttrName.getName() == attr.
getName()) {
219 if (!isa<LLVM::LLVMFuncOp>(op)) {
220 return op->
emitError() <<
"'" << kernelAttrName.getName()
221 <<
"' attribute attached to unexpected op";
232 int optLevel, StringRef triple, StringRef chip,
233 StringRef features, StringRef abiVersion,
235 if (optLevel < 0 || optLevel > 3) {
236 emitError() <<
"The optimization level must be a number between 0 and 3.";
239 if (triple.empty()) {
240 emitError() <<
"The target triple cannot be empty.";
244 emitError() <<
"The target chip cannot be empty.";
247 if (abiVersion !=
"400" && abiVersion !=
"500" && abiVersion !=
"600") {
248 emitError() <<
"Invalid ABI version, it must be `400`, `500` or '600'.";
251 if (files && !llvm::all_of(files, [](::mlir::Attribute attr) {
252 return attr && mlir::isa<StringAttr>(attr);
254 emitError() <<
"All the elements in the `link` array must be strings.";
260#define GET_OP_CLASSES
261#include "mlir/Dialect/LLVMIR/ROCDLOps.cpp.inc"
263#define GET_ATTRDEF_CLASSES
264#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.
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.
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...
Instances of the Type class are uniqued, have an immutable identifier and an optional mutable compone...
Include the generated interface declarations.
InFlightDiagnostic emitError(Location loc)
Utility method to emit an error message using this location.
llvm::function_ref< Fn > function_ref
This represents an operation in an abstracted form, suitable for use with the builder APIs.