Skip to content

Commit cd6b73f

Browse files
authored
Merge pull request #3723 from uweigand/isle-safepoint
ISLE: Allow emitting safepoint insns
2 parents ce63a11 + 906f6a3 commit cd6b73f

4 files changed

Lines changed: 19 additions & 12 deletions

File tree

cranelift/codegen/src/isa/aarch64/lower/isle.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,14 +152,17 @@ where
152152
let imm =
153153
MoveWideConst::maybe_with_shift(((!imm16) & 0xffff) as u16, i * 16)
154154
.unwrap();
155-
self.emitted_insts.push(MInst::MovN { rd, imm, size });
155+
self.emitted_insts
156+
.push((MInst::MovN { rd, imm, size }, false));
156157
} else {
157158
let imm = MoveWideConst::maybe_with_shift(imm16 as u16, i * 16).unwrap();
158-
self.emitted_insts.push(MInst::MovZ { rd, imm, size });
159+
self.emitted_insts
160+
.push((MInst::MovZ { rd, imm, size }, false));
159161
}
160162
} else {
161163
let imm = MoveWideConst::maybe_with_shift(imm16 as u16, i * 16).unwrap();
162-
self.emitted_insts.push(MInst::MovK { rd, imm, size });
164+
self.emitted_insts
165+
.push((MInst::MovK { rd, imm, size }, false));
163166
}
164167
}
165168
}
@@ -200,7 +203,7 @@ where
200203
}
201204

202205
fn emit(&mut self, inst: &MInst) -> Unit {
203-
self.emitted_insts.push(inst.clone());
206+
self.emitted_insts.push((inst.clone(), false));
204207
}
205208

206209
fn cond_br_zero(&mut self, reg: Reg) -> CondBrKind {

cranelift/codegen/src/isa/s390x/lower/isle.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,6 @@ where
469469

470470
#[inline]
471471
fn emit(&mut self, inst: &MInst) -> Unit {
472-
self.emitted_insts.push(inst.clone());
472+
self.emitted_insts.push((inst.clone(), false));
473473
}
474474
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ where
227227

228228
fn emit(&mut self, inst: &MInst) -> Unit {
229229
for inst in inst.clone().mov_mitosis() {
230-
self.emitted_insts.push(inst);
230+
self.emitted_insts.push((inst, false));
231231
}
232232
}
233233

cranelift/codegen/src/machinst/isle.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -299,12 +299,12 @@ macro_rules! isle_prelude_methods {
299299
/// internally has a temporary reference to a machinst `LowerCtx`.
300300
pub(crate) struct IsleContext<'a, C: LowerCtx, F, I, const N: usize>
301301
where
302-
[C::I; N]: smallvec::Array,
302+
[(C::I, bool); N]: smallvec::Array,
303303
{
304304
pub lower_ctx: &'a mut C,
305305
pub flags: &'a F,
306306
pub isa_flags: &'a I,
307-
pub emitted_insts: SmallVec<[C::I; N]>,
307+
pub emitted_insts: SmallVec<[(C::I, bool); N]>,
308308
}
309309

310310
/// Shared lowering code amongst all backends for doing ISLE-based lowering.
@@ -323,7 +323,7 @@ pub(crate) fn lower_common<C, F, I, const N: usize>(
323323
) -> Result<(), ()>
324324
where
325325
C: LowerCtx,
326-
[C::I; N]: smallvec::Array<Item = C::I>,
326+
[(C::I, bool); N]: smallvec::Array<Item = (C::I, bool)>,
327327
{
328328
// TODO: reuse the ISLE context across lowerings so we can reuse its
329329
// internal heap allocations.
@@ -367,7 +367,7 @@ where
367367
renamer.add_rename(*temp, dst.to_reg(), *ty);
368368
}
369369
}
370-
for inst in isle_ctx.emitted_insts.iter_mut() {
370+
for (inst, _) in isle_ctx.emitted_insts.iter_mut() {
371371
map_regs(inst, &renamer);
372372
}
373373

@@ -387,8 +387,12 @@ where
387387
// Once everything is remapped we forward all emitted instructions to the
388388
// `lower_ctx`. Note that this happens after the synthetic mov's above in
389389
// case any of these instruction use those movs.
390-
for inst in isle_ctx.emitted_insts {
391-
lower_ctx.emit(inst);
390+
for (inst, is_safepoint) in isle_ctx.emitted_insts {
391+
if is_safepoint {
392+
lower_ctx.emit_safepoint(inst);
393+
} else {
394+
lower_ctx.emit(inst);
395+
}
392396
}
393397

394398
Ok(())

0 commit comments

Comments
 (0)