28 #include "llvm/Support/raw_ostream.h"
30 #define DEBUG_TYPE "nvvm-to-llvm"
31 #define DBGS() (llvm::dbgs() << "[" DEBUG_TYPE "]: ")
32 #define DBGSNL() (llvm::dbgs() << "\n")
35 #define GEN_PASS_DEF_CONVERTNVVMTOLLVMPASS
36 #include "mlir/Conversion/Passes.h.inc"
52 LogicalResult matchAndRewrite(BasicPtxBuilderInterface op,
54 if (op.hasIntrinsic()) {
55 LLVM_DEBUG(
DBGS() <<
"Ptx Builder does not lower \n\t" << op <<
"\n");
60 LLVM_DEBUG(
DBGS() << op.getPtx() <<
"\n");
63 op.getAsmValues(rewriter, asmValues);
64 for (
auto &[asmValue, modifier] : asmValues) {
65 LLVM_DEBUG(
DBGSNL() << asmValue <<
"\t Modifier : " << &modifier);
66 generator.insertValue(asmValue, modifier);
74 struct ConvertNVVMToLLVMPass
75 :
public impl::ConvertNVVMToLLVMPassBase<ConvertNVVMToLLVMPass> {
79 registry.
insert<LLVM::LLVMDialect, NVVM::NVVMDialect>();
82 void runOnOperation()
override {
84 target.addLegalDialect<::mlir::LLVM::LLVMDialect>();
96 void loadDependentDialects(
MLIRContext *context)
const final {
97 context->loadDialect<NVVMDialect>();
102 void populateConvertToLLVMConversionPatterns(
117 dialect->addInterfaces<NVVMToLLVMDialectInterface>();
static MLIRContext * getContext(OpFoldResult val)
static const mlir::GenInfo * generator
This class describes a specific conversion target.
Base class for dialect interfaces providing translation to LLVM IR.
ConvertToLLVMPatternInterface(Dialect *dialect)
The DialectRegistry maps a dialect namespace to a constructor for the matching dialect.
bool addExtension(TypeID extensionID, std::unique_ptr< DialectExtensionBase > extension)
Add the given extension to the registry.
Conversion from types to the LLVM IR dialect.
MLIRContext is the top-level object for a collection of MLIR operations.
A class to build PTX assembly automatically.
This class represents the benefit of a pattern match in a unitless scheme that ranges from 0 (very li...
A special type of RewriterBase that coordinates the application of a rewrite pattern on the current I...
Include the generated interface declarations.
void populateNVVMToLLVMConversionPatterns(RewritePatternSet &patterns)
const FrozenRewritePatternSet & patterns
LogicalResult applyPartialConversion(ArrayRef< Operation * > ops, const ConversionTarget &target, const FrozenRewritePatternSet &patterns, ConversionConfig config=ConversionConfig())
Below we define several entry points for operation conversion.
void registerConvertNVVMToLLVMInterface(DialectRegistry ®istry)
OpInterfaceRewritePattern is a wrapper around RewritePattern that allows for matching and rewriting a...