Operations
gccjit.access_field
(gccjit::AccessFieldOp)
Access field operation
Syntax:
operation ::= `gccjit.access_field` $composite `[` $field `]` `:` type($composite) `->` type($result) attr-dict
The “access_field” operation represents an access field operation. LValue field access returns an lvalue. RValue field access returns an rvalue.
%res0 = gccjit.access_field %struct [0] : !gccjit.lvalue<!gccjit.struct<(!i32, !i32)>> -> !gccjit.lvalue<!i32>
%res1 = gccjit.access_field %struct [1] : !gccjit.struct<(!i32, !i32)> -> !i32
Attributes:
Attribute | MLIR Type | Description |
---|---|---|
field | ::mlir::IntegerAttr | index attribute |
Operands:
Operand | Description |
---|---|
composite |
any type |
Results:
Result | Description |
---|---|
result |
any type |
gccjit.addr
(gccjit::AddrOp)
Address of an lvalue
Syntax:
operation ::= `gccjit.addr` `(` $lvalue `:` type($lvalue) `)` `:` type($result) attr-dict
The “addr” operation returns the address of an lvalue.
%res = gccjit.addr (%lvalue : !gccjit.lvalue<!i32>) : !gccjit.ptr<!i32>
Operands:
Operand | Description |
---|---|
lvalue |
LValue type |
Results:
Result | Description |
---|---|
result |
GCCJIT pointer type |
gccjit.alignof
(gccjit::AlignOfOp)
Alignment of a type
Syntax:
operation ::= `gccjit.alignof` $type `:` type($align) attr-dict
The “alignof” operation returns the alignment of a type in bytes.
%align = gccjit.alignof !gccjit.int<long double> : !gccjit.int<size_t>
Traits: AlwaysSpeculatableImplTrait
Interfaces: ConditionallySpeculatable
, NoMemoryEffect (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{}
Attributes:
Attribute | MLIR Type | Description |
---|---|---|
type | ::mlir::TypeAttr | any type attribute |
Results:
Result | Description |
---|---|
align |
Integer type |
gccjit.as_rvalue
(gccjit::AsRValueOp)
Read a lvalue to rvalue
Syntax:
operation ::= `gccjit.as_rvalue` $lvalue `:` type($lvalue) `to` type($rvalue) attr-dict
The “as_rvalue” operation converts an lvalue to an rvalue. The operation takes a single operand and produces a single result.
Operands:
Operand | Description |
---|---|
lvalue |
LValue type |
Results:
Result | Description |
---|---|
rvalue |
any type |
gccjit.asm_goto
(gccjit::AsmGotoOp)
Inline assembly operation
Syntax:
operation ::= `gccjit.asm_goto` custom<AsmInlineAttr>($inline_flag)
custom<AsmVolatileAttr>($volatile_flag)
`(`
$template_code
`:` custom<AsmOperands>($outputConstraints, $outputSymbols, $outputs,
type($outputs))
`:` custom<AsmOperands>($inputConstraints, $inputSymbols, $inputs,
type($inputs))
`:` custom<ClobberList>($clobbers)
`:` $labels
`:` $fallthrough
`)` attr-dict
The “asm” operation represents an inline assembly operation.
gccjit.asm_goto inline volatile ("..."
: "=r"(%result)
: "r"(%arg0), "r"(%arg1)
: "memory"
: /* goto labels */ label1, label2
: /* fallthrough label */ "label3"
)
Traits: AttrSizedOperandSegments
, HasParent<FuncOp>
, Terminator
Attributes:
Attribute | MLIR Type | Description |
---|---|---|
inline_flag | ::mlir::UnitAttr | unit attribute |
volatile_flag | ::mlir::UnitAttr | unit attribute |
template_code | ::mlir::StringAttr | string attribute |
outputConstraints | ::mlir::ArrayAttr | array attribute |
outputSymbols | ::mlir::ArrayAttr | array attribute |
inputConstraints | ::mlir::ArrayAttr | array attribute |
inputSymbols | ::mlir::ArrayAttr | array attribute |
clobbers | ::mlir::ArrayAttr | array attribute |
Operands:
Operand | Description |
---|---|
outputs |
variadic of LValue type |
inputs |
variadic of any type |
Successors:
Successor | Description |
---|---|
fallthrough |
any successor |
labels |
any successor |
gccjit.asm
(gccjit::AsmOp)
Inline assembly operation
Syntax:
operation ::= `gccjit.asm` custom<AsmInlineAttr>($inline_flag)
custom<AsmVolatileAttr>($volatile_flag)
`(`
$template_code
`:` custom<AsmOperands>($outputConstraints, $outputSymbols, $outputs,
type($outputs))
`:` custom<AsmOperands>($inputConstraints, $inputSymbols, $inputs,
type($inputs))
`:` custom<ClobberList>($clobbers)
`)` attr-dict
The “asm” operation represents an inline assembly operation.
gccjit.asm inline volatile ("..."
: "=r"(%result)
: "r"(%arg0), "r"(%arg1)
: "memory"
)
Traits: AttrSizedOperandSegments
Attributes:
Attribute | MLIR Type | Description |
---|---|---|
inline_flag | ::mlir::UnitAttr | unit attribute |
volatile_flag | ::mlir::UnitAttr | unit attribute |
template_code | ::mlir::StringAttr | string attribute |
outputConstraints | ::mlir::ArrayAttr | array attribute |
outputSymbols | ::mlir::ArrayAttr | array attribute |
inputConstraints | ::mlir::ArrayAttr | array attribute |
inputSymbols | ::mlir::ArrayAttr | array attribute |
clobbers | ::mlir::ArrayAttr | array attribute |
Operands:
Operand | Description |
---|---|
outputs |
variadic of LValue type |
inputs |
variadic of any type |
gccjit.assign
(gccjit::AssignOp)
Assignment operation
Syntax:
operation ::= `gccjit.assign` $rvalue `to` $lvalue `:` type($rvalue) `,` type($lvalue) attr-dict
The “assign” operation represents an assignment operation.
gccjit.assign %rvalue to $lvalue : !gccjit.lvalue<!i32>, !i32
Operands:
Operand | Description |
---|---|
rvalue |
any type |
lvalue |
LValue type |
gccjit.atomic.cmpxchg
(gccjit::AtomicCompareExchangeOp)
Atomic compare exchange operation
Syntax:
operation ::= `gccjit.atomic.cmpxchg` custom<WeakAttr>($weak)
`success` `(` $success_ord `)`
`failure` `(` $failure_ord `)`
`(`
$ptr `:` type($ptr) `,`
$expected `:` type($expected) `,`
$desired `:` type($desired)
`)` `:` type($result) attr-dict
The gccjit.atomic.cmpxchg
operation represents an atomic compare exchange
operation.
%res = gccjit.atomic.cmpxchg weak success(acq_rel) failure(relaxed)
(%ptr : !gccjit.ptr<!i32>, %expected : !gccjit.ptr<!i32>, %desired : !i32) : !i1
Interfaces: InferTypeOpInterface
Attributes:
Attribute | MLIR Type | Description |
---|---|---|
success_ord | ::mlir::gccjit::AtomicOrderingAttr | atomic ordering |
failure_ord | ::mlir::gccjit::AtomicOrderingAttr | atomic ordering |
weak | ::mlir::UnitAttr | unit attribute |
Operands:
Operand | Description |
---|---|
ptr |
GCCJIT pointer type |
expected |
GCCJIT pointer type |
desired |
any type |
Results:
Result | Description |
---|---|
result |
integer with GCC_JIT_TYPE_BOOL |
gccjit.atomic.load
(gccjit::AtomicLoadOp)
Atomic load operation
Syntax:
operation ::= `gccjit.atomic.load` $ordering `(` $ptr `:` type($ptr) `)` `:` type($result) attr-dict
The gccjit.atomic.load
operation represents an atomic load operation.
%res = gccjit.atomic.load relaxed (%ptr : !gccjit.ptr<!i32>) : !i32
Attributes:
Attribute | MLIR Type | Description |
---|---|---|
ordering | ::mlir::gccjit::AtomicOrderingAttr | atomic ordering |
Operands:
Operand | Description |
---|---|
ptr |
GCCJIT pointer type |
Results:
Result | Description |
---|---|
result |
any type |
gccjit.atomic.rmw
(gccjit::AtomicRMWOp)
Atomic rmw operation
Syntax:
operation ::= `gccjit.atomic.rmw` $ordering $kind `(` $ptr `:` type($ptr) `,` $value `:` type($value) `)`
`:` type($result) attr-dict
The gccjit.atomic.rmw
operation represents an atomic rmw operation.
%res = gccjit.atomic.rmw relaxed add_fetch (%ptr : !gccjit.ptr<!i32>, %value : !i32) : !i32
Attributes:
Attribute | MLIR Type | Description |
---|---|---|
kind | ::mlir::gccjit::AtomicRMWKindAttr | atomic rmw operation |
ordering | ::mlir::gccjit::AtomicOrderingAttr | atomic ordering |
Operands:
Operand | Description |
---|---|
ptr |
GCCJIT pointer type |
value |
any type |
Results:
Result | Description |
---|---|
result |
any type |
gccjit.atomic.store
(gccjit::AtomicStoreOp)
Atomic store operation
Syntax:
operation ::= `gccjit.atomic.store` $ordering `(` $ptr `:` type($ptr) `,` $value `:` type($value) `)` attr-dict
The gccjit.atomic.store
operation represents an atomic store operation.
gccjit.atomic.store relaxed (%ptr : !gccjit.ptr<!i32>, %value : !i32)
Attributes:
Attribute | MLIR Type | Description |
---|---|---|
ordering | ::mlir::gccjit::AtomicOrderingAttr | atomic ordering |
Operands:
Operand | Description |
---|---|
ptr |
GCCJIT pointer type |
value |
any type |
gccjit.binary
(gccjit::BinaryOp)
Binary operation
Syntax:
operation ::= `gccjit.binary` $op `(` $lhs `:` type($lhs) `,` $rhs `:` type($rhs) `)`
`:` type($result) attr-dict
The “binary” operation represents a binary operation.
%res = gccjit.binary plus ( %lhs : !gccjit.int<i32>, %rhs : !gccjit.int<i32> ) : !gccjit.int<i32>
Attributes:
Attribute | MLIR Type | Description |
---|---|---|
op | ::mlir::gccjit::BOpAttr | binary operation |
Operands:
Operand | Description |
---|---|
lhs |
any type |
rhs |
any type |
Results:
Result | Description |
---|---|
result |
any type |
gccjit.bitcast
(gccjit::BitCastOp)
Bitcast operation
Syntax:
operation ::= `gccjit.bitcast` $value `:` type($value) `to` type($result) attr-dict
Given an rvalue of T, bitcast it to another type, meaning that this will generate a new rvalue by interpreting the bits of rvalue to the layout of type.
The type of rvalue must be the same size as the size of type.
%res = gccjit.bitcast %value : !gccjit.int<long> to !gccjit.int<unsigned long>
Operands:
Operand | Description |
---|---|
value |
any type |
Results:
Result | Description |
---|---|
result |
any type |
gccjit.call
(gccjit::CallOp)
Function call
Syntax:
operation ::= `gccjit.call` custom<TailCallAttr>($tail)
custom<BuiltinCallAttr>($builtin)
$callee `(` $args `)` `:` functional-type($args, $result) attr-dict
The “call” operation represents a function call.
%res = gccjit.call @foo ( %arg0 : !gccjit.int<i32>, %arg1 : !gccjit.int<i32> ) : !gccjit.int<i32>
If tail call is required, the tail
attribute should be set to true.
%res = gccjit.call tail @foo ( %arg0 : !gccjit.int<i32>, %arg1 : !gccjit.int<i32> ) : !gccjit.int<i32>
Attributes:
Attribute | MLIR Type | Description |
---|---|---|
callee | ::mlir::SymbolRefAttr | symbol reference attribute |
tail | ::mlir::UnitAttr | unit attribute |
builtin | ::mlir::UnitAttr | unit attribute |
Operands:
Operand | Description |
---|---|
args |
variadic of any type |
Results:
Result | Description |
---|---|
result |
any type |
gccjit.cast
(gccjit::CastOp)
Cast operation
Syntax:
operation ::= `gccjit.cast` $value `:` type($value) `to` type($result) attr-dict
The “cast” operation represents a casting operation.
%res = gccjit.cast %value : !gccjit.int<i32> to !gccjit.int<i64>
Currently only a limited set of conversions are possible:
int <-> float
int <-> pointer
pointer <-> pointer
Operands:
Operand | Description |
---|---|
value |
any type |
Results:
Result | Description |
---|---|
result |
any type |
gccjit.comment
(gccjit::CommentOp)
Comment operation
Syntax:
operation ::= `gccjit.comment` $comment attr-dict
The “comment” operation represents a comment.
gccjit.comment #gccjit.str<"This is a comment">
Traits: AlwaysSpeculatableImplTrait
Interfaces: ConditionallySpeculatable
, NoMemoryEffect (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{}
Attributes:
Attribute | MLIR Type | Description |
---|---|---|
comment | ::mlir::StringAttr | string attribute |
gccjit.compare
(gccjit::CompareOp)
Comparison operation
Syntax:
operation ::= `gccjit.compare` $op `(` $lhs `:` type($lhs) `,` $rhs `:` type($rhs) `)`
`:` type($result) attr-dict
The “compare” operation represents a comparison operation.
%res = gccjit.compare eq ( %lhs : !gccjit.int<i32>, %rhs : !gccjit.int<i32> ) : !gccjit.bool
Interfaces: InferTypeOpInterface
Attributes:
Attribute | MLIR Type | Description |
---|---|---|
op | ::mlir::gccjit::CmpOpAttr | comparison operation |
Operands:
Operand | Description |
---|---|
lhs |
any type |
rhs |
any type |
Results:
Result | Description |
---|---|
result |
integer with GCC_JIT_TYPE_BOOL |
gccjit.conditional
(gccjit::ConditionalOp)
Unconditional jump
Syntax:
operation ::= `gccjit.conditional` `(` $condition `:` type($condition) `)` `,` $on_true `,` $on_false attr-dict
Terminate a block by adding evaluation of an rvalue, branching on the result to the appropriate successor block. This is roughly equivalent to this C code:
if (boolval)
goto on_true;
else
goto on_false;
Unlike other branch op in MLIR, this conditional op does not support any block arguments.
Traits: AlwaysSpeculatableImplTrait
, HasParent<FuncOp>
, Terminator
Interfaces: ConditionallySpeculatable
, NoMemoryEffect (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{}
Operands:
Operand | Description |
---|---|
condition |
integer with GCC_JIT_TYPE_BOOL |
Successors:
Successor | Description |
---|---|
on_true |
any successor |
on_false |
any successor |
gccjit.const
(gccjit::ConstantOp)
A constant value
Syntax:
operation ::= `gccjit.const` $value attr-dict
The gccjit.const
operation creates a constant rvalue for the constant
value specified by the parameter.
Traits: AlwaysSpeculatableImplTrait
, ConstantLike
Interfaces: ConditionallySpeculatable
, InferTypeOpInterface
, NoMemoryEffect (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{}
Attributes:
Attribute | MLIR Type | Description |
---|---|---|
value | ::mlir::TypedAttr | TypedAttr instance |
Results:
Result | Description |
---|---|
result |
any type |
gccjit.deref_field
(gccjit::DerefFieldOp)
Dereference field operation
Syntax:
operation ::= `gccjit.deref_field` $ptr `[` $field `]` `:` type($ptr) `->` type($result) attr-dict
The “deref_field” operation represents a dereference field operation.
%res = gccjit.deref_field %ptr [0] : !gccjit.ptr<!gccjit.struct<(!i32, !i32)>> -> !gccjit.lvalue<!i32>
Attributes:
Attribute | MLIR Type | Description |
---|---|---|
field | ::mlir::IntegerAttr | index attribute |
Operands:
Operand | Description |
---|---|
ptr |
GCCJIT pointer type |
Results:
Result | Description |
---|---|
result |
LValue type |
gccjit.deref
(gccjit::DerefOp)
Dereference a pointer
Syntax:
operation ::= `gccjit.deref` `(` $ptr `:` type($ptr) (`,` $offset^ `:` type($offset) )? `)`
`:` type($result) attr-dict
The “deref” operation dereferences a pointer.
%res = gccjit.deref (%ptr : !gccjit.ptr<!i32>) : !gccjit.lvalue<!i32>
Operands:
Operand | Description |
---|---|
ptr |
any type |
offset |
any type |
Results:
Result | Description |
---|---|
result |
LValue type |
gccjit.expr
(gccjit::ExprOp)
Expression
Syntax:
operation ::= `gccjit.expr` custom<LazyAttribute>($lazy) $body `:` type($result) attr-dict
The “expr” operation represents an expression.
%res = gccjit.expr {
%0 = gccjit.const #gccjit.int<32> : !gccjit.int<32>
%1 = gccjit.const #gccjit.int<32> : !gccjit.int<32>
%2 = gccjit.binary plus %0, %1 : !gccjit.int<32>, !gccjit.int<32>
gccjit.return %2 : !gccjit.int<32>
} : !gccjit.int<32>
The expr operation can be marked with a lazy attribute. If such an attribute exists, the expr will not be materialized until it is used.
The above, for example, will be translated into the following gimple:
%res = 32 + 32
Without the expr block, the above would be translated into:
%0 = 32
%1 = 32
%2 = %0 + %1
%3 = %2
The lazy evaluation attribute is used to compose expression block with other operations that may have side effects. For example,
%x = gccjit.expr lazy {
%0 = gccjit.const #gccjit.int<32> : !gccjit.int<32>
%1 = gccjit.as_rvalue %arg0 : !gccjit.lvalue<!i32> -> !gccjit.int<32>
%2 = gccjit.compare lt (%0 : !gccjit.int<32>, %1 : !gccjit.int<32>) : !gccjit.bool
gccjit.return %2 : !gccjit.bool
} : !gccjit.int<32>
gccjit.conditional %x, ^true, ^false
will be translated into:
if ((int)32 < %arg0) goto ^true; else goto ^false;
Without the lazy attribute, the above would be translated into:
%x = (int)32 < %arg0
if (%x) goto ^true; else goto ^false;
Attributes:
Attribute | MLIR Type | Description |
---|---|---|
lazy | ::mlir::UnitAttr | unit attribute |
Results:
Result | Description |
---|---|
result |
any type |
gccjit.fn_addr
(gccjit::FnAddrOp)
Function address
Syntax:
operation ::= `gccjit.fn_addr` $callee `:` type($result) attr-dict
The “fn_addr” operation returns the address of a function.
%res = gccjit.fn_addr @foo : !gccjit.ptr<!gccjit.func<void (!i32)>>
Attributes:
Attribute | MLIR Type | Description |
---|---|---|
callee | ::mlir::SymbolRefAttr | symbol reference attribute |
Results:
Result | Description |
---|---|
result |
GCCJIT pointer type |
gccjit.func
(gccjit::FuncOp)
Declare or define a function for GCCJIT
Syntax:
operation ::= `gccjit.func` $fn_kind
$sym_name
custom<FunctionType>($function_type)
custom<FunctionAttrs>($gccjit_fn_attrs)
custom<FunctionBody>($body) attr-dict
FuncOp is the top-level operation for defining a new function in GCCJIT.
Unlike func.func or llvm.func, parameters of a function are treated as
lvalues in GCCJIT. Hence, gccjit.func
only accepts regions with lvalue
arguments if any parameter is present.
gccjit.func exported @foo (i32, i32) -> i32 {
^entry(%arg0 : !gccjit.lvalue<i32>, %arg1 : !gccjit.lvalue<i32>):
gccjit.return %2 : i32
}
gccjit.func always_inline @bar () -> void {
^entry:
gccjit.return
}
gccjit.func
can be of four kinds:
- Exported: The function is visible to the outside world.
- Internal: The function is visible only within the module, similar to
static
in C. - Imported: The function is imported from another module.
- AlwaysInline: The function is always inlined.
Traits: IsolatedFromAbove
Attributes:
Attribute | MLIR Type | Description |
---|---|---|
sym_name | ::mlir::StringAttr | string attribute |
fn_kind | ::mlir::gccjit::FnKindAttr | function kind |
function_type | ::mlir::TypeAttr | type attribute of GCCJIT function type |
gccjit_fn_attrs | ::mlir::ArrayAttr | array attribute |
gccjit.get_global
(gccjit::GetGlobalOp)
Get global operation
Syntax:
operation ::= `gccjit.get_global` $sym `:` type($result) attr-dict
The “get_global” operation is used to get a lvalue of a global variable.
%res = gccjit.get_global @foo : !gccjit.lvalue<!i32>
Attributes:
Attribute | MLIR Type | Description |
---|---|---|
sym | ::mlir::SymbolRefAttr | symbol reference attribute |
Results:
Result | Description |
---|---|
result |
LValue type |
gccjit.global
(gccjit::GlobalOp)
Declare a global variable
Syntax:
operation ::= `gccjit.global` $glb_kind
custom<ReadOnlyAttr>($readonly)
$sym_name
oilist (
`reg` `(` qualified($reg_name) `)` |
`align` `(` qualified($alignment) `)` |
`tls_model` `(` qualified($tls_model) `)` |
`link_section` `(` qualified($link_section) `)` |
`visibility` `(` qualified($visibility) `)`
)
custom<GlobalInitializer>($initializer, $body) `:` $type attr-dict
The “global_var” operation declares a global variable.
Traits: IsolatedFromAbove
Attributes:
Attribute | MLIR Type | Description |
---|---|---|
glb_kind | ::mlir::gccjit::GlbKindAttr | global kind |
readonly | ::mlir::UnitAttr | unit attribute |
sym_name | ::mlir::StringAttr | string attribute |
type | ::mlir::TypeAttr | type attribute of LValue type |
reg_name | ::mlir::StringAttr | string attribute |
alignment | ::mlir::IntegerAttr | index attribute |
tls_model | ::mlir::gccjit::TLSModelAttr | Thread Local Storage model |
link_section | ::mlir::StringAttr | string attribute |
visibility | ::mlir::StringAttr | string attribute |
initializer | ::mlir::Attribute | string attribute or Byte array initializer |
gccjit.jump
(gccjit::JumpOp)
Unconditional jump
Syntax:
operation ::= `gccjit.jump` $dest attr-dict
Terminate a block by adding a jump to the given target block. This is roughly equivalent to this C code:
goto target;
Unlike other branch op in MLIR, this jump op does not support any block arguments.
Traits: AlwaysSpeculatableImplTrait
, HasParent<FuncOp>
, Terminator
Interfaces: ConditionallySpeculatable
, NoMemoryEffect (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{}
Successors:
Successor | Description |
---|---|
dest |
any successor |
gccjit.literal
(gccjit::LiteralOp)
Literal operation
Syntax:
operation ::= `gccjit.literal` $value `:` type($result) attr-dict
The “literal” operation represents a literal value.
!str = !gccjit.qualified<!gccjit.int<char>, const>
%res = gccjit.literal #gccjit.str<"Hello, World!"> : !str
Attributes:
Attribute | MLIR Type | Description |
---|---|---|
value | ::mlir::StringAttr | string attribute |
Results:
Result | Description |
---|---|
result |
GCCJIT pointer type |
gccjit.local
(gccjit::LocalOp)
Declare a local variable
Syntax:
operation ::= `gccjit.local` oilist (
`reg` `(` qualified($reg_name) `)` |
`align` `(` qualified($alignment) `)` |
`tls_model` `(` qualified($tls_model) `)`
)
`:` type($var) attr-dict
The “local_var” operation declares a local variable.
Attributes:
Attribute | MLIR Type | Description |
---|---|---|
reg_name | ::mlir::StringAttr | string attribute |
alignment | ::mlir::IntegerAttr | index attribute |
tls_model | ::mlir::gccjit::TLSModelAttr | Thread Local Storage model |
Results:
Result | Description |
---|---|
var |
LValue type |
gccjit.new_array
(gccjit::NewArrayOp)
Construct an array
Syntax:
operation ::= `gccjit.new_array` type($array) `[`
custom<ArrayOrVectorElements>(
ref(type($array)), $elements, type($elements)
)
`]` attr-dict
The “array” operation constructs an array from a list of elements.
%array = gccjit.new_array !gccjit.array<i32, 3> [%1, %2, %3]
Operands:
Operand | Description |
---|---|
elements |
variadic of any type |
Results:
Result | Description |
---|---|
array |
GCCJIT array type |
gccjit.new_struct
(gccjit::NewStructOp)
Construct a struct
Syntax:
operation ::= `gccjit.new_struct` $indices `[` $elements `]` `:` functional-type(operands, results) attr-dict
The “struct” operation constructs a struct from a list of elements. Each value has to have the same unqualified type as the field it is applied to.
%0 = gccjit.new_struct [0, 1] [%1, %2] : (!i32, !i32) -> !gccjit.struct<(!i32, !i32)>
Attributes:
Attribute | MLIR Type | Description |
---|---|---|
indices | ::mlir::DenseI32ArrayAttr | i32 dense array attribute |
Operands:
Operand | Description |
---|---|
elements |
variadic of any type |
Results:
Result | Description |
---|---|
result |
any type |
gccjit.new_union
(gccjit::NewUnionOp)
Construct a union
Syntax:
operation ::= `gccjit.new_union` $element `at` $index `:` type($element) `,` type($result) attr-dict
The “union” operation constructs a union from a list of elements. Each value has to have the same unqualified type as the field it is applied to.
%union = gccjit.new_union %1 at 0 : !i32, !gccjit.union<(!i32)>
Attributes:
Attribute | MLIR Type | Description |
---|---|---|
index | ::mlir::IntegerAttr | index attribute |
Operands:
Operand | Description |
---|---|
element |
any type |
Results:
Result | Description |
---|---|
result |
any type |
gccjit.new_vector
(gccjit::NewVectorOp)
Construct a vector
Syntax:
operation ::= `gccjit.new_vector` type($vector) `[`
custom<ArrayOrVectorElements>(
ref(type($vector)),
$elements,
type($elements)
)
`]` attr-dict
The “vector” operation constructs a vector from a list of elements.
%vector = gccjit.new_vector !gccjit.vector<i32, 4> [%1, %2, %3, %4]
Operands:
Operand | Description |
---|---|
elements |
variadic of any type |
Results:
Result | Description |
---|---|
vector |
GCCJIT vector type |
gccjit.ptr_call
(gccjit::PtrCallOp)
Function pointer call
Syntax:
operation ::= `gccjit.ptr_call` custom<TailCallAttr>($tail)
$callee `(` $args `)` `:` functional-type(operands, results) attr-dict
The “ptr_call” operation represents a function pointer call.
%res = gccjit.ptr_call %fn ( %arg0 : !gccjit.int<i32>, %arg1 : !gccjit.int<i32> ) : !gccjit.int<i32>
If tail call is required, the tail
attribute should be set to true.
%res = gccjit.ptr_call tail %fn ( %arg0 : !gccjit.int<i32>, %arg1 : !gccjit.int<i32> ) : !gccjit.int<i32>
Attributes:
Attribute | MLIR Type | Description |
---|---|---|
tail | ::mlir::UnitAttr | unit attribute |
Operands:
Operand | Description |
---|---|
callee |
GCCJIT pointer type |
args |
variadic of any type |
Results:
Result | Description |
---|---|
result |
any type |
gccjit.return
(gccjit::ReturnOp)
Return from function
Syntax:
operation ::= `gccjit.return` ($value^ `:` type($value))? attr-dict
The “return” operation represents a return operation within a function. The operation takes an optional operand and produces no results. The operand type must match the signature of the function that contains the operation.
gccjit.func @foo() {
^entry:
gccjit.return
}
Traits: HasParent<FuncOp, GlobalOp, ExprOp>
, ReturnLike
, Terminator
Interfaces: RegionBranchTerminatorOpInterface
Operands:
Operand | Description |
---|---|
value |
any type |
gccjit.sizeof
(gccjit::SizeOfOp)
Size of a type
Syntax:
operation ::= `gccjit.sizeof` $type `:` type($size) attr-dict
The “sizeof” operation returns the size of a type in bytes.
%size = gccjit.sizeof !gccjit.int<long double> : !gccjit.int<size_t>
Traits: AlwaysSpeculatableImplTrait
Interfaces: ConditionallySpeculatable
, NoMemoryEffect (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{}
Attributes:
Attribute | MLIR Type | Description |
---|---|---|
type | ::mlir::TypeAttr | any type attribute |
Results:
Result | Description |
---|---|
size |
Integer type |
gccjit.switch
(gccjit::SwitchOp)
Switch operation
Syntax:
operation ::= `gccjit.switch` `(` $value `:` type($value) `)` `{` `\n`
custom<SwitchOpCases>(ref(type($value)),
$defaultDestination,
$case_lowerbound,
$case_upperbound,
$caseDestinations)
`}`
attr-dict
The “switch” operation represents a switch operation within a block.
gccjit.func @foo() {
^entry:
gccjit.switch (%0 : i32) {
default: ^default
case 0..1: ^case1
case 5: ^case2
}
^case1:
gccjit.return
^case2:
gccjit.return
^default:
}
Traits: AlwaysSpeculatableImplTrait
, HasParent<FuncOp>
, Terminator
Interfaces: ConditionallySpeculatable
, NoMemoryEffect (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{}
Attributes:
Attribute | MLIR Type | Description |
---|---|---|
case_lowerbound | ::mlir::ArrayAttr | array attribute |
case_upperbound | ::mlir::ArrayAttr | array attribute |
Operands:
Operand | Description |
---|---|
value |
Integer type |
Successors:
Successor | Description |
---|---|
defaultDestination |
any successor |
caseDestinations |
any successor |
gccjit.unary
(gccjit::UnaryOp)
Unary operation
Syntax:
operation ::= `gccjit.unary` $op `(` $value `:` type($value) `)` `:` type($result) attr-dict
The “unary” operation represents a unary operation.
%res = gccjit.unary minus ( %operand : !gccjit.int<i32> ) : !gccjit.int<i32>
Attributes:
Attribute | MLIR Type | Description |
---|---|---|
op | ::mlir::gccjit::UOpAttr | unary operation |
Operands:
Operand | Description |
---|---|
value |
any type |
Results:
Result | Description |
---|---|
result |
any type |
gccjit.update
(gccjit::UpdateOp)
Update operation
Syntax:
operation ::= `gccjit.update` $op $rvalue `to` $lvalue `:` type($rvalue) `,` type($lvalue) attr-dict
The “update” operation represents an update operation.
gccjit.update minus %rvalue to $lvalue : !gccjit.lvalue<!i32>, !i32
Attributes:
Attribute | MLIR Type | Description |
---|---|---|
op | ::mlir::gccjit::BOpAttr | binary operation |
Operands:
Operand | Description |
---|---|
rvalue |
any type |
lvalue |
LValue type |