Add vector instructions.
Use derived type variables with the 'LaneOf' function. Add u8 immediates to be used for lane indexes and bit shifts.
This commit is contained in:
@@ -296,7 +296,7 @@ class TypeVar(object):
|
||||
def __str__(self):
|
||||
return "`{}`".format(self.name)
|
||||
|
||||
def lane(self):
|
||||
def lane_of(self):
|
||||
"""
|
||||
Return a derived type variable that is the scalar lane type of this
|
||||
type variable.
|
||||
@@ -304,7 +304,7 @@ class TypeVar(object):
|
||||
When this type variable assumes a scalar type, the derived type will be
|
||||
the same scalar type.
|
||||
"""
|
||||
return TypeVar(None, None, base=self, derived_func='Lane')
|
||||
return TypeVar(None, None, base=self, derived_func='LaneOf')
|
||||
|
||||
def as_bool(self):
|
||||
"""
|
||||
|
||||
@@ -6,7 +6,7 @@ support.
|
||||
"""
|
||||
from . import TypeVar, Operand, Instruction, InstructionGroup, variable_args
|
||||
from types import i8, f32, f64
|
||||
from immediates import imm64, ieee32, ieee64, immvector
|
||||
from immediates import imm64, uimm8, ieee32, ieee64, immvector
|
||||
import entities
|
||||
|
||||
instructions = InstructionGroup("base", "Shared base instruction set")
|
||||
@@ -17,7 +17,7 @@ Testable = TypeVar(
|
||||
'Testable', 'A scalar boolean or integer type',
|
||||
ints=True, bools=True)
|
||||
TxN = TypeVar(
|
||||
'%Tx%N', 'A SIMD vector type',
|
||||
'TxN', 'A SIMD vector type',
|
||||
ints=True, floats=True, bools=True, scalars=False, simd=True)
|
||||
Any = TypeVar(
|
||||
'Any', 'Any integer, float, or boolean scalar or vector type',
|
||||
@@ -177,6 +177,42 @@ vselect = Instruction(
|
||||
vector ``c``.
|
||||
""",
|
||||
ins=(c, x, y), outs=a)
|
||||
|
||||
x = Operand('x', TxN.lane_of())
|
||||
|
||||
splat = Instruction(
|
||||
'splat', r"""
|
||||
Vector splat.
|
||||
|
||||
Return a vector whose lanes are all ``x``.
|
||||
""",
|
||||
ins=x, outs=a)
|
||||
|
||||
x = Operand('x', TxN, doc='SIMD vector to modify')
|
||||
y = Operand('y', TxN.lane_of(), doc='New lane value')
|
||||
Idx = Operand('Idx', uimm8, doc='Lane index')
|
||||
|
||||
insertlane = Instruction(
|
||||
'insertlane', r"""
|
||||
Insert ``y`` as lane ``Idx`` in x.
|
||||
|
||||
The lane index, ``Idx``, is an immediate value, not an SSA value. It
|
||||
must indicate a valid lane index for the type of ``x``.
|
||||
""",
|
||||
ins=(x, Idx, y), outs=a)
|
||||
|
||||
x = Operand('x', TxN)
|
||||
a = Operand('a', TxN.lane_of())
|
||||
|
||||
extractlane = Instruction(
|
||||
'extractlane', r"""
|
||||
Extract lane ``Idx`` from ``x``.
|
||||
|
||||
The lane index, ``Idx``, is an immediate value, not an SSA value. It
|
||||
must indicate a valid lane index for the type of ``x``.
|
||||
""",
|
||||
ins=(x, Idx), outs=a)
|
||||
|
||||
#
|
||||
# Integer arithmetic
|
||||
#
|
||||
|
||||
@@ -8,7 +8,7 @@ in this module.
|
||||
|
||||
|
||||
from . import InstructionFormat, value, variable_args
|
||||
from immediates import imm64, ieee32, ieee64, immvector
|
||||
from immediates import imm64, uimm8, ieee32, ieee64, immvector
|
||||
from entities import ebb, function, jump_table
|
||||
|
||||
Nullary = InstructionFormat()
|
||||
@@ -30,6 +30,9 @@ BinaryOverflow = InstructionFormat(value, value, multiple_results=True)
|
||||
# The first value operand is the controlling flag whisch has a derived type.
|
||||
Select = InstructionFormat(value, value, value, typevar_operand=1)
|
||||
|
||||
InsertLane = InstructionFormat(value, uimm8, value)
|
||||
ExtractLane = InstructionFormat(value, uimm8)
|
||||
|
||||
Jump = InstructionFormat(ebb, variable_args, boxed_storage=True)
|
||||
Branch = InstructionFormat(value, ebb, variable_args, boxed_storage=True)
|
||||
BranchTable = InstructionFormat(value, jump_table)
|
||||
|
||||
@@ -11,6 +11,12 @@ from . import ImmediateKind
|
||||
#: :py:class:`cretonne.IntType` type.
|
||||
imm64 = ImmediateKind('imm64', 'A 64-bit immediate integer.')
|
||||
|
||||
#: An unsigned 8-bit immediate integer operand.
|
||||
#:
|
||||
#: This small operand is used to indicate lane indexes in SIMD vectors and
|
||||
#: immediate bit counts on shift instructions.
|
||||
uimm8 = ImmediateKind('uimm8', 'An 8-bit immediate unsigned integer.')
|
||||
|
||||
#: A 32-bit immediate floating point operand.
|
||||
#:
|
||||
#: IEEE 754-2008 binary32 interchange format.
|
||||
|
||||
Reference in New Issue
Block a user