module volt.llvm.type
Backend | LLVM Backend

Code and classes for turning Volt Types into LLVM types.

Code Map

//! Code and classes for turning Volt Types into LLVM types.
module volt.llvm.type;


//! Base class for a LLVM backend types. Contains a refernce to the irType
//! for this type, the llvmType and the debugging info for this type.
class Type
{
public:
	irType: ir.Type;
	llvmType: LLVMTypeRef;
	diType: LLVMMetadataRef;
	passByValAttr: bool;
	passByValPtr: bool;


public:
	fn from(State, ir.Constant, Value) { }
	fn from(State, ir.ArrayLiteral, Value) { }
	fn from(State, ir.UnionLiteral, Value) { }
	fn from(State, ir.StructLiteral, Value) { }
}

//! Void .
class VoidType : Type
{
public:
	static fn fromIr(state: State, pt: ir.PrimitiveType) VoidType { }
}

//! Integer but not void.
class PrimitiveType : Type
{
public:
	boolean: bool;
	signed: bool;
	floating: bool;
	bits: u32;


public:
	fn from(state: State, cnst: ir.Constant, result: Value) { }
	fn fromNumber(state: State, val: i64) LLVMValueRef { }


public:
	static fn fromIr(state: State, pt: ir.PrimitiveType) PrimitiveType { }
}

//! PointerType represents a standard C pointer.
class PointerType : Type
{
public:
	base: Type;


public:
	fn from(state: State, cnst: ir.Constant, result: Value) { }


public:
	static fn fromIr(state: State, pt: ir.PointerType) PointerType { }
}

//! Array type.
class ArrayType : Type
{
public:
	enum lengthIndex;
	enum ptrIndex;


public:
	base: Type;
	ptrType: PointerType;
	lengthType: PrimitiveType;
	types: Type[2];


public:
	fn from(state: State, cnst: ir.Constant, result: Value) { }
	fn from(state: State, al: ir.ArrayLiteral, result: Value) { }
	fn from(state: State, arr: LLVMValueRef[]) LLVMValueRef { }


public:
	static fn fromIr(state: State, at: ir.ArrayType) ArrayType { }
}

//! Static array type.
class StaticArrayType : Type
{
public:
	base: Type;
	length: u32;
	arrayType: ArrayType;
	ptrType: PointerType;


public:
	fn from(state: State, al: ir.ArrayLiteral, result: Value) { }


public:
	static fn fromIr(state: State, sat: ir.StaticArrayType) StaticArrayType { }
}

//! Base class for callable types FunctionType and DelegateType.
class CallableType : Type
{
public:
	ret: Type;
	ct: ir.CallableType;
	params: Type[];


public:
	this(state: State, ct: ir.CallableType, llvmType: LLVMTypeRef, diType: LLVMMetadataRef) { }
}

//! Function type.
class FunctionType : CallableType
{
public:
	hasStructRet: bool;
	llvmCallType: LLVMTypeRef;
	diCallType: LLVMMetadataRef;


public:
	fn from(state: State, cnst: ir.Constant, result: Value) { }


public:
	static fn fromIr(state: State, ft: ir.FunctionType) FunctionType { }
}

//! Delegates are lowered here into a struct with two members.
class DelegateType : CallableType
{
public:
	enum voidPtrIndex;
	enum funcIndex;


public:
	llvmCallPtrType: LLVMTypeRef;


public:
	fn from(state: State, cnst: ir.Constant, result: Value) { }


public:
	static fn fromIr(state: State, dgt: ir.DelegateType) DelegateType { }
}

//! Backend instance of a ir.Struct.
class StructType : Type
{
public:
	indices: u32[string];
	types: Type[];


public:
	fn from(state: State, sl: ir.StructLiteral, result: Value) { }


public:
	static fn fromIr(state: State, irType: ir.Struct) StructType { }
}

//! Backend instance of a ir.Union.
class UnionType : Type
{
public:
	indices: u32[string];
	types: Type[];
	utype: ir.Union;


public:
	fn from(state: State, ul: ir.UnionLiteral, result: Value) { }


public:
	static fn fromIr(state: State, irType: ir.Union) UnionType { }
}

//! Looks up or creates the corresponding LLVMTypeRef and Type for the
//! given irType.
fn fromIr(state: State, irType: ir.Type) Type { }
//! Dispatcher function to Type constructors.
fn fromIrImpl(state: State, irType: ir.Type) Type { }
//! Populate the common types that hang off the state.
fn buildCommonTypes(state: State, V_P64: bool) { }
//! Does a smart copy of a type.
fn scrubStorage(type: ir.Type) ir.Type { }
//! Helper function for adding mangled name to ir types.
fn addMangledName(irType: ir.Type) string { }
//! Helper function to tell if a type is Void.
fn isVoid(type: Type) bool { }
class Type

Base class for a LLVM backend types. Contains a refernce to the irType for this type, the llvmType and the debugging info for this type.

class VoidType : Type

Void .

class PrimitiveType : Type

Integer but not void.

class PointerType : Type

PointerType represents a standard C pointer.

class ArrayType : Type

Array type.

class StaticArrayType : Type

Static array type.

class CallableType : Type

Base class for callable types FunctionType and DelegateType.

class FunctionType : CallableType

Function type.

class DelegateType : CallableType

Delegates are lowered here into a struct with two members.

class StructType : Type

Backend instance of a ir.Struct.

class UnionType : Type

Backend instance of a ir.Union.

fn fromIr(state: State, irType: ir.Type) Type

Looks up or creates the corresponding LLVMTypeRef and Type for the given irType.

fn fromIrImpl(state: State, irType: ir.Type) Type

Dispatcher function to Type constructors.

fn buildCommonTypes(state: State, V_P64: bool)

Populate the common types that hang off the state.

fn scrubStorage(type: ir.Type) ir.Type

Does a smart copy of a type.

Meaning that well copy all types, but skipping TypeReferences, but inserting one when it comes across a named type.

fn addMangledName(irType: ir.Type) string

Helper function for adding mangled name to ir types.

fn isVoid(type: Type) bool

Helper function to tell if a type is Void.