Skip to content

Commit 0f1652d

Browse files
authored
Merge pull request #17262 from jacobly0/x86_64
x86_64: support operations that are implemented in compiler_rt
2 parents 62a0fbd + da335f0 commit 0f1652d

20 files changed

+1894
-1358
lines changed

lib/compiler_rt/common.zig

+2-2
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ pub fn panic(msg: []const u8, error_return_trace: ?*std.builtin.StackTrace, _: ?
8282
/// need for extending them to wider fp types.
8383
/// TODO remove this; do this type selection in the language rather than
8484
/// here in compiler-rt.
85-
pub fn F16T(comptime other_type: type) type {
85+
pub fn F16T(comptime OtherType: type) type {
8686
return switch (builtin.cpu.arch) {
8787
.arm, .armeb, .thumb, .thumbeb => if (std.Target.arm.featureSetHas(builtin.cpu.features, .has_v8))
8888
switch (builtin.abi.floatAbi()) {
@@ -93,7 +93,7 @@ pub fn F16T(comptime other_type: type) type {
9393
u16,
9494
.aarch64, .aarch64_be, .aarch64_32 => f16,
9595
.riscv64 => if (builtin.zig_backend == .stage1) u16 else f16,
96-
.x86, .x86_64 => if (builtin.target.isDarwin()) switch (other_type) {
96+
.x86, .x86_64 => if (builtin.target.isDarwin()) switch (OtherType) {
9797
// Starting with LLVM 16, Darwin uses different abi for f16
9898
// depending on the type of the other return/argument..???
9999
f32, f64 => u16,

src/Compilation.zig

+1-2
Original file line numberDiff line numberDiff line change
@@ -1871,8 +1871,7 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation {
18711871
comp.job_queued_compiler_rt_lib = true;
18721872
} else if (options.output_mode != .Obj) {
18731873
log.debug("queuing a job to build compiler_rt_obj", .{});
1874-
// If build-obj with -fcompiler-rt is requested, that is handled specially
1875-
// elsewhere. In this case we are making a static library, so we ask
1874+
// In this case we are making a static library, so we ask
18761875
// for a compiler-rt object to put in it.
18771876
comp.job_queued_compiler_rt_obj = true;
18781877
}

src/InternPool.zig

+10-15
Original file line numberDiff line numberDiff line change
@@ -5407,19 +5407,19 @@ pub fn getAnonStructType(ip: *InternPool, gpa: Allocator, ini: AnonStructTypeIni
54075407

54085408
/// This is equivalent to `Key.FuncType` but adjusted to have a slice for `param_types`.
54095409
pub const GetFuncTypeKey = struct {
5410-
param_types: []Index,
5410+
param_types: []const Index,
54115411
return_type: Index,
5412-
comptime_bits: u32,
5413-
noalias_bits: u32,
5412+
comptime_bits: u32 = 0,
5413+
noalias_bits: u32 = 0,
54145414
/// `null` means generic.
5415-
alignment: ?Alignment,
5415+
alignment: ?Alignment = .none,
54165416
/// `null` means generic.
5417-
cc: ?std.builtin.CallingConvention,
5418-
is_var_args: bool,
5419-
is_generic: bool,
5420-
is_noinline: bool,
5421-
section_is_generic: bool,
5422-
addrspace_is_generic: bool,
5417+
cc: ?std.builtin.CallingConvention = .Unspecified,
5418+
is_var_args: bool = false,
5419+
is_generic: bool = false,
5420+
is_noinline: bool = false,
5421+
section_is_generic: bool = false,
5422+
addrspace_is_generic: bool = false,
54235423
};
54245424

54255425
pub fn getFuncType(ip: *InternPool, gpa: Allocator, key: GetFuncTypeKey) Allocator.Error!Index {
@@ -5754,15 +5754,10 @@ pub fn getFuncInstance(ip: *InternPool, gpa: Allocator, arg: GetFuncInstanceKey)
57545754
const func_ty = try ip.getFuncType(gpa, .{
57555755
.param_types = arg.param_types,
57565756
.return_type = arg.bare_return_type,
5757-
.comptime_bits = 0,
57585757
.noalias_bits = arg.noalias_bits,
57595758
.alignment = arg.alignment,
57605759
.cc = arg.cc,
5761-
.is_var_args = false,
5762-
.is_generic = false,
57635760
.is_noinline = arg.is_noinline,
5764-
.section_is_generic = false,
5765-
.addrspace_is_generic = false,
57665761
});
57675762

57685763
const generic_owner = unwrapCoercedFunc(ip, arg.generic_owner);

src/Sema.zig

+3-8
Original file line numberDiff line numberDiff line change
@@ -7373,10 +7373,10 @@ fn analyzeCall(
73737373
const memoized_arg_values = try sema.arena.alloc(InternPool.Index, func_ty_info.param_types.len);
73747374

73757375
const owner_info = mod.typeToFunc(fn_owner_decl.ty).?;
7376+
const new_param_types = try sema.arena.alloc(InternPool.Index, owner_info.param_types.len);
73767377
var new_fn_info: InternPool.GetFuncTypeKey = .{
7377-
.param_types = try sema.arena.alloc(InternPool.Index, owner_info.param_types.len),
7378+
.param_types = new_param_types,
73787379
.return_type = owner_info.return_type,
7379-
.comptime_bits = 0,
73807380
.noalias_bits = owner_info.noalias_bits,
73817381
.alignment = if (owner_info.align_is_generic) null else owner_info.alignment,
73827382
.cc = if (owner_info.cc_is_generic) null else owner_info.cc,
@@ -7403,7 +7403,7 @@ fn analyzeCall(
74037403
block,
74047404
&child_block,
74057405
inst,
7406-
new_fn_info.param_types,
7406+
new_param_types,
74077407
&arg_i,
74087408
args_info,
74097409
is_comptime_call,
@@ -21144,16 +21144,11 @@ fn zirReify(
2114421144

2114521145
const ty = try mod.funcType(.{
2114621146
.param_types = param_types,
21147-
.comptime_bits = 0,
2114821147
.noalias_bits = noalias_bits,
2114921148
.return_type = return_type.toIntern(),
2115021149
.alignment = alignment,
2115121150
.cc = cc,
2115221151
.is_var_args = is_var_args,
21153-
.is_generic = false,
21154-
.is_noinline = false,
21155-
.section_is_generic = false,
21156-
.addrspace_is_generic = false,
2115721152
});
2115821153
return Air.internedToRef(ty.toIntern());
2115921154
},

0 commit comments

Comments
 (0)