wasm-c-abi: llvm fix struct handling + reorganize
I changed to `wasm/abi.zig`, this design is certainly better than the previous one. Still there is some conflict of interest between llvm and self-hosted backend, better design will appear when abi tests will be tested with self-hosted. Resolves: #23304 Resolves: #23305
This commit is contained in:
committed by
Andrew Kelley
parent
ad9cb40112
commit
a843be44a0
@@ -11723,7 +11723,7 @@ fn firstParamSRet(fn_info: InternPool.Key.FuncType, zcu: *Zcu, target: std.Targe
|
||||
.x86_64_win => x86_64_abi.classifyWindows(return_type, zcu) == .memory,
|
||||
.x86_sysv, .x86_win => isByRef(return_type, zcu),
|
||||
.x86_stdcall => !isScalar(zcu, return_type),
|
||||
.wasm_mvp => wasm_c_abi.classifyType(return_type, zcu)[0] == .indirect,
|
||||
.wasm_mvp => wasm_c_abi.classifyType(return_type, zcu) == .indirect,
|
||||
.aarch64_aapcs,
|
||||
.aarch64_aapcs_darwin,
|
||||
.aarch64_aapcs_win,
|
||||
@@ -11808,18 +11808,9 @@ fn lowerFnRetTy(o: *Object, fn_info: InternPool.Key.FuncType) Allocator.Error!Bu
|
||||
return o.builder.structType(.normal, types[0..types_len]);
|
||||
},
|
||||
},
|
||||
.wasm_mvp => {
|
||||
if (isScalar(zcu, return_type)) {
|
||||
return o.lowerType(return_type);
|
||||
}
|
||||
const classes = wasm_c_abi.classifyType(return_type, zcu);
|
||||
if (classes[0] == .indirect or classes[0] == .none) {
|
||||
return .void;
|
||||
}
|
||||
|
||||
assert(classes[0] == .direct and classes[1] == .none);
|
||||
const scalar_type = wasm_c_abi.scalarType(return_type, zcu);
|
||||
return o.builder.intType(@intCast(scalar_type.abiSize(zcu) * 8));
|
||||
.wasm_mvp => switch (wasm_c_abi.classifyType(return_type, zcu)) {
|
||||
.direct => |scalar_ty| return o.lowerType(scalar_ty),
|
||||
.indirect => return .void,
|
||||
},
|
||||
// TODO investigate other callconvs
|
||||
else => return o.lowerType(return_type),
|
||||
@@ -12073,17 +12064,28 @@ const ParamTypeIterator = struct {
|
||||
},
|
||||
}
|
||||
},
|
||||
.wasm_mvp => {
|
||||
it.zig_index += 1;
|
||||
it.llvm_index += 1;
|
||||
if (isScalar(zcu, ty)) {
|
||||
return .byval;
|
||||
}
|
||||
const classes = wasm_c_abi.classifyType(ty, zcu);
|
||||
if (classes[0] == .indirect) {
|
||||
.wasm_mvp => switch (wasm_c_abi.classifyType(ty, zcu)) {
|
||||
.direct => |scalar_ty| {
|
||||
if (isScalar(zcu, ty)) {
|
||||
it.zig_index += 1;
|
||||
it.llvm_index += 1;
|
||||
return .byval;
|
||||
} else {
|
||||
var types_buffer: [8]Builder.Type = undefined;
|
||||
types_buffer[0] = try it.object.lowerType(scalar_ty);
|
||||
it.types_buffer = types_buffer;
|
||||
it.types_len = 1;
|
||||
it.llvm_index += 1;
|
||||
it.zig_index += 1;
|
||||
return .multiple_llvm_types;
|
||||
}
|
||||
},
|
||||
.indirect => {
|
||||
it.zig_index += 1;
|
||||
it.llvm_index += 1;
|
||||
it.byval_attr = true;
|
||||
return .byref;
|
||||
}
|
||||
return .abi_sized_int;
|
||||
},
|
||||
},
|
||||
// TODO investigate other callconvs
|
||||
else => {
|
||||
|
||||
Reference in New Issue
Block a user