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:
@@ -712,7 +712,10 @@ class InstructionFormat(object):
|
||||
:py:class:`Instruction` arguments of the same name, except they must be
|
||||
tuples of :py:`Operand` objects.
|
||||
"""
|
||||
multiple_results = len(outs) > 1
|
||||
if len(outs) == 1:
|
||||
multiple_results = outs[0].kind == variable_args
|
||||
else:
|
||||
multiple_results = len(outs) > 1
|
||||
sig = (multiple_results,) + tuple(op.kind for op in ins)
|
||||
if sig not in InstructionFormat._registry:
|
||||
raise RuntimeError(
|
||||
|
||||
@@ -15,6 +15,7 @@ instructions = InstructionGroup("base", "Shared base instruction set")
|
||||
|
||||
Int = TypeVar('Int', 'A scalar or vector integer type', ints=True, simd=True)
|
||||
iB = TypeVar('iB', 'A scalar integer type', ints=True)
|
||||
iPtr = TypeVar('iB', 'An integer address type', ints=(32, 64))
|
||||
Testable = TypeVar(
|
||||
'Testable', 'A scalar boolean or integer type',
|
||||
ints=True, bools=True)
|
||||
@@ -109,6 +110,35 @@ x_return = Instruction(
|
||||
""",
|
||||
ins=rvals)
|
||||
|
||||
FN = Operand(
|
||||
'FN',
|
||||
entities.func_ref,
|
||||
doc='function to call, declared by :inst:`function`')
|
||||
args = Operand('args', variable_args, doc='call arguments')
|
||||
|
||||
call = Instruction(
|
||||
'call', r"""
|
||||
Direct function call.
|
||||
|
||||
Call a function which has been declared in the preamble. The argument
|
||||
types must match the function's signature.
|
||||
""",
|
||||
ins=(FN, args),
|
||||
outs=rvals)
|
||||
|
||||
SIG = Operand('SIG', entities.sig_ref, doc='function signature')
|
||||
callee = Operand('callee', iPtr, doc='address of function to call')
|
||||
|
||||
call_indirect = Instruction(
|
||||
'call_indirect', r"""
|
||||
Indirect function call.
|
||||
|
||||
Call the function pointed to by `callee` with the given arguments. The
|
||||
called function must match the soecified signature.
|
||||
""",
|
||||
ins=(SIG, callee, args),
|
||||
outs=rvals)
|
||||
|
||||
#
|
||||
# Materializing constants.
|
||||
#
|
||||
|
||||
@@ -8,7 +8,7 @@ in this module.
|
||||
from __future__ import absolute_import
|
||||
from . import InstructionFormat, value, variable_args
|
||||
from .immediates import imm64, uimm8, ieee32, ieee64, immvector, intcc, floatcc
|
||||
from .entities import ebb, func_ref, jump_table
|
||||
from .entities import ebb, sig_ref, func_ref, jump_table
|
||||
|
||||
Nullary = InstructionFormat()
|
||||
|
||||
@@ -47,6 +47,9 @@ BranchTable = InstructionFormat(value, jump_table)
|
||||
|
||||
Call = InstructionFormat(
|
||||
func_ref, variable_args, multiple_results=True, boxed_storage=True)
|
||||
IndirectCall = InstructionFormat(
|
||||
sig_ref, value, variable_args,
|
||||
multiple_results=True, boxed_storage=True)
|
||||
Return = InstructionFormat(variable_args, boxed_storage=True)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user