‘emithls’ Dialect

The emithls dialect groups together a set of types, operations and transformations that are useful to represent a High-Level Synthese style C++ code. These abstractions works as a.

Operations

emithls.arith.add (emithls::ArithAddOp)

Syntax:

operation ::= `emithls.arith.add` $lhs `,` $rhs attr-dict `:` type($result)

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultType

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

Operands:

Operand

Description

lhs

any non-token type

rhs

any non-token type

Results:

Result

Description

result

any non-token type

emithls.arith.and (emithls::ArithAndOp)

Syntax:

operation ::= `emithls.arith.and` $lhs `,` $rhs attr-dict `:` type($result)

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultType

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

Operands:

Operand

Description

lhs

any non-token type

rhs

any non-token type

Results:

Result

Description

result

any non-token type

emithls.arith.cast (emithls::ArithCastOp)

Arithmetic type cast operation.

Syntax:

operation ::= `emithls.arith.cast` $from attr-dict `:` type($from) `to` type($to)

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultShape

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

Operands:

Operand

Description

from

any non-token type

Results:

Result

Description

to

any non-token type

emithls.arith.cmp (emithls::ArithCmpOp)

Arithmetic comparison with predicate.

Syntax:

operation ::= `emithls.arith.cmp` $predicate `,` $lhs `,` $rhs attr-dict `:` type($lhs)

Traits: AlwaysSpeculatableImplTrait, SameTypeOperands

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

Attributes:

AttributeMLIR TypeDescription
predicate::mlir::emithls::CmpPredicateAttrpredicate for comparison operation

Operands:

Operand

Description

lhs

any non-token type

rhs

any non-token type

Results:

Result

Description

result

1-bit signless integer

emithls.arith.data_range (emithls::ArithDataRangeOp)

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

Operands:

Operand

Description

data

any non-token type

high_bit

index

low_bit

index

Results:

Result

Description

result

any non-token type

emithls.arith.div (emithls::ArithDivOp)

Syntax:

operation ::= `emithls.arith.div` $lhs `,` $rhs attr-dict `:` type($result)

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultType

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

Operands:

Operand

Description

lhs

any non-token type

rhs

any non-token type

Results:

Result

Description

result

any non-token type

emithls.arith.fused (emithls::ArithFusedOp)

Defines C/C++ style fused assignment.

Syntax:

operation ::= `emithls.arith.fused` $op_code `,` $acc `,` $val attr-dict `:` type($acc)

Traits: SameTypeOperands

Interfaces: MemoryEffectsOpInterface

Attributes:

AttributeMLIR TypeDescription
op_code::mlir::emithls::FusedOperatorAttrfused operator such as `+=`

Operands:

Operand

Description

acc

any non-token type

val

any non-token type

emithls.arith.logical_and (emithls::ArithLogicalAndOp)

Syntax:

operation ::= `emithls.arith.logical_and` $values attr-dict `:` type($result)

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultType

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

Operands:

Operand

Description

values

variadic of 1-bit signless integer

Results:

Result

Description

result

1-bit signless integer

emithls.arith.logical_or (emithls::ArithLogicalOrOp)

Syntax:

operation ::= `emithls.arith.logical_or` $values attr-dict `:` type($result)

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultType

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

Operands:

Operand

Description

values

variadic of 1-bit signless integer

Results:

Result

Description

result

1-bit signless integer

emithls.arith.max (emithls::ArithMaxOp)

Syntax:

operation ::= `emithls.arith.max` $lhs `,` $rhs attr-dict `:` type($result)

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultType

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

Operands:

Operand

Description

lhs

any non-token type

rhs

any non-token type

Results:

Result

Description

result

any non-token type

emithls.arith.min (emithls::ArithMinOp)

Syntax:

operation ::= `emithls.arith.min` $lhs `,` $rhs attr-dict `:` type($result)

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultType

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

Operands:

Operand

Description

lhs

any non-token type

rhs

any non-token type

Results:

Result

Description

result

any non-token type

emithls.arith.mul (emithls::ArithMulOp)

Syntax:

operation ::= `emithls.arith.mul` $lhs `,` $rhs attr-dict `:` type($result)

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultType

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

Operands:

Operand

Description

lhs

any non-token type

rhs

any non-token type

Results:

Result

Description

result

any non-token type

emithls.arith.or (emithls::ArithOrOp)

Syntax:

operation ::= `emithls.arith.or` $lhs `,` $rhs attr-dict `:` type($result)

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultType

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

Operands:

Operand

Description

lhs

any non-token type

rhs

any non-token type

Results:

Result

Description

result

any non-token type

emithls.arith.rem (emithls::ArithRemOp)

Syntax:

operation ::= `emithls.arith.rem` $lhs `,` $rhs attr-dict `:` type($result)

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultType

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

Operands:

Operand

Description

lhs

any non-token type

rhs

any non-token type

Results:

Result

Description

result

any non-token type

emithls.arith.select (emithls::ArithSelectOp)

Syntax:

operation ::= `emithls.arith.select` $condition `,` $true_value `,` $false_value attr-dict `:` type($result)

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

Operands:

Operand

Description

condition

1-bit signless integer

true_value

any non-token type

false_value

any non-token type

Results:

Result

Description

result

any non-token type

emithls.arith.shl (emithls::ArithShlOp)

Syntax:

operation ::= `emithls.arith.shl` $lhs `,` $rhs attr-dict `:` type($result)

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultType

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

Operands:

Operand

Description

lhs

any non-token type

rhs

any non-token type

Results:

Result

Description

result

any non-token type

emithls.arith.shr (emithls::ArithShrOp)

Syntax:

operation ::= `emithls.arith.shr` $lhs `,` $rhs attr-dict `:` type($result)

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultType

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

Operands:

Operand

Description

lhs

any non-token type

rhs

any non-token type

Results:

Result

Description

result

any non-token type

emithls.arith.sub (emithls::ArithSubOp)

Syntax:

operation ::= `emithls.arith.sub` $lhs `,` $rhs attr-dict `:` type($result)

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultType

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

Operands:

Operand

Description

lhs

any non-token type

rhs

any non-token type

Results:

Result

Description

result

any non-token type

emithls.array.ptr_read (emithls::ArrayPointerReadOp)

Reads a value from an pointer

Syntax:

operation ::= `emithls.array.ptr_read` $pointer `[` $indices `]` attr-dict `:` qualified(type($pointer)) `->` type($result)

Interfaces: InferTypeOpInterface, MemoryEffectsOpInterface

Operands:

Operand

Description

pointer

Pointer type in HLS C++

indices

variadic of index

Results:

Result

Description

result

any non-token type

emithls.array.ptr_write (emithls::ArrayPointerWriteOp)

Writes a value into an array

Syntax:

operation ::= `emithls.array.ptr_write` $value `,` $pointer `[` $indices `]` attr-dict `:` type($value) `->` qualified(type($pointer))

Interfaces: MemoryEffectsOpInterface

Operands:

Operand

Description

value

any non-token type

pointer

Pointer type in HLS C++

indices

variadic of index

emithls.array.read (emithls::ArrayReadOp)

Reads a value from an array

Syntax:

operation ::= `emithls.array.read` $array `[` $indices `]` attr-dict `:` qualified(type($array)) `->` type($result)

Interfaces: InferTypeOpInterface, MemoryEffectsOpInterface

Operands:

Operand

Description

array

Array type in C++

indices

variadic of index

Results:

Result

Description

result

any non-token type

emithls.array.write (emithls::ArrayWriteOp)

Writes a value into an array

Syntax:

operation ::= `emithls.array.write` $value `,` $array `[` $indices `]` attr-dict `:` type($value) `->` qualified(type($array))

Interfaces: MemoryEffectsOpInterface

Operands:

Operand

Description

value

any non-token type

array

Array type in C++

indices

variadic of index

emithls.call (emithls::CallOp)

Defines a function call.

Syntax:

operation ::= `emithls.call` $callee `(` $operands `)` attr-dict `:` functional-type($operands, results)

Interfaces: ArgAndResultAttrsOpInterface, CallOpInterface

Attributes:

AttributeMLIR TypeDescription
callee::mlir::FlatSymbolRefAttrflat symbol reference attribute
arg_attrs::mlir::ArrayAttrArray of dictionary attributes
res_attrs::mlir::ArrayAttrArray of dictionary attributes

Operands:

Operand

Description

operands

variadic of any non-token type

Results:

Result

Description

«unnamed»

variadic of any non-token type

emithls.expr (emithls::ExpressionOp)

Represents a combined C/C++ expression.

Syntax:

operation ::= `emithls.expr` attr-dict `:` type($result) $body

The expression operation defines a set of operations that together form a C/C++ style complex expression, such as: int var = (a + b) * c;. This operation returns one value with a scalar type, which is yielded from the region using YieldOp. Nested expressions are also allowed. Example:

// Assume %lhs, %rhs, %cst are i32 values
%expr = emithls.expr : i32 {
    %0 = arith.addi %lhs, %cst : i32
    %1 = arith.muli %0, %rhs : i32
    emithls.yield %1 : i32
}

Traits: NoRegionArguments, SingleBlockImplicitTerminator<YieldOp>, SingleBlock

Interfaces: OpAsmOpInterface

Results:

Result

Description

result

any non-token type

emithls.for (emithls::ForOp)

Defines a C/C++ for loop.

The for operation defines a counted loop with compile-time constant lower bound, upper bound, and step, mapping to a C/C++ for loop. The loop body receives the current induction variable as a block argument and iterates from lowerBound to upperBound (exclusive) in increments of step. Example:

emithls.for %idx0 = 0 to 10 step 1 {
    ops using %idx0 ...
}

Traits: NoTerminator, RecursiveMemoryEffects

Interfaces: OpAsmOpInterface

Attributes:

AttributeMLIR TypeDescription
lowerBound::mlir::IntegerAttrindex attribute
upperBound::mlir::IntegerAttrindex attribute
step::mlir::IntegerAttrindex attribute

emithls.func (emithls::FuncOp)

Defines a C/C++ function with a void return type.

The func operation defines a C/C++ function with a void return type, serving as the node and top-level function unit for HLS code generation. The function is identified by its symbol name and is isolated from above, meaning it cannot reference values defined outside its scope. Function arguments are accessible via the entry block of the body region. Example:

emithls.func @my_func(%arg0: type, %arg1: type, ...) {
    ops...
}

Traits: AutomaticAllocationScope, IsolatedFromAbove, NoTerminator

Interfaces: ArgAndResultAttrsOpInterface, CallableOpInterface, FunctionOpInterface, Symbol

Attributes:

AttributeMLIR TypeDescription
sym_name::mlir::StringAttrstring attribute
function_type::mlir::TypeAttrtype attribute of function type
arg_attrs::mlir::ArrayAttrArray of dictionary attributes
res_attrs::mlir::ArrayAttrArray of dictionary attributes

emithls.helper.accumulate (emithls::HelperAccumulateOp)

Helper to mark the accumulate axis in the computation.

Traits: HasParent<ForOp, affine::AffineForOp>

Attributes:

AttributeMLIR TypeDescription
op_code::mlir::emithls::FusedOperatorAttrfused operator such as `+=`

Operands:

Operand

Description

accu_ref

memref or emithls.array type

value

any non-token type

indices

variadic of index

emithls.helper.linebuf (emithls::HelperLineBufferOp)

Helper to store information of line buffer construction

Traits: HasParent<ForOp, affine::AffineForOp>

Interfaces: OpAsmOpInterface

Attributes:

AttributeMLIR TypeDescription
num_chan::mlir::ArrayAttr32-bit integer array attribute
num_line::mlir::IntegerAttr32-bit signless integer attribute

Operands:

Operand

Description

token_ref

memref or emithls.array type

index

index

Results:

Result

Description

buf_ref

memref or emithls.array type

emithls.helper.window (emithls::HelperWindowOp)

Helper to construct a compute windows from line buffer.

Traits: HasParent<ForOp, affine::AffineForOp>

Interfaces: OpAsmOpInterface

Operands:

Operand

Description

buf_ref

memref or emithls.array type

indices

variadic of index

Results:

Result

Description

win_ref

memref or emithls.array type

emithls.if (emithls::IfOp)

Defines a C/C style if-statement.

The if operation conditionally executes one of two regions based on an i1 condition value, mapping to a C/C++ if/else statement. The then region is always executed when the condition is true. The optional else region is executed when the condition is false; if absent, no action is taken on the false path. Example:

emithls.if %cond {
    ops ...
} else {
    ops ...
}

Traits: NoRegionArguments, NoTerminator, RecursiveMemoryEffects

Operands:

Operand

Description

condition

1-bit signless integer

emithls.include (emithls::IncludeOp)

C/C++ include statement

The include operation abstracts the C/C++ include syntax. However, this operation does not check the existence of the header file. This operation is created automatically by a transformation pass inside this dialect.

Traits: HasParent<ModuleOp>

Attributes:

AttributeMLIR TypeDescription
header::mlir::StringAttrstring attribute

emithls.pragma.array_partition (emithls::PragmaArrayPartitionOp)

#pragma HLS ARRAY_PARTITION variable= type= factor= dim=

Interfaces: EmitHLS_PragmaInterface

Attributes:

AttributeMLIR TypeDescription
part_type::mlir::emithls::ArrayPartitionTypeAttr#pragma HLS array_partition type=?
part_factor::mlir::IntegerAttr32-bit signless integer attribute
part_dim::mlir::IntegerAttr32-bit signless integer attribute

Operands:

Operand

Description

variable

Array type in C++

emithls.pragma.bind_storage (emithls::PragmaBindStorageOp)

#pragma HLS BIND_STORAGE variable= type= impl=

Interfaces: EmitHLS_PragmaInterface

Attributes:

AttributeMLIR TypeDescription
storage_type::mlir::emithls::BindStorageTypeAttr#pragma HLS bind_storage type=?
storage_impl::mlir::emithls::BindStorageImplAttr#pragma HLS bind_storage impl=?

Operands:

Operand

Description

variable

Array type in C++ or Stream type in HLS C++

emithls.pragma.dataflow (emithls::PragmaDataflowOp)

#pragma HLS DATAFLOW

Syntax:

operation ::= `emithls.pragma.dataflow` $body attr-dict

Traits: NoTerminator

Interfaces: EmitHLS_PragmaInterface

emithls.pragma.inline (emithls::PragmaInlineOp)

#pragma HLS INLINE off

Interfaces: EmitHLS_PragmaInterface

Attributes:

AttributeMLIR TypeDescription
off::mlir::UnitAttrunit attribute

emithls.pragma.pipeline (emithls::PragmaPipelineOp)

#pragma HLS PIPELINE II=

Interfaces: EmitHLS_PragmaInterface

Attributes:

AttributeMLIR TypeDescription
interval::mlir::IntegerAttr32-bit signless integer attribute
style::mlir::emithls::PipelineStyleAttr##pragma HLS HLS pipeline style=?

emithls.pragma.stream (emithls::PragmaStreamOp)

#pragma HLS STREAM type=fifo depth=

Interfaces: EmitHLS_PragmaInterface

Attributes:

AttributeMLIR TypeDescription
depth::mlir::IntegerAttr32-bit signless integer attribute

Operands:

Operand

Description

variable

Stream type in HLS C++ or Array type in C++

emithls.pragma.unroll (emithls::PragmaUnrollOp)

#pragma HLS UNROLL factor=

Traits: HasParent<ForOp>

Interfaces: EmitHLS_PragmaInterface

Attributes:

AttributeMLIR TypeDescription
factor::mlir::IntegerAttr32-bit signless integer attribute

emithls.stream.read (emithls::StreamReadOp)

Reads data out from hls::stream.

Syntax:

operation ::= `emithls.stream.read` $stream (`[` $indices^ `]`)? attr-dict `:` qualified(type($stream)) `->` type($data)

Interfaces: MemoryEffectsOpInterface

Operands:

Operand

Description

stream

Stream type in HLS C++ or Array type in C++

indices

variadic of index

Results:

Result

Description

data

any non-token type

emithls.stream.write (emithls::StreamWriteOp)

Writes data into hls::stream.

Syntax:

operation ::= `emithls.stream.write` $data `to` $stream (`[` $indices^ `]`)? attr-dict `:` type($data) `->` qualified(type($stream))

Interfaces: MemoryEffectsOpInterface

Operands:

Operand

Description

data

any non-token type

stream

Stream type in HLS C++ or Array type in C++

indices

variadic of index

emithls.top_interface (emithls::PragmaTopInterfaceOp)

#pragma HLS INTERFACE for the top function

Syntax:

operation ::= `emithls.top_interface` attr-dict

Interfaces: EmitHLS_PragmaInterface

emithls.update (emithls::UpdateOp)

Defines a C/C++ style assignment.

The update operation performs a C/C++ style assignment to an existing variable. This operation also supports element-wise assignment for array types using a list of IndexType indices.

emithls.update %var with %new_value : type <- type
emithls.update %var with %arr[%indices]
    : type <- !emithls.array<shape x type>
emithls.update %arr[%indices] with %new_value
    : !emithls.array<shape x type> <- type
emithls.update %arr0[%indices] with %arr1[%indices]
    : !emithls.array<shape x type> <- !emithls.array<shape x type>

Traits: AttrSizedOperandSegments

Interfaces: MemoryEffectsOpInterface

Operands:

Operand

Description

variable

any non-token type

indices

variadic of index

new_value

any non-token type

new_value_indices

variadic of index

emithls.variable (emithls::VariableOp)

Defines a C/C++ style variable.

The variable operation defines a C/C++ variable, which is used to simplify the translation from emithls dialect to HLS code. MLIR adopts the Single Static Assignment form, which forbids multiple assignments to the same variable. To solve this, the variable operation and an update operation are defined, such as:

%var = emithls.variable : type
emithls.update %var, %value : type

A variable can also be defined as a constant as in C/C++.

Interfaces: OpAsmOpInterface

Attributes:

AttributeMLIR TypeDescription
init_number::mlir::Attributeany attribute
is_const::mlir::UnitAttrunit attribute

Operands:

Operand

Description

init_value

any non-token type

Results:

Result

Description

variable

any non-token type

emithls.yield (emithls::YieldOp)

Yields the result value of an expression.

Syntax:

operation ::= `emithls.yield` attr-dict $value `:` type($value)

The yield operation terminates an expression block with a value, which becomes the result of the enclosing expression. This operation mimics a combined expression in C/C++.

Traits: AlwaysSpeculatableImplTrait, HasParent<ExpressionOp>, Terminator

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

Operands:

Operand

Description

value

any non-token type

Types

ArrayType

Array type in C++

The array type represents a C++ style array, which contains a shaped amount of variables of one scalar type, such as: !emithls.array<2xi32>, !emithls.array<2x2xi32>

Parameters:

Parameter

C++ type

Description

shape

::llvm::ArrayRef<int64_t>

elementType

Type

PointerType

Pointer type in HLS C++

Syntax:

!emithls.ptr<
  Type   # elementType
>

The pointer type represents a C++ pointer type, which points to the address of a value, e.g. !emithls.ptr<i32>.

Parameters:

Parameter

C++ type

Description

elementType

Type

StreamType

Stream type in HLS C++

Syntax:

!emithls.stream<
  Type   # elementType
>

The stream type represents a HLS C++ hls::stream type, which constructs an FIFO stream with element type flowing in it, e.g. !emithls.stream<i32>.

Parameters:

Parameter

C++ type

Description

elementType

Type

Enums

ArrayPartitionType

#pragma HLS array_partition type=?

Cases:

Symbol

Value

String

cyclic

0

cyclic

block

1

block

complete

2

complete

BindStorageImpl

#pragma HLS bind_storage impl=?

Cases:

Symbol

Value

String

bram

0

bram

lutram

1

lutram

srl

2

srl

BindStorageType

#pragma HLS bind_storage type=?

Cases:

Symbol

Value

String

fifo

0

fifo

ram_1p

1

ram_1p

ram_2p

2

ram_2p

rom_1p

3

rom_1p

rom_2p

4

rom_2p

CmpPredicate

Predicate for comparison operation

Cases:

Symbol

Value

String

eq

0

eq

ne

1

ne

lt

2

lt

le

3

le

gt

4

gt

ge

5

ge

FusedOperator

Fused operator such as +=

Cases:

Symbol

Value

String

add

0

add

sub

1

sub

mul

2

mul

PipelineStyle

##pragma HLS HLS pipeline style=?

Cases:

Symbol

Value

String

stp

0

stp

flp

1

flp

frp

2

frp