Class VariableOp

Inheritance Relationships

Base Type

  • public mlir::Op< VariableOp, ::mlir::OpTrait::ZeroRegions, ::mlir::OpTrait::OneResult, ::mlir::OpTrait::OneTypedResult<::mlir::Type >::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::VariadicOperands, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::OpAsmOpInterface::Trait >

Class Documentation

class VariableOp : public mlir::Op<VariableOp, ::mlir::OpTrait::ZeroRegions, ::mlir::OpTrait::OneResult, ::mlir::OpTrait::OneTypedResult<::mlir::Type>::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::VariadicOperands, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::OpAsmOpInterface::Trait>

Public Types

using Adaptor = VariableOpAdaptor
template<typename RangeT>
using GenericAdaptor = VariableOpGenericAdaptor<RangeT>
using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>
using Properties = FoldAdaptor::Properties

Public Functions

inline ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames()
inline ::mlir::StringAttr getInitNumberAttrName()
inline ::mlir::StringAttr getIsConstAttrName()
std::pair<unsigned, unsigned> getODSOperandIndexAndLength(unsigned index)
inline ::mlir::Operation::operand_range getODSOperands(unsigned index)
inline ::mlir::TypedValue<::mlir::Type> getInitValue()
::mlir::MutableOperandRange getInitValueMutable()
inline std::pair<unsigned, unsigned> getODSResultIndexAndLength(unsigned index)
inline ::mlir::Operation::result_range getODSResults(unsigned index)
inline ::mlir::TypedValue<::mlir::Type> getVariable()
void writeProperties(::mlir::DialectBytecodeWriter &writer)
inline ::mlir::Attribute getInitNumberAttr()
::std::optional<::mlir::Attribute> getInitNumber()
inline ::mlir::UnitAttr getIsConstAttr()
bool getIsConst()
inline void setInitNumberAttr(::mlir::Attribute attr)
inline void setIsConstAttr(::mlir::UnitAttr attr)
void setIsConst(bool attrValue)
inline ::mlir::Attribute removeInitNumberAttr()
inline ::mlir::Attribute removeIsConstAttr()
void print(::mlir::OpAsmPrinter &p)

Prints an emithls::VariableOp in the custom assembly syntax consumed by parse.

::llvm::LogicalResult verifyInvariantsImpl()
::llvm::LogicalResult verifyInvariants()
::llvm::LogicalResult verify()

Verifies an emithls::VariableOp has a supported type and consistent initialization.

  • The op must be nested (at any depth) inside an emithls::FuncOp, e.g. directly in the function body or inside a ForOp/IfOp/ExpressionOp region within it.

  • Pointer types are rejected (dynamic memory is unsupported in HLS).

  • A literal initNumber attribute is only allowed for integer, index, float, and array types.

void getAsmResultNames(::mlir::OpAsmSetValueNameFn setNameFn)

Names the SSA result of a VariableOp.

Assigns a human-readable name of the form <prefix><type>_<count> to the variable result so that printed IR reads, e.g., var_int32_0 or const_array_1 instead of the default %0, %1, … scheme. The prefix is "const" for constant variables and "var" for mutable ones. The count is the zero-based index among sibling variables of the same type class and const-ness that appear before this op in the parent function’s entry block.

inline bool hasInit()

Returns true if a variable is defiend as constant.

Public Static Functions

static inline ::mlir::StringAttr getInitNumberAttrName(::mlir::OperationName name)
static inline ::mlir::StringAttr getIsConstAttrName(::mlir::OperationName name)
static inline constexpr ::llvm::StringLiteral getOperationName()
static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError)
static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop)
static llvm::hash_code computePropertiesHash(const Properties &prop)
static std::optional<mlir::Attribute> getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name)
static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value)
static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs)
static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError)
static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state)
static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Type type, Attribute initNumber = {}, bool isConst = false)
static VariableOp create(::mlir::OpBuilder &builder, ::mlir::Location location, Type type, Attribute initNumber = {}, bool isConst = false)
static VariableOp create(::mlir::ImplicitLocOpBuilder &builder, Type type, Attribute initNumber = {}, bool isConst = false)
static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Type type, Value initValue = {}, bool isConst = false)
static VariableOp create(::mlir::OpBuilder &builder, ::mlir::Location location, Type type, Value initValue = {}, bool isConst = false)
static VariableOp create(::mlir::ImplicitLocOpBuilder &builder, Type type, Value initValue = {}, bool isConst = false)
static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result)

Parses an emithls::VariableOp from its custom assembly syntax.

The expected syntax is:

`emithls.variable` `as` [`const`] type [`=` (ssa-value | attribute)]

The const keyword marks read-only variables. The optional = <init> clause sets an initial value: either an SSA operand or a literal attribute. A const variable without an initializer is rejected as ill-formed.

static void getCanonicalizationPatterns(::mlir::RewritePatternSet &results, ::mlir::MLIRContext *context)

Canonicalization patterns for VariableOp.

  • RemoveUnusedVariable: erases any VariableOp whose result has no uses.

  • RemoveSameConstVariable: deduplicates const variables with identical type and init attribute, replacing later ones with the first occurrence.

  • HoistToFunctionTop: moves const variables nested inside control-flow blocks to the top of the enclosing FuncOp entry block.

static ::llvm::LogicalResult setPropertiesFromParsedAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError)

Public Static Attributes

static constexpr int odsIndex_init_value = 0