Types


ArrayType

CIR array type

Syntax:

!cir.array<
  mlir::Type,   # elementType
  uint64_t   # size
>

CIR.array represents C/C++ constant arrays.

Parameters:

Parameter C++ type Description
elementType mlir::Type  
size uint64_t  

BF16Type

CIR type that represents

Syntax: !cir.bf16

Floating-point type that represents the bfloat16 format.

BoolType

CIR bool type

Syntax: !cir.bool

cir.bool represent's C++ bool type.

ComplexType

CIR complex type

Syntax:

!cir.complex<
  ::mlir::Type   # elementType
>

CIR type that represents a C complex number. cir.complex models the C type T _Complex.

The type models complex values, per C99 6.2.5p11. It supports the C99 complex float types as well as the GCC integer complex extensions.

The parameter elementType gives the type of the real and imaginary part of the complex number. elementType must be either a CIR integer type or a CIR floating-point type.

Parameters:

Parameter C++ type Description
elementType ::mlir::Type integer or floating point type

DataMemberType

CIR type that represents pointer-to-data-member type in C++

Syntax:

!cir.data_member<
  mlir::Type,   # memberTy
  cir::RecordType   # clsTy
>

cir.member_ptr models the pointer-to-data-member type in C++. Values of this type are essentially offsets of the pointed-to member within one of its containing record.

Parameters:

Parameter C++ type Description
memberTy mlir::Type  
clsTy cir::RecordType  

DoubleType

CIR double-precision float type

Syntax: !cir.double

Floating-point type that represents the double type in C/C++. Its underlying floating-point format is the IEEE-754 binary64 format.

ExceptionInfoType

CIR exception info

Syntax: !cir.exception

In presence of an inflight exception, this type holds all specific information for an exception: the associated type id, and the exception object pointer. These are materialzed from this type through other specific operations.

FP16Type

CIR type that represents IEEE-754 binary16 format

Syntax: !cir.f16

Floating-point type that represents the IEEE-754 binary16 format.

FP80Type

CIR type that represents x87 80-bit floating-point format

Syntax: !cir.f80

Floating-point type that represents the x87 80-bit floating-point format.

FP128Type

CIR type that represents IEEEquad 128-bit floating-point format

Syntax: !cir.f128

Floating-point type that represents the IEEEquad 128-bit floating-point format.

FuncType

CIR function type

Syntax:

!cir.func<
  ::llvm::ArrayRef<mlir::Type>,   # inputs
  mlir::Type,   # optionalReturnType
  bool   # varArg
>

The !cir.func is a function type. It consists of an optional return type, a list of parameter types and can optionally be variadic.

Example:

!cir.func<()>
!cir.func<() -> !bool>
!cir.func<(!s8i, !s8i)>
!cir.func<(!s8i, !s8i) -> !s32i>
!cir.func<(!s32i, ...) -> !s32i>

Parameters:

Parameter C++ type Description
inputs ::llvm::ArrayRef<mlir::Type>  
optionalReturnType mlir::Type  
varArg bool  

IntType

Integer type with arbitrary precision up to a fixed limit

CIR type that represents integer types with arbitrary precision.

Those integer types that are directly available in C/C++ standard are called fundamental integer types. Said types are: signed char, short, int, long, long long, and their unsigned variations.

Parameters:

Parameter C++ type Description
width unsigned  
isSigned bool  

LongDoubleType

CIR extended-precision float type

Syntax:

!cir.long_double<
  ::mlir::Type   # underlying
>

Floating-point type that represents the long double type in C/C++.

The underlying floating-point format of a long double value depends on the implementation. The underlying parameter specifies the CIR floating-point type that corresponds to this format.

Parameters:

Parameter C++ type Description
underlying ::mlir::Type expects !cir.double, !cir.fp80 or !cir.fp128

MethodType

CIR type that represents C++ pointer-to-member-function type

Syntax:

!cir.method<
  cir::FuncType,   # memberFuncTy
  cir::RecordType   # clsTy
>

cir.method models the pointer-to-member-function type in C++. The layout of this type is ABI-dependent.

Parameters:

Parameter C++ type Description
memberFuncTy cir::FuncType  
clsTy cir::RecordType  

PointerType

CIR pointer type

Syntax:

!cir.ptr<
  mlir::Type,   # pointee
  mlir::Attribute   # addrSpace
>

CIR.ptr is a type returned by any op generating a pointer in C++.

Parameters:

Parameter C++ type Description
pointee mlir::Type  
addrSpace mlir::Attribute  

RecordType

CIR record type

Each unique clang::RecordDecl is mapped to a cir.record and any object in C/C++ that has a struct or class type will have a cir.record in CIR.

There are three possible formats for this type:

  • Identified and complete records: unique name and a known body.
  • Identified and incomplete records: unique name and unknown body.
  • Anonymous records: no name and a known body.

Identified records are uniqued by their name, and anonymous records are uniqued by their body. This means that two anonymous records with the same body will be the same type, and two identified records with the same name will be the same type. Attempting to build a record with an existing name, but a different body will result in an error.

A few examples:

    !complete = !cir.record<struct {!cir.int<u, 8>}>
    !incomplete = !cir.record<struct "incomplete" incomplete>
    !anonymous = !cir.record<struct {!cir.int<u, 8>}>

Incomplete records are mutable, meaning they can be later completed with a body automatically updating in place every type in the code that uses the incomplete record. Mutability allows for recursive types to be represented, meaning the record can have members that refer to itself. This is useful for representing recursive records and is implemented through a special syntax. In the example below, the Node record has a member that is a pointer to a Node record:

    !s = !cir.record<struct "Node" {!cir.ptr<!cir.record<struct "Node">>}>

Parameters:

Parameter C++ type Description
members ::llvm::ArrayRef<mlir::Type>  
name mlir::StringAttr  
complete bool  
packed bool  
padded bool  
kind RecordType::RecordKind  
ast ASTRecordDeclInterface  

SingleType

CIR single-precision float type

Syntax: !cir.float

Floating-point type that represents the float type in C/C++. Its underlying floating-point format is the IEEE-754 binary32 format.

VectorType

CIR vector type

Syntax:

!cir.vector<
  mlir::Type,   # elementType
  uint64_t   # size
>

`cir.vector' represents fixed-size vector types. The parameters are the element type and the number of elements.

Parameters:

Parameter C++ type Description
elementType mlir::Type  
size uint64_t  

VoidType

CIR void type

Syntax: !cir.void

The !cir.void type represents the C/C++ void type.