diff --git a/lib/module/src/module.rs b/lib/module/src/module.rs index 185057b946..cc89ad68c0 100644 --- a/lib/module/src/module.rs +++ b/lib/module/src/module.rs @@ -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,