Add ImmediateType for declaring immediate operands.
This commit is contained in:
@@ -200,6 +200,18 @@ in this reference.
|
|||||||
|
|
||||||
Either :type:`bool` or :type:`iN`.
|
Either :type:`bool` or :type:`iN`.
|
||||||
|
|
||||||
|
Immediate operand types
|
||||||
|
-----------------------
|
||||||
|
|
||||||
|
These types are not part of the normal SSA type system. They are used to
|
||||||
|
indicate the different kinds of immediate operands on an instruction.
|
||||||
|
|
||||||
|
.. type:: imm64
|
||||||
|
|
||||||
|
A 64-bit immediate integer. The value of this operand is interpreted as a
|
||||||
|
signed two's complement integer. Instruction encodings may limit the valid
|
||||||
|
range.
|
||||||
|
|
||||||
Control flow
|
Control flow
|
||||||
============
|
============
|
||||||
|
|
||||||
|
|||||||
@@ -38,13 +38,28 @@ Predefined types
|
|||||||
.. automodule:: cretonne.types
|
.. automodule:: cretonne.types
|
||||||
:members:
|
:members:
|
||||||
|
|
||||||
|
.. currentmodule:: cretonne
|
||||||
|
|
||||||
Parametric polymorphism
|
Parametric polymorphism
|
||||||
-----------------------
|
-----------------------
|
||||||
.. currentmodule:: cretonne
|
|
||||||
|
|
||||||
Instruction operands can be defined with *type variables* instead of concrete
|
Instruction operands can be defined with *type variables* instead of concrete
|
||||||
types for their operands. This makes the instructions polymorphic.
|
types for their operands. This makes the instructions polymorphic.
|
||||||
|
|
||||||
.. autoclass:: TypeVar
|
.. autoclass:: TypeVar
|
||||||
|
|
||||||
|
Immediates
|
||||||
|
----------
|
||||||
|
|
||||||
|
Immediate instruction operands don't correspond to SSA values, but have values
|
||||||
|
that are encoded directly in the instruction. Immediate operands don't
|
||||||
|
have types from the :class:`cretonne.Type` type system; they often have
|
||||||
|
enumerated values of a specific type. The type of an immediate operand is
|
||||||
|
indicated with an instance of :class:`ImmediateType`.
|
||||||
|
|
||||||
|
.. autoclass:: ImmediateType
|
||||||
|
|
||||||
|
.. automodule:: cretonne.immediates
|
||||||
|
:members:
|
||||||
|
|
||||||
|
.. currentmodule:: cretonne
|
||||||
|
|||||||
@@ -110,3 +110,23 @@ class TypeVar(object):
|
|||||||
def __init__(self, name):
|
def __init__(self, name):
|
||||||
self.name = name
|
self.name = name
|
||||||
|
|
||||||
|
#
|
||||||
|
# Immediate operands.
|
||||||
|
#
|
||||||
|
# Instances of immediate operand types are provided in the cretonne.immediates
|
||||||
|
# module.
|
||||||
|
|
||||||
|
class ImmediateType(object):
|
||||||
|
"""
|
||||||
|
The type of an immediate instruction operand.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def __init__(self, name, doc):
|
||||||
|
self.name = name
|
||||||
|
self.__doc__ = doc
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return self.name
|
||||||
|
|
||||||
|
def __repr__(self):
|
||||||
|
return 'ImmediateType({})'.format(self.name)
|
||||||
|
|||||||
12
meta/cretonne/immediates.py
Normal file
12
meta/cretonne/immediates.py
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
"""
|
||||||
|
The cretonne.immdiates module predefines all the Cretonne immediate operand
|
||||||
|
types.
|
||||||
|
"""
|
||||||
|
|
||||||
|
from . import ImmediateType
|
||||||
|
|
||||||
|
#: A 64-bit immediate integer operand.
|
||||||
|
#:
|
||||||
|
#: This type of immediate integer can interact with SSA values with any
|
||||||
|
#: :py:class:`cretonne.IntType` type.
|
||||||
|
imm64 = ImmediateType('imm64', 'A 64-bit immediate integer.')
|
||||||
Reference in New Issue
Block a user