[CIR] Upstream missing support for static l-value casts
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
### Overview
Upstream code from the incubator project to replace errorNYI calls in the
CIR codegen implementation related to additional cast kinds when emitting
cast lvalues:
- Address space conversion casts using `toCIRLangAddressSpaceAttr` and
`getTargetHooks().performAddrSpaceCast()`
- `CK_NoOp` casts where the CIR memory types differ, requiring a
`createElementBitCast()` to reconcile them
Upstream NYI locations:
- `CIRGenExpr.cpp` — `emitCastLValue`: address space conversion from non-target
address space
- `CIRGenExpr.cpp` — `emitCastLValue`: `CK_NoOp` where CIR memory types differ
### Suggested minimal test cases
```cpp
void f() {
int (*p[2])[4];
int (*const(&r)[2])[] = p; // CK_NoOp on int(*[2])[4] -> int(*const[2])[]
(void)r;
}
```
```cpp
// clang -cc1 -x clcpp -triple spir64 -cl-std=clc++ -fclangir -emit-cir as1.cl -o -
__kernel void k(__global int *gp) {
__global int &gr = *gp;
int &r = gr; // bind generic-AS reference to a __global lvalue
(void)r;
}
```
### Existing incubator tests
- `clang/test/CIR/CodeGen/cast-lvalue.cpp`
- `clang/test/CIR/CodeGen/cast.cpp`
- `clang/test/CIR/CodeGen/address-space-conversion.cpp`
Contributor guide
Assessment
This issue has not been assessed yet.