forked from OSchip/llvm-project
Add constant build() method not requiring result type
Instead, we deduce the result type from the given attribute. This is in preparation for generating constant ops with TableGen. PiperOrigin-RevId: 232723467
This commit is contained in:
parent
c78d708487
commit
888b9fa8a6
|
@ -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"; }
|
||||
|
|
|
@ -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");
|
||||
|
|
Loading…
Reference in New Issue