Add a make_signature function for making callable signatures.

The `Module` can create signatures with the appropriate calling
convention.
This commit is contained in:
Dan Gohman
2018-08-28 12:31:38 -07:00
parent 0e67255f52
commit e60477092a

View File

@@ -339,7 +339,7 @@ where
ctx
}
/// Create a new `Context` initialized for use with this `Module`.
/// Clear the given `Context` and reset it for use with a new function.
///
/// This ensures that the `Context` is initialized with the default calling
/// convention for the `TargetIsa`.
@@ -348,6 +348,21 @@ where
ctx.func.signature.call_conv = self.backend.isa().flags().call_conv();
}
/// Create a new empty `Signature` with the default calling convention for
/// the `TargetIsa`, to which parameter and return types can be added for
/// declaring a function to be called by this `Module`.
pub fn make_signature(&self) -> ir::Signature {
ir::Signature::new(self.backend.isa().flags().call_conv())
}
/// Clear the given `Signature` and reset for use with a new function.
///
/// This ensures that the `Signature` is initialized with the default
/// calling convention for the `TargetIsa`.
pub fn clear_signature(&self, sig: &mut ir::Signature) {
sig.clear(self.backend.isa().flags().call_conv());
}
/// Declare a function in this module.
pub fn declare_function(
&mut self,