diff options
| author | Jacob Young <jacobly0@users.noreply.github.com> | 2022-10-25 07:00:17 -0400 |
|---|---|---|
| committer | Jacob Young <jacobly0@users.noreply.github.com> | 2022-10-25 07:02:06 -0400 |
| commit | e20d2b3151607fe078b43331ea27d5b34f95360b (patch) | |
| tree | ba23d07445cbedb81404b7fc02647be281be3f2f /src | |
| parent | 3d22327b2392050e088c8b6d5c21ae31bbd0cd90 (diff) | |
| download | zig-e20d2b3151607fe078b43331ea27d5b34f95360b.tar.gz zig-e20d2b3151607fe078b43331ea27d5b34f95360b.zip | |
cbe: fix floating point builtins
Diffstat (limited to 'src')
| -rw-r--r-- | src/codegen/c.zig | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/codegen/c.zig b/src/codegen/c.zig index 74a4fb178a..098424524f 100644 --- a/src/codegen/c.zig +++ b/src/codegen/c.zig @@ -798,7 +798,7 @@ pub const DeclGen = struct { "inf" else unreachable; - try writer.writeAll("zig_builtin_"); + try writer.writeAll("zig_builtin_constant_"); try dg.renderTypeForBuiltinFnName(writer, ty); try writer.writeByte('('); try writer.writeAll(operation); @@ -2006,18 +2006,16 @@ pub const DeclGen = struct { fn renderTypeForBuiltinFnName(dg: *DeclGen, writer: anytype, ty: Type) !void { const target = dg.module.getTarget(); - const c_bits = if (ty.isAbiInt()) c_bits: { + if (ty.isAbiInt()) { const int_info = ty.intInfo(target); - try writer.writeByte(signAbbrev(int_info.signedness)); - break :c_bits toCIntBits(int_info.bits) orelse + const c_bits = toCIntBits(int_info.bits) orelse return dg.fail("TODO: C backend: implement integer types larger than 128 bits", .{}); - } else if (ty.isRuntimeFloat()) c_bits: { - try writer.writeByte('f'); - break :c_bits ty.floatBits(target); + try writer.print("{c}{d}", .{ signAbbrev(int_info.signedness), c_bits }); + } else if (ty.isRuntimeFloat()) { + try ty.print(writer, dg.module); } else return dg.fail("TODO: CBE: implement renderTypeForBuiltinFnName for type {}", .{ ty.fmt(dg.module), }); - try writer.print("{d}", .{c_bits}); } fn renderBuiltinInfo(dg: *DeclGen, writer: anytype, ty: Type, info: BuiltinInfo) !void { @@ -3077,7 +3075,8 @@ fn airBinOp( const operand_ty = f.air.typeOf(bin_op.lhs); const target = f.object.dg.module.getTarget(); - if (operand_ty.bitSize(target) > 64) return try airBinBuiltinCall(f, inst, operation, info); + if (operand_ty.isInt() and operand_ty.bitSize(target) > 64) + return try airBinBuiltinCall(f, inst, operation, info); const inst_ty = f.air.typeOfIndex(inst); const lhs = try f.resolveInst(bin_op.lhs); @@ -3104,7 +3103,8 @@ fn airCmpOp(f: *Function, inst: Air.Inst.Index, operator: []const u8) !CValue { const operand_ty = f.air.typeOf(bin_op.lhs); const target = f.object.dg.module.getTarget(); - if (operand_ty.bitSize(target) > 64) return try airCmpBuiltinCall(f, inst, operator); + if (operand_ty.isInt() and operand_ty.bitSize(target) > 64) + return try airCmpBuiltinCall(f, inst, operator); const inst_ty = f.air.typeOfIndex(inst); const lhs = try f.resolveInst(bin_op.lhs); |
