[llvm] RISCV: Replace most Specifier constants with relocation types (PR #138644)

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Tue May 6 20:21:33 PDT 2025


MaskRay wrote:

> Mixing VK_ and R_ breaks if any relocation is >= FirstTargetFixupKind (4000 + a few), which is legitimate. This should be following the same model as for fixup_* and separating out the R_ and VK_ cases based on whether it's < FirstTargetFixupKind.

`R_*` and `Specifier::VK_*` are already separate. The first `Specifier` constant VK_LO starts at 4000.
In `RISCVMCCodeEmitter::getImmOpValue`, there is an assert to catch new `Specifier` constants that are not in the switch.

```
+    default:
+      assert(FixupKind && FixupKind < FirstTargetFixupKind &&
+             "invalid specifier");
+      break;
```

What else do you have in mind?

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


More information about the llvm-commits mailing list