forked from OSchip/llvm-project
[mlir][ODS] Add `constBuilderCall` to `Dense*ArrayAttr`s
These are useful in builders of Ops taking DenseArrayAttrs or for use in Rewriter, to create constant instances. Differential Revision: https://reviews.llvm.org/D132067
This commit is contained in:
parent
19ce5e515f
commit
f289c47b5e
|
@ -770,11 +770,6 @@ def LLVM_InsertValueOp : LLVM_Op<
|
|||
DenseI64ArrayAttr:$position);
|
||||
let results = (outs LLVM_AnyAggregate:$res);
|
||||
|
||||
let builders = [
|
||||
OpBuilder<(ins "Value":$container, "Value":$value,
|
||||
"ArrayRef<int64_t>":$position)>
|
||||
];
|
||||
|
||||
let assemblyFormat = [{
|
||||
$value `,` $container `` $position attr-dict `:` type($container)
|
||||
custom<InsertExtractValueElementType>(type($value), ref(type($container)),
|
||||
|
|
|
@ -138,6 +138,7 @@ public:
|
|||
DenseIntElementsAttr getIndexTensorAttr(ArrayRef<int64_t> values);
|
||||
|
||||
/// Tensor-typed DenseArrayAttr getters.
|
||||
DenseBoolArrayAttr getDenseBoolArrayAttr(ArrayRef<bool> values);
|
||||
DenseI8ArrayAttr getDenseI8ArrayAttr(ArrayRef<int8_t> values);
|
||||
DenseI16ArrayAttr getDenseI16ArrayAttr(ArrayRef<int16_t> values);
|
||||
DenseI32ArrayAttr getDenseI32ArrayAttr(ArrayRef<int32_t> values);
|
||||
|
|
|
@ -1291,6 +1291,7 @@ class DenseArrayAttrBase<string denseAttrName, string cppType, string summaryNam
|
|||
summaryName # " dense array attribute"> {
|
||||
let storageType = "::mlir::" # denseAttrName;
|
||||
let returnType = "::llvm::ArrayRef<" # cppType # ">";
|
||||
let constBuilderCall = "$_builder.get" # denseAttrName # "($0)";
|
||||
}
|
||||
def DenseBoolArrayAttr : DenseArrayAttrBase<"DenseBoolArrayAttr", "bool", "i1">;
|
||||
def DenseI8ArrayAttr : DenseArrayAttrBase<"DenseI8ArrayAttr", "int8_t", "i8">;
|
||||
|
|
|
@ -1619,13 +1619,6 @@ LogicalResult InsertValueOp::verify() {
|
|||
return success();
|
||||
}
|
||||
|
||||
void InsertValueOp::build(OpBuilder &builder, OperationState &state,
|
||||
Value container, Value value,
|
||||
ArrayRef<int64_t> position) {
|
||||
build(builder, state, container.getType(), container, value,
|
||||
builder.getAttr<DenseI64ArrayAttr>(position));
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// ReturnOp
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
|
|
@ -124,6 +124,10 @@ DenseIntElementsAttr Builder::getIndexVectorAttr(ArrayRef<int64_t> values) {
|
|||
values);
|
||||
}
|
||||
|
||||
DenseBoolArrayAttr Builder::getDenseBoolArrayAttr(ArrayRef<bool> values) {
|
||||
return DenseBoolArrayAttr::get(context, values);
|
||||
}
|
||||
|
||||
DenseI8ArrayAttr Builder::getDenseI8ArrayAttr(ArrayRef<int8_t> values) {
|
||||
return DenseI8ArrayAttr::get(context, values);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue