When emitting the synthesized integer index for an access whose
LinearCombination contains a variable, use the variable's own type
for the constant `[0]` immediate (and for the rest of the index
arithmetic) instead of always using a generic pointer-sized integer.
With model-sized pointers in the picture the two integer widths can
differ, and using the wrong one trips Clift's type checking
downstream.
Re-run the emit-field-accesses if any replacement propagates a type
through an IndirectionOp. This is needed to discover new rewriting
opportunities enabled by the newly typed pointers.
After a replacement, check if the replaced value feeds into an
IndirectionOp. If the "rich" pre-bitcast value has a ptr<ptr<T>>
type, create a new typed IndirectionOp and insert a fixup bitcast
for existing non-lvalue uses. Lvalue uses (assign LHS) stay on the
old indirection to preserve type and lvalue constraints.
Returns true if propagation occurred, signaling the EFA driver to
rerun and discover new rewriting opportunities.
Value types is the set of non-array object types. These types are
assignable, can be used as function parameters, and as return types
(along with void), and in other scenarios where the type must have usual
value-like behaviour with no weirdness (such as array decay).
`mlir::Type` is now used as the default C++ type for representing all
MLIR types, even when `ValueType` would be a valid constraint, unless
doing so provides a clear benefit in that specific context.
* PrimitiveType is now an interface.
* VoidKind is now VoidType.
* FloatKind is now FloatType.
* The integer kinds are now IntegerType with IntegerKind.
* DecayOp - array or function to pointer decay. Not shown in C.
* BitCastOp - bit-preserving conversion. Emitted as bit_cast if
necessary.
* ExtendOp - zero- or sign-extending conversion from any integer type to
any wider integer type.
* TruncateOp - truncating conversion from any integer type to any
narrower integer type.
* PtrResizeOp - resizes a pointer without changing its pointee type.
Introduce the support to decouple the `BaseType` from `BasePointer`
pointee type.
This enable us to wrap pointee typees into an implicit array. This
enables pointer arithmetic rewriting of `*(p + i)` as `p[i]`.
We now don't assume that the `PointerOperand` of a `ptr_add` leads to a
`Address` PA, nor that the `OffsetOperand` leads to a `Numeric` PA.
We now behave as a simple `composeAdd`, keeping the special `Offset`
scaling by the `PointeeSize` of the `PointerOperand`.
Remove the special casing for `composeBitcast`, where we created a
`leaf` PA in case the traversal of the upward tree did only provide a
`Numeric` PA.
This was introduced as a workaround for handling `composePtrAdd` when
the `PointerOperand` was a `Numeric` PA.
The `EmitFieldAccesses` pass transforms `clift` by taking pointer-typed
expressions computed via integerr arithmetic with type-safe field
accesses and array accesses.
The transformation is split in three main phases:
1) `PointerArithmetic` computation.
2) `BestTraversal` computation.
3) `FieldAccess` `clift` rewrite.
The high level driver is implemented in the `EmitFieldAccesses` header
and cpp, while the nested 3 phases are implemented respectively in
`PointerArithmetic`, `BestTraversal` and `FieldAccessReplacement`.
The `computerPointerArithmetic` phase is concerned with taking a
pointer-typed `ExpressionOp`, called `PointerToReplace`, and expressing
it in a `BasePointer+Offset` form.
The `computeBestTraversal` phase is concerned with computing the best
traversal of the type pointed to by `BasePointer`, that can be used to
rewrite the pointer arithmetic in `clift` with just field accesses and
array subscripts.
The `replaceFieldAccess` phase takes the `Traversal` computed at the
previous step, and actually rewrites in `clift` the `PointerToReplace`
in terms of field accesses and array accesses w.r.t. the `BasePointer`.
Reject the `assignTypePunnedConstraint` DDR `Expressions.td` rewrite
when the `DstType` is an `ArrayType`, to avoid an invalid rewrite that
would violate the assumption that `bitcast`s do not admit a `ArrayType`
as `result` type.
Contains APIs from upstream LLVM that are not yet present in the current
version, as well as helpers not present in upstream.
See upstream commit 42c31d8302ff8f716601df9c276a5cd9ace6b158.