cretonne::Context: add for_function constructor

This commit is contained in:
Pat Hickey
2018-01-25 17:11:13 -08:00
committed by Jakob Stoklund Olesen
parent ef2640d8a4
commit 3f69581d03

View File

@@ -49,8 +49,16 @@ impl Context {
/// The returned instance should be reused for compiling multiple functions in order to avoid
/// needless allocator thrashing.
pub fn new() -> Self {
Context::for_function(Function::new())
}
/// Allocate a new compilation context with an existing Function.
///
/// The returned instance should be reused for compiling multiple functions in order to avoid
/// needless allocator thrashing.
pub fn for_function(func: Function) -> Self {
Self {
func: Function::new(),
func: func,
cfg: ControlFlowGraph::new(),
domtree: DominatorTree::new(),
regalloc: regalloc::Context::new(),