llvm / llvm/llvm-project

[CIR] Upstream missing support for static l-value casts

Open
#192,314 4 comments 0 reactions 1 assignee Claimed by @AbdallahRashed View on GitHub
ClangIR
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.