[clang] [llvm] [BPF] Add load-acquire and store-release instructions under -mcpu=v4 (PR #108636)

Peilin Ye via cfe-commits cfe-commits at lists.llvm.org
Mon Oct 28 14:55:03 PDT 2024


peilin-ye wrote:

Changes in v7:

1. Change encoding to make it easier to support `SEQ_CST` in the future (Yingchi)
```
 (before)      | imm{7-4}            | imm{3-0} |
 ------------- | ------------------- | -------- |
 load-acquire  | BPF_LOAD_ACQ (0x1)  | 0x0      |
 store-release | BPF_STORE_REL (0x2) | 0x0      |
```
```
 (after)       | imm{7-4}        | imm{3-0}          |
 ------------- | --------------- | ----------------- |
 load-acquire  | BPF_LOAD (0x1)  | BPF_ACQUIRE (0x1) |
 store-release | BPF_STORE (0x2) | BPF_RELEASE (0x2) |
```
Introduce the following new flags for memory orders:
```
def BPF_RELAXED : BPFAtomicOrdering<0x0>;
def BPF_ACQUIRE : BPFAtomicOrdering<0x1>;
def BPF_RELEASE : BPFAtomicOrdering<0x2>;
def BPF_ACQ_REL : BPFAtomicOrdering<0x3>;
def BPF_SEQ_CST : BPFAtomicOrdering<0x4>;
```
Include all orders defined by the C++ standard except `CONSUME` (Yonghong)

2. `BPFISelLowering.cpp` changes (Matt)
   - Avoid unnecessarily setting `MVT::i{8,16}` `ATOMIC_{LOAD,STORE}` to `Custom`
   - Coding style change

3. `acquire-release.ll` changes (Yingchi)
   - Move `; CHECK` labels into their corresponding function bodies
   - Delete the `; Source:` section

4. Update `bpf-predefined-macros.c`

https://github.com/llvm/llvm-project/pull/108636


More information about the cfe-commits mailing list