‘py’ Dialect#
A dialect representing python programs TODO
Operations#
py.bool_fromI1
(::pylir::Py::BoolFromI1Op)#
Syntax:
operation ::= `py.bool_fromI1` $input attr-dict
This op converts an I1
given by $input
into a python bool object_
Traits: AlwaysBound
, KnownTypeObjectInterface
, ReturnsImmutable
Interfaces: CaptureInterface
, InferTypeOpInterface
, NoMemoryEffect (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{}
Operands:#
Operand |
Description |
---|---|
|
1-bit signless integer |
Results:#
Result |
Description |
---|---|
|
dynamic type |
py.bool_toI1
(::pylir::Py::BoolToI1Op)#
Syntax:
operation ::= `py.bool_toI1` $input attr-dict
This op converts the boolean given by $input
into an I1
value that is
usable for eg. conditional branches.
If $input
is not really a bool
(or a subclasses of) the behaviour is
undefined.
Interfaces: CaptureInterface
, InferTypeOpInterface
, NoMemoryEffect (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{}
Operands:#
Operand |
Description |
---|---|
|
dynamic type |
Results:#
Result |
Description |
---|---|
|
1-bit signless integer |
py.call
(::pylir::Py::CallOp)#
Call operation
Syntax:
operation ::= `py.call` $callee `(` $call_operands `)` attr-dict `:` functional-type($call_operands, results)
Traits: AddableExceptionHandling<InvokeOp>
, AlwaysBound
Interfaces: CallOpInterface
, SymbolUserOpInterface
Attributes:#
Attribute | MLIR Type | Description |
---|---|---|
callee | ::mlir::FlatSymbolRefAttr | flat symbol reference attribute |
Operands:#
Operand |
Description |
---|---|
|
variadic of any type |
Results:#
Result |
Description |
---|---|
|
variadic of any type |
py.constant
(::pylir::Py::ConstantOp)#
Syntax:
operation ::= `py.constant` `(` $constant `)` attr-dict
Creates a constant value from the given attribute. Writing to a value returned from this op is undefined behaviour.
Traits: ConstantLike
, KnownTypeObjectInterface
Interfaces: InferTypeOpInterface
, NoMemoryEffect (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{}
Attributes:#
Attribute | MLIR Type | Description |
---|---|---|
constant | ::mlir::Attribute | python unbound value or ObjectAttrInterface instance or |
Results:#
Result |
Description |
---|---|
|
dynamic type |
py.dict_delItem
(::pylir::Py::DictDelItemOp)#
Syntax:
operation ::= `py.dict_delItem` $key `hash` `(` $hash `)` `from` $dict attr-dict
This op deletes the entry identified by $key
with the help of $hash
from
the dictionary.
If the dictionary did not contain an entry with the given key the result is
0, otherwise 1.
If $dict
is not a dictionary (or a subclass of) the behaviour is
undefined.
Interfaces: CaptureInterface
, InferTypeOpInterface
, SROAReadWriteOpInterface
Operands:#
Operand |
Description |
---|---|
|
dynamic type |
|
dynamic type |
|
index |
Results:#
Result |
Description |
---|---|
|
1-bit signless integer |
py.dict_len
(::pylir::Py::DictLenOp)#
Syntax:
operation ::= `py.dict_len` $input attr-dict
Returns the amount of key-value pairs stored in $input
.
Interfaces: CaptureInterface
, InferTypeOpInterface
, MemoryFoldInterface
, SROAReadWriteOpInterface
Operands:#
Operand |
Description |
---|---|
|
dynamic type |
Results:#
Result |
Description |
---|---|
|
index |
py.dict_setItem
(::pylir::Py::DictSetItemOp)#
Syntax:
operation ::= `py.dict_setItem` $dict `[` $key `hash` `(` $hash `)` `]` `to` $value attr-dict
This op inserts the value $value
into the dictionary with the key $key
with the help of $hash
.
If $key
already exists the previous value gets overwritten.
If $dict
is not a dictionary (or a subclass of) the behaviour is
undefined.
Interfaces: CaptureInterface
, SROAReadWriteOpInterface
Operands:#
Operand |
Description |
---|---|
|
dynamic type |
|
dynamic type |
|
index |
|
dynamic type |
py.dict_tryGetItem
(::pylir::Py::DictTryGetItemOp)#
Syntax:
operation ::= `py.dict_tryGetItem` $dict `[` $key `hash` `(` $hash `)` `]` attr-dict
This op looks up the value of $key
with the help of $hash
in the
dictionary $dict
.
If found it’ll be returned in $result
.
If not found, $result
is an unbound
value.
If $dict
is not really a dict (or a subclass of) the behaviour is
undefined.
Interfaces: CaptureInterface
, InferTypeOpInterface
, MemoryFoldInterface
, SROAReadWriteOpInterface
Operands:#
Operand |
Description |
---|---|
|
dynamic type |
|
dynamic type |
|
index |
Results:#
Result |
Description |
---|---|
|
dynamic type |
py.external
(::pylir::Py::ExternalOp)#
Syntax:
operation ::= `py.external` $sym_name `,` $attr attr-dict
This op is used to mark a #py.globalValue
as external.
This may have one of two semantics, depending on whether the
#py.globalValue
has an initializer:
If it has an initializer, the attribute is visible from other modules importing it using a
py.external
op with the same name and a#py.globalValue
without an initializer. This can also be used from other programming languages to import the global value given a matching target dependent memory layout.Otherwise, the
#py.globalValue
is referencing a#py.globalValue
with an initializer marked external in another module, or a#py.globalValue
defined in another programming language. There must be exactly one such#py.globalValue
in the program.
A #py.globalValue
may only occur in a py.external
once.
Interfaces: Symbol
Attributes:#
Attribute | MLIR Type | Description |
---|---|---|
sym_name | ::mlir::StringAttr | string attribute |
attr | ::pylir::Py::GlobalValueAttr |
py.float_fromF64
(::pylir::Py::FloatFromF64)#
Syntax:
operation ::= `py.float_fromF64` $input attr-dict
Traits: AlwaysBound
, KnownTypeObjectInterface
, ReturnsImmutable
Interfaces: CaptureInterface
, InferTypeOpInterface
, NoMemoryEffect (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{}
Operands:#
Operand |
Description |
---|---|
|
64-bit float |
Results:#
Result |
Description |
---|---|
|
dynamic type |
py.float_toF64
(::pylir::Py::FloatToF64)#
Syntax:
operation ::= `py.float_toF64` $input attr-dict
Interfaces: CaptureInterface
, InferTypeOpInterface
, NoMemoryEffect (MemoryEffectOpInterface)
, OnlyReadsValueInterface
Effects: MemoryEffects::Effect{}
Operands:#
Operand |
Description |
---|---|
|
dynamic type |
Results:#
Result |
Description |
---|---|
|
64-bit float |
py.func
(::pylir::Py::FuncOp)#
Traits: AutomaticAllocationScope
, EntryArgsBound
, IsolatedFromAbove
, VerifyAttributesOpTrait
Interfaces: CallableOpInterface
, FunctionOpInterface
, OpAsmOpInterface
, Symbol
Attributes:#
Attribute | MLIR Type | Description |
---|---|---|
sym_name | ::mlir::StringAttr | string attribute |
function_type | ::mlir::TypeAttr | type attribute of function type |
sym_visibility | ::mlir::StringAttr | string attribute |
arg_attrs | ::mlir::ArrayAttr | Array of dictionary attributes |
res_attrs | ::mlir::ArrayAttr | Array of dictionary attributes |
py.function_call
(::pylir::Py::FunctionCallOp)#
Syntax:
operation ::= `py.function_call` $function `(` $call_operands `)` attr-dict
Traits: AddableExceptionHandling<FunctionInvokeOp, ::pylir::Py::OperandShape::Single, ::pylir::Py::OperandShape::Variadic>
, AlwaysBound
Interfaces: CallOpInterface
, InferTypeOpInterface
Operands:#
Operand |
Description |
---|---|
|
dynamic type |
|
variadic of dynamic type |
Results:#
Result |
Description |
---|---|
|
dynamic type |
py.function_closureArg
(::pylir::Py::FunctionGetClosureArgOp)#
Syntax:
operation ::= `py.function_closureArg` $function `[` $index `]` `:` $closure_types attr-dict
Returns the closure argument at the given index within function
.
function
must have been created with closure arguments whose types match
closure_types
or whose type of closure arguments match up until and
including index
.
Traits: InferTypeOpAdaptor
Interfaces: InferTypeOpInterface
, NoMemoryEffect (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{}
Attributes:#
Attribute | MLIR Type | Description |
---|---|---|
index | ::mlir::IntegerAttr | 32-bit signless integer attribute |
closure_types | ::mlir::ArrayAttr | type array attribute |
Operands:#
Operand |
Description |
---|---|
|
dynamic type |
Results:#
Result |
Description |
---|---|
|
any type |
py.function_invoke
(::pylir::Py::FunctionInvokeOp)#
Invoke operation
Syntax:
operation ::= `py.function_invoke` $function `(` $call_operands `)` attr-dict
`\n` ` ` ` `
`label` $happy_path ( `(` $normal_dest_operands^ `:` type($normal_dest_operands) `)`)?
`unwind` $exception_path ( `(` $unwind_dest_operands^ `:` type($unwind_dest_operands) `)`)?
Traits: AlwaysBound
, AttrSizedOperandSegments
, Terminator
Interfaces: BranchOpInterface
, CallOpInterface
, ExceptionHandlingInterface
, InferTypeOpInterface
Operands:#
Operand |
Description |
---|---|
|
dynamic type |
|
variadic of dynamic type |
|
variadic of any type |
|
variadic of any type |
Results:#
Result |
Description |
---|---|
|
dynamic type |
Successors:#
Successor |
Description |
---|---|
|
any successor |
|
any successor |
py.getSlot
(::pylir::Py::GetSlotOp)#
Syntax:
operation ::= `py.getSlot` $object `[` $slot `]` attr-dict
Retrieves the value stored in the slot with index $slot
inside of
$object
.
If $slot
is greater or equal to the amount of slots of $object
it is
undefined behaviour.
$result
will contain the value in the slot, or unbound value if it was
never assigned to.
Interfaces: CaptureInterface
, InferTypeOpInterface
, MemoryFoldInterface
, SROAReadWriteOpInterface
Operands:#
Operand |
Description |
---|---|
|
dynamic type |
|
index |
Results:#
Result |
Description |
---|---|
|
dynamic type |
py.global
(::pylir::Py::GlobalOp)#
Syntax:
operation ::= `py.global` ($sym_visibility^)? $sym_name `:` $type (`=` $initializer^)? attr-dict
This op creates a global to which values of type $type
can be assigned.
See py.store
and py.load
how to use it.
The global may optionally have an initializer which serves as the initial
value returned by py.load
if no value has ever been stored into the
global.
If the global does not have an initializer loading from it before a value
has ever been stored in it is undefined behaviour.
Traits: VerifyAttributesOpTrait
Interfaces: Symbol
Attributes:#
Attribute | MLIR Type | Description |
---|---|---|
sym_name | ::mlir::StringAttr | string attribute |
sym_visibility | ::mlir::StringAttr | string attribute |
type | ::mlir::TypeAttr | type attribute of dynamic type or index or 64-bit float |
initializer | ::mlir::Attribute | ObjectAttrInterface instance or index attribute or 64-bit float attribute or |
py.int_add
(::pylir::Py::IntAddOp)#
Syntax:
operation ::= `py.int_add` $lhs `,` $rhs attr-dict
Traits: AlwaysBound
, Commutative
, KnownTypeObjectInterface
, ReturnsImmutable
Interfaces: CaptureInterface
, InferTypeOpInterface
, NoMemoryEffect (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{}
Operands:#
Operand |
Description |
---|---|
|
dynamic type |
|
dynamic type |
Results:#
Result |
Description |
---|---|
|
dynamic type |
py.int_cmp
(::pylir::Py::IntCmpOp)#
Syntax:
operation ::= `py.int_cmp` $pred $lhs `,` $rhs attr-dict
Interfaces: CaptureInterface
, InferTypeOpInterface
, NoMemoryEffect (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{}
Attributes:#
Attribute | MLIR Type | Description |
---|---|---|
pred | ::pylir::Py::IntCmpKindAttr | allowed 64-bit signless integer cases: 0, 1, 2, 3, 4, 5 |
Operands:#
Operand |
Description |
---|---|
|
dynamic type |
|
dynamic type |
Results:#
Result |
Description |
---|---|
|
1-bit signless integer |
py.int_fromSigned
(::pylir::Py::IntFromSignedOp)#
Syntax:
operation ::= `py.int_fromSigned` $input attr-dict
Interprets an index as signed and converts it into a python integer.
Traits: AlwaysBound
, KnownTypeObjectInterface
, ReturnsImmutable
Interfaces: InferTypeOpInterface
, NoMemoryEffect (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{}
Operands:#
Operand |
Description |
---|---|
|
index |
Results:#
Result |
Description |
---|---|
|
dynamic type |
py.int_fromUnsigned
(::pylir::Py::IntFromUnsignedOp)#
Syntax:
operation ::= `py.int_fromUnsigned` $input attr-dict
Interprets an index as unsigned and converts it into a python integer.
Traits: AlwaysBound
, KnownTypeObjectInterface
, ReturnsImmutable
Interfaces: InferTypeOpInterface
, NoMemoryEffect (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{}
Operands:#
Operand |
Description |
---|---|
|
index |
Results:#
Result |
Description |
---|---|
|
dynamic type |
py.int_toIndex
(::pylir::Py::IntToIndexOp)#
Syntax:
operation ::= `py.int_toIndex` $input attr-dict
Converts the python integer $input
into an index.
The python integers value is interpreted as if encoded via twos complement
with the bit-width of the index type.
That means any python integer created via py.fromUnsigned
or
py.int_fromSigned
can be converted back to the exact index value it was
created with.
If $input
is outside the range of values representable by index
, that is
less than \(-2^{\text{index_width}-1}\) or larger than
\(2^{\text{index_width}}-1\), the behaviour is undefined.
If $input
is not really an int (or subclass of) the behaviour is
undefined.
Interfaces: CaptureInterface
, InferTypeOpInterface
, NoMemoryEffect (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{}
Operands:#
Operand |
Description |
---|---|
|
dynamic type |
Results:#
Result |
Description |
---|---|
|
index |
py.int_toStr
(::pylir::Py::IntToStrOp)#
Syntax:
operation ::= `py.int_toStr` $input attr-dict
Converts a python integer into a python string.
If $input
is not really an int (or subclass of) the behaviour is
undefined.
Traits: AlwaysBound
, KnownTypeObjectInterface
, ReturnsImmutable
Interfaces: CaptureInterface
, InferTypeOpInterface
, NoMemoryEffect (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{}
Operands:#
Operand |
Description |
---|---|
|
dynamic type |
Results:#
Result |
Description |
---|---|
|
dynamic type |
py.intr_print
(::pylir::Py::PrintOp)#
Syntax:
operation ::= `py.intr_print` $string attr-dict
Interfaces: CaptureInterface
, MemoryEffectOpInterface (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{MemoryEffects::Write on ::mlir::SideEffects::DefaultResource}
Operands:#
Operand |
Description |
---|---|
|
dynamic type |
py.invoke
(::pylir::Py::InvokeOp)#
Invoke operation
Syntax:
operation ::= `py.invoke` $callee `(` $call_operands `)` attr-dict `:` functional-type($call_operands, results)
`\n` ` ` ` `
`label` $happy_path ( `(` $normal_dest_operands^ `:` type($normal_dest_operands) `)`)?
`unwind` $exception_path ( `(` $unwind_dest_operands^ `:` type($unwind_dest_operands) `)`)?
Traits: AlwaysBound
, AttrSizedOperandSegments
, Terminator
Interfaces: BranchOpInterface
, CallOpInterface
, ExceptionHandlingInterface
, SymbolUserOpInterface
Attributes:#
Attribute | MLIR Type | Description |
---|---|---|
callee | ::mlir::FlatSymbolRefAttr | flat symbol reference attribute |
Operands:#
Operand |
Description |
---|---|
|
variadic of any type |
|
variadic of any type |
|
variadic of any type |
Results:#
Result |
Description |
---|---|
|
variadic of any type |
Successors:#
Successor |
Description |
---|---|
|
any successor |
|
any successor |
py.is
(::pylir::Py::IsOp)#
Syntax:
operation ::= `py.is` $lhs `,` $rhs attr-dict
Traits: Commutative
Interfaces: InferTypeOpInterface
, NoMemoryEffect (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{}
Operands:#
Operand |
Description |
---|---|
|
dynamic type |
|
dynamic type |
Results:#
Result |
Description |
---|---|
|
1-bit signless integer |
py.isUnboundValue
(::pylir::Py::IsUnboundValueOp)#
Checks whether the value is an unbound value
Syntax:
operation ::= `py.isUnboundValue` $value attr-dict
Interfaces: CaptureInterface
, InferTypeOpInterface
, NoMemoryEffect (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{}
Operands:#
Operand |
Description |
---|---|
|
dynamic type |
Results:#
Result |
Description |
---|---|
|
1-bit signless integer |
py.list_getItem
(::pylir::Py::ListGetItemOp)#
Syntax:
operation ::= `py.list_getItem` $list `[` $index `]` attr-dict
This op gets the item referred to by the $index
inside of the $list
.
If $list
is not really a list (or subclass of) the behaviour is undefined.
If $index
is greater or equal to the length of the list the behaviour is
undefined.
Traits: AlwaysBound
Interfaces: CaptureInterface
, InferTypeOpInterface
, SROAReadWriteOpInterface
Operands:#
Operand |
Description |
---|---|
|
dynamic type |
|
index |
Results:#
Result |
Description |
---|---|
|
dynamic type |
py.list_len
(::pylir::Py::ListLenOp)#
Syntax:
operation ::= `py.list_len` $list attr-dict
This op returns the length of $input
.
If $input
is not really a list (or a subclass of) then the behaviour is
undefined.
Interfaces: CaptureInterface
, InferTypeOpInterface
, MemoryFoldInterface
, SROAReadWriteOpInterface
Operands:#
Operand |
Description |
---|---|
|
dynamic type |
Results:#
Result |
Description |
---|---|
|
index |
py.list_resize
(::pylir::Py::ListResizeOp)#
Syntax:
operation ::= `py.list_resize` $list `to` $length attr-dict
This op resizes the $list
to $length
amount of elements, allowing both
growing and shrinking.
If this op caused the $list
to grow then the newly added accessible
elements are initially undefined and reading them prior to setting them is
undefined behaviour.
If $list
is not really a list (or subclass of) the behaviour is undefined.
Interfaces: CaptureInterface
, SROAReadWriteOpInterface
Operands:#
Operand |
Description |
---|---|
|
dynamic type |
|
index |
py.list_setItem
(::pylir::Py::ListSetItemOp)#
Syntax:
operation ::= `py.list_setItem` $list `[` $index `]` `to` $element attr-dict
This op sets the item referred to by the $index
inside of the
$list
to $element
.
If $list
is not really a list (or subclass of) the behaviour is undefined.
If $index
is greater or equal to the length of the list the behaviour is
undefined.
Interfaces: CaptureInterface
, SROAReadWriteOpInterface
Operands:#
Operand |
Description |
---|---|
|
dynamic type |
|
index |
|
dynamic type |
py.list_toTuple
(::pylir::Py::ListToTupleOp)#
Syntax:
operation ::= `py.list_toTuple` $list attr-dict
This op creates a tuple from the elements in $list
. The list remains
unmodified.
If $list
is not really a list (or subclass of) the behaviour is undefined.
Traits: AlwaysBound
, KnownTypeObjectInterface
, ReturnsImmutable
Interfaces: CaptureInterface
, InferTypeOpInterface
Operands:#
Operand |
Description |
---|---|
|
dynamic type |
Results:#
Result |
Description |
---|---|
|
dynamic type |
py.load
(::pylir::Py::LoadOp)#
Load operation
Syntax:
operation ::= `py.load` $global `:` type($result) attr-dict
This op retrieves the value that was last stored into $global
.
If no value was previously stored into $global
the behaviour is undefined.
Interfaces: MemoryFoldInterface
, SymbolUserOpInterface
Attributes:#
Attribute | MLIR Type | Description |
---|---|---|
global | ::mlir::FlatSymbolRefAttr | flat symbol reference attribute |
Results:#
Result |
Description |
---|---|
|
any type |
py.makeDict
(::pylir::Py::MakeDictOp)#
Syntax:
operation ::= `py.makeDict` custom<MappingArguments>($keys, $hashes, $values, $mapping_expansion)
attr-dict
Traits: AddableExceptionHandling<MakeDictExOp>
, AlwaysBound
, AttrSizedOperandSegments
, KnownTypeObjectInterface
Interfaces: InferTypeOpInterface
, SROAAllocOpInterface
Attributes:#
Attribute | MLIR Type | Description |
---|---|---|
mapping_expansion | ::mlir::DenseI32ArrayAttr | i32 dense array attribute |
Operands:#
Operand |
Description |
---|---|
|
variadic of dynamic type |
|
variadic of index |
|
variadic of dynamic type |
Results:#
Result |
Description |
---|---|
|
dynamic type |
py.makeDictEx
(::pylir::Py::MakeDictExOp)#
Exception-handling variant of py.makeDict
Syntax:
operation ::= `py.makeDictEx` custom<MappingArguments>($keys, $hashes, $values, $mapping_expansion)
attr-dict
`\n` ` ` ` `
`label` $happy_path ( `(` $normal_dest_operands^ `:` type($normal_dest_operands) `)`)?
`unwind` $exception_path ( `(` $unwind_dest_operands^ `:` type($unwind_dest_operands) `)`)?
Traits: AlwaysBound
, AttrSizedOperandSegments
, KnownTypeObjectInterface
, Terminator
Interfaces: BranchOpInterface
, ExceptionHandlingInterface
, InferTypeOpInterface
, SROAAllocOpInterface
Attributes:#
Attribute | MLIR Type | Description |
---|---|---|
mapping_expansion | ::mlir::DenseI32ArrayAttr | i32 dense array attribute |
Operands:#
Operand |
Description |
---|---|
|
variadic of dynamic type |
|
variadic of index |
|
variadic of dynamic type |
|
variadic of any type |
|
variadic of any type |
Results:#
Result |
Description |
---|---|
|
dynamic type |
Successors:#
Successor |
Description |
---|---|
|
any successor |
|
any successor |
py.makeFunc
(::pylir::Py::MakeFuncOp)#
Syntax:
operation ::= `py.makeFunc` $function (`[` $closure_args^ `:` type($closure_args) `]`)? attr-dict
Creates a new instance of a python function that refers to function
.
closure_args
are extra operands that are stored as part of the function
object and can only be read using py.function_closureArg
, where the index
refers to the position within closure_args
.
Traits: AlwaysBound
, KnownTypeObjectInterface
Interfaces: InferTypeOpInterface
, SROAAllocOpInterface
, SymbolUserOpInterface
Attributes:#
Attribute | MLIR Type | Description |
---|---|---|
function | ::mlir::FlatSymbolRefAttr | flat symbol reference attribute |
Operands:#
Operand |
Description |
---|---|
|
variadic of any type |
Results:#
Result |
Description |
---|---|
|
dynamic type |
py.makeList
(::pylir::Py::MakeListOp)#
Syntax:
operation ::= `py.makeList` custom<IterArguments>($arguments, $iter_expansion) attr-dict
Traits: AddableExceptionHandling<MakeListExOp>
, AlwaysBound
, KnownTypeObjectInterface
Interfaces: InferTypeOpInterface
, SROAAllocOpInterface
Attributes:#
Attribute | MLIR Type | Description |
---|---|---|
iter_expansion | ::mlir::DenseI32ArrayAttr | i32 dense array attribute |
Operands:#
Operand |
Description |
---|---|
|
variadic of dynamic type |
Results:#
Result |
Description |
---|---|
|
dynamic type |
py.makeListEx
(::pylir::Py::MakeListExOp)#
Exception-handling variant of py.makeList
Syntax:
operation ::= `py.makeListEx` custom<IterArguments>($arguments, $iter_expansion) attr-dict
`\n` ` ` ` `
`label` $happy_path ( `(` $normal_dest_operands^ `:` type($normal_dest_operands) `)`)?
`unwind` $exception_path ( `(` $unwind_dest_operands^ `:` type($unwind_dest_operands) `)`)?
Traits: AlwaysBound
, AttrSizedOperandSegments
, KnownTypeObjectInterface
, Terminator
Interfaces: BranchOpInterface
, ExceptionHandlingInterface
, InferTypeOpInterface
, SROAAllocOpInterface
Attributes:#
Attribute | MLIR Type | Description |
---|---|---|
iter_expansion | ::mlir::DenseI32ArrayAttr | i32 dense array attribute |
Operands:#
Operand |
Description |
---|---|
|
variadic of dynamic type |
|
variadic of any type |
|
variadic of any type |
Results:#
Result |
Description |
---|---|
|
dynamic type |
Successors:#
Successor |
Description |
---|---|
|
any successor |
|
any successor |
py.makeObject
(::pylir::Py::MakeObjectOp)#
Syntax:
operation ::= `py.makeObject` $type_object attr-dict
Creates a new object of the type of the given type object.
If $type_object
is not an instance of builtins.type
the behaviour is
undefined.
Traits: AlwaysBound
Interfaces: InferTypeOpInterface
, KnownTypeObjectInterface
, SROAAllocOpInterface
Operands:#
Operand |
Description |
---|---|
|
dynamic type |
Results:#
Result |
Description |
---|---|
|
dynamic type |
py.makeSet
(::pylir::Py::MakeSetOp)#
Syntax:
operation ::= `py.makeSet` custom<IterArguments>($arguments, $iter_expansion) attr-dict
Traits: AddableExceptionHandling<MakeSetExOp>
, AlwaysBound
, KnownTypeObjectInterface
Interfaces: InferTypeOpInterface
Attributes:#
Attribute | MLIR Type | Description |
---|---|---|
iter_expansion | ::mlir::DenseI32ArrayAttr | i32 dense array attribute |
Operands:#
Operand |
Description |
---|---|
|
variadic of dynamic type |
Results:#
Result |
Description |
---|---|
|
dynamic type |
py.makeSetEx
(::pylir::Py::MakeSetExOp)#
Exception-handling variant of py.makeSet
Syntax:
operation ::= `py.makeSetEx` custom<IterArguments>($arguments, $iter_expansion) attr-dict
`\n` ` ` ` `
`label` $happy_path ( `(` $normal_dest_operands^ `:` type($normal_dest_operands) `)`)?
`unwind` $exception_path ( `(` $unwind_dest_operands^ `:` type($unwind_dest_operands) `)`)?
Traits: AlwaysBound
, AttrSizedOperandSegments
, KnownTypeObjectInterface
, Terminator
Interfaces: BranchOpInterface
, ExceptionHandlingInterface
, InferTypeOpInterface
Attributes:#
Attribute | MLIR Type | Description |
---|---|---|
iter_expansion | ::mlir::DenseI32ArrayAttr | i32 dense array attribute |
Operands:#
Operand |
Description |
---|---|
|
variadic of dynamic type |
|
variadic of any type |
|
variadic of any type |
Results:#
Result |
Description |
---|---|
|
dynamic type |
Successors:#
Successor |
Description |
---|---|
|
any successor |
|
any successor |
py.makeTuple
(::pylir::Py::MakeTupleOp)#
Syntax:
operation ::= `py.makeTuple` custom<IterArguments>($arguments, $iter_expansion) attr-dict
This op creates a tuple from the given arguments.
If an argument is prefixed by a *
then it must be iterable and its
elements will be copied into the tuple at the given position.
As this operation creates a tuple it can never alias another tuple created
by this op unless both are turned into the same constants
(at which point aliasing becomes irrelevant).
This op as well as the constant op are the only ones capable of creating a tuple. After creation it is impossible to be modified. If it contains objects that are mutable however, those may still be modified. This way one is capable of arguing about the tuple in a typical SSA fashion.
Traits: AddableExceptionHandling<MakeTupleExOp>
, AlwaysBound
, KnownTypeObjectInterface
, ReturnsImmutable
Interfaces: InferTypeOpInterface
, MemoryEffectOpInterface
Attributes:#
Attribute | MLIR Type | Description |
---|---|---|
iter_expansion | ::mlir::DenseI32ArrayAttr | i32 dense array attribute |
Operands:#
Operand |
Description |
---|---|
|
variadic of dynamic type |
Results:#
Result |
Description |
---|---|
|
dynamic type |
py.makeTupleEx
(::pylir::Py::MakeTupleExOp)#
Exception-handling variant of py.makeTuple
Syntax:
operation ::= `py.makeTupleEx` custom<IterArguments>($arguments, $iter_expansion) attr-dict
`\n` ` ` ` `
`label` $happy_path ( `(` $normal_dest_operands^ `:` type($normal_dest_operands) `)`)?
`unwind` $exception_path ( `(` $unwind_dest_operands^ `:` type($unwind_dest_operands) `)`)?
Traits: AlwaysBound
, AttrSizedOperandSegments
, KnownTypeObjectInterface
, ReturnsImmutable
, Terminator
Interfaces: BranchOpInterface
, ExceptionHandlingInterface
, InferTypeOpInterface
, MemoryEffectOpInterface
Attributes:#
Attribute | MLIR Type | Description |
---|---|---|
iter_expansion | ::mlir::DenseI32ArrayAttr | i32 dense array attribute |
Operands:#
Operand |
Description |
---|---|
|
variadic of dynamic type |
|
variadic of any type |
|
variadic of any type |
Results:#
Result |
Description |
---|---|
|
dynamic type |
Successors:#
Successor |
Description |
---|---|
|
any successor |
|
any successor |
py.makeType
(::pylir::Py::MakeTypeOp)#
Syntax:
operation ::= `py.makeType` `(` `name` `=` $name `,`
`mro` `=` $mro_tuple `,`
`slots` `=` $slots_tuple `)` attr-dict
Creates a new type object with the given name, MRO tuple and slots tuple.
The MRO tuple must be a tuple of type objects.
It is not captured, but rather copied with the result of the makeType
operation prepended.
The slots tuple must be a tuple of strings and is captured.
Traits: AlwaysBound
, KnownTypeObjectInterface
Interfaces: InferTypeOpInterface
Operands:#
Operand |
Description |
---|---|
|
dynamic type |
|
dynamic type |
|
dynamic type |
Results:#
Result |
Description |
---|---|
|
dynamic type |
py.mroLookup
(::pylir::Py::MROLookupOp)#
Syntax:
operation ::= `py.mroLookup` $slot `in` $mro_tuple attr-dict
This op does a linear search through the given tuple, accessing the slot on
every element and returning the first one bound, not accessing any objects
after.
If $mro_tuple
is not really a tuple (or subclass of) the behaviour is
undefined.
If $slot
is greater or equal to the amount of slots in an element accessed
during traversal, the behaviour is undefined.
If a bound slot was found it is returned to $result
, else it is unbound.
Interfaces: CaptureInterface
, InferTypeOpInterface
, MemoryEffectOpInterface (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{MemoryEffects::Read on ::pylir::Py::ObjectResource}
Operands:#
Operand |
Description |
---|---|
|
dynamic type |
|
index |
Results:#
Result |
Description |
---|---|
|
dynamic type |
py.object_hash
(::pylir::Py::ObjectHashOp)#
Syntax:
operation ::= `py.object_hash` $object attr-dict
Returns a hash value from an arbitrary object using its identity.
Interfaces: CaptureInterface
, InferTypeOpInterface
, NoMemoryEffect (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{}
Operands:#
Operand |
Description |
---|---|
|
dynamic type |
Results:#
Result |
Description |
---|---|
|
index |
py.object_id
(::pylir::Py::ObjectIdOp)#
Syntax:
operation ::= `py.object_id` $object attr-dict
Interfaces: CaptureInterface
, InferTypeOpInterface
, NoMemoryEffect (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{}
Operands:#
Operand |
Description |
---|---|
|
dynamic type |
Results:#
Result |
Description |
---|---|
|
index |
py.raise
(::pylir::Py::RaiseOp)#
Raise exception
Syntax:
operation ::= `py.raise` $exception attr-dict
Traits: AddableExceptionHandling<RaiseExOp>
, Terminator
Operands:#
Operand |
Description |
---|---|
|
dynamic type |
py.raiseEx
(::pylir::Py::RaiseExOp)#
Exception-handling variant of py.raise
Syntax:
operation ::= `py.raiseEx` $exception attr-dict
`\n` ` ` ` `
`label` $happy_path ( `(` $normal_dest_operands^ `:` type($normal_dest_operands) `)`)?
`unwind` $exception_path ( `(` $unwind_dest_operands^ `:` type($unwind_dest_operands) `)`)?
Traits: AttrSizedOperandSegments
, Terminator
Interfaces: BranchOpInterface
, ExceptionHandlingInterface
Operands:#
Operand |
Description |
---|---|
|
dynamic type |
|
variadic of any type |
|
variadic of any type |
Successors:#
Successor |
Description |
---|---|
|
any successor |
|
any successor |
py.return
(::pylir::Py::ReturnOp)#
Syntax:
operation ::= `py.return` ($arguments^ `:` type($arguments))? attr-dict
Traits: HasParent<FuncOp>
, ReturnLike
, Terminator
Interfaces: RegionBranchTerminatorOpInterface
Operands:#
Operand |
Description |
---|---|
|
variadic of any type |
py.setSlot
(::pylir::Py::SetSlotOp)#
Syntax:
operation ::= `py.setSlot` $object `[`$slot`]` `to` $value attr-dict
Sets the value of the slot with index $slot
inside of $object
to
$value
.
If $slot
is greater or equal to the amount of slots of $object
it is
undefined behaviour.
Interfaces: CaptureInterface
, SROAReadWriteOpInterface
Operands:#
Operand |
Description |
---|---|
|
dynamic type |
|
index |
|
dynamic type |
py.store
(::pylir::Py::StoreOp)#
Store operation
Syntax:
operation ::= `py.store` $value `:` type($value) `into` $global attr-dict
This op binds the value denoted by $value
to the $global
.
Subsequent loads will return the last stored values.
The type of $value
has to match up exactly with the type of $global
.
Interfaces: SymbolUserOpInterface
Attributes:#
Attribute | MLIR Type | Description |
---|---|---|
global | ::mlir::FlatSymbolRefAttr | flat symbol reference attribute |
Operands:#
Operand |
Description |
---|---|
|
any type |
py.str_concat
(::pylir::Py::StrConcatOp)#
Syntax:
operation ::= `py.str_concat` $strings attr-dict
Creates a new string by concatenating all $strings
from left to right.
If any of the operands are not really a string (or a subclass of) the
behaviour is undefined.
Traits: AlwaysBound
, KnownTypeObjectInterface
, ReturnsImmutable
Interfaces: CaptureInterface
, InferTypeOpInterface
, NoMemoryEffect (MemoryEffectOpInterface)
, OnlyReadsValueInterface
Effects: MemoryEffects::Effect{}
Operands:#
Operand |
Description |
---|---|
|
variadic of dynamic type |
Results:#
Result |
Description |
---|---|
|
dynamic type |
py.str_copy
(::pylir::Py::StrCopyOp)#
Syntax:
operation ::= `py.str_copy` $string `:` $type_object attr-dict
Creates a copy of $string
which will have the type $type_object
.
If $string
is not really a string (or subclass of) or $type_object
is
not builtins.str
(or subclass of) the behaviour is undefined.
Traits: AlwaysBound
Interfaces: CaptureInterface
, CopyObjectInterface
, InferTypeOpInterface
, KnownTypeObjectInterface
, OnlyReadsValueInterface
, SROAAllocOpInterface
Operands:#
Operand |
Description |
---|---|
|
dynamic type |
|
dynamic type |
Results:#
Result |
Description |
---|---|
|
dynamic type |
py.str_equal
(::pylir::Py::StrEqualOp)#
Syntax:
operation ::= `py.str_equal` $lhs `,` $rhs attr-dict
Checks whether two strings are equal.
If $lhs
or $rhs
are not really strings (or a subclass of) the behaviour
is undefined.
Interfaces: CaptureInterface
, InferTypeOpInterface
, NoMemoryEffect (MemoryEffectOpInterface)
, OnlyReadsValueInterface
Effects: MemoryEffects::Effect{}
Operands:#
Operand |
Description |
---|---|
|
dynamic type |
|
dynamic type |
Results:#
Result |
Description |
---|---|
|
1-bit signless integer |
py.str_hash
(::pylir::Py::StrHashOp)#
Syntax:
operation ::= `py.str_hash` $object attr-dict
Returns the hash value for the string $object
.
If $object
is not really a string (or a subclass of) the behaviour is
undefined.
Interfaces: CaptureInterface
, InferTypeOpInterface
, NoMemoryEffect (MemoryEffectOpInterface)
, OnlyReadsValueInterface
Effects: MemoryEffects::Effect{}
Operands:#
Operand |
Description |
---|---|
|
dynamic type |
Results:#
Result |
Description |
---|---|
|
index |
py.tuple_contains
(::pylir::Py::TupleContainsOp)#
Syntax:
operation ::= `py.tuple_contains` $element `in` $tuple attr-dict
This op does a linear search through the given tuple, checking whether
$element
is contained within.
Equality is determined via identity comparison.
If it is $success
returns true
, false
otherwise.
This is used to check whether a type is a subclass of another.
If $tuple
is not really a tuple (or subclass of) the behaviour is
undefined.
Interfaces: CaptureInterface
, InferTypeOpInterface
, NoMemoryEffect (MemoryEffectOpInterface)
, OnlyReadsValueInterface
Effects: MemoryEffects::Effect{}
Operands:#
Operand |
Description |
---|---|
|
dynamic type |
|
dynamic type |
Results:#
Result |
Description |
---|---|
|
1-bit signless integer |
py.tuple_copy
(::pylir::Py::TupleCopyOp)#
Syntax:
operation ::= `py.tuple_copy` $tuple `:` $type_object attr-dict
Creates a new tuple object of type $type_object
and initializes it by
copying the tuple parts of $tuple
.
This results in a copy of all references within $tuple
as well as the
size. No copy of any slots are performed.
If $tuple
is not a tuple or a subclass of the behaviour is undefined.
If $type_object
is not the tuple type object or a type object deriving
from tuple the behaviour is undefined.
Traits: AlwaysBound
Interfaces: CaptureInterface
, CopyObjectInterface
, InferTypeOpInterface
, KnownTypeObjectInterface
, OnlyReadsValueInterface
, SROAAllocOpInterface
Operands:#
Operand |
Description |
---|---|
|
dynamic type |
|
dynamic type |
Results:#
Result |
Description |
---|---|
|
dynamic type |
py.tuple_dropFront
(::pylir::Py::TupleDropFrontOp)#
Syntax:
operation ::= `py.tuple_dropFront` $count `,` $tuple attr-dict
Traits: AlwaysBound
, KnownTypeObjectInterface
, ReturnsImmutable
Interfaces: CaptureInterface
, InferTypeOpInterface
, NoMemoryEffect (MemoryEffectOpInterface)
, OnlyReadsValueInterface
Effects: MemoryEffects::Effect{}
Operands:#
Operand |
Description |
---|---|
|
index |
|
dynamic type |
Results:#
Result |
Description |
---|---|
|
dynamic type |
py.tuple_getItem
(::pylir::Py::TupleGetItemOp)#
Syntax:
operation ::= `py.tuple_getItem` $tuple `[` $index `]` attr-dict
This op fetches the object stored at $index
in $tuple
.
If $tuple
is not really a tuple (or subclass of) or $index
is out of
range for the tuple, the behaviour is undefined.
Traits: AlwaysBound
Interfaces: CaptureInterface
, InferTypeOpInterface
, NoMemoryEffect (MemoryEffectOpInterface)
, OnlyReadsValueInterface
Effects: MemoryEffects::Effect{}
Operands:#
Operand |
Description |
---|---|
|
dynamic type |
|
index |
Results:#
Result |
Description |
---|---|
|
dynamic type |
py.tuple_len
(::pylir::Py::TupleLenOp)#
Syntax:
operation ::= `py.tuple_len` $input attr-dict
This op returns the length of $input
as the given integer type.
If $tuple
is not really a tuple (or a subclass of) then the behaviour of
is undefined.
Interfaces: CaptureInterface
, InferTypeOpInterface
, NoMemoryEffect (MemoryEffectOpInterface)
, OnlyReadsValueInterface
Effects: MemoryEffects::Effect{}
Operands:#
Operand |
Description |
---|---|
|
dynamic type |
Results:#
Result |
Description |
---|---|
|
index |
py.tuple_prepend
(::pylir::Py::TuplePrependOp)#
Syntax:
operation ::= `py.tuple_prepend` $input `,` $tuple attr-dict
Traits: AlwaysBound
, KnownTypeObjectInterface
, ReturnsImmutable
Interfaces: CaptureInterface
, InferTypeOpInterface
, NoMemoryEffect (MemoryEffectOpInterface)
, OnlyReadsValueInterface
Effects: MemoryEffects::Effect{}
Operands:#
Operand |
Description |
---|---|
|
dynamic type |
|
dynamic type |
Results:#
Result |
Description |
---|---|
|
dynamic type |
py.type_mro
(::pylir::Py::TypeMROOp)#
Syntax:
operation ::= `py.type_mro` $type_object attr-dict
Traits: AlwaysBound
, KnownTypeObjectInterface
, ReturnsImmutable
Interfaces: CaptureInterface
, InferTypeOpInterface
, NoMemoryEffect (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{}
Operands:#
Operand |
Description |
---|---|
|
dynamic type |
Results:#
Result |
Description |
---|---|
|
dynamic type |
py.type_slots
(::pylir::Py::TypeSlotsOp)#
Syntax:
operation ::= `py.type_slots` $type_object attr-dict
Returns the tuple containing the names of all slots of an instance of
$type_object
as strings.
If $type_object
is not really a type (or a subclass of) the behaviour is
undefined.
Traits: AlwaysBound
, KnownTypeObjectInterface
, ReturnsImmutable
Interfaces: CaptureInterface
, InferTypeOpInterface
, NoMemoryEffect (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{}
Operands:#
Operand |
Description |
---|---|
|
dynamic type |
Results:#
Result |
Description |
---|---|
|
dynamic type |
py.typeOf
(::pylir::Py::TypeOfOp)#
Syntax:
operation ::= `py.typeOf` $object attr-dict
Retrieves the type of the object. This will always be an instance of
builtins.type
or a subclass.
Traits: AlwaysBound
Interfaces: CaptureInterface
, InferTypeOpInterface
, NoMemoryEffect (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{}
Operands:#
Operand |
Description |
---|---|
|
dynamic type |
Results:#
Result |
Description |
---|---|
|
dynamic type |
py.unpack
(::pylir::Py::UnpackOp)#
Syntax:
operation ::= `py.unpack` $iterable `:` `(` ( `)` ) : ( `` type($before)^ `)`)? (`,` type($rest)^
(`,` `(` type($after)^ `)`)?)? attr-dict
Takes an iterable object and unpacks it into multiple values. The results of this operation may consist of one or three result parts.
One part form example:
%before:3 = unpack %iterable : (!py.dynamic, !py.dynamic, !py.dynamic)
This expects the iterable to contain 3 elements to unpack them into
Three part form example:
%before:3, %rest, %after:2 = unpack %iterable : (!py.dynamic, !py.dynamic, !py.dynamic), !py.dynamic, (!py.dynamic, !py.dynamic)
This expects the iterable to contain at least 5 elements. The first 3 elements are unpacked into %before:0 to 2, and the last 2 elements of the iterable into %after:0 to 1. All other left over elements will form a list that is assigned to %rest.
The iterable’s iterator is created via a call to pythons builtin iter
function, and the elements extracted via pythons builtin next
function.
Exceptions emitted by either of these methods, with the exception of
StopIteration
, are propagated as is.
If the iterable contains too few or too many elements, a ValueError
is
raised.
Traits: AddableExceptionHandling<UnpackExOp>
, AlwaysBound
, AttrSizedResultSegments
Operands:#
Operand |
Description |
---|---|
|
dynamic type |
Results:#
Result |
Description |
---|---|
|
variadic of dynamic type |
|
dynamic type |
|
variadic of dynamic type |
py.unpackEx
(::pylir::Py::UnpackExOp)#
Exception-handling variant of py.unpack
Syntax:
operation ::= `py.unpackEx` $iterable `:` `(` ( `)` ) : ( `` type($before)^ `)`)? (`,` type($rest)^
(`,` `(` type($after)^ `)`)?)? attr-dict
`\n` ` ` ` `
`label` $happy_path ( `(` $normal_dest_operands^ `:` type($normal_dest_operands) `)`)?
`unwind` $exception_path ( `(` $unwind_dest_operands^ `:` type($unwind_dest_operands) `)`)?
Traits: AlwaysBound
, AttrSizedOperandSegments
, AttrSizedResultSegments
, Terminator
Interfaces: BranchOpInterface
, ExceptionHandlingInterface
Operands:#
Operand |
Description |
---|---|
|
dynamic type |
|
variadic of any type |
|
variadic of any type |
Results:#
Result |
Description |
---|---|
|
variadic of dynamic type |
|
dynamic type |
|
variadic of dynamic type |
Successors:#
Successor |
Description |
---|---|
|
any successor |
|
any successor |
py.unreachable
(::pylir::Py::UnreachableOp)#
Syntax:
operation ::= `py.unreachable` attr-dict
Traits: Terminator
Attributes#
BoolAttr#
python boolean
Syntax:
#py.bool<
bool # value
>
Parameters:#
Parameter |
C++ type |
Description |
---|---|---|
value |
|
boolean |
DictAttr#
python dictionary
Syntax:
#py.dict<
::llvm::ArrayRef<std::pair<mlir::Attribute, std::size_t>>, # normalized_keys_internal
::llvm::ArrayRef<std::pair<mlir::Attribute, mlir::Attribute>> # key_value_pairs
>
Attribute for representing a constant dictionary.
Like most ObjectAttrInterface
implementations it is also capable of having
a custom typeObject
as well as slots
.
If a typeObject
is specified, it has to be a subclass of builtins.dict
.
If unspecified, it defaults to builtins.dict
.
DictAttr
semantically behaves the same as python dictionaries:
It uniques the key-value pairs based on the key, ensuring only the latest
entry is present, and retains insertion order of all key-value pairs while
doing so.
The deduplication already happens during parsing.
The most important detail about using DictAttr
is understanding the
restrictions on the keys.
Attributes that are passed in as keys need to have both a known __hash__
implementation as well as __eq__
implementation
(as is determined by getHashFunction
and getEqualsFunction
).
It is therefore not possible to have arbitrary keys in a DictAttr
.
Additionally, it is necessary to also specify a “normalized key” when
constructing a DictAttr
or within the IR syntax, if using a GlobalValueAttr
as
key that does not use identity equality as equals function.
The normalized key is the result of calling getCanonicalEqualsForm
on the
actual key of an entry and is what is used to determine whether two keys are
equal. Given a GlobalValueAttr
referring to a py.globalValue
with the given
equals function of the initializer argument, the following attribute kinds
are returned by getCanonicalEqualsForm
:
py.int
,py.float
->py.frac
py.str
-> “string literal”
Syntax:
dict ::= `#py.dict` `<` `{` { attr [`norm` attr] `to` attr } `}` `>`
Examples:
#py.dict<{#py.ref<@intGlobalValue> norm #py.frac<3,5> to #py.str<"value">}>
#py.dict<{#py.ref<@strGlobalValue> norm "the text" to #py.str<"value">}>
#py.dict<{#py.int<5> to #py.str<"value">}>
Parameters:#
Parameter |
C++ type |
Description |
---|---|---|
normalized_keys_internal |
|
|
key_value_pairs |
|
FloatAttr#
python float
Syntax:
#py.float<
::llvm::APFloat # value
>
Parameters:#
Parameter |
C++ type |
Description |
---|---|---|
value |
|
FractionalAttr#
Syntax:
#py.frac<
::pylir::BigInt, # nominator
::pylir::BigInt # denominator
>
Parameters:#
Parameter |
C++ type |
Description |
---|---|---|
nominator |
|
Arbitrary sized integer |
denominator |
|
Arbitrary sized integer |
FunctionAttr#
python function
Syntax:
#py.function<
mlir::FlatSymbolRefAttr, # value
mlir::Attribute, # qual_name
mlir::Attribute, # defaults
mlir::Attribute, # kw_defaults
mlir::Attribute # dict
>
Parameters:#
Parameter |
C++ type |
Description |
---|---|---|
value |
|
|
qual_name |
|
|
defaults |
|
|
kw_defaults |
|
|
dict |
|
GlobalValueAttr#
A #py.globalValue
is a special kind of attribute, representing an instance
of a globally accessibly Python object.
The op is optionally initialized with $initializer
, dictating the type and
initial value of the global value.
If no $initializer
is given, the op must have been marked external using a
py.external
in the module.
It differs from other attributes in the following way:
It is mutable unless marked with
const
. The attribute can be turned into an SSA-value usingpy.constant
and mutated with the usual operations. If markedconst
, any operations writing to thepy.globalValue
leads to undefined behaviour.It has nominal identity instead of structural identity. This means that two
#py.globalValue
instances that have different names are considered different objects. Apy.is
operation comparing these would therefore result inFalse
.
Syntax:
global-value ::= `#py.globalValue` `<` name { (`,` `const`)? (`,` `initializer` `=` attr) } `>`
Examples:
#py.globalValue<builtins.str, const, initializer = #py.type<mro_tuple = #py.tuple<()>>>
#py.globalValue<builtins.list>
#py.globalValue<builtins.type, initializer = #py.type>
Parameters:#
Parameter |
C++ type |
Description |
---|---|---|
name |
|
|
constant |
|
|
initializer |
|
IntAttr#
python integer
Syntax:
#py.int<
::pylir::BigInt # value
>
Parameters:#
Parameter |
C++ type |
Description |
---|---|---|
value |
|
Arbitrary sized integer |
ListAttr#
Syntax:
#py.list<
::llvm::ArrayRef<mlir::Attribute> # elements
>
Parameters:#
Parameter |
C++ type |
Description |
---|---|---|
elements |
|
ObjectAttr#
python object
Syntax:
#py.obj<
ObjectBaseAttribute, # type_object
::mlir::DictionaryAttr # slots
>
Parameters:#
Parameter |
C++ type |
Description |
---|---|---|
type_object |
|
|
slots |
|
StrAttr#
python string
Syntax:
#py.str<
::llvm::StringRef # value
>
Parameters:#
Parameter |
C++ type |
Description |
---|---|---|
value |
|
TupleAttr#
python tuple
Syntax:
#py.tuple<
::llvm::ArrayRef<mlir::Attribute> # elements
>
Parameters:#
Parameter |
C++ type |
Description |
---|---|---|
elements |
|
TypeAttr#
python type
Syntax:
#py.type<
mlir::Attribute, # mro_tuple
TupleAttr, # instance_slots
::mlir::DictionaryAttr # slots
>
Attribute for representing Python type
objects and subclasses.
For the most part, it acts as any other object attribute, having both a
customizable type object as well as slots.
Additionally, it contains two parameters. mroTuple
is a tuple of type
objects (or references to type objects) forming the order in which method
lookups are resolved.
instance_slots
is a tuple of strings, which denotes the slots an instance
of this type has.
If neither of the two parameters are specified (in the C++ builder or in
IR syntax), they default to an empty tuple.
Syntax:
optional-attrs ::= (`slots` | `mro_tuple` | `instance_slots`) `=` attr
dict ::= `#py.type` [ `<` optional-attrs { `,` optional-attrs} ] `>` ]
Examples:
#py.type
#py.type<instance_slots = #py.tuple<(#py.str<"lol">)>>
#py.type<mroTuple = #py.tuple<(#py.ref<@lol>)>>
Parameters:#
Parameter |
C++ type |
Description |
---|---|---|
mro_tuple |
|
|
instance_slots |
|
|
slots |
|
UnboundAttr#
python unbound value
Syntax: #py.unbound
Types#
DynamicType#
dynamic type
Syntax: !py.dynamic