stage2: astgen for while loops

See #6021
This commit is contained in:
Andrew Kelley
2020-08-12 21:13:07 -07:00
parent 30db5b1fb2
commit de4f3f11f7
6 changed files with 269 additions and 21 deletions

View File

@@ -23,6 +23,8 @@ pub const BlockData = struct {
relocs: std.ArrayListUnmanaged(Reloc) = .{},
};
pub const LoopData = struct { };
pub const Reloc = union(enum) {
/// The value is an offset into the `Function` `code` from the beginning.
/// To perform the reloc, write 32-bit signed little-endian integer
@@ -657,6 +659,7 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type {
.isnonnull => return self.genIsNonNull(inst.castTag(.isnonnull).?),
.isnull => return self.genIsNull(inst.castTag(.isnull).?),
.load => return self.genLoad(inst.castTag(.load).?),
.loop => return self.genLoop(inst.castTag(.loop).?),
.not => return self.genNot(inst.castTag(.not).?),
.ptrtoint => return self.genPtrToInt(inst.castTag(.ptrtoint).?),
.ref => return self.genRef(inst.castTag(.ref).?),
@@ -1346,6 +1349,10 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type {
}
}
fn genLoop(self: *Self, inst: *ir.Inst.Loop) !MCValue {
return self.fail(inst.base.src, "TODO codegen loop", .{});
}
fn genBlock(self: *Self, inst: *ir.Inst.Block) !MCValue {
if (inst.base.ty.hasCodeGenBits()) {
return self.fail(inst.base.src, "TODO codegen Block with non-void type", .{});