From f80fe949c63c6361468325a93c2d8b56e5cd11a9 Mon Sep 17 00:00:00 2001 From: Chris Fallin Date: Thu, 9 Apr 2020 12:01:11 -0700 Subject: [PATCH] ARM64 backend, part 2 / 11: remove old ARM64 backend. This removes the old ARM64 backend completely, leaving only an empty `arm64` module. The tree at this state will not build with the `arm64` feature enabled, but that feature has to be enabled explicitly (it is not default). Subsequent patches will fill in the new backend. --- cranelift/codegen/src/isa/arm64/abi.rs | 31 ---- cranelift/codegen/src/isa/arm64/binemit.rs | 8 -- cranelift/codegen/src/isa/arm64/enc_tables.rs | 10 -- cranelift/codegen/src/isa/arm64/mod.rs | 133 +----------------- cranelift/codegen/src/isa/arm64/registers.rs | 39 ----- cranelift/codegen/src/isa/arm64/settings.rs | 9 -- cranelift/codegen/src/isa/mod.rs | 1 - 7 files changed, 1 insertion(+), 230 deletions(-) delete mode 100644 cranelift/codegen/src/isa/arm64/abi.rs delete mode 100644 cranelift/codegen/src/isa/arm64/binemit.rs delete mode 100644 cranelift/codegen/src/isa/arm64/enc_tables.rs delete mode 100644 cranelift/codegen/src/isa/arm64/registers.rs delete mode 100644 cranelift/codegen/src/isa/arm64/settings.rs diff --git a/cranelift/codegen/src/isa/arm64/abi.rs b/cranelift/codegen/src/isa/arm64/abi.rs deleted file mode 100644 index 8d486d4193..0000000000 --- a/cranelift/codegen/src/isa/arm64/abi.rs +++ /dev/null @@ -1,31 +0,0 @@ -//! ARM 64 ABI implementation. - -use super::registers::{FPR, GPR}; -use crate::ir; -use crate::isa::RegClass; -use crate::regalloc::RegisterSet; -use crate::settings as shared_settings; -use alloc::borrow::Cow; - -/// Legalize `sig`. -pub fn legalize_signature( - _sig: &mut Cow, - _flags: &shared_settings::Flags, - _current: bool, -) { - unimplemented!() -} - -/// Get register class for a type appearing in a legalized signature. -pub fn regclass_for_abi_type(ty: ir::Type) -> RegClass { - if ty.is_int() { - GPR - } else { - FPR - } -} - -/// Get the set of allocatable registers for `func`. -pub fn allocatable_registers(_func: &ir::Function) -> RegisterSet { - unimplemented!() -} diff --git a/cranelift/codegen/src/isa/arm64/binemit.rs b/cranelift/codegen/src/isa/arm64/binemit.rs deleted file mode 100644 index 4401b6d6f5..0000000000 --- a/cranelift/codegen/src/isa/arm64/binemit.rs +++ /dev/null @@ -1,8 +0,0 @@ -//! Emitting binary ARM64 machine code. - -use crate::binemit::{bad_encoding, CodeSink}; -use crate::ir::{Function, Inst}; -use crate::isa::TargetIsa; -use crate::regalloc::RegDiversions; - -include!(concat!(env!("OUT_DIR"), "/binemit-arm64.rs")); diff --git a/cranelift/codegen/src/isa/arm64/enc_tables.rs b/cranelift/codegen/src/isa/arm64/enc_tables.rs deleted file mode 100644 index 6040a9b866..0000000000 --- a/cranelift/codegen/src/isa/arm64/enc_tables.rs +++ /dev/null @@ -1,10 +0,0 @@ -//! Encoding tables for ARM64 ISA. - -use crate::ir; -use crate::isa; -use crate::isa::constraints::*; -use crate::isa::enc_tables::*; -use crate::isa::encoding::RecipeSizing; - -include!(concat!(env!("OUT_DIR"), "/encoding-arm64.rs")); -include!(concat!(env!("OUT_DIR"), "/legalize-arm64.rs")); diff --git a/cranelift/codegen/src/isa/arm64/mod.rs b/cranelift/codegen/src/isa/arm64/mod.rs index f00062b2af..2bd6dce476 100644 --- a/cranelift/codegen/src/isa/arm64/mod.rs +++ b/cranelift/codegen/src/isa/arm64/mod.rs @@ -1,132 +1 @@ -//! ARM 64-bit Instruction Set Architecture. - -mod abi; -mod binemit; -mod enc_tables; -mod registers; -pub mod settings; - -use super::super::settings as shared_settings; -#[cfg(feature = "testing_hooks")] -use crate::binemit::CodeSink; -use crate::binemit::{emit_function, MemoryCodeSink}; -use crate::ir; -use crate::isa::enc_tables::{lookup_enclist, Encodings}; -use crate::isa::Builder as IsaBuilder; -use crate::isa::{EncInfo, RegClass, RegInfo, TargetIsa}; -use crate::regalloc; -use alloc::borrow::Cow; -use alloc::boxed::Box; -use core::fmt; -use target_lexicon::Triple; - -#[allow(dead_code)] -struct Isa { - triple: Triple, - shared_flags: shared_settings::Flags, - isa_flags: settings::Flags, -} - -/// Get an ISA builder for creating ARM64 targets. -pub fn isa_builder(triple: Triple) -> IsaBuilder { - IsaBuilder { - triple, - setup: settings::builder(), - constructor: isa_constructor, - } -} - -fn isa_constructor( - triple: Triple, - shared_flags: shared_settings::Flags, - builder: shared_settings::Builder, -) -> Box { - Box::new(Isa { - triple, - isa_flags: settings::Flags::new(&shared_flags, builder), - shared_flags, - }) -} - -impl TargetIsa for Isa { - fn name(&self) -> &'static str { - "arm64" - } - - fn triple(&self) -> &Triple { - &self.triple - } - - fn flags(&self) -> &shared_settings::Flags { - &self.shared_flags - } - - fn register_info(&self) -> RegInfo { - registers::INFO.clone() - } - - fn encoding_info(&self) -> EncInfo { - enc_tables::INFO.clone() - } - - fn legal_encodings<'a>( - &'a self, - func: &'a ir::Function, - inst: &'a ir::InstructionData, - ctrl_typevar: ir::Type, - ) -> Encodings<'a> { - lookup_enclist( - ctrl_typevar, - inst, - func, - &enc_tables::LEVEL1_A64[..], - &enc_tables::LEVEL2[..], - &enc_tables::ENCLISTS[..], - &enc_tables::LEGALIZE_ACTIONS[..], - &enc_tables::RECIPE_PREDICATES[..], - &enc_tables::INST_PREDICATES[..], - self.isa_flags.predicate_view(), - ) - } - - fn legalize_signature(&self, sig: &mut Cow, current: bool) { - abi::legalize_signature(sig, &self.shared_flags, current) - } - - fn regclass_for_abi_type(&self, ty: ir::Type) -> RegClass { - abi::regclass_for_abi_type(ty) - } - - fn allocatable_registers(&self, func: &ir::Function) -> regalloc::RegisterSet { - abi::allocatable_registers(func) - } - - #[cfg(feature = "testing_hooks")] - fn emit_inst( - &self, - func: &ir::Function, - inst: ir::Inst, - divert: &mut regalloc::RegDiversions, - sink: &mut dyn CodeSink, - ) { - binemit::emit_inst(func, inst, divert, sink, self) - } - - fn emit_function_to_memory(&self, func: &ir::Function, sink: &mut MemoryCodeSink) { - emit_function(func, binemit::emit_inst, sink, self) - } - - fn unsigned_add_overflow_condition(&self) -> ir::condcodes::IntCC { - ir::condcodes::IntCC::UnsignedLessThan - } - - fn unsigned_sub_overflow_condition(&self) -> ir::condcodes::IntCC { - ir::condcodes::IntCC::UnsignedGreaterThanOrEqual - } -} - -impl fmt::Display for Isa { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "{}\n{}", self.shared_flags, self.isa_flags) - } -} +// Empty. diff --git a/cranelift/codegen/src/isa/arm64/registers.rs b/cranelift/codegen/src/isa/arm64/registers.rs deleted file mode 100644 index c02f6b7d4d..0000000000 --- a/cranelift/codegen/src/isa/arm64/registers.rs +++ /dev/null @@ -1,39 +0,0 @@ -//! ARM64 register descriptions. - -use crate::isa::registers::{RegBank, RegClass, RegClassData, RegInfo, RegUnit}; - -include!(concat!(env!("OUT_DIR"), "/registers-arm64.rs")); - -#[cfg(test)] -mod tests { - use super::INFO; - use crate::isa::RegUnit; - use alloc::string::{String, ToString}; - - #[test] - fn unit_encodings() { - assert_eq!(INFO.parse_regunit("x0"), Some(0)); - assert_eq!(INFO.parse_regunit("x31"), Some(31)); - assert_eq!(INFO.parse_regunit("v0"), Some(32)); - assert_eq!(INFO.parse_regunit("v31"), Some(63)); - - assert_eq!(INFO.parse_regunit("x32"), None); - assert_eq!(INFO.parse_regunit("v32"), None); - } - - #[test] - fn unit_names() { - fn uname(ru: RegUnit) -> String { - INFO.display_regunit(ru).to_string() - } - - assert_eq!(uname(0), "%x0"); - assert_eq!(uname(1), "%x1"); - assert_eq!(uname(31), "%x31"); - assert_eq!(uname(32), "%v0"); - assert_eq!(uname(33), "%v1"); - assert_eq!(uname(63), "%v31"); - assert_eq!(uname(64), "%nzcv"); - assert_eq!(uname(65), "%INVALID65"); - } -} diff --git a/cranelift/codegen/src/isa/arm64/settings.rs b/cranelift/codegen/src/isa/arm64/settings.rs deleted file mode 100644 index 56d0f4ee0b..0000000000 --- a/cranelift/codegen/src/isa/arm64/settings.rs +++ /dev/null @@ -1,9 +0,0 @@ -//! ARM64 Settings. - -use crate::settings::{self, detail, Builder}; -use core::fmt; - -// Include code generated by `cranelift-codegen/meta/src/gen_settings.rs`. This file contains a -// public `Flags` struct with an impl for all of the settings defined in -// `cranelift-codegen/meta/src/isa/arm64/mod.rs`. -include!(concat!(env!("OUT_DIR"), "/settings-arm64.rs")); diff --git a/cranelift/codegen/src/isa/mod.rs b/cranelift/codegen/src/isa/mod.rs index 9c91d42193..bad6fd7e79 100644 --- a/cranelift/codegen/src/isa/mod.rs +++ b/cranelift/codegen/src/isa/mod.rs @@ -116,7 +116,6 @@ pub fn lookup(triple: Triple) -> Result { isa_builder!(x86, "x86", triple) } Architecture::Arm { .. } => isa_builder!(arm32, "arm32", triple), - Architecture::Aarch64 { .. } => isa_builder!(arm64, "arm64", triple), _ => Err(LookupError::Unsupported), } }