Move constant instructions into meta.

Add new immediate types for floating point and vector immediates.
Use new immediates to define the constant value instructions in meta.

Split the fconst instruction into two: f32const and f64const. This prevents
confusion about the interpretation of 64 immediate bits when generating an f32
constant.

Add an immvector ImmediateType. This immediate type is variable length, and
provides all the bits of a SIMD vector directly.
This commit is contained in:
Jakob Stoklund Olesen
2016-03-31 14:18:02 -07:00
parent a2db4b680e
commit ad07f67331
5 changed files with 87 additions and 30 deletions

View File

@@ -4,11 +4,59 @@ Cretonne base instruction set.
This module defines the basic Cretonne instruction set that all targets support.
"""
from . import TypeVar, Operand, Instruction
from types import i8
from immediates import imm64
from types import i8, f32, f64
from immediates import imm64, ieee32, ieee64, immvector
Int = TypeVar('Int', 'A scalar or vector integer type')
iB = TypeVar('iB', 'A scalar integer type')
TxN = TypeVar('%Tx%N', 'A SIMD vector type')
#
# Materializing constants.
#
N = Operand('N', imm64)
a = Operand('a', Int, doc='A constant integer scalar or vector value')
iconst = Instruction('iconst', r"""
Integer constant.
Create a scalar integer SSA value with an immediate constant value, or an
integer vector where all the lanes have the same value.
""",
ins=N, outs=a)
N = Operand('N', ieee32)
a = Operand('a', f32, doc='A constant integer scalar or vector value')
f32const = Instruction('f32const', r"""
Floating point constant.
Create a :type:`f32` SSA value with an immediate constant value, or a
floating point vector where all the lanes have the same value.
""",
ins=N, outs=a)
N = Operand('N', ieee64)
a = Operand('a', f64, doc='A constant integer scalar or vector value')
f64const = Instruction('f64const', r"""
Floating point constant.
Create a :type:`f64` SSA value with an immediate constant value, or a
floating point vector where all the lanes have the same value.
""",
ins=N, outs=a)
N = Operand('N', immvector)
a = Operand('a', TxN, doc='A constant vector value')
vconst = Instruction('vconst', r"""
Vector constant (floating point or integer).
Create a SIMD vector value where the lanes don't have to be identical.
""",
ins=N, outs=a)
#
# Integer arithmetic
#
a = Operand('a', Int)
x = Operand('x', Int)