glove
Types
Function block with a label
pub type Block {
Block(label: String, statements: List(Statement))
}
Constructors
-
Block(label: String, statements: List(Statement))
QBE Comparison Operators
pub type Comp {
Slt
Sle
Sgt
Sge
Eq
Ne
}
Constructors
-
Slt
Less Than
-
Sle
Less or Equal
-
Sgt
Greater than
-
Sge
Greater or equal
-
Eq
Equal
-
Ne
Not equal
QBE data definition
pub type DataDef {
DataDef(
linkage: Linkage,
name: String,
align: Option(Int),
items: List(#(Type, DataItem)),
)
}
Constructors
-
DataDef( linkage: Linkage, name: String, align: Option(Int), items: List(#(Type, DataItem)), )
QBE Data definition item
pub type DataItem {
Symbol(String, Option(Int))
Str(String)
Constant(Int)
}
Constructors
-
Symbol(String, Option(Int))
Symbol and offset
-
Str(String)
String
-
Constant(Int)
Integer
QBE Function
pub type Function {
Function(
linkage: Linkage,
name: String,
arguments: List(#(Type, Value)),
return_ty: Option(Type),
blocks: List(Block),
)
}
Constructors
-
Function( linkage: Linkage, name: String, arguments: List(#(Type, Value)), return_ty: Option(Type), blocks: List(Block), )
QBE instruction
pub type Inst {
Add(Value, Value)
Sub(Value, Value)
Mul(Value, Value)
Div(Value, Value)
Rem(Value, Value)
Comp(Type, Comp, Value, Value)
And(Value, Value)
Or(Value, Value)
Copy(Value)
Ret(Option(Value))
Jnz(Value, String, String)
Jmp(String)
Call(Value, List(#(Type, Value)))
Alloc4(Int)
Alloc8(Int)
Alloc16(Int)
Store(Type, Value, Value)
Load(Type, Value)
Blit(Value, Value, Int)
}
Constructors
-
Add(Value, Value)
Adds values
-
Sub(Value, Value)
Substracts value(b) from value(a)
-
Mul(Value, Value)
Multiplies values
-
Div(Value, Value)
Divides value(a) by value(b)
-
Rem(Value, Value)
Returns a remaider from division
-
Comp(Type, Comp, Value, Value)
Perform a Comparison
-
And(Value, Value)
Bitwise AND
-
Or(Value, Value)
Bitwise OR
-
Copy(Value)
Copies either temporary or literal value
-
Ret(Option(Value))
Return from a function, optionally with a value
-
Jnz(Value, String, String)
Jumps to first label if a value is nonzero or to the second one otherwise
-
Jmp(String)
Unconditionally jumps to a label
-
Call(Value, List(#(Type, Value)))
Calls a function
-
Alloc4(Int)
Allocates a 4-byte aligned area on the stack
-
Alloc8(Int)
Allocates a 8-byte aligned area on the stack
-
Alloc16(Int)
Allocates a 16-byte aligned area on the stack
-
Store(Type, Value, Value)
Stores a value into memory pointed to by destination. (type, destination, value)
-
Load(Type, Value)
Loads a value from memory pointed to by source (type, source)
-
Blit(Value, Value, Int)
(source, destination, n)
Copy
n
bytes from the source address to the destination address.n must be a constant value.
Minimum supported QBE version 1.1
Linkage of a function or data defintion (e.g. section and private/public status)
pub type Linkage {
Linkage(
exported: Bool,
section: Option(String),
secflags: Option(String),
)
}
Constructors
-
Linkage( exported: Bool, section: Option(String), secflags: Option(String), )
A complete IL file
pub type Module {
Module(
functions: List(Function),
types: List(TypeDef),
data: List(DataDef),
)
}
Constructors
-
Module( functions: List(Function), types: List(TypeDef), data: List(DataDef), )
IR Statement
pub type Statement {
Assign(Value, Type, Inst)
Volatile(Inst)
}
Constructors
-
Assign(Value, Type, Inst)
-
Volatile(Inst)
QBE Types
pub type Type {
Word
Long
Single
Double
Byte
Halfword
Aggregate(TypeDef)
}
Constructors
-
Word
Base Types
-
Long
-
Single
-
Double
-
Byte
Extended Types
-
Halfword
-
Aggregate(TypeDef)
QBE aggregate type definition
pub type TypeDef {
TypeDef(
name: String,
align: Option(Int),
items: List(#(Type, Int)),
)
}
Constructors
-
TypeDef( name: String, align: Option(Int), items: List(#(Type, Int)), )
Functions
pub fn add_block(label: String) -> Block
Adds a new empty block with a specified label and returns a reference to it
pub fn add_function(module: Module, function: Function) -> Module
Add function to module
pub fn assign_inst(
block: Block,
val: Value,
typ: Type,
inst: Inst,
) -> Block
Adds a new instruction assigned to a temporary
pub fn display_arguments(
arguments: List(#(Type, Value)),
) -> String
Display functions Arguments
pub fn display_data_item(item: DataItem) -> String
Display function for DataItem
pub fn display_function(func: Function) -> String
Display function for functions
pub fn display_statement(stmt: Statement) -> String
Display function for Statement
pub fn into_abi(self: Type) -> Type
Aggregate type with a specified name Returns a C ABI type. Extended types are converted to closest base types
pub fn last_block(blocks: List(Block)) -> Option(Block)
Returns a reference to the last block
pub fn new_datadef() -> DataDef
pub fn private_with_section(section: String) -> Linkage
Returns the configuration for private linkage with a provided section
pub fn public_with_section(section: String) -> Linkage
Returns the configuration for public linkage with a provided section