[][src]Module llir::types

LLVM Types

The LLVM Types mainly follows the following hierarchy

How to use

You can get a type from a valid value, for example a function

for func in module.iter_functions() {
  let func_pointer_type = func.get_type();
  match func_pointer_type {
    Type::PointerType(p) => {
      match p.element_type() {
        Type::FunctionType(func_type) => {
          let return_type = func_type.return_type();
          let argument_types = func_type.argument_types();
          // Do things to function type...
        }
        _ => panic!("Type of a function should be a pointer to a function type")
      }
    }
    _ => panic!("Type of a function should be a pointer to a function type")
  }
}

You can also get a type from globals, constants, arguments, and part of instructions.

Note that instructions like branch doesn't contain a type. So we don't provide get_type() method for every instruction.

Structs

ArrayType

Array Type

FloatType

Float Type

FunctionType

Function Type

GenericType

A placeholder type; used when the type is not supported yet

IntType

Integer type

LiteralStructType

A struct literal without name

NamedStructType

A named struct type that you can get name from

PointerType

Pointer type

VectorType

Vector type

VoidType

Void type

Enums

FloatTypeKind

The type kind for Float Type

StructType

Struct type

Type

Type

Traits

AsType

Turn every type's child classes into a type container enum

StructTypeTrait

The struct type API applicable to every struct type