Intel encodings for regspill and regfill.

These are always SP-based.
This commit is contained in:
Jakob Stoklund Olesen
2017-10-04 17:01:40 -07:00
parent 826d4062fb
commit 73d4bb47c0
8 changed files with 138 additions and 55 deletions

View File

@@ -24,25 +24,28 @@ pub struct StackRef {
impl StackRef {
/// Get a reference to the stack slot `ss` using one of the base pointers in `mask`.
pub fn masked(ss: StackSlot, mask: StackBaseMask, frame: &StackSlots) -> Option<StackRef> {
let size = frame.frame_size.expect(
"Stack layout must be computed before referencing stack slots",
);
// Offsets relative to the caller's stack pointer.
let offset = frame[ss].offset;
// Try an SP-relative reference.
if mask.contains(StackBase::SP) {
// Offset where SP is pointing. (All ISAs have stacks growing downwards.)
let sp_offset = -(size as StackOffset);
return Some(StackRef {
base: StackBase::SP,
offset: offset - sp_offset,
});
return Some(StackRef::sp(ss, frame));
}
// No reference possible with this mask.
None
}
/// Get a reference to `ss` using the stack pointer as a base.
pub fn sp(ss: StackSlot, frame: &StackSlots) -> StackRef {
let size = frame.frame_size.expect(
"Stack layout must be computed before referencing stack slots",
);
// Offset where SP is pointing. (All ISAs have stacks growing downwards.)
let sp_offset = -(size as StackOffset);
return StackRef {
base: StackBase::SP,
offset: frame[ss].offset - sp_offset,
};
}
}
/// Generic base register for referencing stack slots.