EmitHLSOps

page EmitHLSOps

‘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

<tt>emithls.arith.add</tt> (emithls::ArithAddOp)

Syntax:

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

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultType

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

<tt>emithls.arith.and</tt> (emithls::ArithAndOp)

Syntax:

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

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultType

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

<tt>emithls.arith.cast</tt> (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{}

<tt>emithls.arith.cmp</tt> (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{}

<tt>emithls.arith.data_range</tt> (emithls::ArithDataRangeOp)

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

<tt>emithls.arith.div</tt> (emithls::ArithDivOp)

Syntax:

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

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultType

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

<tt>emithls.arith.fused</tt> (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

<tt>emithls.arith.logical_and</tt> (emithls::ArithLogicalAndOp)

Syntax:

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

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultType

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

<tt>emithls.arith.logical_or</tt> (emithls::ArithLogicalOrOp)

Syntax:

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

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultType

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

<tt>emithls.arith.max</tt> (emithls::ArithMaxOp)

Syntax:

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

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultType

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

<tt>emithls.arith.min</tt> (emithls::ArithMinOp)

Syntax:

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

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultType

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

<tt>emithls.arith.mul</tt> (emithls::ArithMulOp)

Syntax:

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

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultType

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

<tt>emithls.arith.or</tt> (emithls::ArithOrOp)

Syntax:

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

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultType

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

<tt>emithls.arith.rem</tt> (emithls::ArithRemOp)

Syntax:

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

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultType

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

<tt>emithls.arith.select</tt> (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{}

<tt>emithls.arith.shl</tt> (emithls::ArithShlOp)

Syntax:

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

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultType

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

<tt>emithls.arith.shr</tt> (emithls::ArithShrOp)

Syntax:

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

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultType

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

<tt>emithls.arith.sub</tt> (emithls::ArithSubOp)

Syntax:

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

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultType

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

<tt>emithls.array.ptr_read</tt> (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

<tt>emithls.array.ptr_write</tt> (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

<tt>emithls.array.read</tt> (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

<tt>emithls.array.write</tt> (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

<tt>emithls.call</tt> (emithls::CallOp)

Defines a function call.

Syntax:

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

Interfaces: ArgAndResultAttrsOpInterface, CallOpInterface

<tt>emithls.expr</tt> (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

<tt>emithls.for</tt> (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

<tt>emithls.func</tt> (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

<tt>emithls.helper.accumulate</tt> (emithls::HelperAccumulateOp)

Helper to mark the accumulate axis in the computation.

Traits: HasParent<ForOp, affine::AffineForOp>

<tt>emithls.helper.linebuf</tt> (emithls::HelperLineBufferOp)

Helper to store information of line buffer construction

Traits: HasParent<ForOp, affine::AffineForOp>

Interfaces: OpAsmOpInterface

<tt>emithls.helper.window</tt> (emithls::HelperWindowOp)

Helper to construct a compute windows from line buffer.

Traits: HasParent<ForOp, affine::AffineForOp>

Interfaces: OpAsmOpInterface

<tt>emithls.if</tt> (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

<tt>emithls.include</tt> (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>

<tt>emithls.pragma.array_partition</tt> (emithls::PragmaArrayPartitionOp)

_::pragma HLS ARRAY_PARTITION variable= type= factor= dim=_

Interfaces: EmitHLS_PragmaInterface

<tt>emithls.pragma.bind_storage</tt> (emithls::PragmaBindStorageOp)

_::pragma HLS BIND_STORAGE variable= type= impl=_

Interfaces: EmitHLS_PragmaInterface

<tt>emithls.pragma.dataflow</tt> (emithls::PragmaDataflowOp)

_::pragma HLS DATAFLOW_

Syntax:

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

Traits: NoTerminator

Interfaces: EmitHLS_PragmaInterface

<tt>emithls.pragma.inline</tt> (emithls::PragmaInlineOp)

_::pragma HLS INLINE off_

Interfaces: EmitHLS_PragmaInterface

<tt>emithls.pragma.pipeline</tt> (emithls::PragmaPipelineOp)

_::pragma HLS PIPELINE II=_

Interfaces: EmitHLS_PragmaInterface

<tt>emithls.pragma.stream</tt> (emithls::PragmaStreamOp)

_::pragma HLS STREAM type=fifo depth=_

Interfaces: EmitHLS_PragmaInterface

<tt>emithls.pragma.unroll</tt> (emithls::PragmaUnrollOp)

_::pragma HLS UNROLL factor=_

Traits: HasParent<ForOp>

Interfaces: EmitHLS_PragmaInterface

<tt>emithls.stream.read</tt> (emithls::StreamReadOp)

Reads data out from hls::stream.

Syntax:

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

Interfaces: MemoryEffectsOpInterface

<tt>emithls.stream.write</tt> (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

<tt>emithls.top_interface</tt> (emithls::PragmaTopInterfaceOp)

_::pragma HLS INTERFACE for the top function_

Syntax:

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

Interfaces: EmitHLS_PragmaInterface

<tt>emithls.update</tt> (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

<tt>emithls.variable</tt> (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

<tt>emithls.yield</tt> (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{}

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>

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>.

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>.

Enums

ArrayPartitionType

_::pragma HLS array_partition type=?_

BindStorageImpl

_::pragma HLS bind_storage impl=?_

BindStorageType

_::pragma HLS bind_storage type=?_

CmpPredicate

Predicate for comparison operation

FusedOperator

Fused operator such as

PipelineStyle

_##pragma HLS HLS pipeline style=?_