aboutsummaryrefslogtreecommitdiff
path: root/src/Sema.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2021-03-23 16:12:26 -0700
committerAndrew Kelley <andrew@ziglang.org>2021-03-23 16:12:26 -0700
commitbe673e67937bbc3e2c74591f8f447f848b2a566a (patch)
treea6784230d35bbb35ea0374984d475228313ac265 /src/Sema.zig
parentaa46a705ad998636443e744b63471bf0864e90c9 (diff)
downloadzig-be673e67937bbc3e2c74591f8f447f848b2a566a.tar.gz
zig-be673e67937bbc3e2c74591f8f447f848b2a566a.zip
stage2: implement inttype ZIR
also add i128 and u128 to const inst list
Diffstat (limited to 'src/Sema.zig')
-rw-r--r--src/Sema.zig9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/Sema.zig b/src/Sema.zig
index 8615968183..38e4ca7241 100644
--- a/src/Sema.zig
+++ b/src/Sema.zig
@@ -1226,7 +1226,11 @@ fn zirIntType(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError
const tracy = trace(@src());
defer tracy.end();
- return sema.mod.fail(&block.base, sema.src, "TODO implement inttype", .{});
+ const int_type = sema.code.instructions.items(.data)[inst].int_type;
+ const src = int_type.src();
+ const ty = try Module.makeIntType(sema.arena, int_type.signedness, int_type.bit_count);
+
+ return sema.mod.constType(sema.arena, src, ty);
}
fn zirOptionalType(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst {
@@ -3967,7 +3971,8 @@ fn cmpNumeric(
const casted_bits = std.math.cast(u16, max_bits) catch |err| switch (err) {
error.Overflow => return sema.mod.fail(&block.base, src, "{d} exceeds maximum integer bit count", .{max_bits}),
};
- break :blk try Module.makeIntType(sema.arena, dest_int_is_signed, casted_bits);
+ const signedness: std.builtin.Signedness = if (dest_int_is_signed) .signed else .unsigned;
+ break :blk try Module.makeIntType(sema.arena, signedness, casted_bits);
};
const casted_lhs = try sema.coerce(block, dest_type, lhs, lhs.src);
const casted_rhs = try sema.coerce(block, dest_type, rhs, rhs.src);