aboutsummaryrefslogtreecommitdiff
path: root/src/arch/riscv64/abi.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/arch/riscv64/abi.zig')
-rw-r--r--src/arch/riscv64/abi.zig26
1 files changed, 14 insertions, 12 deletions
diff --git a/src/arch/riscv64/abi.zig b/src/arch/riscv64/abi.zig
index 26286a1e22..41a1850635 100644
--- a/src/arch/riscv64/abi.zig
+++ b/src/arch/riscv64/abi.zig
@@ -3,17 +3,19 @@ const bits = @import("bits.zig");
const Register = bits.Register;
const RegisterManagerFn = @import("../../register_manager.zig").RegisterManager;
const Type = @import("../../type.zig").Type;
+const Module = @import("../../Module.zig");
pub const Class = enum { memory, byval, integer, double_integer };
-pub fn classifyType(ty: Type, target: std.Target) Class {
- std.debug.assert(ty.hasRuntimeBitsIgnoreComptime());
+pub fn classifyType(ty: Type, mod: *Module) Class {
+ const target = mod.getTarget();
+ std.debug.assert(ty.hasRuntimeBitsIgnoreComptime(mod));
- const max_byval_size = target.cpu.arch.ptrBitWidth() * 2;
- switch (ty.zigTypeTag()) {
+ const max_byval_size = target.ptrBitWidth() * 2;
+ switch (ty.zigTypeTag(mod)) {
.Struct => {
- const bit_size = ty.bitSize(target);
- if (ty.containerLayout() == .Packed) {
+ const bit_size = ty.bitSize(mod);
+ if (ty.containerLayout(mod) == .Packed) {
if (bit_size > max_byval_size) return .memory;
return .byval;
}
@@ -23,8 +25,8 @@ pub fn classifyType(ty: Type, target: std.Target) Class {
return .integer;
},
.Union => {
- const bit_size = ty.bitSize(target);
- if (ty.containerLayout() == .Packed) {
+ const bit_size = ty.bitSize(mod);
+ if (ty.containerLayout(mod) == .Packed) {
if (bit_size > max_byval_size) return .memory;
return .byval;
}
@@ -36,21 +38,21 @@ pub fn classifyType(ty: Type, target: std.Target) Class {
.Bool => return .integer,
.Float => return .byval,
.Int, .Enum, .ErrorSet => {
- const bit_size = ty.bitSize(target);
+ const bit_size = ty.bitSize(mod);
if (bit_size > max_byval_size) return .memory;
return .byval;
},
.Vector => {
- const bit_size = ty.bitSize(target);
+ const bit_size = ty.bitSize(mod);
if (bit_size > max_byval_size) return .memory;
return .integer;
},
.Optional => {
- std.debug.assert(ty.isPtrLikeOptional());
+ std.debug.assert(ty.isPtrLikeOptional(mod));
return .byval;
},
.Pointer => {
- std.debug.assert(!ty.isSlice());
+ std.debug.assert(!ty.isSlice(mod));
return .byval;
},
.ErrorUnion,