Documentation ¶
Overview ¶
Package types declares the data types of LLVM IR.
Index ¶
- Variables
- func Equal(t, u Type) bool
- func IsArray(t Type) bool
- func IsFloat(t Type) bool
- func IsFunc(t Type) bool
- func IsInt(t Type) bool
- func IsLabel(t Type) bool
- func IsMMX(t Type) bool
- func IsMetadata(t Type) bool
- func IsPointer(t Type) bool
- func IsStruct(t Type) bool
- func IsToken(t Type) bool
- func IsVector(t Type) bool
- func IsVoid(t Type) bool
- type AddrSpace
- type ArrayType
- type FloatKind
- type FloatType
- type FuncType
- type IntType
- type LabelType
- type MMXType
- type MetadataType
- type PointerType
- type StructType
- type TokenType
- type Type
- type VectorType
- type VoidType
Constants ¶
This section is empty.
Variables ¶
var ( // Basic types. Void = &VoidType{} // void MMX = &MMXType{} // x86_mmx Label = &LabelType{} // label Token = &TokenType{} // token Metadata = &MetadataType{} // metadata // Integer types. I1 = &IntType{BitSize: 1} // i1 I2 = &IntType{BitSize: 2} // i2 I3 = &IntType{BitSize: 3} // i3 I4 = &IntType{BitSize: 4} // i4 I5 = &IntType{BitSize: 5} // i5 I6 = &IntType{BitSize: 6} // i6 I7 = &IntType{BitSize: 7} // i7 I8 = &IntType{BitSize: 8} // i8 I16 = &IntType{BitSize: 16} // i16 I32 = &IntType{BitSize: 32} // i32 I64 = &IntType{BitSize: 64} // i64 I128 = &IntType{BitSize: 128} // i128 I256 = &IntType{BitSize: 256} // i256 I512 = &IntType{BitSize: 512} // i512 I1024 = &IntType{BitSize: 1024} // i1024 // Floating-point types. Half = &FloatType{Kind: FloatKindHalf} // half Float = &FloatType{Kind: FloatKindFloat} // float Double = &FloatType{Kind: FloatKindDouble} // double X86_FP80 = &FloatType{Kind: FloatKindX86_FP80} // x86_fp80 FP128 = &FloatType{Kind: FloatKindFP128} // fp128 PPC_FP128 = &FloatType{Kind: FloatKindPPC_FP128} // ppc_fp128 // Integer pointer types. I1Ptr = &PointerType{ElemType: I1} // i1* I8Ptr = &PointerType{ElemType: I8} // i8* I16Ptr = &PointerType{ElemType: I16} // i16* I32Ptr = &PointerType{ElemType: I32} // i32* I64Ptr = &PointerType{ElemType: I64} // i64* I128Ptr = &PointerType{ElemType: I128} // i128* )
Convenience types.
Functions ¶
func IsMetadata ¶
IsMetadata reports whether the given type is a metadata type.
Types ¶
type ArrayType ¶
type ArrayType struct { // Type name; or empty if not present. TypeName string // Array length. Len uint64 // Element type. ElemType Type }
ArrayType is an LLVM IR array type.
func (*ArrayType) LLString ¶
LLString returns the LLVM syntax representation of the definition of the type.
'[' Len=UintLit 'x' Elem=Type ']'
type FloatKind ¶
type FloatKind uint8
FloatKind represents the set of floating-point kinds.
const ( // 16-bit floating-point type (IEEE 754 half precision). FloatKindHalf FloatKind = iota // half // 32-bit floating-point type (IEEE 754 single precision). FloatKindFloat // float // 64-bit floating-point type (IEEE 754 double precision). FloatKindDouble // double // 128-bit floating-point type (IEEE 754 quadruple precision). FloatKindFP128 // fp128 // 80-bit floating-point type (x86 extended precision). FloatKindX86_FP80 // x86_fp80 // 128-bit floating-point type (PowerPC double-double arithmetic). FloatKindPPC_FP128 // ppc_fp128 )
Floating-point kinds.
type FloatType ¶
type FloatType struct { // Type name; or empty if not present. TypeName string // Floating-point kind. Kind FloatKind }
FloatType is an LLVM IR floating-point type.
func (*FloatType) LLString ¶
LLString returns the LLVM syntax representation of the definition of the type.
FloatKind
type FuncType ¶
type FuncType struct { // Type name; or empty if not present. TypeName string // Return type. RetType Type // Function parameters. Params []Type // Variable number of function arguments. Variadic bool }
FuncType is an LLVM IR function type.
func NewFunc ¶
NewFunc returns a new function type based on the given return type and function parameter types.
func (*FuncType) LLString ¶
LLString returns the LLVM syntax representation of the definition of the type.
RetType=Type '(' Params ')'
type IntType ¶
type IntType struct { // Type name; or empty if not present. TypeName string // Integer size in number of bits. BitSize uint64 }
IntType is an LLVM IR integer type.
func (*IntType) LLString ¶
LLString returns the LLVM syntax representation of the definition of the type.
int_type_tok
type LabelType ¶
type LabelType struct { // Type name; or empty if not present. TypeName string }
LabelType is an LLVM IR label type, which is used for basic block values.
func (*LabelType) LLString ¶
LLString returns the LLVM syntax representation of the definition of the type.
'label'
type MMXType ¶
type MMXType struct { // Type name; or empty if not present. TypeName string }
MMXType is an LLVM IR MMX type.
func (*MMXType) LLString ¶
LLString returns the LLVM syntax representation of the definition of the type.
'x86_mmx'
type MetadataType ¶
type MetadataType struct { // Type name; or empty if not present. TypeName string }
MetadataType is an LLVM IR metadata type.
func (*MetadataType) Equal ¶
func (t *MetadataType) Equal(u Type) bool
Equal reports whether t and u are of equal type.
func (*MetadataType) LLString ¶
func (t *MetadataType) LLString() string
LLString returns the LLVM syntax representation of the definition of the type.
'metadata'
func (*MetadataType) Name ¶
func (t *MetadataType) Name() string
Name returns the type name of the type.
func (*MetadataType) SetName ¶
func (t *MetadataType) SetName(name string)
SetName sets the type name of the type.
func (*MetadataType) String ¶
func (t *MetadataType) String() string
String returns the string representation of the metadata type.
type PointerType ¶
type PointerType struct { // Type name; or empty if not present. TypeName string // Element type. ElemType Type // Address space; or zero value for default address space. AddrSpace AddrSpace }
PointerType is an LLVM IR pointer type.
func NewPointer ¶
func NewPointer(elemType Type) *PointerType
NewPointer returns a new pointer type based on the given element type.
func (*PointerType) Equal ¶
func (t *PointerType) Equal(u Type) bool
Equal reports whether t and u are of equal type.
func (*PointerType) LLString ¶
func (t *PointerType) LLString() string
LLString returns the LLVM syntax representation of the definition of the type.
Elem=Type AddrSpaceopt '*'
func (*PointerType) Name ¶
func (t *PointerType) Name() string
Name returns the type name of the type.
func (*PointerType) SetName ¶
func (t *PointerType) SetName(name string)
SetName sets the type name of the type.
func (*PointerType) String ¶
func (t *PointerType) String() string
String returns the string representation of the pointer type.
type StructType ¶
type StructType struct { // Type name; or empty if not present. TypeName string // Packed memory layout. Packed bool // Struct fields. Fields []Type // Opaque struct type. Opaque bool }
StructType is an LLVM IR structure type. Identified (named) struct types are uniqued by type names, not by structural identity.
func NewStruct ¶
func NewStruct(fields ...Type) *StructType
NewStruct returns a new struct type based on the given field types.
func (*StructType) Equal ¶
func (t *StructType) Equal(u Type) bool
Equal reports whether t and u are of equal type.
func (*StructType) LLString ¶
func (t *StructType) LLString() string
LLString returns the LLVM syntax representation of the definition of the type.
Opaque struct type.
'opaque'
Struct type.
'{' Fields=(Type separator ',')+? '}'
Packed struct type.
'<' '{' Fields=(Type separator ',')+? '}' '>' -> PackedStructType
func (*StructType) Name ¶
func (t *StructType) Name() string
Name returns the type name of the type.
func (*StructType) SetName ¶
func (t *StructType) SetName(name string)
SetName sets the type name of the type.
func (*StructType) String ¶
func (t *StructType) String() string
String returns the string representation of the structure type.
type TokenType ¶
type TokenType struct { // Type name; or empty if not present. TypeName string }
TokenType is an LLVM IR token type.
func (*TokenType) LLString ¶
LLString returns the LLVM syntax representation of the definition of the type.
'token'
type Type ¶
type Type interface { fmt.Stringer // LLString returns the LLVM syntax representation of the definition of the // type. LLString() string // Equal reports whether t and u are of equal type. Equal(u Type) bool // Name returns the type name of the type. Name() string // SetName sets the type name of the type. SetName(name string) }
Type is an LLVM IR type.
A Type has one of the following underlying types.
*types.VoidType // https://pkg.go.dev/github.com/llir/llvm/ir/types#VoidType *types.FuncType // https://pkg.go.dev/github.com/llir/llvm/ir/types#FuncType *types.IntType // https://pkg.go.dev/github.com/llir/llvm/ir/types#IntType *types.FloatType // https://pkg.go.dev/github.com/llir/llvm/ir/types#FloatType *types.MMXType // https://pkg.go.dev/github.com/llir/llvm/ir/types#MMXType *types.PointerType // https://pkg.go.dev/github.com/llir/llvm/ir/types#PointerType *types.VectorType // https://pkg.go.dev/github.com/llir/llvm/ir/types#VectorType *types.LabelType // https://pkg.go.dev/github.com/llir/llvm/ir/types#LabelType *types.TokenType // https://pkg.go.dev/github.com/llir/llvm/ir/types#TokenType *types.MetadataType // https://pkg.go.dev/github.com/llir/llvm/ir/types#MetadataType *types.ArrayType // https://pkg.go.dev/github.com/llir/llvm/ir/types#ArrayType *types.StructType // https://pkg.go.dev/github.com/llir/llvm/ir/types#StructType
type VectorType ¶
type VectorType struct { // Type name; or empty if not present. TypeName string // Scalable vector type. Scalable bool // Vector length. Len uint64 // Element type. ElemType Type }
VectorType is an LLVM IR vector type.
func NewVector ¶
func NewVector(len uint64, elemType Type) *VectorType
NewVector returns a new vector type based on the given vector length and element type.
func (*VectorType) Equal ¶
func (t *VectorType) Equal(u Type) bool
Equal reports whether t and u are of equal type.
func (*VectorType) LLString ¶
func (t *VectorType) LLString() string
LLString returns the LLVM syntax representation of the definition of the type.
scalable: '<' 'vscale' 'x' Len=UintLit 'x' Elem=Type '>' non-scalable: '<' Len=UintLit 'x' Elem=Type '>'
func (*VectorType) Name ¶
func (t *VectorType) Name() string
Name returns the type name of the type.
func (*VectorType) SetName ¶
func (t *VectorType) SetName(name string)
SetName sets the type name of the type.
func (*VectorType) String ¶
func (t *VectorType) String() string
String returns the string representation of the vector type.
type VoidType ¶
type VoidType struct { // Type name; or empty if not present. TypeName string }
VoidType is an LLVM IR void type.
func (*VoidType) LLString ¶
LLString returns the LLVM syntax representation of the definition of the type.
'void'