From 99be82c866e73a59b74ea66f4bdb959becaa890d Mon Sep 17 00:00:00 2001 From: Kasey Carrothers Date: Fri, 29 Jan 2021 01:09:32 -0800 Subject: [PATCH] Replace MachInst::gen_zero_len_nop with gen_nop(0) --- cranelift/codegen/src/isa/aarch64/inst/mod.rs | 7 +++---- cranelift/codegen/src/isa/arm32/inst/mod.rs | 7 +++---- cranelift/codegen/src/isa/x64/inst/mod.rs | 4 ---- cranelift/codegen/src/machinst/mod.rs | 3 --- cranelift/codegen/src/machinst/vcode.rs | 2 +- 5 files changed, 7 insertions(+), 16 deletions(-) diff --git a/cranelift/codegen/src/isa/aarch64/inst/mod.rs b/cranelift/codegen/src/isa/aarch64/inst/mod.rs index b85928edcc..aff9b36e0a 100644 --- a/cranelift/codegen/src/isa/aarch64/inst/mod.rs +++ b/cranelift/codegen/src/isa/aarch64/inst/mod.rs @@ -2907,11 +2907,10 @@ impl MachInst for Inst { } } - fn gen_zero_len_nop() -> Inst { - Inst::Nop0 - } - fn gen_nop(preferred_size: usize) -> Inst { + if preferred_size == 0 { + return Inst::Nop0; + } // We can't give a NOP (or any insn) < 4 bytes. assert!(preferred_size >= 4); Inst::Nop4 diff --git a/cranelift/codegen/src/isa/arm32/inst/mod.rs b/cranelift/codegen/src/isa/arm32/inst/mod.rs index 309aa43102..811e8cf920 100644 --- a/cranelift/codegen/src/isa/arm32/inst/mod.rs +++ b/cranelift/codegen/src/isa/arm32/inst/mod.rs @@ -831,11 +831,10 @@ impl MachInst for Inst { } } - fn gen_zero_len_nop() -> Inst { - Inst::Nop0 - } - fn gen_nop(preferred_size: usize) -> Inst { + if preferred_size == 0 { + return Inst::Nop0; + } assert!(preferred_size >= 2); Inst::Nop2 } diff --git a/cranelift/codegen/src/isa/x64/inst/mod.rs b/cranelift/codegen/src/isa/x64/inst/mod.rs index 76bde8e139..e6a6ec9486 100644 --- a/cranelift/codegen/src/isa/x64/inst/mod.rs +++ b/cranelift/codegen/src/isa/x64/inst/mod.rs @@ -2601,10 +2601,6 @@ impl MachInst for Inst { } } - fn gen_zero_len_nop() -> Inst { - Inst::nop(0) - } - fn gen_nop(preferred_size: usize) -> Inst { Inst::nop(std::cmp::min(preferred_size, 15) as u8) } diff --git a/cranelift/codegen/src/machinst/mod.rs b/cranelift/codegen/src/machinst/mod.rs index d65fd9b3ca..c7e86437fa 100644 --- a/cranelift/codegen/src/machinst/mod.rs +++ b/cranelift/codegen/src/machinst/mod.rs @@ -148,9 +148,6 @@ pub trait MachInst: Clone + Debug { alloc_tmp: F, ) -> SmallVec<[Self; 4]>; - /// Generate a zero-length no-op. - fn gen_zero_len_nop() -> Self; - /// Possibly operate on a value directly in a spill-slot rather than a /// register. Useful if the machine has register-memory instruction forms /// (e.g., add directly from or directly to memory), like x86. diff --git a/cranelift/codegen/src/machinst/vcode.rs b/cranelift/codegen/src/machinst/vcode.rs index 9fc46d9655..ab1cca0f47 100644 --- a/cranelift/codegen/src/machinst/vcode.rs +++ b/cranelift/codegen/src/machinst/vcode.rs @@ -726,7 +726,7 @@ impl RegallocFunction for VCode { } fn gen_zero_len_nop(&self) -> I { - I::gen_zero_len_nop() + I::gen_nop(0) } fn maybe_direct_reload(&self, insn: &I, reg: VirtualReg, slot: SpillSlot) -> Option {