authorgravatar for joachim.schmidt557@outlook.comJoachim Schmidt <joachim.schmidt557@outlook.com> 2021-12-29 11:27:37+01:00
committergravatar for joachim.schmidt557@outlook.comJoachim Schmidt <joachim.schmidt557@outlook.com> 2021-12-29 11:27:37+01:00
logbaec07cfcd11ab51b3cec1fde66db1a084d7a97f
tree8251c569977b3e97f8566a65d4054353b36c77a7
parent96e59fd1c29ef03616bdba147cfbd896be59c202
signaturelock-open Commit is signed but in an unrecognized format.

stage2 ARM: change MCValue.immediate to u32


1 files changed, 7 insertions(+), 9 deletions(-)

src/arch/arm/CodeGen.zig+7-9
......@@ -105,7 +105,7 @@ const MCValue = union(enum) {
105105 undef,
106106 /// A pointer-sized integer that fits in a register.
107107 /// If the type is a pointer, this is the pointer address in virtual address space.
108 immediate: u64,
108 immediate: u32,
109109 /// The constant was emitted into the code, at this offset.
110110 /// If the type is a pointer, it means the pointer address is embedded in the code.
111111 embedded_in_code: usize,
......@@ -2920,7 +2920,6 @@ fn genSetStack(self: *Self, ty: Type, stack_offset: u32, mcv: MCValue) InnerErro
29202920 1 => return self.genSetStack(ty, stack_offset, .{ .immediate = 0xaa }),
29212921 2 => return self.genSetStack(ty, stack_offset, .{ .immediate = 0xaaaa }),
29222922 4 => return self.genSetStack(ty, stack_offset, .{ .immediate = 0xaaaaaaaa }),
2923 8 => return self.genSetStack(ty, stack_offset, .{ .immediate = 0xaaaaaaaaaaaaaaaa }),
29242923 else => return self.fail("TODO implement memset", .{}),
29252924 }
29262925 },
......@@ -2936,7 +2935,7 @@ fn genSetStack(self: *Self, ty: Type, stack_offset: u32, mcv: MCValue) InnerErro
29362935 return self.fail("TODO implement set stack variable from embedded_in_code", .{});
29372936 },
29382937 .register => |reg| {
2939 const abi_size = ty.abiSize(self.target.*);
2938 const abi_size = @intCast(u32, ty.abiSize(self.target.*));
29402939 const adj_off = stack_offset + abi_size;
29412940
29422941 switch (abi_size) {
......@@ -3195,7 +3194,7 @@ fn genSetReg(self: *Self, ty: Type, reg: Register, mcv: MCValue) InnerError!void
31953194 .memory => |addr| {
31963195 // The value is in memory at a hard-coded address.
31973196 // If the type is a pointer, it means the pointer address is at this memory location.
3198 try self.genSetReg(ty, reg, .{ .immediate = addr });
3197 try self.genSetReg(ty, reg, .{ .immediate = @intCast(u32, addr) });
31993198 _ = try self.addInst(.{
32003199 .tag = .ldr,
32013200 .cond = .al,
......@@ -3208,7 +3207,7 @@ fn genSetReg(self: *Self, ty: Type, reg: Register, mcv: MCValue) InnerError!void
32083207 },
32093208 .stack_offset => |unadjusted_off| {
32103209 // TODO: maybe addressing from sp instead of fp
3211 const abi_size = ty.abiSize(self.target.*);
3210 const abi_size = @intCast(u32, ty.abiSize(self.target.*));
32123211 const adj_off = unadjusted_off + abi_size;
32133212
32143213 switch (abi_size) {
......@@ -3294,12 +3293,11 @@ fn genSetStackArgument(self: *Self, ty: Type, stack_offset: u32, mcv: MCValue) I
32943293 1 => return self.genSetStackArgument(ty, stack_offset, .{ .immediate = 0xaa }),
32953294 2 => return self.genSetStackArgument(ty, stack_offset, .{ .immediate = 0xaaaa }),
32963295 4 => return self.genSetStackArgument(ty, stack_offset, .{ .immediate = 0xaaaaaaaa }),
3297 8 => return self.genSetStackArgument(ty, stack_offset, .{ .immediate = 0xaaaaaaaaaaaaaaaa }),
32983296 else => return self.fail("TODO implement memset", .{}),
32993297 }
33003298 },
33013299 .register => |reg| {
3302 const abi_size = ty.abiSize(self.target.*);
3300 const abi_size = @intCast(u32, ty.abiSize(self.target.*));
33033301 const adj_off = stack_offset - abi_size;
33043302
33053303 switch (abi_size) {
......@@ -3540,7 +3538,7 @@ fn genTypedValue(self: *Self, typed_value: TypedValue) InnerError!MCValue {
35403538 }
35413539 }
35423540 if (typed_value.val.tag() == .int_u64) {
3543 return MCValue{ .immediate = typed_value.val.toUnsignedInt() };
3541 return MCValue{ .immediate = @intCast(u32, typed_value.val.toUnsignedInt()) };
35443542 }
35453543 return self.fail("TODO codegen more kinds of const pointers", .{});
35463544 },
......@@ -3550,7 +3548,7 @@ fn genTypedValue(self: *Self, typed_value: TypedValue) InnerError!MCValue {
35503548 if (info.bits > ptr_bits or info.signedness == .signed) {
35513549 return self.fail("TODO const int bigger than ptr and signed int", .{});
35523550 }
3553 return MCValue{ .immediate = typed_value.val.toUnsignedInt() };
3551 return MCValue{ .immediate = @intCast(u32, typed_value.val.toUnsignedInt()) };
35543552 },
35553553 .Bool => {
35563554 return MCValue{ .immediate = @boolToInt(typed_value.val.toBool()) };