14 #ifndef NVVM_DIALECT_NVVM_IR_BASICPTXBUILDERINTERFACE_H_
15 #define NVVM_DIALECT_NVVM_IR_BASICPTXBUILDERINTERFACE_H_
21 #include "llvm/Support/LogicalResult.h"
38 inline llvm::raw_ostream &
operator<<(llvm::raw_ostream &os,
46 return os <<
"ReadWrite";
48 llvm_unreachable(
"Unknown PTXRegisterMod value");
54 #include "mlir/Dialect/LLVMIR/BasicPtxBuilderInterface.h.inc"
64 BasicPtxBuilderInterface interfaceOp;
70 std::string registerConstraints;
74 bool hasResult =
false;
76 bool needsManualRegisterMapping =
false;
81 bool needsManualRegisterMapping =
false)
82 : interfaceOp(op), rewriter(rewriter),
83 needsManualRegisterMapping(needsManualRegisterMapping) {}
91 LLVM::InlineAsmOp
build();
101 llvm::SmallDenseSet<unsigned> &seenRW,
102 llvm::SmallDenseSet<unsigned> &seenW,
103 llvm::SmallDenseSet<unsigned> &seenR,
A class to build PTX assembly automatically.
PtxBuilder(Operation *op, PatternRewriter &rewriter, bool needsManualRegisterMapping=false)
Single constructor that only initializes members.
LogicalResult insertValue(Value v, PTXRegisterMod itype=PTXRegisterMod::Read)
Add an operand with the read/write input type.
LLVM::InlineAsmOp build()
Builds the inline assembly Op and returns it.
void buildAndReplaceOp()
Shortcut to build the inline assembly Op and replace or erase the original op with.
Operation is the basic unit of execution within MLIR.
A special type of RewriterBase that coordinates the application of a rewrite pattern on the current I...
This class represents an instance of an SSA value in the MLIR system, representing a computable value...
PTXRegisterMod
Register read/write modifier to build constraint string for PTX inline https://docs....
@ Write
Write register with '=' modifier.
@ ReadWrite
ReadWrite register with '+' modifier.
@ Read
Read register with no modifier.
llvm::raw_ostream & operator<<(llvm::raw_ostream &os, PTXRegisterMod mod)
void countPlaceholderNumbers(StringRef ptxCode, llvm::SmallDenseSet< unsigned > &seenRW, llvm::SmallDenseSet< unsigned > &seenW, llvm::SmallDenseSet< unsigned > &seenR, llvm::SmallVectorImpl< unsigned > &rwNums, llvm::SmallVectorImpl< unsigned > &wNums, llvm::SmallVectorImpl< unsigned > &rNums)
Count the number of placeholder variables such as {$r}, {$w}, {$rw} in the PTX code.
Include the generated interface declarations.