From 27e7945f63f437444d3ca35db464beac4bb59e08 Mon Sep 17 00:00:00 2001 From: Angus Holder Date: Sat, 11 Mar 2017 15:44:49 +0000 Subject: [PATCH] Define boolean conversion instructions. --- docs/langref.rst | 4 ++ lib/cretonne/meta/base/instructions.py | 61 ++++++++++++++++++++++++++ 2 files changed, 65 insertions(+) diff --git a/docs/langref.rst b/docs/langref.rst index b1262c0335..9a08da062d 100644 --- a/docs/langref.rst +++ b/docs/langref.rst @@ -819,6 +819,10 @@ Conversion operations --------------------- .. autoinst:: bitcast +.. autoinst:: breduce +.. autoinst:: bextend +.. autoinst:: bint +.. autoinst:: bmask .. autoinst:: ireduce .. autoinst:: uextend .. autoinst:: sextend diff --git a/lib/cretonne/meta/base/instructions.py b/lib/cretonne/meta/base/instructions.py index 4f5febb0c4..e0efafb1f5 100644 --- a/lib/cretonne/meta/base/instructions.py +++ b/lib/cretonne/meta/base/instructions.py @@ -1063,6 +1063,67 @@ bitcast = Instruction( """, ins=x, outs=a) +Bool = TypeVar( + 'Bool', + 'A scalar or vector boolean type', + bools=True, simd=True) +BoolTo = TypeVar( + 'BoolTo', + 'A smaller boolean type with the same number of lanes', + bools=True, simd=True) + +x = Operand('x', Bool) +a = Operand('a', BoolTo) + +breduce = Instruction( + 'breduce', r""" + Convert `x` to a smaller boolean type in the platform-defined way. + + 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) + +BoolTo = TypeVar( + 'BoolTo', + 'A larger boolean type with the same number of lanes', + bools=True, simd=True) + +x = Operand('x', Bool) +a = Operand('a', BoolTo) + +bextend = Instruction( + 'bextend', r""" + Convert `x` to a larger boolean type in the platform-defined way. + + 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) + +IntTo = TypeVar( + 'IntTo', 'An integer type with the same number of lanes', + ints=True, simd=True) + +x = Operand('x', Bool) +a = Operand('a', IntTo) + +bint = Instruction( + 'bint', r""" + Convert `x` to an integer. + + True maps to 1 and false maps to 0. The result type must have the same + number of vector lanes as the input. + """, ins=x, outs=a) + +bmask = Instruction( + 'bmask', r""" + Convert `x` to an integer mask. + + True maps to all 1s and false maps to all 0s. The result type must have + the same number of vector lanes as the input. + """, 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',