diff options
| author | River Riddle <riverriddle@google.com> | 2019-12-12 15:31:39 -0800 |
|---|---|---|
| committer | A. Unique TensorFlower <gardener@tensorflow.org> | 2019-12-12 15:32:21 -0800 |
| commit | e7aa47ff111c53127587d8aea71b088db3a671aa (patch) | |
| tree | f2b4841362b381de4f2beb1632250b8cdbc49cf2 /mlir/include | |
| parent | a50cb184a0c5ebc342a871b2e338e2591115639f (diff) | |
| download | bcm5719-llvm-e7aa47ff111c53127587d8aea71b088db3a671aa.tar.gz bcm5719-llvm-e7aa47ff111c53127587d8aea71b088db3a671aa.zip | |
NFC: Cleanup the various Op::print methods.
This cleans up the implementation of the various operation print methods. This is done via a combination of code cleanup, adding new streaming methods to the printer(e.g. operand ranges), etc.
PiperOrigin-RevId: 285285181
Diffstat (limited to 'mlir/include')
| -rw-r--r-- | mlir/include/mlir/Dialect/LLVMIR/NVVMOps.td | 2 | ||||
| -rw-r--r-- | mlir/include/mlir/IR/OpImplementation.h | 29 |
2 files changed, 29 insertions, 2 deletions
diff --git a/mlir/include/mlir/Dialect/LLVMIR/NVVMOps.td b/mlir/include/mlir/Dialect/LLVMIR/NVVMOps.td index c6e89afa3f8..bc6887da8e4 100644 --- a/mlir/include/mlir/Dialect/LLVMIR/NVVMOps.td +++ b/mlir/include/mlir/Dialect/LLVMIR/NVVMOps.td @@ -140,7 +140,7 @@ def NVVM_MmaOp : }]; let parser = [{ return parseNVVMMmaOp(parser, result); }]; let printer = [{ printNVVMMmaOp(p, *this); }]; - let verifier = [{ return mlir::NVVM::verify(*this); }]; + let verifier = [{ return ::verify(*this); }]; } #endif // NVVMIR_OPS diff --git a/mlir/include/mlir/IR/OpImplementation.h b/mlir/include/mlir/IR/OpImplementation.h index 3052f797ab6..05beaeaee59 100644 --- a/mlir/include/mlir/IR/OpImplementation.h +++ b/mlir/include/mlir/IR/OpImplementation.h @@ -154,6 +154,18 @@ inline OpAsmPrinter &operator<<(OpAsmPrinter &p, Value &value) { p.printOperand(&value); return p; } +inline OpAsmPrinter &operator<<(OpAsmPrinter &p, Value *value) { + return p << *value; +} + +template <typename T, + typename std::enable_if<std::is_convertible<T &, ValueRange>::value && + !std::is_convertible<T &, Value *>::value, + T>::type * = nullptr> +inline OpAsmPrinter &operator<<(OpAsmPrinter &p, const T &values) { + p.printOperands(values); + return p; +} inline OpAsmPrinter &operator<<(OpAsmPrinter &p, Type type) { p.printType(type); @@ -170,14 +182,29 @@ inline OpAsmPrinter &operator<<(OpAsmPrinter &p, Attribute attr) { // FunctionType with the Type version above, not have it match this. template <typename T, typename std::enable_if< !std::is_convertible<T &, Value &>::value && + !std::is_convertible<T &, Value *>::value && !std::is_convertible<T &, Type &>::value && - !std::is_convertible<T &, Attribute &>::value, + !std::is_convertible<T &, Attribute &>::value && + !std::is_convertible<T &, ValueRange>::value && + !llvm::is_one_of<T, bool>::value, T>::type * = nullptr> inline OpAsmPrinter &operator<<(OpAsmPrinter &p, const T &other) { p.getStream() << other; return p; } +inline OpAsmPrinter &operator<<(OpAsmPrinter &p, bool value) { + return p << (value ? StringRef("true") : "false"); +} + +template <typename IteratorT> +inline OpAsmPrinter & +operator<<(OpAsmPrinter &p, + const iterator_range<ValueTypeIterator<IteratorT>> &types) { + interleaveComma(types, p); + return p; +} + //===----------------------------------------------------------------------===// // OpAsmParser //===----------------------------------------------------------------------===// |

