Add call and call_indirect instructions.

Add a new IndirectCall instruction format which has a value callee as
well as the call arguments.

Define call and call_indirect instructions.
This commit is contained in:
Jakob Stoklund Olesen
2016-10-18 09:48:05 -07:00
parent b8a76822cf
commit bdc95990d4
8 changed files with 74 additions and 30 deletions

View File

@@ -373,22 +373,15 @@ platform. When calling other Cretonne functions, the flags are not necessary.
Functions that are called directly must be declared in the :term:`function
preamble`:
.. inst:: F = function NAME signature
.. inst:: FN = function NAME signature
Declare a function so it can be called directly.
:arg NAME: Name of the function, passed to the linker for resolution.
:arg signature: Function signature. See below.
:result F: A function identifier that can be used with :inst:`call`.
.. inst:: a, b, ... = call F(args...)
Direct function call.
:arg F: Function identifier to call, declared by :inst:`function`.
:arg args...: Function arguments matching the signature of F.
:result a,b,...: Return values matching the signature of F.
:result FN: A function identifier that can be used with :inst:`call`.
.. autoinst:: call
.. autoinst:: x_return
This simple example illustrates direct function calls and signatures::
@@ -414,14 +407,7 @@ Indirect function calls use a signature declared in the preamble.
:arg signature: Function signature. See :token:`signature`.
:result SIG: A signature identifier.
.. inst:: a, b, ... = call_indirect SIG, x(args...)
Indirect function call.
:arg SIG: A function signature identifier declared with :inst:`signature`.
:arg iPtr x: The address of the function to call.
:arg args...: Function arguments matching SIG.
:result a,b,...: Return values matching SIG.
.. autoinst:: call_indirect
.. todo:: Define safe indirect function calls.