fix code broken from previous commit
This commit is contained in:
@@ -674,7 +674,7 @@ pub const Instruction = union(enum) {
|
||||
};
|
||||
const imm4h: u4 = switch (offset) {
|
||||
.immediate => |imm| @truncate(u4, imm >> 4),
|
||||
.register => |reg| 0b0000,
|
||||
.register => 0b0000,
|
||||
};
|
||||
|
||||
return Instruction{
|
||||
|
||||
@@ -47,6 +47,8 @@ fn formatTypeAsCIdentifier(
|
||||
options: std.fmt.FormatOptions,
|
||||
writer: anytype,
|
||||
) !void {
|
||||
_ = fmt;
|
||||
_ = options;
|
||||
var buffer = [1]u8{0} ** 128;
|
||||
// We don't care if it gets cut off, it's still more unique than a number
|
||||
var buf = std.fmt.bufPrint(&buffer, "{}", .{data}) catch &buffer;
|
||||
@@ -63,6 +65,8 @@ fn formatIdent(
|
||||
options: std.fmt.FormatOptions,
|
||||
writer: anytype,
|
||||
) !void {
|
||||
_ = fmt;
|
||||
_ = options;
|
||||
for (ident) |c, i| {
|
||||
switch (c) {
|
||||
'a'...'z', 'A'...'Z', '_' => try writer.writeByte(c),
|
||||
@@ -747,6 +751,7 @@ pub fn genBody(o: *Object, body: ir.Body) error{ AnalysisFail, OutOfMemory }!voi
|
||||
}
|
||||
|
||||
fn genVarPtr(o: *Object, inst: *Inst.VarPtr) !CValue {
|
||||
_ = o;
|
||||
return CValue{ .decl_ref = inst.variable.owner_decl };
|
||||
}
|
||||
|
||||
@@ -937,6 +942,8 @@ fn genCall(o: *Object, inst: *Inst.Call) !CValue {
|
||||
}
|
||||
|
||||
fn genDbgStmt(o: *Object, inst: *Inst.DbgStmt) !CValue {
|
||||
_ = o;
|
||||
_ = inst;
|
||||
// TODO emit #line directive here with line number and filename
|
||||
return CValue.none;
|
||||
}
|
||||
@@ -1016,11 +1023,13 @@ fn genBitcast(o: *Object, inst: *Inst.UnOp) !CValue {
|
||||
}
|
||||
|
||||
fn genBreakpoint(o: *Object, inst: *Inst.NoOp) !CValue {
|
||||
_ = inst;
|
||||
try o.writer().writeAll("zig_breakpoint();\n");
|
||||
return CValue.none;
|
||||
}
|
||||
|
||||
fn genUnreach(o: *Object, inst: *Inst.NoOp) !CValue {
|
||||
_ = inst;
|
||||
try o.writer().writeAll("zig_unreachable();\n");
|
||||
return CValue.none;
|
||||
}
|
||||
|
||||
@@ -154,6 +154,7 @@ pub const Object = struct {
|
||||
object_pathZ: [:0]const u8,
|
||||
|
||||
pub fn create(allocator: *Allocator, sub_path: []const u8, options: link.Options) !*Object {
|
||||
_ = sub_path;
|
||||
const self = try allocator.create(Object);
|
||||
errdefer allocator.destroy(self);
|
||||
|
||||
@@ -742,6 +743,7 @@ pub const FuncGen = struct {
|
||||
}
|
||||
|
||||
fn genRetVoid(self: *FuncGen, inst: *Inst.NoOp) ?*const llvm.Value {
|
||||
_ = inst;
|
||||
_ = self.builder.buildRetVoid();
|
||||
return null;
|
||||
}
|
||||
@@ -873,6 +875,7 @@ pub const FuncGen = struct {
|
||||
}
|
||||
|
||||
fn genUnreach(self: *FuncGen, inst: *Inst.NoOp) ?*const llvm.Value {
|
||||
_ = inst;
|
||||
_ = self.builder.buildUnreachable();
|
||||
return null;
|
||||
}
|
||||
@@ -1013,6 +1016,7 @@ pub const FuncGen = struct {
|
||||
}
|
||||
|
||||
fn genBreakpoint(self: *FuncGen, inst: *Inst.NoOp) !?*const llvm.Value {
|
||||
_ = inst;
|
||||
const llvn_fn = self.getIntrinsic("llvm.debugtrap");
|
||||
_ = self.builder.buildCall(llvn_fn, null, 0, "");
|
||||
return null;
|
||||
|
||||
@@ -702,7 +702,7 @@ pub const Context = struct {
|
||||
try writer.writeByte(wasm.valtype(.i32)); // error code is always an i32 integer.
|
||||
try writer.writeByte(val_type);
|
||||
},
|
||||
else => |ret_type| {
|
||||
else => {
|
||||
try leb.writeULEB128(writer, @as(u32, 1));
|
||||
// Can we maybe get the source index of the return type?
|
||||
const val_type = try self.genValtype(.{ .node_offset = 0 }, return_type);
|
||||
@@ -721,7 +721,7 @@ pub const Context = struct {
|
||||
// TODO: check for and handle death of instructions
|
||||
const mod_fn = blk: {
|
||||
if (typed_value.val.castTag(.function)) |func| break :blk func.data;
|
||||
if (typed_value.val.castTag(.extern_fn)) |ext_fn| return Result.appended; // don't need code body for extern functions
|
||||
if (typed_value.val.castTag(.extern_fn)) |_| return Result.appended; // don't need code body for extern functions
|
||||
unreachable;
|
||||
};
|
||||
|
||||
@@ -910,7 +910,7 @@ pub const Context = struct {
|
||||
},
|
||||
else => unreachable,
|
||||
},
|
||||
.local => |local| {
|
||||
.local => {
|
||||
try self.emitWValue(rhs);
|
||||
try writer.writeByte(wasm.opcode(.local_set));
|
||||
try leb.writeULEB128(writer, lhs.local);
|
||||
@@ -925,6 +925,7 @@ pub const Context = struct {
|
||||
}
|
||||
|
||||
fn genArg(self: *Context, inst: *Inst.Arg) InnerError!WValue {
|
||||
_ = inst;
|
||||
// arguments share the index with locals
|
||||
defer self.local_index += 1;
|
||||
return WValue{ .local = self.local_index };
|
||||
@@ -1213,12 +1214,15 @@ pub const Context = struct {
|
||||
}
|
||||
|
||||
fn genBreakpoint(self: *Context, breakpoint: *Inst.NoOp) InnerError!WValue {
|
||||
_ = self;
|
||||
_ = breakpoint;
|
||||
// unsupported by wasm itself. Can be implemented once we support DWARF
|
||||
// for wasm
|
||||
return .none;
|
||||
}
|
||||
|
||||
fn genUnreachable(self: *Context, unreach: *Inst.NoOp) InnerError!WValue {
|
||||
_ = unreach;
|
||||
try self.code.append(wasm.opcode(.@"unreachable"));
|
||||
return .none;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user