Wraps a ‘const clang::CXXConstructorDecl *' AST node.
Operations optionally refer to this node, they could be available depending on the CIR lowering stage. Whether it's attached to the appropriated CIR operation is delegated to the operation verifier.
This always implies a non-null AST reference (verified).
Parameter | C++ type | Description |
---|---|---|
ast | const clang::CXXConstructorDecl * |
Wraps a ‘const clang::CXXConversionDecl *' AST node.
Operations optionally refer to this node, they could be available depending on the CIR lowering stage. Whether it's attached to the appropriated CIR operation is delegated to the operation verifier.
This always implies a non-null AST reference (verified).
Parameter | C++ type | Description |
---|---|---|
ast | const clang::CXXConversionDecl * |
Wraps a ‘const clang::CXXDestructorDecl *' AST node.
Operations optionally refer to this node, they could be available depending on the CIR lowering stage. Whether it's attached to the appropriated CIR operation is delegated to the operation verifier.
This always implies a non-null AST reference (verified).
Parameter | C++ type | Description |
---|---|---|
ast | const clang::CXXDestructorDecl * |
Wraps a ‘const clang::CXXMethodDecl *' AST node.
Operations optionally refer to this node, they could be available depending on the CIR lowering stage. Whether it's attached to the appropriated CIR operation is delegated to the operation verifier.
This always implies a non-null AST reference (verified).
Parameter | C++ type | Description |
---|---|---|
ast | const clang::CXXMethodDecl * |
Wraps a ‘const clang::CallExpr *' AST node.
Operations optionally refer to this node, they could be available depending on the CIR lowering stage. Whether it's attached to the appropriated CIR operation is delegated to the operation verifier.
This always implies a non-null AST reference (verified).
Parameter | C++ type | Description |
---|---|---|
ast | const clang::CallExpr * |
Wraps a ‘const clang::Decl *' AST node.
Operations optionally refer to this node, they could be available depending on the CIR lowering stage. Whether it's attached to the appropriated CIR operation is delegated to the operation verifier.
This always implies a non-null AST reference (verified).
Parameter | C++ type | Description |
---|---|---|
ast | const clang::Decl * |
Wraps a ‘const clang::Expr *' AST node.
Operations optionally refer to this node, they could be available depending on the CIR lowering stage. Whether it's attached to the appropriated CIR operation is delegated to the operation verifier.
This always implies a non-null AST reference (verified).
Parameter | C++ type | Description |
---|---|---|
ast | const clang::Expr * |
Wraps a ‘const clang::FunctionDecl *' AST node.
Operations optionally refer to this node, they could be available depending on the CIR lowering stage. Whether it's attached to the appropriated CIR operation is delegated to the operation verifier.
This always implies a non-null AST reference (verified).
Parameter | C++ type | Description |
---|---|---|
ast | const clang::FunctionDecl * |
Wraps a ‘const clang::RecordDecl *' AST node.
Operations optionally refer to this node, they could be available depending on the CIR lowering stage. Whether it's attached to the appropriated CIR operation is delegated to the operation verifier.
This always implies a non-null AST reference (verified).
Parameter | C++ type | Description |
---|---|---|
ast | const clang::RecordDecl * |
Wraps a ‘const clang::TagDecl *' AST node.
Operations optionally refer to this node, they could be available depending on the CIR lowering stage. Whether it's attached to the appropriated CIR operation is delegated to the operation verifier.
This always implies a non-null AST reference (verified).
Parameter | C++ type | Description |
---|---|---|
ast | const clang::TagDecl * |
Wraps a ‘const clang::TypeDecl *' AST node.
Operations optionally refer to this node, they could be available depending on the CIR lowering stage. Whether it's attached to the appropriated CIR operation is delegated to the operation verifier.
This always implies a non-null AST reference (verified).
Parameter | C++ type | Description |
---|---|---|
ast | const clang::TypeDecl * |
Wraps a ‘const clang::VarDecl *' AST node.
Operations optionally refer to this node, they could be available depending on the CIR lowering stage. Whether it's attached to the appropriated CIR operation is delegated to the operation verifier.
This always implies a non-null AST reference (verified).
Parameter | C++ type | Description |
---|---|---|
ast | const clang::VarDecl * |
Address space attribute for pointer types
Syntax:
#cir.addrspace<
int32_t # value
>
The address space attribute is used in pointer types. It essentially provides a unified model on top of clang::LangAS
, rather than LLVM address spaces.
The representation is further simplified: LangAS::Default
is encoded as a null attribute; many address spaces from different offloading languages are unified as offload_*
; etc.
The meaning of value
parameter is defined as an extensible enum Kind
, which encodes target AS as offset to the last language AS.
Parameter | C++ type | Description |
---|---|---|
value | int32_t |
Annotation attribute for global variables and functions
Syntax:
#cir.annotation<
StringAttr, # name
ArrayAttr # args
>
Represent C/C++ attribute of annotate in CIR. Example C code:
int *a __attribute__((annotate("testptr", "21", 12 )));
In this example code, the AnnotationAttr
has annotation name "testptr", and arguments "21" and 12 constitutes an ArrayAttr
type parameter args
for global variable a
. In CIR, the attribute for above annotation looks like:
[#cir.annotation<name = "withargs", args = ["21", 12 : i32]>]
Parameter | C++ type | Description |
---|---|---|
name | StringAttr | |
args | ArrayAttr |
Represents a bit field info
Syntax:
#cir.bitfield_info<
StringAttr, # name
Type, # storage_type
uint64_t, # size
uint64_t, # offset
bool # is_signed
>
Holds the next information about bitfields: name, storage type, a bitfield size and position in the storage, if the bitfield is signed or not.
Parameter | C++ type | Description |
---|---|---|
name | StringAttr | |
storage_type | Type | |
size | uint64_t | |
offset | uint64_t | |
is_signed | bool |
Represent true/false for !cir.bool types
Syntax:
#cir.bool<
mlir::cir::BoolType, # type
bool # value
>
The BoolAttr represents a ‘true' or ‘false' value.
Parameter | C++ type | Description |
---|---|---|
type | mlir::cir::BoolType | |
value | bool |
Holds information about a three-way comparison operation
Syntax:
#cir.cmp3way_info<
CmpOrdering, # ordering
int64_t, # lt
int64_t, # eq
int64_t, # gt
std::optional<int64_t> # unordered
>
The #cmp3way_info
attribute contains information about a three-way comparison operation cir.cmp3way
.
The ordering
parameter gives the ordering kind of the three-way comparison operation. It may be either strong ordering or partial ordering.
Given the two input operands of the three-way comparison operation lhs
and rhs
, the lt
, eq
, gt
, and unordered
parameters gives the result value that should be produced by the three-way comparison operation when the ordering between lhs
and rhs
is lhs < rhs
, lhs == rhs
, lhs > rhs
, or neither, respectively.
Parameter | C++ type | Description |
---|---|---|
ordering | CmpOrdering | |
lt | int64_t | |
eq | int64_t | |
gt | int64_t | |
unordered | std::optional<int64_t> |
An attribute that contains a constant complex value
Syntax:
#cir.complex<
mlir::cir::ComplexType, # type
mlir::TypedAttr, # real
mlir::TypedAttr # imag
>
The #cir.complex
attribute contains a constant value of complex number type. The real
parameter gives the real part of the complex number and the imag
parameter gives the imaginary part of the complex number.
The real
and imag
parameter must be either an IntAttr or an FPAttr that contains values of the same CIR type.
Parameter | C++ type | Description |
---|---|---|
type | mlir::cir::ComplexType | |
real | mlir::TypedAttr | |
imag | mlir::TypedAttr |
A constant array from ArrayAttr or StringRefAttr
An CIR array attribute is an array of literals of the specified attr types.
Parameter | C++ type | Description |
---|---|---|
type | ::mlir::Type | |
elts | Attribute | |
trailingZerosNum | int |
Holds a constant pointer value
Syntax:
#cir.ptr<
::mlir::cir::PointerType, # type
mlir::IntegerAttr # value
>
A pointer attribute is a literal attribute that represents an integral value of a pointer type.
Parameter | C++ type | Description |
---|---|---|
type | ::mlir::cir::PointerType | |
value | mlir::IntegerAttr |
Represents a constant struct
Syntax:
#cir.const_struct<
::mlir::Type, # type
ArrayAttr # members
>
Effectively supports "struct-like" constants. It's must be built from an mlir::ArrayAttr
instance where each elements is a typed attribute (mlir::TypedAttribute
).
Example:
cir.global external @rgb2 = #cir.const_struct<{0 : i8,
5 : i64, #cir.null : !cir.ptr<i8>
}> : !cir.struct<"", i8, i64, !cir.ptr<i8>>
Parameter | C++ type | Description |
---|---|---|
type | ::mlir::Type | |
members | ArrayAttr |
A constant vector from ArrayAttr
A CIR vector attribute is an array of literals of the specified attribute types.
Parameter | C++ type | Description |
---|---|---|
type | ::mlir::Type | |
elts | ArrayAttr |
Syntax: #cir.convergent
Holds a constant data member pointer value
Syntax:
#cir.data_member<
mlir::cir::DataMemberType, # type
std::optional<unsigned> # member_index
>
A data member attribute is a literal attribute that represents a constant pointer-to-data-member value.
The member_index
parameter represents the index of the pointed-to member within its containing struct. It is an optional parameter; lack of this parameter indicates a null pointer-to-data-member value.
Example:
#ptr = #cir.data_member<1> : !cir.data_member<!s32i in !ty_22Point22>
#null = #cir.data_member<null> : !cir.data_member<!s32i in !ty_22Point22>
Parameter | C++ type | Description |
---|---|---|
type | mlir::cir::DataMemberType | |
member_index | std::optional<unsigned> |
ABI specific information about a dynamic cast
Syntax:
#cir.dyn_cast_info<
::mlir::cir::GlobalViewAttr, # srcRtti
::mlir::cir::GlobalViewAttr, # destRtti
FlatSymbolRefAttr, # runtimeFunc
FlatSymbolRefAttr, # badCastFunc
::mlir::cir::IntAttr # offsetHint
>
Provide ABI specific information about a dynamic cast operation.
The srcRtti
and the destRtti
parameters give the RTTI of the source struct type and the destination struct type, respectively.
The runtimeFunc
parameter gives the __dynamic_cast
function which is provided by the runtime. The badCastFunc
parameter gives the __cxa_bad_cast
function which is also provided by the runtime.
The offsetHint
parameter gives the hint value that should be passed to the __dynamic_cast
runtime function.
Parameter | C++ type | Description |
---|---|---|
srcRtti | ::mlir::cir::GlobalViewAttr | Provides constant access to a global address |
destRtti | ::mlir::cir::GlobalViewAttr | Provides constant access to a global address |
runtimeFunc | FlatSymbolRefAttr | |
badCastFunc | FlatSymbolRefAttr | |
offsetHint | ::mlir::cir::IntAttr | An Attribute containing a integer value |
Represents aggregated attributes for a function
Syntax:
#cir.extra<
DictionaryAttr # elements
>
This is a wrapper of attribute dictionary that contains extra attributes of a function.
Parameter | C++ type | Description |
---|---|---|
elements | DictionaryAttr |
An attribute containing a floating-point value
Syntax:
#cir.fp<
::mlir::Type, # type
APFloat # value
>
An fp attribute is a literal attribute that represents a floating-point value of the specified floating-point type.
Parameter | C++ type | Description |
---|---|---|
type | ::mlir::Type | |
value | APFloat |
Array of annotations, each element consists of name ofa global var or func and one of its annotations
Syntax:
#cir.global_annotations<
ArrayAttr # annotations
>
This is annotation value array, which holds the annotation values for all global variables and functions in a module. This array is used to create the initial value of a global annotation metadata variable in LLVM IR. Example C code:
double *a __attribute__((annotate("withargs", "21", 12 )));
int *b __attribute__((annotate("withargs", "21", 12 )));
void *c __attribute__((annotate("noargvar")));
void foo(int i) __attribute__((annotate("noargfunc"))) {}
After CIR lowering prepare pass, compiler generates a GlobalAnnotationValuesAttr
like the following:
#cir<global_annotations [
["a", #cir.annotation<name = "withargs", args = ["21", 12 : i32]>],
["b", #cir.annotation<name = "withargs", args = ["21", 12 : i32]>],
["c", #cir.annotation<name = "noargvar", args = []>],
["foo", #cir.annotation<name = "noargfunc", args = []>]]>
Parameter | C++ type | Description |
---|---|---|
annotations | ArrayAttr |
Marks a function as a global constructor
Syntax:
#cir.global_ctor<
StringAttr, # name
int # priority
>
A function with this attribute executes before main()
Parameter | C++ type | Description |
---|---|---|
name | StringAttr | |
priority | int |
Marks a function as a global destructor
Syntax:
#cir.global_dtor<
StringAttr, # name
int # priority
>
A function with this attribute excutes before module unloading
Parameter | C++ type | Description |
---|---|---|
name | StringAttr | |
priority | int |
Provides constant access to a global address
Syntax:
#cir.global_view<
::mlir::Type, # type
FlatSymbolRefAttr, # symbol
ArrayAttr # indices
>
Get constant address of global symbol
and optionally apply offsets to access existing subelements. It provides a way to access globals from other global and always produces a pointer.
The type of the input symbol can be different from #cir.global_view
output type, since a given view of the global might require a static cast for initializing other globals.
A list of indices can be optionally passed and each element subsequently indexes underlying types. For symbol
types like !cir.array
and !cir.struct
, it leads to the constant address of sub-elements, while for !cir.ptr
, an offset is applied. The first index is relative to the original symbol type, not the produced one.
Example:
cir.global external @s = @".str2": !cir.ptr<i8>
cir.global external @x = #cir.global_view<@s> : !cir.ptr<i8>
cir.global external @rgb = #cir.const_array<[0 : i8, -23 : i8, 33 : i8] : !cir.array<i8 x 3>>
cir.global external @elt_ptr = #cir.global_view<@rgb, [1]> : !cir.ptr<i8>
cir.global external @table_of_ptrs = #cir.const_array<[#cir.global_view<@rgb, [1]> : !cir.ptr<i8>] : !cir.array<!cir.ptr<i8> x 1>>
Parameter | C++ type | Description |
---|---|---|
type | ::mlir::Type | |
symbol | FlatSymbolRefAttr | |
indices | ArrayAttr |
Inline attribute
Syntax:
#cir.inline<
InlineKind # value
>
Inline attributes represents user directives.
Parameter | C++ type | Description |
---|---|---|
value | InlineKind |
An Attribute containing a integer value
An integer attribute is a literal attribute that represents an integral value of the specified integer type.
Parameter | C++ type | Description |
---|---|---|
type | ::mlir::Type | |
value | APInt |
Module source language
Represents the source language used to generate the module.
Example:
// Module compiled from C.
module attributes {cir.lang = cir.lang<c>} {}
// Module compiled from C++.
module attributes {cir.lang = cir.lang<cxx>} {}
Parameter | C++ type | Description |
---|---|---|
lang | SourceLanguageAttr |
Holds a constant pointer-to-member-function value
A method attribute is a literal attribute that represents a constant pointer-to-member-function value.
If the member function is a non-virtual function, the symbol
parameter gives the global symbol for the non-virtual member function.
If the member function is a virtual function, the vtable_offset
parameter gives the offset of the vtable entry corresponding to the virtual member function.
symbol
and vtable_offset
cannot be present at the same time. If both of symbol
and vtable_offset
are not present, the attribute represents a null pointer constant.
Parameter | C++ type | Description |
---|---|---|
type | mlir::cir::MethodType | |
symbol | std::optional<FlatSymbolRefAttr> | |
vtable_offset | std::optional<uint64_t> |
Syntax: #cir.nothrow
OpenCL kernel argument metadata
Syntax:
#cir.cl.kernel_arg_metadata<
ArrayAttr, # addr_space
ArrayAttr, # access_qual
ArrayAttr, # type
ArrayAttr, # base_type
ArrayAttr, # type_qual
ArrayAttr # name
>
Provide the required information of an OpenCL kernel argument for the SPIR-V backend.
All parameters are arrays, containing the information of the argument in the same order as they appear in the source code.
The addr_space
parameter is an array of I32 that provides the address space of the argument. It's useful for special types like image
, which have implicit global address space.
Other parameters are arrays of strings that pass through the information from the source code correspondingly.
All the fields are mandatory except for name
, which is optional.
Example:
#fn_attr = #cir<extra({cl.kernel_arg_metadata = #cir.cl.kernel_arg_metadata<
addr_space = [1 : i32],
access_qual = ["none"],
type = ["char*"],
base_type = ["char*"],
type_qual = [""],
name = ["in"]
>})>
cir.func @kernel(%arg0: !s32i) extra(#fn_attr) {
cir.return
}
Parameter | C++ type | Description |
---|---|---|
addr_space | ArrayAttr | |
access_qual | ArrayAttr | |
type | ArrayAttr | |
base_type | ArrayAttr | |
type_qual | ArrayAttr | |
name | ArrayAttr |
OpenCL kernel
Syntax: #cir.cl.kernel
Indicate the function is a OpenCL kernel.
OpenCL kernel metadata
Syntax:
#cir.cl.kernel_metadata<
ArrayAttr, # work_group_size_hint
ArrayAttr, # reqd_work_group_size
TypeAttr, # vec_type_hint
std::optional<bool>, # vec_type_hint_signedness
IntegerAttr # intel_reqd_sub_group_size
>
Provide the required information of an OpenCL kernel for the SPIR-V backend.
The work_group_size_hint
and reqd_work_group_size
parameter are integer arrays with 3 elements that provide hints for the work-group size and the required work-group size, respectively.
The vec_type_hint
parameter is a type attribute that provides a hint for the vectorization. It can be a CIR or LLVM type, depending on the lowering stage.
The vec_type_hint_signedness
parameter is a boolean that indicates the signedness of the vector type hint. It's useful when LLVM type is set in vec_type_hint
, which is signless by design. It should be set if and only if the vec_type_hint
is present.
The intel_reqd_sub_group_size
parameter is an integer that restricts the sub-group size to the specified value.
Example:
#fn_attr = #cir<extra({cl.kernel_metadata = #cir.cl.kernel_metadata<
work_group_size_hint = [8 : i32, 16 : i32, 32 : i32],
reqd_work_group_size = [1 : i32, 2 : i32, 4 : i32],
vec_type_hint = !s32i,
vec_type_hint_signedness = 1,
intel_reqd_sub_group_size = 8 : i32
>})>
cir.func @kernel(%arg0: !s32i) extra(#fn_attr) {
cir.return
}
Parameter | C++ type | Description |
---|---|---|
work_group_size_hint | ArrayAttr | |
reqd_work_group_size | ArrayAttr | |
vec_type_hint | TypeAttr | |
vec_type_hint_signedness | std::optional<bool> | |
intel_reqd_sub_group_size | IntegerAttr |
OpenCL kernel work-group uniformity
Syntax: #cir.cl.uniform_work_group_size
In OpenCL v2.0, work groups can either be uniform or non-uniform. This attribute is associated with kernels to represent the work group type. Non-kernel entities should not interact with this attribute.
Clang's -cl-uniform-work-group-size
compilation option provides a hint to the compiler, indicating that the global work size should be a multiple of the work-group size specified in the clEnqueueNDRangeKernel
function, thereby ensuring that the work groups are uniform.
OpenCL version
Syntax:
#cir.cl.version<
int32_t, # major_version
int32_t # minor_version
>
Represents the version of OpenCL.
Example:
// Module compiled from OpenCL 1.2.
module attributes {cir.cl.version = cir.cl.version<1, 2>} {}
// Module compiled from OpenCL 3.0.
module attributes {cir.cl.version = cir.cl.version<3, 0>} {}
Parameter | C++ type | Description |
---|---|---|
major_version | int32_t | |
minor_version | int32_t |
Syntax: #cir.optnone
Parameter | C++ type | Description |
---|---|---|
behavior | sob::SignedOverflowBehavior |
ABI specific information about a struct layout
Syntax:
#cir.struct_layout<
unsigned, # size
unsigned, # alignment
bool, # padded
mlir::Type, # largest_member
mlir::ArrayAttr # offsets
>
Holds layout information often queried by !cir.struct users during lowering passes and optimizations.
Parameter | C++ type | Description |
---|---|---|
size | unsigned | |
alignment | unsigned | |
padded | bool | |
largest_member | mlir::Type | |
offsets | mlir::ArrayAttr |
Represents a typeinfo used for RTTI
Syntax:
#cir.typeinfo<
::mlir::Type, # type
mlir::ArrayAttr # data
>
The typeinfo data for a given class is stored into an ArrayAttr. The layout is determined by the C++ ABI used (clang only implements itanium on CIRGen).
The verifier enforces that the output type is always a !cir.struct
, and that the ArrayAttr element types match the equivalent member type for the resulting struct, i.e, a GlobalViewAttr for symbol reference or an IntAttr for flags.
Example:
cir.global "private" external @_ZTVN10__cxxabiv120__si_class_type_infoE : !cir.ptr<i32>
cir.global external @type_info_B = #cir.typeinfo<<
{#cir.global_view<@_ZTVN10__cxxabiv120__si_class_type_infoE, [2]> : !cir.ptr<i8>}
>> : !cir.struct<"", !cir.ptr<i8>>
Parameter | C++ type | Description |
---|---|---|
type | ::mlir::Type | |
data | mlir::ArrayAttr |
Represents a C++ vtable
Syntax:
#cir.vtable<
::mlir::Type, # type
ArrayAttr # vtable_data
>
Wraps a #cir.const_struct containing vtable data.
Example:
cir.global linkonce_odr @_ZTV1B = #cir.vtable<<
{#cir.const_array<[#cir.null : !cir.ptr<i8>,
#cir.global_view<@_ZTI1B> : !cir.ptr<i8>,
#cir.global_view<@_ZN1BD1Ev> : !cir.ptr<i8>,
#cir.global_view<@_ZN1BD0Ev> : !cir.ptr<i8>,
#cir.global_view<@_ZNK1A5quackEv> : !cir.ptr<i8>]>
: !cir.array<!cir.ptr<i8> x 5>}>>
: !cir.struct<"", !cir.array<!cir.ptr<i8> x 5>>
Parameter | C++ type | Description |
---|---|---|
type | ::mlir::Type | |
vtable_data | ArrayAttr |
Visibility attribute
Syntax:
#cir.visibility<
VisibilityKind # value
>
Visibility attributes.
Parameter | C++ type | Description |
---|---|---|
value | VisibilityKind |
Attribute to represent zero initialization
Syntax:
#cir.zero<
::mlir::Type # type
>
The ZeroAttr is used to indicate zero initialization on structs.
Parameter | C++ type | Description |
---|---|---|
type | ::mlir::Type |