Browse Source

only lower on linux

pull/9078/head
Frank Emrich 3 months ago
parent
commit
2af10f9441
  1. 3
      cranelift/codegen/src/isa/x64/lower.isle
  2. 8
      cranelift/codegen/src/machinst/abi.rs
  3. 8
      cranelift/codegen/src/machinst/isle.rs
  4. 3
      cranelift/codegen/src/prelude_lower.isle
  5. 2
      cranelift/filetests/filetests/isa/x64/stack_switch.clif

3
cranelift/codegen/src/isa/x64/lower.isle

@ -3359,6 +3359,9 @@
;; Rules for `stack_switch` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(rule (lower (stack_switch store_context_ptr load_context_ptr in_payload0))
;; For the time being, stack switching is only supported on x64 Linux
(if (on_linux))
(let ((store_context_ptr Gpr (put_in_gpr store_context_ptr))
(load_context_ptr Gpr (put_in_gpr load_context_ptr))
(in_payload0 Gpr (put_in_gpr in_payload0)))

8
cranelift/codegen/src/machinst/abi.rs

@ -112,6 +112,7 @@ use smallvec::smallvec;
use std::collections::HashMap;
use std::marker::PhantomData;
use std::mem;
use target_lexicon::Triple;
/// A small vector of instructions (with some reasonable size); appropriate for
/// a small fixed sequence implementing one operation.
@ -1035,6 +1036,8 @@ pub struct Callee<M: ABIMachineSpec> {
/// manually register-allocated and carefully only use caller-saved
/// registers and keep nothing live after this sequence of instructions.
stack_limit: Option<(Reg, SmallInstVec<M::I>)>,
// Target triple
triple: Triple,
_mach: PhantomData<M>,
}
@ -1160,6 +1163,7 @@ impl<M: ABIMachineSpec> Callee<M> {
isa_flags: isa_flags.clone(),
is_leaf: f.is_leaf(),
stack_limit,
triple: isa.triple().clone(),
_mach: PhantomData,
})
}
@ -1384,6 +1388,10 @@ impl<M: ABIMachineSpec> Callee<M> {
&self.dynamic_stackslots
}
pub fn triple(&self) -> &Triple {
&self.triple
}
/// Generate an instruction which copies an argument to a destination
/// register.
pub fn gen_copy_arg_to_regs(

8
cranelift/codegen/src/machinst/isle.rs

@ -340,6 +340,14 @@ macro_rules! isle_lower_prelude_methods {
}
}
#[inline]
fn on_linux(&mut self) -> Option<()> {
match self.lower_ctx.abi().triple().operating_system {
target_lexicon::OperatingSystem::Linux => Some(()),
_ => None,
}
}
#[inline]
fn func_ref_data(&mut self, func_ref: FuncRef) -> (SigRef, ExternalName, RelocDistance) {
let funcdata = &self.lower_ctx.dfg().ext_funcs[func_ref];

3
cranelift/codegen/src/prelude_lower.isle

@ -870,6 +870,9 @@
(decl pure partial preserve_frame_pointers () Unit)
(extern constructor preserve_frame_pointers preserve_frame_pointers)
(decl pure partial on_linux () Unit)
(extern constructor on_linux on_linux)
;;;; Helpers for accessing instruction data ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(decl box_external_name (ExternalName) BoxExternalName)

2
cranelift/filetests/filetests/isa/x64/stack_switch.clif

@ -1,6 +1,6 @@
test compile precise-output
set opt_level=speed
target x86_64
target x86_64-unknown-linux-gnu
;; Test clobbering of all 14 GPRs used by Cranelift

Loading…
Cancel
Save