Switch Cranelift over to regalloc2. (#3989)

This PR switches Cranelift over to the new register allocator, regalloc2.

See [this document](https://gist.github.com/cfallin/08553421a91f150254fe878f67301801)
for a summary of the design changes. This switchover has implications for
core VCode/MachInst types and the lowering pass.

Overall, this change brings improvements to both compile time and speed of
generated code (runtime), as reported in #3942:

```
Benchmark       Compilation (wallclock)     Execution (wallclock)
blake3-scalar   25% faster                  28% faster
blake3-simd     no diff                     no diff
meshoptimizer   19% faster                  17% faster
pulldown-cmark  17% faster                  no diff
bz2             15% faster                  no diff
SpiderMonkey,   21% faster                  2% faster
  fib(30)
clang.wasm      42% faster                  N/A
```
This commit is contained in:
Chris Fallin
2022-04-14 10:28:21 -07:00
committed by GitHub
parent bfae6384aa
commit a0318f36f0
181 changed files with 16887 additions and 21587 deletions

View File

@@ -1585,7 +1585,7 @@ fn test_s390x_binemit() {
op: CmpOp::CmpS32,
rn: gpr(1),
mem: MemArg::Label {
target: MachLabel::from_block(1),
target: MachLabel::from_block(BlockIndex::new(1)),
},
},
"C61D00000003",
@@ -1624,7 +1624,7 @@ fn test_s390x_binemit() {
op: CmpOp::CmpS32Ext16,
rn: gpr(1),
mem: MemArg::Label {
target: MachLabel::from_block(1),
target: MachLabel::from_block(BlockIndex::new(1)),
},
},
"C61500000003",
@@ -1649,7 +1649,7 @@ fn test_s390x_binemit() {
op: CmpOp::CmpS64,
rn: gpr(1),
mem: MemArg::Label {
target: MachLabel::from_block(1),
target: MachLabel::from_block(BlockIndex::new(1)),
},
},
"C61800000003",
@@ -1674,7 +1674,7 @@ fn test_s390x_binemit() {
op: CmpOp::CmpS64Ext16,
rn: gpr(1),
mem: MemArg::Label {
target: MachLabel::from_block(1),
target: MachLabel::from_block(BlockIndex::new(1)),
},
},
"C61400000003",
@@ -1699,7 +1699,7 @@ fn test_s390x_binemit() {
op: CmpOp::CmpS64Ext32,
rn: gpr(1),
mem: MemArg::Label {
target: MachLabel::from_block(1),
target: MachLabel::from_block(BlockIndex::new(1)),
},
},
"C61C00000003",
@@ -1738,7 +1738,7 @@ fn test_s390x_binemit() {
op: CmpOp::CmpL32,
rn: gpr(1),
mem: MemArg::Label {
target: MachLabel::from_block(1),
target: MachLabel::from_block(BlockIndex::new(1)),
},
},
"C61F00000003",
@@ -1749,7 +1749,7 @@ fn test_s390x_binemit() {
op: CmpOp::CmpL32Ext16,
rn: gpr(1),
mem: MemArg::Label {
target: MachLabel::from_block(1),
target: MachLabel::from_block(BlockIndex::new(1)),
},
},
"C61700000003",
@@ -1774,7 +1774,7 @@ fn test_s390x_binemit() {
op: CmpOp::CmpL64,
rn: gpr(1),
mem: MemArg::Label {
target: MachLabel::from_block(1),
target: MachLabel::from_block(BlockIndex::new(1)),
},
},
"C61A00000003",
@@ -1785,7 +1785,7 @@ fn test_s390x_binemit() {
op: CmpOp::CmpL64Ext16,
rn: gpr(1),
mem: MemArg::Label {
target: MachLabel::from_block(1),
target: MachLabel::from_block(BlockIndex::new(1)),
},
},
"C61600000003",
@@ -1810,7 +1810,7 @@ fn test_s390x_binemit() {
op: CmpOp::CmpL64Ext32,
rn: gpr(1),
mem: MemArg::Label {
target: MachLabel::from_block(1),
target: MachLabel::from_block(BlockIndex::new(1)),
},
},
"C61E00000003",
@@ -4536,7 +4536,7 @@ fn test_s390x_binemit() {
Inst::Load32 {
rd: writable_gpr(1),
mem: MemArg::Label {
target: MachLabel::from_block(1),
target: MachLabel::from_block(BlockIndex::new(1)),
},
},
"C41D00000003",
@@ -4546,7 +4546,7 @@ fn test_s390x_binemit() {
Inst::Load32SExt16 {
rd: writable_gpr(1),
mem: MemArg::Label {
target: MachLabel::from_block(1),
target: MachLabel::from_block(BlockIndex::new(1)),
},
},
"C41500000003",
@@ -4556,7 +4556,7 @@ fn test_s390x_binemit() {
Inst::Load32ZExt16 {
rd: writable_gpr(1),
mem: MemArg::Label {
target: MachLabel::from_block(1),
target: MachLabel::from_block(BlockIndex::new(1)),
},
},
"C41200000003",
@@ -4566,7 +4566,7 @@ fn test_s390x_binemit() {
Inst::Load64 {
rd: writable_gpr(1),
mem: MemArg::Label {
target: MachLabel::from_block(1),
target: MachLabel::from_block(BlockIndex::new(1)),
},
},
"C41800000003",
@@ -4576,7 +4576,7 @@ fn test_s390x_binemit() {
Inst::Load64SExt16 {
rd: writable_gpr(1),
mem: MemArg::Label {
target: MachLabel::from_block(1),
target: MachLabel::from_block(BlockIndex::new(1)),
},
},
"C41400000003",
@@ -4586,7 +4586,7 @@ fn test_s390x_binemit() {
Inst::Load64ZExt16 {
rd: writable_gpr(1),
mem: MemArg::Label {
target: MachLabel::from_block(1),
target: MachLabel::from_block(BlockIndex::new(1)),
},
},
"C41600000003",
@@ -4596,7 +4596,7 @@ fn test_s390x_binemit() {
Inst::Load64SExt32 {
rd: writable_gpr(1),
mem: MemArg::Label {
target: MachLabel::from_block(1),
target: MachLabel::from_block(BlockIndex::new(1)),
},
},
"C41C00000003",
@@ -4606,7 +4606,7 @@ fn test_s390x_binemit() {
Inst::Load64ZExt32 {
rd: writable_gpr(1),
mem: MemArg::Label {
target: MachLabel::from_block(1),
target: MachLabel::from_block(BlockIndex::new(1)),
},
},
"C41E00000003",
@@ -5790,7 +5790,7 @@ fn test_s390x_binemit() {
Inst::Store16 {
rd: gpr(1),
mem: MemArg::Label {
target: MachLabel::from_block(1),
target: MachLabel::from_block(BlockIndex::new(1)),
},
},
"C41700000003",
@@ -5800,7 +5800,7 @@ fn test_s390x_binemit() {
Inst::Store32 {
rd: gpr(1),
mem: MemArg::Label {
target: MachLabel::from_block(1),
target: MachLabel::from_block(BlockIndex::new(1)),
},
},
"C41F00000003",
@@ -5810,7 +5810,7 @@ fn test_s390x_binemit() {
Inst::Store64 {
rd: gpr(1),
mem: MemArg::Label {
target: MachLabel::from_block(1),
target: MachLabel::from_block(BlockIndex::new(1)),
},
},
"C41B00000003",
@@ -6035,7 +6035,7 @@ fn test_s390x_binemit() {
Inst::LoadAddr {
rd: writable_gpr(1),
mem: MemArg::Label {
target: MachLabel::from_block(1),
target: MachLabel::from_block(BlockIndex::new(1)),
},
},
"C01000000003",
@@ -6499,7 +6499,7 @@ fn test_s390x_binemit() {
insns.push((
Inst::Jump {
dest: MachLabel::from_block(0),
dest: MachLabel::from_block(BlockIndex::new(0)),
},
"C0F400000000",
"jg label0",
@@ -6507,7 +6507,7 @@ fn test_s390x_binemit() {
insns.push((
Inst::OneWayCondBr {
target: MachLabel::from_block(0),
target: MachLabel::from_block(BlockIndex::new(0)),
cond: Cond::from_mask(1),
},
"C01400000000",
@@ -6515,7 +6515,7 @@ fn test_s390x_binemit() {
));
insns.push((
Inst::OneWayCondBr {
target: MachLabel::from_block(0),
target: MachLabel::from_block(BlockIndex::new(0)),
cond: Cond::from_mask(2),
},
"C02400000000",
@@ -6523,7 +6523,7 @@ fn test_s390x_binemit() {
));
insns.push((
Inst::OneWayCondBr {
target: MachLabel::from_block(0),
target: MachLabel::from_block(BlockIndex::new(0)),
cond: Cond::from_mask(3),
},
"C03400000000",
@@ -6531,7 +6531,7 @@ fn test_s390x_binemit() {
));
insns.push((
Inst::OneWayCondBr {
target: MachLabel::from_block(0),
target: MachLabel::from_block(BlockIndex::new(0)),
cond: Cond::from_mask(4),
},
"C04400000000",
@@ -6539,7 +6539,7 @@ fn test_s390x_binemit() {
));
insns.push((
Inst::OneWayCondBr {
target: MachLabel::from_block(0),
target: MachLabel::from_block(BlockIndex::new(0)),
cond: Cond::from_mask(5),
},
"C05400000000",
@@ -6547,7 +6547,7 @@ fn test_s390x_binemit() {
));
insns.push((
Inst::OneWayCondBr {
target: MachLabel::from_block(0),
target: MachLabel::from_block(BlockIndex::new(0)),
cond: Cond::from_mask(6),
},
"C06400000000",
@@ -6555,7 +6555,7 @@ fn test_s390x_binemit() {
));
insns.push((
Inst::OneWayCondBr {
target: MachLabel::from_block(0),
target: MachLabel::from_block(BlockIndex::new(0)),
cond: Cond::from_mask(7),
},
"C07400000000",
@@ -6563,7 +6563,7 @@ fn test_s390x_binemit() {
));
insns.push((
Inst::OneWayCondBr {
target: MachLabel::from_block(0),
target: MachLabel::from_block(BlockIndex::new(0)),
cond: Cond::from_mask(8),
},
"C08400000000",
@@ -6571,7 +6571,7 @@ fn test_s390x_binemit() {
));
insns.push((
Inst::OneWayCondBr {
target: MachLabel::from_block(0),
target: MachLabel::from_block(BlockIndex::new(0)),
cond: Cond::from_mask(9),
},
"C09400000000",
@@ -6579,7 +6579,7 @@ fn test_s390x_binemit() {
));
insns.push((
Inst::OneWayCondBr {
target: MachLabel::from_block(0),
target: MachLabel::from_block(BlockIndex::new(0)),
cond: Cond::from_mask(10),
},
"C0A400000000",
@@ -6587,7 +6587,7 @@ fn test_s390x_binemit() {
));
insns.push((
Inst::OneWayCondBr {
target: MachLabel::from_block(0),
target: MachLabel::from_block(BlockIndex::new(0)),
cond: Cond::from_mask(11),
},
"C0B400000000",
@@ -6595,7 +6595,7 @@ fn test_s390x_binemit() {
));
insns.push((
Inst::OneWayCondBr {
target: MachLabel::from_block(0),
target: MachLabel::from_block(BlockIndex::new(0)),
cond: Cond::from_mask(12),
},
"C0C400000000",
@@ -6603,7 +6603,7 @@ fn test_s390x_binemit() {
));
insns.push((
Inst::OneWayCondBr {
target: MachLabel::from_block(0),
target: MachLabel::from_block(BlockIndex::new(0)),
cond: Cond::from_mask(13),
},
"C0D400000000",
@@ -6611,7 +6611,7 @@ fn test_s390x_binemit() {
));
insns.push((
Inst::OneWayCondBr {
target: MachLabel::from_block(0),
target: MachLabel::from_block(BlockIndex::new(0)),
cond: Cond::from_mask(14),
},
"C0E400000000",
@@ -6620,8 +6620,8 @@ fn test_s390x_binemit() {
insns.push((
Inst::CondBr {
taken: MachLabel::from_block(0),
not_taken: MachLabel::from_block(0),
taken: MachLabel::from_block(BlockIndex::new(0)),
not_taken: MachLabel::from_block(BlockIndex::new(0)),
cond: Cond::from_mask(1),
},
"C01400000000C0F4FFFFFFFD",
@@ -6629,8 +6629,8 @@ fn test_s390x_binemit() {
));
insns.push((
Inst::CondBr {
taken: MachLabel::from_block(0),
not_taken: MachLabel::from_block(0),
taken: MachLabel::from_block(BlockIndex::new(0)),
not_taken: MachLabel::from_block(BlockIndex::new(0)),
cond: Cond::from_mask(2),
},
"C02400000000C0F4FFFFFFFD",
@@ -6638,8 +6638,8 @@ fn test_s390x_binemit() {
));
insns.push((
Inst::CondBr {
taken: MachLabel::from_block(0),
not_taken: MachLabel::from_block(0),
taken: MachLabel::from_block(BlockIndex::new(0)),
not_taken: MachLabel::from_block(BlockIndex::new(0)),
cond: Cond::from_mask(3),
},
"C03400000000C0F4FFFFFFFD",
@@ -6647,8 +6647,8 @@ fn test_s390x_binemit() {
));
insns.push((
Inst::CondBr {
taken: MachLabel::from_block(0),
not_taken: MachLabel::from_block(0),
taken: MachLabel::from_block(BlockIndex::new(0)),
not_taken: MachLabel::from_block(BlockIndex::new(0)),
cond: Cond::from_mask(4),
},
"C04400000000C0F4FFFFFFFD",
@@ -6656,8 +6656,8 @@ fn test_s390x_binemit() {
));
insns.push((
Inst::CondBr {
taken: MachLabel::from_block(0),
not_taken: MachLabel::from_block(0),
taken: MachLabel::from_block(BlockIndex::new(0)),
not_taken: MachLabel::from_block(BlockIndex::new(0)),
cond: Cond::from_mask(5),
},
"C05400000000C0F4FFFFFFFD",
@@ -6665,8 +6665,8 @@ fn test_s390x_binemit() {
));
insns.push((
Inst::CondBr {
taken: MachLabel::from_block(0),
not_taken: MachLabel::from_block(0),
taken: MachLabel::from_block(BlockIndex::new(0)),
not_taken: MachLabel::from_block(BlockIndex::new(0)),
cond: Cond::from_mask(6),
},
"C06400000000C0F4FFFFFFFD",
@@ -6674,8 +6674,8 @@ fn test_s390x_binemit() {
));
insns.push((
Inst::CondBr {
taken: MachLabel::from_block(0),
not_taken: MachLabel::from_block(0),
taken: MachLabel::from_block(BlockIndex::new(0)),
not_taken: MachLabel::from_block(BlockIndex::new(0)),
cond: Cond::from_mask(7),
},
"C07400000000C0F4FFFFFFFD",
@@ -6683,8 +6683,8 @@ fn test_s390x_binemit() {
));
insns.push((
Inst::CondBr {
taken: MachLabel::from_block(0),
not_taken: MachLabel::from_block(0),
taken: MachLabel::from_block(BlockIndex::new(0)),
not_taken: MachLabel::from_block(BlockIndex::new(0)),
cond: Cond::from_mask(8),
},
"C08400000000C0F4FFFFFFFD",
@@ -6692,8 +6692,8 @@ fn test_s390x_binemit() {
));
insns.push((
Inst::CondBr {
taken: MachLabel::from_block(0),
not_taken: MachLabel::from_block(0),
taken: MachLabel::from_block(BlockIndex::new(0)),
not_taken: MachLabel::from_block(BlockIndex::new(0)),
cond: Cond::from_mask(9),
},
"C09400000000C0F4FFFFFFFD",
@@ -6701,8 +6701,8 @@ fn test_s390x_binemit() {
));
insns.push((
Inst::CondBr {
taken: MachLabel::from_block(0),
not_taken: MachLabel::from_block(0),
taken: MachLabel::from_block(BlockIndex::new(0)),
not_taken: MachLabel::from_block(BlockIndex::new(0)),
cond: Cond::from_mask(10),
},
"C0A400000000C0F4FFFFFFFD",
@@ -6710,8 +6710,8 @@ fn test_s390x_binemit() {
));
insns.push((
Inst::CondBr {
taken: MachLabel::from_block(0),
not_taken: MachLabel::from_block(0),
taken: MachLabel::from_block(BlockIndex::new(0)),
not_taken: MachLabel::from_block(BlockIndex::new(0)),
cond: Cond::from_mask(11),
},
"C0B400000000C0F4FFFFFFFD",
@@ -6719,8 +6719,8 @@ fn test_s390x_binemit() {
));
insns.push((
Inst::CondBr {
taken: MachLabel::from_block(0),
not_taken: MachLabel::from_block(0),
taken: MachLabel::from_block(BlockIndex::new(0)),
not_taken: MachLabel::from_block(BlockIndex::new(0)),
cond: Cond::from_mask(12),
},
"C0C400000000C0F4FFFFFFFD",
@@ -6728,8 +6728,8 @@ fn test_s390x_binemit() {
));
insns.push((
Inst::CondBr {
taken: MachLabel::from_block(0),
not_taken: MachLabel::from_block(0),
taken: MachLabel::from_block(BlockIndex::new(0)),
not_taken: MachLabel::from_block(BlockIndex::new(0)),
cond: Cond::from_mask(13),
},
"C0D400000000C0F4FFFFFFFD",
@@ -6737,8 +6737,8 @@ fn test_s390x_binemit() {
));
insns.push((
Inst::CondBr {
taken: MachLabel::from_block(0),
not_taken: MachLabel::from_block(0),
taken: MachLabel::from_block(BlockIndex::new(0)),
not_taken: MachLabel::from_block(BlockIndex::new(0)),
cond: Cond::from_mask(14),
},
"C0E400000000C0F4FFFFFFFD",
@@ -6782,7 +6782,14 @@ fn test_s390x_binemit() {
"basr %r14, %r1",
));
insns.push((Inst::Ret { link: gpr(14) }, "07FE", "br %r14"));
insns.push((
Inst::Ret {
link: gpr(14),
rets: vec![],
},
"07FE",
"br %r14",
));
insns.push((Inst::Debugtrap, "0001", "debugtrap"));
@@ -8246,7 +8253,6 @@ fn test_s390x_binemit() {
isa_flag_builder.enable("arch13").unwrap();
let isa_flags = s390x_settings::Flags::new(&flags, isa_flag_builder);
let rru = create_reg_universe(&flags);
let emit_info = EmitInfo::new(flags, isa_flags);
for (insn, expected_encoding, expected_printing) in insns {
println!(
@@ -8255,7 +8261,8 @@ fn test_s390x_binemit() {
);
// Check the printed text is as expected.
let actual_printing = insn.show_rru(Some(&rru));
let actual_printing =
insn.print_with_state(&mut EmitState::default(), &mut AllocationConsumer::new(&[]));
assert_eq!(expected_printing, actual_printing);
let mut buffer = MachBuffer::new();
@@ -8265,7 +8272,7 @@ fn test_s390x_binemit() {
buffer.bind_label(label0);
// Emit the instruction.
insn.emit(&mut buffer, &emit_info, &mut Default::default());
insn.emit(&[], &mut buffer, &emit_info, &mut Default::default());
// Label 1 after the instruction.
let label1 = buffer.get_label();