diff options
| author | Veikka Tuominen <git@vexu.eu> | 2022-10-21 21:44:52 +0300 |
|---|---|---|
| committer | Veikka Tuominen <git@vexu.eu> | 2022-10-22 11:31:41 +0300 |
| commit | 031c768cc8399ccdf5440df87d37c03a238315d5 (patch) | |
| tree | d9299c0405ae7beb0633b406aa99f473f94bf26d /src/codegen/llvm.zig | |
| parent | 3981250b84b4eb4a34832e3fa5888aa3442e8a74 (diff) | |
| download | zig-031c768cc8399ccdf5440df87d37c03a238315d5.tar.gz zig-031c768cc8399ccdf5440df87d37c03a238315d5.zip | |
add C ABI tests for simd vectors
Diffstat (limited to 'src/codegen/llvm.zig')
| -rw-r--r-- | src/codegen/llvm.zig | 30 |
1 files changed, 13 insertions, 17 deletions
diff --git a/src/codegen/llvm.zig b/src/codegen/llvm.zig index b3c8e225dc..cc8ab10e4b 100644 --- a/src/codegen/llvm.zig +++ b/src/codegen/llvm.zig @@ -10110,11 +10110,11 @@ fn firstParamSRet(fn_info: Type.Payload.Function.Data, target: std.Target) bool .mips, .mipsel => return false, .x86_64 => switch (target.os.tag) { .windows => return x86_64_abi.classifyWindows(fn_info.return_type, target) == .memory, - else => return x86_64_abi.classifySystemV(fn_info.return_type, target)[0] == .memory, + else => return x86_64_abi.classifySystemV(fn_info.return_type, target, .ret)[0] == .memory, }, .wasm32 => return wasm_c_abi.classifyType(fn_info.return_type, target)[0] == .indirect, .aarch64, .aarch64_be => return aarch64_c_abi.classifyType(fn_info.return_type, target) == .memory, - .arm, .armeb => switch (arm_c_abi.classifyType(fn_info.return_type, target)) { + .arm, .armeb => switch (arm_c_abi.classifyType(fn_info.return_type, target, .ret)) { .memory, .i64_array => return true, .i32_array => |size| return size != 1, .none, .byval => return false, @@ -10171,7 +10171,7 @@ fn lowerFnRetTy(dg: *DeclGen, fn_info: Type.Payload.Function.Data) !*llvm.Type { if (is_scalar) { return dg.lowerType(fn_info.return_type); } - const classes = x86_64_abi.classifySystemV(fn_info.return_type, target); + const classes = x86_64_abi.classifySystemV(fn_info.return_type, target, .ret); if (classes[0] == .memory) { return dg.context.voidType(); } @@ -10229,12 +10229,10 @@ fn lowerFnRetTy(dg: *DeclGen, fn_info: Type.Payload.Function.Data) !*llvm.Type { return dg.context.intType(@intCast(c_uint, abi_size * 8)); }, .aarch64, .aarch64_be => { - if (is_scalar) { - return dg.lowerType(fn_info.return_type); - } switch (aarch64_c_abi.classifyType(fn_info.return_type, target)) { .memory, .none => return dg.context.voidType(), .float_array => return dg.lowerType(fn_info.return_type), + .byval => return dg.lowerType(fn_info.return_type), .integer => { const bit_size = fn_info.return_type.bitSize(target); return dg.context.intType(@intCast(c_uint, bit_size)); @@ -10243,7 +10241,7 @@ fn lowerFnRetTy(dg: *DeclGen, fn_info: Type.Payload.Function.Data) !*llvm.Type { } }, .arm, .armeb => { - switch (arm_c_abi.classifyType(fn_info.return_type, target)) { + switch (arm_c_abi.classifyType(fn_info.return_type, target, .ret)) { .memory, .i64_array => return dg.context.voidType(), .i32_array => |len| if (len == 1) { return dg.context.intType(32); @@ -10376,18 +10374,18 @@ const ParamTypeIterator = struct { else => unreachable, }, else => { - if (is_scalar) { - it.zig_index += 1; - it.llvm_index += 1; - return .byval; - } - const classes = x86_64_abi.classifySystemV(ty, it.target); + const classes = x86_64_abi.classifySystemV(ty, it.target, .arg); if (classes[0] == .memory) { it.zig_index += 1; it.llvm_index += 1; it.byval_attr = true; return .byref; } + if (is_scalar) { + it.zig_index += 1; + it.llvm_index += 1; + return .byval; + } var llvm_types_buffer: [8]u16 = undefined; var llvm_types_index: u32 = 0; for (classes) |class| { @@ -10452,13 +10450,11 @@ const ParamTypeIterator = struct { .aarch64, .aarch64_be => { it.zig_index += 1; it.llvm_index += 1; - if (is_scalar) { - return .byval; - } switch (aarch64_c_abi.classifyType(ty, it.target)) { .none => unreachable, .memory => return .byref, .float_array => |len| return Lowering{ .float_array = len }, + .byval => return .byval, .integer => { it.llvm_types_len = 1; it.llvm_types_buffer[0] = 64; @@ -10470,7 +10466,7 @@ const ParamTypeIterator = struct { .arm, .armeb => { it.zig_index += 1; it.llvm_index += 1; - switch (arm_c_abi.classifyType(ty, it.target)) { + switch (arm_c_abi.classifyType(ty, it.target, .arg)) { .none => unreachable, .memory => { it.byval_attr = true; |
