s390x: Migrate branches and traps to ISLE
In order to migrate branches to ISLE, we define a second entry point `lower_branch` which gets the list of branch targets as additional argument. This requires a small change to `lower_common`: the `isle_lower` callback argument is changed from a function pointer to a closure. This allows passing the extra argument via a closure. Traps make use of the recently added facility to emit safepoints from ISLE, but are otherwise straightforward.
This commit is contained in:
@@ -51,6 +51,28 @@ where
|
||||
)
|
||||
}
|
||||
|
||||
/// The main entry point for branch lowering with ISLE.
|
||||
pub(crate) fn lower_branch<C>(
|
||||
lower_ctx: &mut C,
|
||||
flags: &Flags,
|
||||
isa_flags: &IsaFlags,
|
||||
branch: Inst,
|
||||
targets: &[MachLabel],
|
||||
) -> Result<(), ()>
|
||||
where
|
||||
C: LowerCtx<I = MInst>,
|
||||
{
|
||||
lower_common(
|
||||
lower_ctx,
|
||||
flags,
|
||||
isa_flags,
|
||||
&[],
|
||||
branch,
|
||||
|cx, insn| generated_code::constructor_lower_branch(cx, insn, &targets.to_vec()),
|
||||
s390x_map_regs,
|
||||
)
|
||||
}
|
||||
|
||||
impl<C> generated_code::Context for IsleContext<'_, C, Flags, IsaFlags, 6>
|
||||
where
|
||||
C: LowerCtx<I = MInst>,
|
||||
@@ -369,6 +391,16 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn vec_length_minus1(&mut self, vec: &VecMachLabel) -> u32 {
|
||||
u32::try_from(vec.len()).unwrap() - 1
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn vec_element(&mut self, vec: &VecMachLabel, index: u8) -> MachLabel {
|
||||
vec[usize::from(index)]
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn reloc_distance_near(&mut self, dist: &RelocDistance) -> Option<()> {
|
||||
if *dist == RelocDistance::Near {
|
||||
@@ -471,4 +503,9 @@ where
|
||||
fn emit(&mut self, inst: &MInst) -> Unit {
|
||||
self.emitted_insts.push((inst.clone(), false));
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn emit_safepoint(&mut self, inst: &MInst) -> Unit {
|
||||
self.emitted_insts.push((inst.clone(), true));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
src/clif.isle 9ea75a6f790b5c03
|
||||
src/prelude.isle 51d2aef2566c1c96
|
||||
src/isa/s390x/inst.isle 17b77476355c4509
|
||||
src/isa/s390x/lower.isle a0e21a567040bc33
|
||||
src/isa/s390x/inst.isle d7bfd05fb4d4a66d
|
||||
src/isa/s390x/lower.isle 57dcc39cbab2d1c6
|
||||
|
||||
1921
cranelift/codegen/src/isa/s390x/lower/isle/generated_code.rs
generated
1921
cranelift/codegen/src/isa/s390x/lower/isle/generated_code.rs
generated
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user