feature. See also
. The project being documented here (as the example) is the Zig library itself.
Ir.Inst
pub const Inst = struct
File
Code
pub const Inst = struct {
tag: Tag,
data: Data,
ty: Interner.Ref,
pub const Tag = enum {
// not included in blocks
constant,
// not included in blocks
arg,
symbol,
label,
label_addr,
jmp,
@"switch",
branch,
select,
jmp_val,
call,
alloc,
phi,
store,
bit_or,
bit_xor,
bit_and,
bit_shl,
bit_shr,
cmp_eq,
cmp_ne,
cmp_lt,
cmp_lte,
cmp_gt,
cmp_gte,
add,
sub,
mul,
div,
mod,
ret,
load,
bit_not,
negate,
trunc,
zext,
sext,
};
pub const Data = union {
constant: Interner.Ref,
none: void,
bin: struct {
lhs: Ref,
rhs: Ref,
},
un: Ref,
arg: u32,
alloc: struct {
size: u32,
@"align": u32,
},
@"switch": *Switch,
call: *Call,
label: [*:0]const u8,
branch: *Branch,
phi: Phi,
};
pub const Branch = struct {
cond: Ref,
then: Ref,
@"else": Ref,
};
pub const Switch = struct {
target: Ref,
cases_len: u32,
default: Ref,
case_vals: [*]Interner.Ref,
case_labels: [*]Ref,
};
pub const Call = struct {
func: Ref,
args_len: u32,
args_ptr: [*]Ref,
pub fn args(c: Call) []Ref {
return c.args_ptr[0..c.args_len];
}
};
pub const Phi = struct {
ptr: [*]Ir.Ref,
pub const Input = struct {
label: Ir.Ref,
value: Ir.Ref,
};
pub fn inputs(p: Phi) []Input {
const len = @backingInt(p.ptr[0]) * 2;
const slice = (p.ptr + 1)[0..len];
return std.mem.bytesAsSlice(Input, std.mem.sliceAsBytes(slice));
}
};
}