glove
Types
QBE Comparison Operators QBE Comparison Operators
pub type Comp {
Sltw
Sltl
Slew
Slel
Sgtw
Sgtl
Sgew
Sgel
Cultw
Cultl
Culew
Culel
Cugtw
Cugtl
Cugew
Cugel
Ceqw
Ceql
Cnew
Cnel
Ceqs
Ceqd
Cnes
Cned
Clts
Cltd
Cles
Cled
Cgts
Cgtd
Cges
Cged
Cos
Cod
Cuos
Cuod
Slt
Sle
Sgt
Sge
Eq
Ne
}
Constructors
-
SltwSigned less than (word)
-
SltlSigned less than (long)
-
SlewSigned less or equal (word)
-
SlelSigned less or equal (long)
-
SgtwSigned greater than (word)
-
SgtlSigned greater than (long)
-
SgewSigned greater or equal (word)
-
SgelSigned greater or equal (long)
-
CultwUnsigned less than (word)
-
CultlUnsigned less than (long)
-
CulewUnsigned less or equal (word)
-
CulelUnsigned less or equal (long)
-
CugtwUnsigned greater than (word)
-
CugtlUnsigned greater than (long)
-
CugewUnsigned greater or equal (word)
-
CugelUnsigned greater or equal (long)
-
CeqwEqual (word)
-
CeqlEqual (long)
-
CnewNot equal (word)
-
CnelNot equal (long)
-
CeqsEqual (single)
-
CeqdEqual (double)
-
CnesNot equal (single)
-
CnedNot equal (double)
-
CltsLess than (single)
-
CltdLess than (double)
-
ClesLess or equal (single)
-
CledLess or equal (double)
-
CgtsGreater than (single)
-
CgtdGreater than (double)
-
CgesGreater or equal (single)
-
CgedGreater or equal (double)
-
CosOrdered - no NaN (single)
-
CodOrdered - no NaN (double)
-
CuosUnordered - contains NaN (single)
-
CuodUnordered - contains NaN (double)
-
SltLegacy: Less Than (deprecated - use Sltw/Sltl)
-
SleLegacy: Less or Equal (deprecated - use Slew/Slel)
-
SgtLegacy: Greater than (deprecated - use Sgtw/Sgtl)
-
SgeLegacy: Greater or equal (deprecated - use Sgew/Sgel)
-
EqLegacy: Equal (deprecated - use Ceqw/Ceql)
-
NeLegacy: Not equal (deprecated - use Cnew/Cnel)
QBE data definition
pub type DataDef {
DataDef(
linkage: Linkage,
name: String,
align: option.Option(Int),
items: List(#(Type, DataItem)),
)
}
Constructors
-
DataDef( linkage: Linkage, name: String, align: option.Option(Int), items: List(#(Type, DataItem)), )
QBE Data definition item
pub type DataItem {
Symbol(String, option.Option(Int))
Str(String)
Constant(Int)
}
Constructors
-
Symbol(String, option.Option(Int))Symbol and offset
-
Str(String)String
-
Constant(Int)Integer
QBE instruction
pub type Inst {
Add(Value, Value)
Sub(Value, Value)
Mul(Value, Value)
Div(Value, Value)
Udiv(Value, Value)
Rem(Value, Value)
Urem(Value, Value)
Neg(Value)
And(Value, Value)
Or(Value, Value)
Xor(Value, Value)
Sar(Value, Value)
Shr(Value, Value)
Shl(Value, Value)
Comp(Type, Comp, Value, Value)
Alloc4(Int)
Alloc8(Int)
Alloc16(Int)
Storew(Value, Value)
Storel(Value, Value)
Stores(Value, Value)
Stored(Value, Value)
Storeh(Value, Value)
Storeb(Value, Value)
Loadw(Value)
Loadsw(Value)
Loaduw(Value)
Loadl(Value)
Loads(Value)
Loadd(Value)
Loadsh(Value)
Loaduh(Value)
Loadsb(Value)
Loadub(Value)
Blit(Value, Value, Int)
Extsw(Value)
Extuw(Value)
Extsh(Value)
Extuh(Value)
Extsb(Value)
Extub(Value)
Exts(Value)
Truncd(Value)
Stosi(Value)
Stoui(Value)
Dtosi(Value)
Dtoui(Value)
Swtof(Value)
Uwtof(Value)
Sltof(Value)
Ultof(Value)
Cast(Value)
Copy(Value)
Vastart(Value)
Vaarg(Value)
Ret(option.Option(Value))
Jnz(Value, String, String)
Jmp(String)
Hlt
Call(
Value,
List(#(Type, Value)),
option.Option(List(#(Type, Value))),
)
Phi(List(#(String, Value)))
Store(Type, Value, Value)
Load(Type, Value)
}
Constructors
-
Adds values
-
Substracts value(b) from value(a)
-
Multiplies values
-
Divides value(a) by value(b) (signed)
-
Unsigned division
-
Returns a remainder from division (signed)
-
Unsigned remainder
-
Neg(Value)Negation
-
Bitwise AND
-
Bitwise OR
-
Bitwise XOR
-
Arithmetic right shift
-
Logical right shift
-
Left shift
-
Perform a Comparison
-
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 word
-
Store long
-
Store single
-
Store double
-
Store half-word
-
Store byte
-
Loadw(Value)Load word (syntactic sugar - same as loadsw)
-
Loadsw(Value)Load word with sign extension
-
Loaduw(Value)Load word with zero extension
-
Loadl(Value)Load long
-
Loads(Value)Load single
-
Loadd(Value)Load double
-
Loadsh(Value)Load half-word signed
-
Loaduh(Value)Load half-word unsigned
-
Loadsb(Value)Load byte signed
-
Loadub(Value)Load byte unsigned
-
Copy
nbytes from source to destination address -
Extsw(Value)Sign-extend word to long
-
Extuw(Value)Zero-extend word to long
-
Extsh(Value)Sign-extend half-word
-
Extuh(Value)Zero-extend half-word
-
Extsb(Value)Sign-extend byte
-
Extub(Value)Zero-extend byte
-
Exts(Value)Extend single to double
-
Truncd(Value)Truncate double to single
-
Stosi(Value)Single to signed integer
-
Stoui(Value)Single to unsigned integer
-
Dtosi(Value)Double to signed integer
-
Dtoui(Value)Double to unsigned integer
-
Swtof(Value)Signed word to float
-
Uwtof(Value)Unsigned word to float
-
Sltof(Value)Signed long to float
-
Ultof(Value)Unsigned long to float
-
Cast(Value)Bitwise reinterpret cast
-
Copy(Value)Copies either temporary or literal value
-
Vastart(Value)Initialize variable argument list
-
Vaarg(Value)Fetch next variadic argument
-
Ret(option.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
-
HltProgram termination
-
Call(function, args, variadic_args)
-
Phi(List(#(String, Value)))SSA phi node - value selection from predecessors List of (label, value) pairs
-
Generic store (deprecated - use specific store instructions)
-
Generic load (deprecated - use specific load instructions)
Linkage of a function or data defintion (e.g. section and private/public status)
pub type Linkage {
Linkage(
exported: Bool,
section: option.Option(String),
secflags: option.Option(String),
)
}
Constructors
-
Linkage( exported: Bool, section: option.Option(String), secflags: option.Option(String), )
QBE aggregate type definition
pub type TypeDef {
TypeDef(
name: String,
align: option.Option(Int),
items: List(#(Type, Int)),
)
}
Constructors
-
TypeDef( name: String, align: option.Option(Int), items: List(#(Type, Int)), )
Values
pub fn add_block(label: String) -> Block
Adds a new empty block with a specified label and returns a reference to it
pub fn assign_inst(
block: Block,
val: Value,
typ: Type,
inst: Inst,
) -> Block
Adds a new instruction assigned to a temporary
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.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