8 #ifndef MLIR_CONVERSION_GPUCOMMON_INDEXINTRINSICSOPLOWERING_H_ 9 #define MLIR_CONVERSION_GPUCOMMON_INDEXINTRINSICSOPLOWERING_H_ 15 #include "llvm/ADT/StringSwitch.h" 24 template <
typename Op,
typename XOp,
typename YOp,
typename ZOp>
27 enum dimension { X = 0, Y = 1, Z = 2, invalid };
28 unsigned indexBitwidth;
30 static dimension dimensionToIndex(
Op op) {
31 return llvm::StringSwitch<dimension>(op.dimension())
40 return dialect->
getLLVMModule().getDataLayout().getPointerSizeInBits();
46 lowering_.getDialect()->getContext(), lowering_),
47 indexBitwidth(getIndexBitWidth(lowering_)) {}
56 switch (dimensionToIndex(cast<Op>(op))) {
70 if (indexBitwidth > 32) {
71 newOp = rewriter.
create<LLVM::SExtOp>(
73 }
else if (indexBitwidth < 32) {
74 newOp = rewriter.
create<LLVM::TruncOp>(
85 #endif // MLIR_CONVERSION_GPUCOMMON_INDEXINTRINSICSOPLOWERING_H_ Definition: InferTypeOpInterface.cpp:20
Definition: IndexIntrinsicsOpLowering.h:25
Definition: Operation.h:27
static LLVMType getIntNTy(LLVMDialect *dialect, unsigned numBits)
Utilities used to generate integer types.
Definition: LLVMDialect.cpp:1589
LLVMTypeConverter & lowering
Definition: ConvertStandardToLLVM.h:239
OpTy create(Location location, Args... args)
Definition: PatternMatch.h:265
void replaceOp(Operation *op, ValueRange newValues, ValueRange valuesToRemoveIfDead) override
PatternRewriter hook for replacing the results of an operation.
Definition: DialectConversion.cpp:841
static LLVMType getInt32Ty(LLVMDialect *dialect)
Definition: LLVMDialect.h:112
Location getLoc()
The source location the operation was defined or derived from.
Definition: Operation.h:107
PatternMatchResult matchSuccess(std::unique_ptr< PatternState > state={}) const
This method indicates that a match was found and has the specified cost.
Definition: PatternMatch.h:116
GPUIndexIntrinsicOpLowering(LLVMTypeConverter &lowering_)
Definition: IndexIntrinsicsOpLowering.h:44
Conversion from types in the Standard dialect to the LLVM IR dialect.
Definition: ConvertStandardToLLVM.h:37
Definition: DialectConversion.h:311
llvm::Module & getLLVMModule()
Definition: LLVMDialect.cpp:1436
Definition: OpDefinition.h:949
static PatternMatchResult matchFailure()
This method indicates that no match was found.
Definition: PatternMatch.h:112
PatternMatchResult matchAndRewrite(Operation *op, ArrayRef< Value > operands, ConversionPatternRewriter &rewriter) const override
Hook for derived classes to implement combined matching and rewriting.
Definition: IndexIntrinsicsOpLowering.h:51
Definition: ConvertStandardToLLVM.h:231
LLVM::LLVMDialect * getDialect()
Returns the LLVM dialect.
Definition: ConvertStandardToLLVM.h:63