| ... | @@ -101,8 +101,8 @@ pub const Block = struct { | ... | @@ -101,8 +101,8 @@ pub const Block = struct { |
| 101 | fn branch(target_block: *Block, isel: *Select) !void { | 101 | fn branch(target_block: *Block, isel: *Select) !void { |
| 102 | if (isel.instructions.items.len > target_block.target_label) { | 102 | if (isel.instructions.items.len > target_block.target_label) { |
| 103 | try isel.internal_relocs.append(isel.pt.zcu.gpa, .{ | 103 | try isel.internal_relocs.append(isel.pt.zcu.gpa, .{ |
| 104 | .label = @intCast(isel.instructions.items.len), | | |
| 105 | .target = target_block.target_label, | 104 | .target = target_block.target_label, |
| | 105 | .reloc = .{ .label = @intCast(isel.instructions.items.len), .type = .B26 }, |
| 106 | }); | 106 | }); |
| 107 | try isel.emit(.b(0, 0)); | 107 | try isel.emit(.b(0, 0)); |
| 108 | } | 108 | } |
| ... | @@ -1449,6 +1449,7 @@ pub const Value = struct { | ... | @@ -1449,6 +1449,7 @@ pub const Value = struct { |
| 1449 | .reloc = .{ | 1449 | .reloc = .{ |
| 1450 | .label = @intCast(isel.instructions.items.len), | 1450 | .label = @intCast(isel.instructions.items.len), |
| 1451 | .addend = @intCast(total_root_offset), | 1451 | .addend = @intCast(total_root_offset), |
| | 1452 | .type = .PCALA_LO12, |
| 1452 | }, | 1453 | }, |
| 1453 | }); | 1454 | }); |
| 1454 | try isel.emit(.@"addi.d"(ptr_reg, ptr_reg, 0)); | 1455 | try isel.emit(.@"addi.d"(ptr_reg, ptr_reg, 0)); |
| ... | @@ -1460,6 +1461,7 @@ pub const Value = struct { | ... | @@ -1460,6 +1461,7 @@ pub const Value = struct { |
| 1460 | .reloc = .{ | 1461 | .reloc = .{ |
| 1461 | .label = @intCast(isel.instructions.items.len), | 1462 | .label = @intCast(isel.instructions.items.len), |
| 1462 | .addend = @intCast(total_root_offset), | 1463 | .addend = @intCast(total_root_offset), |
| | 1464 | .type = .PCALA_HI20, |
| 1463 | }, | 1465 | }, |
| 1464 | }); | 1466 | }); |
| 1465 | try isel.emit(.pcalau12i(ptr_reg, 0)); | 1467 | try isel.emit(.pcalau12i(ptr_reg, 0)); |
| ... | @@ -3164,8 +3166,8 @@ pub fn body(isel: *Select, air_body: []const Air.Inst.Index) error{ OutOfMemory, | ... | @@ -3164,8 +3166,8 @@ pub fn body(isel: *Select, air_body: []const Air.Inst.Index) error{ OutOfMemory, |
| 3164 | const next_repeat_label = instruction.*; | 3166 | const next_repeat_label = instruction.*; |
| 3165 | instruction.* = .b(0, 0); | 3167 | instruction.* = .b(0, 0); |
| 3166 | try isel.internal_relocs.append(gpa, .{ | 3168 | try isel.internal_relocs.append(gpa, .{ |
| 3167 | .label = repeat_label, | | |
| 3168 | .target = isel.instructions.items.len, | 3169 | .target = isel.instructions.items.len, |
| | 3170 | .reloc = .{ .label = repeat_label, .type = .B26 }, |
| 3169 | }); | 3171 | }); |
| 3170 | repeat_label = @bitCast(next_repeat_label); | 3172 | repeat_label = @bitCast(next_repeat_label); |
| 3171 | } | 3173 | } |
| ... | @@ -3197,8 +3199,8 @@ pub fn body(isel: *Select, air_body: []const Air.Inst.Index) error{ OutOfMemory, | ... | @@ -3197,8 +3199,8 @@ pub fn body(isel: *Select, air_body: []const Air.Inst.Index) error{ OutOfMemory, |
| 3197 | .extension = .zero_ext, | 3199 | .extension = .zero_ext, |
| 3198 | }); | 3200 | }); |
| 3199 | try isel.internal_relocs.append(gpa, .{ | 3201 | try isel.internal_relocs.append(gpa, .{ |
| 3200 | .label = @intCast(isel.instructions.items.len), | | |
| 3201 | .target = else_label, | 3202 | .target = else_label, |
| | 3203 | .reloc = .{ .label = @intCast(isel.instructions.items.len), .type = .B21 }, |
| 3202 | }); | 3204 | }); |
| 3203 | try isel.emit(.beqz(cond_mat.reg(), 0, 0)); | 3205 | try isel.emit(.beqz(cond_mat.reg(), 0, 0)); |
| 3204 | try cond_mat.finish(isel); | 3206 | try cond_mat.finish(isel); |
| ... | @@ -3241,8 +3243,8 @@ pub fn body(isel: *Select, air_body: []const Air.Inst.Index) error{ OutOfMemory, | ... | @@ -3241,8 +3243,8 @@ pub fn body(isel: *Select, air_body: []const Air.Inst.Index) error{ OutOfMemory, |
| 3241 | }); | 3243 | }); |
| 3242 | | 3244 | |
| 3243 | try isel.internal_relocs.append(gpa, .{ | 3245 | try isel.internal_relocs.append(gpa, .{ |
| 3244 | .label = @intCast(isel.instructions.items.len), | | |
| 3245 | .target = next_label, | 3246 | .target = next_label, |
| | 3247 | .reloc = .{ .label = @intCast(isel.instructions.items.len), .type = .B26 }, |
| 3246 | }); | 3248 | }); |
| 3247 | try isel.emit(.b(0, 0)); | 3249 | try isel.emit(.b(0, 0)); |
| 3248 | | 3250 | |
| ... | @@ -3268,8 +3270,8 @@ pub fn body(isel: *Select, air_body: []const Air.Inst.Index) error{ OutOfMemory, | ... | @@ -3268,8 +3270,8 @@ pub fn body(isel: *Select, air_body: []const Air.Inst.Index) error{ OutOfMemory, |
| 3268 | defer isel.freeReg(item_reg); | 3270 | defer isel.freeReg(item_reg); |
| 3269 | | 3271 | |
| 3270 | try isel.internal_relocs.append(gpa, .{ | 3272 | try isel.internal_relocs.append(gpa, .{ |
| 3271 | .label = @intCast(isel.instructions.items.len), | | |
| 3272 | .target = case_label, | 3273 | .target = case_label, |
| | 3274 | .reloc = .{ .label = @intCast(isel.instructions.items.len), .type = .B16 }, |
| 3273 | }); | 3275 | }); |
| 3274 | try isel.emit(.beq(cond_mat.reg(), item_reg, 0)); | 3276 | try isel.emit(.beq(cond_mat.reg(), item_reg, 0)); |
| 3275 | try isel.moveIntImm(item_reg, @bitCast(item_int)); | 3277 | try isel.moveIntImm(item_reg, @bitCast(item_int)); |
| ... | @@ -3323,13 +3325,14 @@ pub fn body(isel: *Select, air_body: []const Air.Inst.Index) error{ OutOfMemory, | ... | @@ -3323,13 +3325,14 @@ pub fn body(isel: *Select, air_body: []const Air.Inst.Index) error{ OutOfMemory, |
| 3323 | else => unreachable, | 3325 | else => unreachable, |
| 3324 | inline .@"extern", .func => |func| .{ | 3326 | inline .@"extern", .func => |func| .{ |
| 3325 | .nav = func.owner_nav, | 3327 | .nav = func.owner_nav, |
| 3326 | .reloc = .{ .label = @intCast(isel.instructions.items.len) }, | 3328 | .reloc = .{ .label = @intCast(isel.instructions.items.len), .type = .CALL36 }, |
| 3327 | }, | 3329 | }, |
| 3328 | .ptr => |ptr| .{ | 3330 | .ptr => |ptr| .{ |
| 3329 | .nav = ptr.base_addr.nav, | 3331 | .nav = ptr.base_addr.nav, |
| 3330 | .reloc = .{ | 3332 | .reloc = .{ |
| 3331 | .label = @intCast(isel.instructions.items.len), | 3333 | .label = @intCast(isel.instructions.items.len), |
| 3332 | .addend = @intCast(ptr.byte_offset), | 3334 | .addend = @intCast(ptr.byte_offset), |
| | 3335 | .type = .CALL36, |
| 3333 | }, | 3336 | }, |
| 3334 | }, | 3337 | }, |
| 3335 | }); | 3338 | }); |
| ... | @@ -3920,13 +3923,13 @@ pub fn body(isel: *Select, air_body: []const Air.Inst.Index) error{ OutOfMemory, | ... | @@ -3920,13 +3923,13 @@ pub fn body(isel: *Select, air_body: []const Air.Inst.Index) error{ OutOfMemory, |
| 3920 | .extension = .zero_ext, | 3923 | .extension = .zero_ext, |
| 3921 | }); | 3924 | }); |
| 3922 | try isel.internal_relocs.append(gpa, .{ | 3925 | try isel.internal_relocs.append(gpa, .{ |
| 3923 | .label = @intCast(isel.instructions.items.len), | | |
| 3924 | .target = cmp_label, | 3926 | .target = cmp_label, |
| | 3927 | .reloc = .{ .label = @intCast(isel.instructions.items.len), .type = .B21 }, |
| 3925 | }); | 3928 | }); |
| 3926 | try isel.emit(.beqz(lhs_tag_mat.reg(), 0, 0)); | 3929 | try isel.emit(.beqz(lhs_tag_mat.reg(), 0, 0)); |
| 3927 | try isel.internal_relocs.append(gpa, .{ | 3930 | try isel.internal_relocs.append(gpa, .{ |
| 3928 | .label = @intCast(isel.instructions.items.len), | | |
| 3929 | .target = cmp_label, | 3931 | .target = cmp_label, |
| | 3932 | .reloc = .{ .label = @intCast(isel.instructions.items.len), .type = .B21 }, |
| 3930 | }); | 3933 | }); |
| 3931 | try isel.emit(.beqz(res_reg, 0, 0)); | 3934 | try isel.emit(.beqz(res_reg, 0, 0)); |
| 3932 | | 3935 | |
| ... | @@ -4274,8 +4277,8 @@ pub fn body(isel: *Select, air_body: []const Air.Inst.Index) error{ OutOfMemory, | ... | @@ -4274,8 +4277,8 @@ pub fn body(isel: *Select, air_body: []const Air.Inst.Index) error{ OutOfMemory, |
| 4274 | ); | 4277 | ); |
| 4275 | const error_set_part_mat = try error_set_part_vi.matIntRegZeroExt(isel); | 4278 | const error_set_part_mat = try error_set_part_vi.matIntRegZeroExt(isel); |
| 4276 | try isel.internal_relocs.append(gpa, .{ | 4279 | try isel.internal_relocs.append(gpa, .{ |
| 4277 | .label = @intCast(isel.instructions.items.len), | | |
| 4278 | .target = cont_label, | 4280 | .target = cont_label, |
| | 4281 | .reloc = .{ .label = @intCast(isel.instructions.items.len), .type = .B26 }, |
| 4279 | }); | 4282 | }); |
| 4280 | try isel.emit(.beqz(error_set_part_mat.reg(), 0, 0)); | 4283 | try isel.emit(.beqz(error_set_part_mat.reg(), 0, 0)); |
| 4281 | try error_set_part_mat.finish(isel); | 4284 | try error_set_part_mat.finish(isel); |
| ... | @@ -4312,8 +4315,8 @@ pub fn body(isel: *Select, air_body: []const Air.Inst.Index) error{ OutOfMemory, | ... | @@ -4312,8 +4315,8 @@ pub fn body(isel: *Select, air_body: []const Air.Inst.Index) error{ OutOfMemory, |
| 4312 | defer isel.freeReg(tmp_reg); | 4315 | defer isel.freeReg(tmp_reg); |
| 4313 | | 4316 | |
| 4314 | try isel.internal_relocs.append(gpa, .{ | 4317 | try isel.internal_relocs.append(gpa, .{ |
| 4315 | .label = @intCast(isel.instructions.items.len), | | |
| 4316 | .target = cont_label, | 4318 | .target = cont_label, |
| | 4319 | .reloc = .{ .label = @intCast(isel.instructions.items.len), .type = .B26 }, |
| 4317 | }); | 4320 | }); |
| 4318 | try isel.emit(.beqz(tmp_reg, 0, 0)); | 4321 | try isel.emit(.beqz(tmp_reg, 0, 0)); |
| 4319 | | 4322 | |
| ... | @@ -6467,6 +6470,7 @@ fn moveConstant(isel: *Select, dst: Value.Location, init_constant: Constant, ini | ... | @@ -6467,6 +6470,7 @@ fn moveConstant(isel: *Select, dst: Value.Location, init_constant: Constant, ini |
| 6467 | .reloc = .{ | 6470 | .reloc = .{ |
| 6468 | .label = @intCast(isel.instructions.items.len), | 6471 | .label = @intCast(isel.instructions.items.len), |
| 6469 | .addend = @intCast(ptr.byte_offset), | 6472 | .addend = @intCast(ptr.byte_offset), |
| | 6473 | .type = .PCALA_LO12, |
| 6470 | }, | 6474 | }, |
| 6471 | }); | 6475 | }); |
| 6472 | try isel.emit(.@"addi.d"(rd, rd, 0)); | 6476 | try isel.emit(.@"addi.d"(rd, rd, 0)); |
| ... | @@ -6475,6 +6479,7 @@ fn moveConstant(isel: *Select, dst: Value.Location, init_constant: Constant, ini | ... | @@ -6475,6 +6479,7 @@ fn moveConstant(isel: *Select, dst: Value.Location, init_constant: Constant, ini |
| 6475 | .reloc = .{ | 6479 | .reloc = .{ |
| 6476 | .label = @intCast(isel.instructions.items.len), | 6480 | .label = @intCast(isel.instructions.items.len), |
| 6477 | .addend = @intCast(ptr.byte_offset), | 6481 | .addend = @intCast(ptr.byte_offset), |
| | 6482 | .type = .PCALA_HI20, |
| 6478 | }, | 6483 | }, |
| 6479 | }); | 6484 | }); |
| 6480 | try isel.emit(.pcalau12i(rd, 0)); | 6485 | try isel.emit(.pcalau12i(rd, 0)); |
| ... | @@ -6489,6 +6494,7 @@ fn moveConstant(isel: *Select, dst: Value.Location, init_constant: Constant, ini | ... | @@ -6489,6 +6494,7 @@ fn moveConstant(isel: *Select, dst: Value.Location, init_constant: Constant, ini |
| 6489 | .reloc = .{ | 6494 | .reloc = .{ |
| 6490 | .label = @intCast(isel.instructions.items.len), | 6495 | .label = @intCast(isel.instructions.items.len), |
| 6491 | .addend = @intCast(ptr.byte_offset), | 6496 | .addend = @intCast(ptr.byte_offset), |
| | 6497 | .type = .PCALA_LO12, |
| 6492 | }, | 6498 | }, |
| 6493 | }); | 6499 | }); |
| 6494 | try isel.emit(.@"addi.d"(rd, rd, 0)); | 6500 | try isel.emit(.@"addi.d"(rd, rd, 0)); |
| ... | @@ -6497,6 +6503,7 @@ fn moveConstant(isel: *Select, dst: Value.Location, init_constant: Constant, ini | ... | @@ -6497,6 +6503,7 @@ fn moveConstant(isel: *Select, dst: Value.Location, init_constant: Constant, ini |
| 6497 | .reloc = .{ | 6503 | .reloc = .{ |
| 6498 | .label = @intCast(isel.instructions.items.len), | 6504 | .label = @intCast(isel.instructions.items.len), |
| 6499 | .addend = @intCast(ptr.byte_offset), | 6505 | .addend = @intCast(ptr.byte_offset), |
| | 6506 | .type = .PCALA_HI20, |
| 6500 | }, | 6507 | }, |
| 6501 | }); | 6508 | }); |
| 6502 | try isel.emit(.pcalau12i(rd, 0)); | 6509 | try isel.emit(.pcalau12i(rd, 0)); |
| ... | @@ -6752,15 +6759,12 @@ fn moveConstant(isel: *Select, dst: Value.Location, init_constant: Constant, ini | ... | @@ -6752,15 +6759,12 @@ fn moveConstant(isel: *Select, dst: Value.Location, init_constant: Constant, ini |
| 6752 | // load constant pointer | 6759 | // load constant pointer |
| 6753 | try isel.uav_relocs.append(zcu.gpa, .{ | 6760 | try isel.uav_relocs.append(zcu.gpa, .{ |
| 6754 | .uav = uav, | 6761 | .uav = uav, |
| 6755 | .reloc = .{ .label = @intCast(isel.instructions.items.len), .addend = 0 }, | 6762 | .reloc = .{ .label = @intCast(isel.instructions.items.len), .type = .PCALA_LO12 }, |
| 6756 | }); | 6763 | }); |
| 6757 | try isel.emit(.@"addi.d"(tmp_reg, tmp_reg, 0)); | 6764 | try isel.emit(.@"addi.d"(tmp_reg, tmp_reg, 0)); |
| 6758 | try isel.uav_relocs.append(zcu.gpa, .{ | 6765 | try isel.uav_relocs.append(zcu.gpa, .{ |
| 6759 | .uav = uav, | 6766 | .uav = uav, |
| 6760 | .reloc = .{ | 6767 | .reloc = .{ .label = @intCast(isel.instructions.items.len), .type = .PCALA_HI20 }, |
| 6761 | .label = @intCast(isel.instructions.items.len), | | |
| 6762 | .addend = 0, | | |
| 6763 | }, | | |
| 6764 | }); | 6768 | }); |
| 6765 | try isel.emit(.pcalau12i(tmp_reg, 0)); | 6769 | try isel.emit(.pcalau12i(tmp_reg, 0)); |
| 6766 | | 6770 | |