diff options
Diffstat (limited to 'mlir')
| -rw-r--r-- | mlir/include/mlir/IR/BuiltinOps.h | 5 | ||||
| -rw-r--r-- | mlir/lib/IR/BuiltinOps.cpp | 6 |
2 files changed, 11 insertions, 0 deletions
diff --git a/mlir/include/mlir/IR/BuiltinOps.h b/mlir/include/mlir/IR/BuiltinOps.h index 02e3a39c09b..ebd55a998d0 100644 --- a/mlir/include/mlir/IR/BuiltinOps.h +++ b/mlir/include/mlir/IR/BuiltinOps.h @@ -225,6 +225,11 @@ public: static void build(Builder *builder, OperationState *result, Type type, Attribute value); + /// Builds a constant op with the specified attribute value and the + /// attribute's type. + static void build(Builder *builder, OperationState *result, + NumericAttr value); + Attribute getValue() const { return getAttr("value"); } static StringRef getOperationName() { return "constant"; } diff --git a/mlir/lib/IR/BuiltinOps.cpp b/mlir/lib/IR/BuiltinOps.cpp index bfa7701e500..cb8d42b0e9f 100644 --- a/mlir/lib/IR/BuiltinOps.cpp +++ b/mlir/lib/IR/BuiltinOps.cpp @@ -250,6 +250,12 @@ void ConstantOp::build(Builder *builder, OperationState *result, Type type, result->types.push_back(type); } +void ConstantOp::build(Builder *builder, OperationState *result, + NumericAttr value) { + result->addAttribute("value", value); + result->types.push_back(value.getType()); +} + void ConstantOp::print(OpAsmPrinter *p) const { *p << "constant "; p->printOptionalAttrDict(getAttrs(), /*elidedAttrs=*/"value"); |

