29 #include "llvm/Support/raw_ostream.h"
31 #define DEBUG_TYPE "nvvm-to-llvm"
32 #define DBGS() (llvm::dbgs() << "[" DEBUG_TYPE "]: ")
33 #define DBGSNL() (llvm::dbgs() << "\n")
36 #define GEN_PASS_DEF_CONVERTNVVMTOLLVMPASS
37 #include "mlir/Conversion/Passes.h.inc"
55 if (op.hasIntrinsic()) {
56 LLVM_DEBUG(
DBGS() <<
"Ptx Builder does not lower \n\t" << op <<
"\n");
61 LLVM_DEBUG(
DBGS() << op.getPtx() <<
"\n");
64 op.getAsmValues(rewriter, asmValues);
65 for (
auto &[asmValue, modifier] : asmValues) {
66 LLVM_DEBUG(
DBGSNL() << asmValue <<
"\t Modifier : " << &modifier);
67 generator.insertValue(asmValue, modifier);
75 struct ConvertNVVMToLLVMPass
76 :
public impl::ConvertNVVMToLLVMPassBase<ConvertNVVMToLLVMPass> {
80 registry.
insert<LLVM::LLVMDialect, NVVM::NVVMDialect>();
83 void runOnOperation()
override {
85 target.addLegalDialect<::mlir::LLVM::LLVMDialect>();
97 void loadDependentDialects(
MLIRContext *context)
const final {
98 context->loadDialect<NVVMDialect>();
103 void populateConvertToLLVMConversionPatterns(
118 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.
void addExtension(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...
MLIRContext * getContext() const
RewritePatternSet & add(ConstructorArg &&arg, ConstructorArgs &&...args)
Add an instance of each of the pattern types 'Ts' to the pattern list with the given arguments.
Include the generated interface declarations.
LogicalResult failure(bool isFailure=true)
Utility function to generate a LogicalResult.
void populateNVVMToLLVMConversionPatterns(RewritePatternSet &patterns)
LogicalResult applyPartialConversion(ArrayRef< Operation * > ops, const ConversionTarget &target, const FrozenRewritePatternSet &patterns, DenseSet< Operation * > *unconvertedOps=nullptr)
Below we define several entry points for operation conversion.
LogicalResult success(bool isSuccess=true)
Utility function to generate a LogicalResult.
bool failed(LogicalResult result)
Utility function that returns true if the provided LogicalResult corresponds to a failure value.
void registerConvertNVVMToLLVMInterface(DialectRegistry ®istry)
This class represents an efficient way to signal success or failure.
OpInterfaceRewritePattern is a wrapper around RewritePattern that allows for matching and rewriting a...