Metadefs for integer reduce and extend operations.
Naming is interesting here. Since 'truncate' refers to removing the least significant digits, use 'ireduce' instead. The 'extend' use is fairly established. Don't abbreviate, avoid unfortunate modern vernacular.
This commit is contained in:
@@ -818,9 +818,9 @@ Conversion operations
|
|||||||
---------------------
|
---------------------
|
||||||
|
|
||||||
.. autoinst:: bitcast
|
.. autoinst:: bitcast
|
||||||
.. inst:: a = itrunc x
|
.. autoinst:: ireduce
|
||||||
.. inst:: a = uext x
|
.. autoinst:: uextend
|
||||||
.. inst:: a = sext x
|
.. autoinst:: sextend
|
||||||
.. inst:: a = ftrunc x
|
.. inst:: a = ftrunc x
|
||||||
.. inst:: a = fext x
|
.. inst:: a = fext x
|
||||||
.. inst:: a = cvt_ftou x
|
.. inst:: a = cvt_ftou x
|
||||||
|
|||||||
@@ -786,4 +786,51 @@ bitcast = Instruction(
|
|||||||
""",
|
""",
|
||||||
ins=x, outs=a)
|
ins=x, outs=a)
|
||||||
|
|
||||||
|
Int = TypeVar('Int', 'A scalar or vector integer type', ints=True, simd=True)
|
||||||
|
IntTo = TypeVar('IntTo', 'A smaller integer type with the same number of lanes', ints=True, simd=True)
|
||||||
|
|
||||||
|
x = Operand('x', Int)
|
||||||
|
a = Operand('a', IntTo)
|
||||||
|
|
||||||
|
ireduce = Instruction(
|
||||||
|
'ireduce', r"""
|
||||||
|
Convert `x` to a smaller integer type by dropping high bits.
|
||||||
|
|
||||||
|
Each lane in `x` is converted to a smaller integer type by discarding
|
||||||
|
the most significant bits. This is the same as reducing modulo
|
||||||
|
:math:`2^n`.
|
||||||
|
|
||||||
|
The result type must have the same number of vector lanes as the input,
|
||||||
|
and each lane must not have more bits that the input lanes. If the input
|
||||||
|
and output types are the same, this is a no-op.
|
||||||
|
""",
|
||||||
|
ins=x, outs=a)
|
||||||
|
|
||||||
|
uextend = Instruction(
|
||||||
|
'uextend', r"""
|
||||||
|
Convert `x` to a larger integer type by zero-extending.
|
||||||
|
|
||||||
|
Each lane in `x` is converted to a larger integer type by adding zeroes.
|
||||||
|
The result has the same numerical value as `x` when both are interpreted
|
||||||
|
as unsigned integers.
|
||||||
|
|
||||||
|
The result type must have the same number of vector lanes as the input,
|
||||||
|
and each lane must not have fewer bits that the input lanes. If the input
|
||||||
|
and output types are the same, this is a no-op.
|
||||||
|
""",
|
||||||
|
ins=x, outs=a)
|
||||||
|
|
||||||
|
sextend = Instruction(
|
||||||
|
'sextend', r"""
|
||||||
|
Convert `x` to a larger integer type by sign-extending.
|
||||||
|
|
||||||
|
Each lane in `x` is converted to a larger integer type by replicating
|
||||||
|
the sign bit. The result has the same numerical value as `x` when both
|
||||||
|
are interpreted as signed integers.
|
||||||
|
|
||||||
|
The result type must have the same number of vector lanes as the input,
|
||||||
|
and each lane must not have fewer bits that the input lanes. If the input
|
||||||
|
and output types are the same, this is a no-op.
|
||||||
|
""",
|
||||||
|
ins=x, outs=a)
|
||||||
instructions.close()
|
instructions.close()
|
||||||
|
|||||||
Reference in New Issue
Block a user