-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ISLE: Allow emitting safepoint insns #3723
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -299,12 +299,12 @@ macro_rules! isle_prelude_methods { | |
/// internally has a temporary reference to a machinst `LowerCtx`. | ||
pub(crate) struct IsleContext<'a, C: LowerCtx, F, I, const N: usize> | ||
where | ||
[C::I; N]: smallvec::Array, | ||
[(C::I, bool); N]: smallvec::Array, | ||
{ | ||
pub lower_ctx: &'a mut C, | ||
pub flags: &'a F, | ||
pub isa_flags: &'a I, | ||
pub emitted_insts: SmallVec<[C::I; N]>, | ||
pub emitted_insts: SmallVec<[(C::I, bool); N]>, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This probably increases memory usage by a considerable amount due to padding. Maybe we could instead have an There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This vector tends to be small, it only holds the machine instructions emitted for a single CLIF instruction. So I don't think memory usage is really any concern here ... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Right, forgot about that. |
||
} | ||
|
||
/// 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>( | |
) -> Result<(), ()> | ||
where | ||
C: LowerCtx, | ||
[C::I; N]: smallvec::Array<Item = C::I>, | ||
[(C::I, bool); N]: smallvec::Array<Item = (C::I, bool)>, | ||
{ | ||
// TODO: reuse the ISLE context across lowerings so we can reuse its | ||
// internal heap allocations. | ||
|
@@ -367,7 +367,7 @@ where | |
renamer.add_rename(*temp, dst.to_reg(), *ty); | ||
} | ||
} | ||
for inst in isle_ctx.emitted_insts.iter_mut() { | ||
for (inst, _) in isle_ctx.emitted_insts.iter_mut() { | ||
map_regs(inst, &renamer); | ||
} | ||
|
||
|
@@ -387,8 +387,12 @@ where | |
// Once everything is remapped we forward all emitted instructions to the | ||
// `lower_ctx`. Note that this happens after the synthetic mov's above in | ||
// case any of these instruction use those movs. | ||
for inst in isle_ctx.emitted_insts { | ||
lower_ctx.emit(inst); | ||
for (inst, is_safepoint) in isle_ctx.emitted_insts { | ||
if is_safepoint { | ||
lower_ctx.emit_safepoint(inst); | ||
} else { | ||
lower_ctx.emit(inst); | ||
} | ||
} | ||
|
||
Ok(()) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we use
self.emit(..)
here to hide the bool tuple entry, which is noise/distracting/raises irrelevant questions for new code readers who stumble upon this?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah I see this already merged, I'll send a follow up PR.