diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2020-07-06 06:10:44 +0000 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2020-07-06 06:10:44 +0000 |
| commit | 8be8ebd698aac447db2babf95def4725d9ddd05f (patch) | |
| tree | 9a63bcd593efed5358244bd922e7dec4b0778a92 /src-self-hosted/ir.zig | |
| parent | ad2ed457dd925c65d7d2bcac9208cee5619c523d (diff) | |
| download | zig-8be8ebd698aac447db2babf95def4725d9ddd05f.tar.gz zig-8be8ebd698aac447db2babf95def4725d9ddd05f.zip | |
stage2: skeleton codegen for x64 ADD
also rework Module to take advantage of the new hash map implementation.
Diffstat (limited to 'src-self-hosted/ir.zig')
| -rw-r--r-- | src-self-hosted/ir.zig | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/src-self-hosted/ir.zig b/src-self-hosted/ir.zig index 6fa06c8138..17e6a54725 100644 --- a/src-self-hosted/ir.zig +++ b/src-self-hosted/ir.zig @@ -2,6 +2,7 @@ const std = @import("std"); const Value = @import("value.zig").Value; const Type = @import("type.zig").Type; const Module = @import("Module.zig"); +const assert = std.debug.assert; /// These are in-memory, analyzed instructions. See `zir.Inst` for the representation /// of instructions that correspond to the ZIR text format. @@ -12,18 +13,28 @@ pub const Inst = struct { tag: Tag, /// Each bit represents the index of an `Inst` parameter in the `args` field. /// If a bit is set, it marks the end of the lifetime of the corresponding - /// instruction parameter. For example, 0b00000101 means that the first and + /// instruction parameter. For example, 0b000_00101 means that the first and /// third `Inst` parameters' lifetimes end after this instruction, and will /// not have any more following references. /// The most significant bit being set means that the instruction itself is /// never referenced, in other words its lifetime ends as soon as it finishes. - /// If the byte is `0xff`, it means this is a special case and this data is - /// encoded elsewhere. - deaths: u8 = 0xff, + /// If bit 7 (0b1xxx_xxxx) is set, it means this instruction itself is unreferenced. + /// If bit 6 (0bx1xx_xxxx) is set, it means this is a special case and the + /// lifetimes of operands are encoded elsewhere. + deaths: u8 = undefined, ty: Type, /// Byte offset into the source. src: usize, + pub fn isUnused(self: Inst) bool { + return (self.deaths & 0b1000_0000) != 0; + } + + pub fn operandDies(self: Inst, index: u3) bool { + assert(index < 6); + return @truncate(u1, self.deaths << index) != 0; + } + pub const Tag = enum { add, arg, @@ -240,4 +251,4 @@ pub const Inst = struct { pub const Body = struct { instructions: []*Inst, -};
\ No newline at end of file +}; |
