Changeset View
Changeset View
Standalone View
Standalone View
mlir/test/mlir-tblgen/op-attribute.td
Show First 20 Lines • Show All 99 Lines • ▼ Show 20 Lines | |||||
// DEF: some-return-type AOp::aAttr() { | // DEF: some-return-type AOp::aAttr() { | ||||
// DEF-NEXT: auto attr = aAttrAttr() | // DEF-NEXT: auto attr = aAttrAttr() | ||||
// DEF-NEXT: return attr.some-convert-from-storage(); | // DEF-NEXT: return attr.some-convert-from-storage(); | ||||
// DEF: some-attr-kind AOp::bAttrAttr() | // DEF: some-attr-kind AOp::bAttrAttr() | ||||
// DEF-NEXT: ::mlir::impl::getAttrFromSortedRange((*this)->getAttrs().begin() + 1, (*this)->getAttrs().end() - 0, bAttrAttrName()).dyn_cast_or_null<some-attr-kind>() | // DEF-NEXT: ::mlir::impl::getAttrFromSortedRange((*this)->getAttrs().begin() + 1, (*this)->getAttrs().end() - 0, bAttrAttrName()).dyn_cast_or_null<some-attr-kind>() | ||||
// DEF: some-return-type AOp::bAttr() { | // DEF: some-return-type AOp::bAttr() { | ||||
// DEF-NEXT: auto attr = bAttrAttr(); | // DEF-NEXT: auto attr = bAttrAttr(); | ||||
// DEF-NEXT: if (!attr) | |||||
// DEF-NEXT: return some-const-builder-call(::mlir::Builder((*this)->getContext()), 4.2).some-convert-from-storage(); | |||||
// DEF-NEXT: return attr.some-convert-from-storage(); | // DEF-NEXT: return attr.some-convert-from-storage(); | ||||
// DEF: some-attr-kind AOp::cAttrAttr() | // DEF: some-attr-kind AOp::cAttrAttr() | ||||
// DEF-NEXT: ::mlir::impl::getAttrFromSortedRange((*this)->getAttrs().begin() + 1, (*this)->getAttrs().end() - 0, cAttrAttrName()).dyn_cast_or_null<some-attr-kind>() | // DEF-NEXT: ::mlir::impl::getAttrFromSortedRange((*this)->getAttrs().begin() + 1, (*this)->getAttrs().end() - 0, cAttrAttrName()).dyn_cast_or_null<some-attr-kind>() | ||||
// DEF: ::llvm::Optional<some-return-type> AOp::cAttr() { | // DEF: ::llvm::Optional<some-return-type> AOp::cAttr() { | ||||
// DEF-NEXT: auto attr = cAttrAttr() | // DEF-NEXT: auto attr = cAttrAttr() | ||||
// DEF-NEXT: return attr ? ::llvm::Optional<some-return-type>(attr.some-convert-from-storage()) : (::llvm::None); | // DEF-NEXT: return attr ? ::llvm::Optional<some-return-type>(attr.some-convert-from-storage()) : (::llvm::None); | ||||
▲ Show 20 Lines • Show All 200 Lines • ▼ Show 20 Lines | |||||
// DEF: ::mlir::ArrayAttr BOp::some_attr_array() | // DEF: ::mlir::ArrayAttr BOp::some_attr_array() | ||||
// DEF: ::mlir::Type BOp::type_attr() | // DEF: ::mlir::Type BOp::type_attr() | ||||
// Test building constant values for array attribute kinds | // Test building constant values for array attribute kinds | ||||
// --- | // --- | ||||
def COp : NS_Op<"c_op", []> { | def COp : NS_Op<"c_op", []> { | ||||
let arguments = (ins | let arguments = (ins | ||||
DefaultValuedAttr<I32ArrayAttr, "{1, 2}">:$i32_array_attr, | DefaultValuedOptionalAttr<I32ArrayAttr, "{1, 2}">:$i32_array_attr, | ||||
DefaultValuedAttr<I64ArrayAttr, "{3, 4}">:$i64_array_attr, | DefaultValuedOptionalAttr<I64ArrayAttr, "{3, 4}">:$i64_array_attr, | ||||
DefaultValuedAttr<F32ArrayAttr, "{5.f, 6.f}">:$f32_array_attr, | DefaultValuedOptionalAttr<F32ArrayAttr, "{5.f, 6.f}">:$f32_array_attr, | ||||
DefaultValuedAttr<F64ArrayAttr, "{7., 8.}">:$f64_array_attr, | DefaultValuedOptionalAttr<F64ArrayAttr, "{7., 8.}">:$f64_array_attr, | ||||
DefaultValuedAttr<StrArrayAttr, "{\"a\", \"b\"}">:$str_array_attr | DefaultValuedOptionalAttr<StrArrayAttr, "{\"a\", \"b\"}">:$str_array_attr | ||||
); | ); | ||||
} | } | ||||
// DEF-LABEL: COp definitions | // DEF-LABEL: COp definitions | ||||
// DEF: ::mlir::Builder((*this)->getContext()).getI32ArrayAttr({1, 2}) | // DEF: ::mlir::Builder((*this)->getContext()).getI32ArrayAttr({1, 2}) | ||||
// DEF: ::mlir::Builder((*this)->getContext()).getI64ArrayAttr({3, 4}) | // DEF: ::mlir::Builder((*this)->getContext()).getI64ArrayAttr({3, 4}) | ||||
// DEF: ::mlir::Builder((*this)->getContext()).getF32ArrayAttr({5.f, 6.f}) | // DEF: ::mlir::Builder((*this)->getContext()).getF32ArrayAttr({5.f, 6.f}) | ||||
// DEF: ::mlir::Builder((*this)->getContext()).getF64ArrayAttr({7., 8.}) | // DEF: ::mlir::Builder((*this)->getContext()).getF64ArrayAttr({7., 8.}) | ||||
▲ Show 20 Lines • Show All 147 Lines • Show Last 20 Lines |