-
Notifications
You must be signed in to change notification settings - Fork 2
OpenVMSettings
type
#30
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
Conversation
integration/src/womir_translation.rs
Outdated
fn allocate_loop_frame_slots( | ||
&self, | ||
need_ret_info: bool, | ||
saved_fps: BTreeSet<u32>, | ||
) -> (RegisterGenerator<'a, Self>, LoopFrameLayout) { | ||
let mut rgen = RegisterGenerator::new(); | ||
|
||
let ret_info = need_ret_info.then(|| { | ||
// Allocate the return PC and frame pointer for the loop. | ||
let ret_pc = rgen.allocate_words(Self::words_per_ptr()); | ||
let ret_fp = rgen.allocate_words(Self::words_per_ptr()); | ||
ReturnInfo { ret_pc, ret_fp } | ||
}); | ||
|
||
// Allocate the slots for the saved frame pointers. | ||
let saved_fps = saved_fps | ||
.into_iter() | ||
.map(|depth| { | ||
let outer_fp = rgen.allocate_words(Self::words_per_ptr()); | ||
(depth, outer_fp) | ||
}) | ||
.collect(); | ||
|
||
( | ||
rgen, | ||
LoopFrameLayout { | ||
saved_fps, | ||
ret_info, | ||
}, | ||
) | ||
} |
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.
This is a matter for another PR, in womir
, but I think this function should have a default implementation. It was created for PetraVM, that I think would require a different layout...
fn emit_jump_into_loop( | ||
&self, | ||
_g: &mut womir::loader::flattening::Generators<'a, '_, Self>, | ||
loop_label: String, | ||
loop_frame_ptr: std::ops::Range<u32>, | ||
ret_info_to_copy: Option<womir::loader::flattening::settings::ReturnInfosToCopy>, | ||
saved_curr_fp_ptr: Option<std::ops::Range<u32>>, | ||
) -> Vec<Self::Directive> { | ||
let mut directives = if let Some(to_copy) = ret_info_to_copy { | ||
assert_eq!(Self::words_per_ptr(), 1); | ||
vec![ | ||
Directive::Instruction(ib::copy_into_frame( | ||
to_copy.dest.ret_pc.start as usize, | ||
to_copy.src.ret_pc.start as usize, | ||
loop_frame_ptr.start as usize, | ||
)), | ||
Directive::Instruction(ib::copy_into_frame( | ||
to_copy.dest.ret_fp.start as usize, | ||
to_copy.src.ret_fp.start as usize, | ||
loop_frame_ptr.start as usize, | ||
)), | ||
] | ||
} else { | ||
Vec::new() | ||
}; | ||
|
||
let jump = if let Some(saved_caller_fp) = saved_curr_fp_ptr { | ||
Directive::JaafSave { | ||
target: loop_label, | ||
new_frame_ptr: loop_frame_ptr.start, | ||
saved_caller_fp: saved_caller_fp.start, | ||
} | ||
} else { | ||
Directive::Jaaf { | ||
target: loop_label, | ||
new_frame_ptr: loop_frame_ptr.start, | ||
} | ||
}; | ||
|
||
directives.push(jump); | ||
directives | ||
} |
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.
Similar situation to allocate_loop_frame_slots
: implementing this at this level should not be needed, and can be improved in womir
.
Use OpenVM specific settings instead of the generic one, so we're able to do "one to many" translation of directives