Add functions to Module for initializing Contexts.

This allows Module to assign the Context the TargetIsa's default calling
convention.
This commit is contained in:
Dan Gohman
2018-04-27 05:38:53 -07:00
parent 9e48344f7f
commit c40a4ddc53

View File

@@ -331,6 +331,25 @@ where
} }
} }
/// Create a new `Context` initialized for use with this `Module`.
///
/// This ensures that the `Context` is initialized with the default calling
/// convention for the `TargetIsa`.
pub fn make_context(&self) -> Context {
let mut ctx = Context::new();
ctx.func.signature.call_conv = self.backend.isa().flags().call_conv();
ctx
}
/// Create a new `Context` initialized for use with this `Module`.
///
/// This ensures that the `Context` is initialized with the default calling
/// convention for the `TargetIsa`.
pub fn clear_context(&self, ctx: &mut Context) {
ctx.clear();
ctx.func.signature.call_conv = self.backend.isa().flags().call_conv();
}
/// Declare a function in this module. /// Declare a function in this module.
pub fn declare_function( pub fn declare_function(
&mut self, &mut self,