Document that b8 etc. are intended for use as SIMD elements.

This commit is contained in:
Dan Gohman
2018-09-05 14:23:03 -07:00
parent 1e0c9b546b
commit 608e74d8cb
2 changed files with 15 additions and 8 deletions

View File

@@ -96,12 +96,16 @@ different types.
Boolean types
-------------
Boolean values are either true or false. While this only requires a single bit
to represent, more bits are often used when holding a boolean value in a
register or in memory. The :type:`b1` type represents an abstract boolean
value. It can only exist as an SSA value, it can't be stored in memory or
converted to another type. The larger boolean types can be stored in memory.
They are represented as either all zero bits or all one bits.
Boolean values are either true or false.
The :type:`b1` type represents an abstract boolean value. It can only exist as
an SSA value, and can't be directly stored in memory. It can, however, be
converted into an integer with value 0 or 1 by the :inst:`bint` instruction (and
converted back with :inst:`icmp_imm` with 0).
Several larger boolean types are also defined, primarily to be used as SIMD
element types. They can be stored in memory, and are represented as either all
zero bits or all one bits.
.. autocliftype:: b1
.. autocliftype:: b8

View File

@@ -4,13 +4,16 @@ The base.types module predefines all the Cranelift scalar types.
from __future__ import absolute_import
from cdsl.types import IntType, FloatType, BoolType, FlagsType
#: Boolean.
b1 = BoolType(1) #: 1-bit bool. Type is abstract (can't be stored in mem)
#: Abstract boolean (can't be stored in memory, use bint to convert to 0 or 1).
b1 = BoolType(1) #: 1-bit bool.
#: Booleans used as SIMD elements (can be stored in memory, true is all-ones).
b8 = BoolType(8) #: 8-bit bool.
b16 = BoolType(16) #: 16-bit bool.
b32 = BoolType(32) #: 32-bit bool.
b64 = BoolType(64) #: 64-bit bool.
# Integers.
i8 = IntType(8) #: 8-bit int.
i16 = IntType(16) #: 16-bit int.
i32 = IntType(32) #: 32-bit int.