| ... | ... | @@ -1709,11 +1709,11 @@ fn genBody(f: *Function, body: []const Air.Inst.Index) error{ AnalysisFail, OutO |
| 1709 | 1709 | .memcpy => try airMemcpy(f, inst), |
| 1710 | 1710 | .set_union_tag => try airSetUnionTag(f, inst), |
| 1711 | 1711 | .get_union_tag => try airGetUnionTag(f, inst), |
| 1712 | | .clz => try airBuiltinCall(f, inst, "clz"), |
| 1713 | | .ctz => try airBuiltinCall(f, inst, "ctz"), |
| 1714 | | .popcount => try airBuiltinCall(f, inst, "popcount"), |
| 1715 | | .byte_swap => try airBuiltinCall(f, inst, "byte_swap"), |
| 1716 | | .bit_reverse => try airBuiltinCall(f, inst, "bit_reverse"), |
| 1712 | .clz => try airBuiltinCall(f, inst, "clz", .{}), |
| 1713 | .ctz => try airBuiltinCall(f, inst, "ctz", .{}), |
| 1714 | .popcount => try airBuiltinCall(f, inst, "popcount", .{}), |
| 1715 | .byte_swap => try airBuiltinCall(f, inst, "byte_swap", .{ .needs_signedness_info = true }), |
| 1716 | .bit_reverse => try airBuiltinCall(f, inst, "bit_reverse", .{ .needs_signedness_info = true }), |
| 1717 | 1717 | .tag_name => try airTagName(f, inst), |
| 1718 | 1718 | .error_name => try airErrorName(f, inst), |
| 1719 | 1719 | .splat => try airSplat(f, inst), |
| ... | ... | @@ -3351,7 +3351,7 @@ fn airPtrToInt(f: *Function, inst: Air.Inst.Index) !CValue { |
| 3351 | 3351 | return local; |
| 3352 | 3352 | } |
| 3353 | 3353 | |
| 3354 | | fn airBuiltinCall(f: *Function, inst: Air.Inst.Index, fn_name: [*:0]const u8) !CValue { |
| 3354 | fn airBuiltinCall(f: *Function, inst: Air.Inst.Index, fn_name: [*:0]const u8, options: struct { needs_signedness_info: bool = false }) !CValue { |
| 3355 | 3355 | if (f.liveness.isUnused(inst)) return CValue.none; |
| 3356 | 3356 | |
| 3357 | 3357 | const inst_ty = f.air.typeOfIndex(inst); |
| ... | ... | @@ -3364,14 +3364,18 @@ fn airBuiltinCall(f: *Function, inst: Air.Inst.Index, fn_name: [*:0]const u8) !C |
| 3364 | 3364 | const int_info = operand_ty.intInfo(target); |
| 3365 | 3365 | _ = toCIntBits(int_info.bits) orelse |
| 3366 | 3366 | return f.fail("TODO: C backend: implement integer types larger than 128 bits", .{}); |
| 3367 | | const signed_type = switch (int_info.signedness) { |
| 3368 | | .signed => "true", |
| 3369 | | .unsigned => "false", |
| 3370 | | }; |
| 3371 | 3367 | |
| 3372 | 3368 | try writer.print(" = zig_{s}(", .{fn_name}); |
| 3373 | 3369 | try f.writeCValue(writer, try f.resolveInst(operand)); |
| 3374 | | try writer.print(", {d}, {s});\n", .{ int_info.bits, signed_type }); |
| 3370 | try writer.print(", {d}", .{int_info.bits}); |
| 3371 | if (options.needs_signedness_info) { |
| 3372 | const signed_type = switch (int_info.signedness) { |
| 3373 | .signed => "true", |
| 3374 | .unsigned => "false", |
| 3375 | }; |
| 3376 | try writer.print(", {s}", .{signed_type}); |
| 3377 | } |
| 3378 | try writer.writeAll(");\n"); |
| 3375 | 3379 | return local; |
| 3376 | 3380 | } |
| 3377 | 3381 | |