Remove more old backend ISA concepts (#3402)

This also paves the way for unifying TargetIsa and MachBackend, since now they map one to one. In theory the two traits could be merged, which would be nice to limit the number of total concepts. Also they have quite different responsibilities, so it might be fine to keep them separate.

Interestingly, this PR started as removing RegInfo from the TargetIsa trait since the adapter returned a dummy value there. From the fallout, noticed that all Display implementations didn't needed an ISA anymore (since these were only used to render ISA specific registers). Also the whole family of RegInfo / ValueLoc / RegUnit was exclusively used for the old backend, and these could be removed. Notably, some IR instructions needed to be removed, because they were using RegUnit too: this was the oddball of regfill / regmove / regspill / copy_special, which were IR instructions inserted by the old regalloc. Fare thee well!
This commit is contained in:
Benjamin Bouvier
2021-10-04 10:36:12 +02:00
committed by GitHub
parent 76afcab0c2
commit 43a86f14d5
71 changed files with 302 additions and 2059 deletions

View File

@@ -4,14 +4,13 @@ use crate::variable::Variable;
use cranelift_codegen::cursor::{Cursor, FuncCursor};
use cranelift_codegen::entity::{EntitySet, SecondaryMap};
use cranelift_codegen::ir;
use cranelift_codegen::ir::function::DisplayFunction;
use cranelift_codegen::ir::{
types, AbiParam, Block, DataFlowGraph, ExtFuncData, ExternalName, FuncRef, Function,
GlobalValue, GlobalValueData, Heap, HeapData, Inst, InstBuilder, InstBuilderBase,
InstructionData, JumpTable, JumpTableData, LibCall, MemFlags, SigRef, Signature, StackSlot,
StackSlotData, Type, Value, ValueLabel, ValueLabelAssignments, ValueLabelStart,
};
use cranelift_codegen::isa::{TargetFrontendConfig, TargetIsa};
use cranelift_codegen::isa::TargetFrontendConfig;
use cranelift_codegen::packed_option::PackedOption;
/// Structure used for translating a series of functions into Cranelift IR.
@@ -481,7 +480,7 @@ impl<'a> FunctionBuilder<'a> {
// Iterate manually to provide more helpful error messages.
for block in self.func_ctx.blocks.keys() {
if let Err((inst, _msg)) = self.func.is_block_basic(block) {
let inst_str = self.func.dfg.display_inst(inst, None);
let inst_str = self.func.dfg.display_inst(inst);
panic!("{} failed basic block invariants on {}", block, inst_str);
}
}
@@ -579,15 +578,6 @@ impl<'a> FunctionBuilder<'a> {
pub fn is_filled(&self) -> bool {
self.func_ctx.blocks[self.position.unwrap()].filled
}
/// Returns a displayable object for the function as it is.
///
/// Useful for debug purposes. Use it with `None` for standard printing.
// Clippy thinks the lifetime that follows is needless, but rustc needs it
#[cfg_attr(feature = "cargo-clippy", allow(clippy::needless_lifetimes))]
pub fn display<'b, I: Into<Option<&'b dyn TargetIsa>>>(&'b self, isa: I) -> DisplayFunction {
self.func.display(isa)
}
}
/// Helper functions
@@ -955,7 +945,7 @@ mod tests {
let flags = settings::Flags::new(settings::builder());
// println!("{}", func.display(None));
if let Err(errors) = verify_function(&func, &flags) {
panic!("{}\n{}", func.display(None), errors)
panic!("{}\n{}", func.display(), errors)
}
}
@@ -1009,7 +999,7 @@ mod tests {
}
assert_eq!(
func.display(None).to_string(),
func.display().to_string(),
"function %sample() -> i32 system_v {
sig0 = (i64, i64, i64) system_v
fn0 = %Memcpy sig0
@@ -1065,7 +1055,7 @@ block0:
}
assert_eq!(
func.display(None).to_string(),
func.display().to_string(),
"function %sample() -> i32 system_v {
block0:
v4 = iconst.i64 0
@@ -1119,7 +1109,7 @@ block0:
}
assert_eq!(
func.display(None).to_string(),
func.display().to_string(),
"function %sample() -> i32 system_v {
sig0 = (i64, i64, i64) system_v
fn0 = %Memcpy sig0
@@ -1164,7 +1154,7 @@ block0:
}
assert_eq!(
func.display(None).to_string(),
func.display().to_string(),
"function %sample() -> i32 system_v {
block0:
v2 = iconst.i64 0
@@ -1204,7 +1194,7 @@ block0:
}
assert_eq!(
func.display(None).to_string(),
func.display().to_string(),
"function %sample() -> i32 system_v {
sig0 = (i64, i32, i64) system_v
fn0 = %Memset sig0
@@ -1253,7 +1243,7 @@ block0:
}
assert_eq!(
func.display(None).to_string(),
func.display().to_string(),
"function %sample() -> i8x16, b8x16, f32x4 system_v {
const0 = 0x00000000000000000000000000000000

View File

@@ -156,7 +156,7 @@
//!
//! let flags = settings::Flags::new(settings::builder());
//! let res = verify_function(&func, &flags);
//! println!("{}", func.display(None));
//! println!("{}", func.display());
//! if let Err(errors) = res {
//! panic!("{}", errors);
//! }