| ... | @@ -105,7 +105,7 @@ const MCValue = union(enum) { | ... | @@ -105,7 +105,7 @@ const MCValue = union(enum) { |
| 105 | undef, | 105 | undef, |
| 106 | /// A pointer-sized integer that fits in a register. | 106 | /// A pointer-sized integer that fits in a register. |
| 107 | /// If the type is a pointer, this is the pointer address in virtual address space. | 107 | /// If the type is a pointer, this is the pointer address in virtual address space. |
| 108 | immediate: u64, | 108 | immediate: u32, |
| 109 | /// The constant was emitted into the code, at this offset. | 109 | /// The constant was emitted into the code, at this offset. |
| 110 | /// If the type is a pointer, it means the pointer address is embedded in the code. | 110 | /// If the type is a pointer, it means the pointer address is embedded in the code. |
| 111 | embedded_in_code: usize, | 111 | embedded_in_code: usize, |
| ... | @@ -2920,7 +2920,6 @@ fn genSetStack(self: *Self, ty: Type, stack_offset: u32, mcv: MCValue) InnerErro | ... | @@ -2920,7 +2920,6 @@ fn genSetStack(self: *Self, ty: Type, stack_offset: u32, mcv: MCValue) InnerErro |
| 2920 | 1 => return self.genSetStack(ty, stack_offset, .{ .immediate = 0xaa }), | 2920 | 1 => return self.genSetStack(ty, stack_offset, .{ .immediate = 0xaa }), |
| 2921 | 2 => return self.genSetStack(ty, stack_offset, .{ .immediate = 0xaaaa }), | 2921 | 2 => return self.genSetStack(ty, stack_offset, .{ .immediate = 0xaaaa }), |
| 2922 | 4 => return self.genSetStack(ty, stack_offset, .{ .immediate = 0xaaaaaaaa }), | 2922 | 4 => return self.genSetStack(ty, stack_offset, .{ .immediate = 0xaaaaaaaa }), |
| 2923 | 8 => return self.genSetStack(ty, stack_offset, .{ .immediate = 0xaaaaaaaaaaaaaaaa }), | | |
| 2924 | else => return self.fail("TODO implement memset", .{}), | 2923 | else => return self.fail("TODO implement memset", .{}), |
| 2925 | } | 2924 | } |
| 2926 | }, | 2925 | }, |
| ... | @@ -2936,7 +2935,7 @@ fn genSetStack(self: *Self, ty: Type, stack_offset: u32, mcv: MCValue) InnerErro | ... | @@ -2936,7 +2935,7 @@ fn genSetStack(self: *Self, ty: Type, stack_offset: u32, mcv: MCValue) InnerErro |
| 2936 | return self.fail("TODO implement set stack variable from embedded_in_code", .{}); | 2935 | return self.fail("TODO implement set stack variable from embedded_in_code", .{}); |
| 2937 | }, | 2936 | }, |
| 2938 | .register => |reg| { | 2937 | .register => |reg| { |
| 2939 | const abi_size = ty.abiSize(self.target.*); | 2938 | const abi_size = @intCast(u32, ty.abiSize(self.target.*)); |
| 2940 | const adj_off = stack_offset + abi_size; | 2939 | const adj_off = stack_offset + abi_size; |
| 2941 | | 2940 | |
| 2942 | switch (abi_size) { | 2941 | switch (abi_size) { |
| ... | @@ -3195,7 +3194,7 @@ fn genSetReg(self: *Self, ty: Type, reg: Register, mcv: MCValue) InnerError!void | ... | @@ -3195,7 +3194,7 @@ fn genSetReg(self: *Self, ty: Type, reg: Register, mcv: MCValue) InnerError!void |
| 3195 | .memory => |addr| { | 3194 | .memory => |addr| { |
| 3196 | // The value is in memory at a hard-coded address. | 3195 | // The value is in memory at a hard-coded address. |
| 3197 | // If the type is a pointer, it means the pointer address is at this memory location. | 3196 | // 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) }); |
| 3199 | _ = try self.addInst(.{ | 3198 | _ = try self.addInst(.{ |
| 3200 | .tag = .ldr, | 3199 | .tag = .ldr, |
| 3201 | .cond = .al, | 3200 | .cond = .al, |
| ... | @@ -3208,7 +3207,7 @@ fn genSetReg(self: *Self, ty: Type, reg: Register, mcv: MCValue) InnerError!void | ... | @@ -3208,7 +3207,7 @@ fn genSetReg(self: *Self, ty: Type, reg: Register, mcv: MCValue) InnerError!void |
| 3208 | }, | 3207 | }, |
| 3209 | .stack_offset => |unadjusted_off| { | 3208 | .stack_offset => |unadjusted_off| { |
| 3210 | // TODO: maybe addressing from sp instead of fp | 3209 | // 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.*)); |
| 3212 | const adj_off = unadjusted_off + abi_size; | 3211 | const adj_off = unadjusted_off + abi_size; |
| 3213 | | 3212 | |
| 3214 | switch (abi_size) { | 3213 | switch (abi_size) { |
| ... | @@ -3294,12 +3293,11 @@ fn genSetStackArgument(self: *Self, ty: Type, stack_offset: u32, mcv: MCValue) I | ... | @@ -3294,12 +3293,11 @@ fn genSetStackArgument(self: *Self, ty: Type, stack_offset: u32, mcv: MCValue) I |
| 3294 | 1 => return self.genSetStackArgument(ty, stack_offset, .{ .immediate = 0xaa }), | 3293 | 1 => return self.genSetStackArgument(ty, stack_offset, .{ .immediate = 0xaa }), |
| 3295 | 2 => return self.genSetStackArgument(ty, stack_offset, .{ .immediate = 0xaaaa }), | 3294 | 2 => return self.genSetStackArgument(ty, stack_offset, .{ .immediate = 0xaaaa }), |
| 3296 | 4 => return self.genSetStackArgument(ty, stack_offset, .{ .immediate = 0xaaaaaaaa }), | 3295 | 4 => return self.genSetStackArgument(ty, stack_offset, .{ .immediate = 0xaaaaaaaa }), |
| 3297 | 8 => return self.genSetStackArgument(ty, stack_offset, .{ .immediate = 0xaaaaaaaaaaaaaaaa }), | | |
| 3298 | else => return self.fail("TODO implement memset", .{}), | 3296 | else => return self.fail("TODO implement memset", .{}), |
| 3299 | } | 3297 | } |
| 3300 | }, | 3298 | }, |
| 3301 | .register => |reg| { | 3299 | .register => |reg| { |
| 3302 | const abi_size = ty.abiSize(self.target.*); | 3300 | const abi_size = @intCast(u32, ty.abiSize(self.target.*)); |
| 3303 | const adj_off = stack_offset - abi_size; | 3301 | const adj_off = stack_offset - abi_size; |
| 3304 | | 3302 | |
| 3305 | switch (abi_size) { | 3303 | switch (abi_size) { |
| ... | @@ -3540,7 +3538,7 @@ fn genTypedValue(self: *Self, typed_value: TypedValue) InnerError!MCValue { | ... | @@ -3540,7 +3538,7 @@ fn genTypedValue(self: *Self, typed_value: TypedValue) InnerError!MCValue { |
| 3540 | } | 3538 | } |
| 3541 | } | 3539 | } |
| 3542 | if (typed_value.val.tag() == .int_u64) { | 3540 | 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()) }; |
| 3544 | } | 3542 | } |
| 3545 | return self.fail("TODO codegen more kinds of const pointers", .{}); | 3543 | return self.fail("TODO codegen more kinds of const pointers", .{}); |
| 3546 | }, | 3544 | }, |
| ... | @@ -3550,7 +3548,7 @@ fn genTypedValue(self: *Self, typed_value: TypedValue) InnerError!MCValue { | ... | @@ -3550,7 +3548,7 @@ fn genTypedValue(self: *Self, typed_value: TypedValue) InnerError!MCValue { |
| 3550 | if (info.bits > ptr_bits or info.signedness == .signed) { | 3548 | if (info.bits > ptr_bits or info.signedness == .signed) { |
| 3551 | return self.fail("TODO const int bigger than ptr and signed int", .{}); | 3549 | return self.fail("TODO const int bigger than ptr and signed int", .{}); |
| 3552 | } | 3550 | } |
| 3553 | return MCValue{ .immediate = typed_value.val.toUnsignedInt() }; | 3551 | return MCValue{ .immediate = @intCast(u32, typed_value.val.toUnsignedInt()) }; |
| 3554 | }, | 3552 | }, |
| 3555 | .Bool => { | 3553 | .Bool => { |
| 3556 | return MCValue{ .immediate = @boolToInt(typed_value.val.toBool()) }; | 3554 | return MCValue{ .immediate = @boolToInt(typed_value.val.toBool()) }; |