[llvm] [MC][AMDGPU] Support .reloc BFD_RELOC_{NONE, 32, 64} (PR #114617)

Johannes Doerfert via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 5 10:30:01 PST 2024


================
@@ -163,12 +163,17 @@ void AMDGPUAsmBackend::applyFixup(const MCAssembler &Asm, const MCFixup &Fixup,
 
 std::optional<MCFixupKind>
 AMDGPUAsmBackend::getFixupKind(StringRef Name) const {
-  return StringSwitch<std::optional<MCFixupKind>>(Name)
-#define ELF_RELOC(Name, Value)                                                 \
-  .Case(#Name, MCFixupKind(FirstLiteralRelocationKind + Value))
+  auto Type = StringSwitch<unsigned>(Name)
+#define ELF_RELOC(Name, Value) .Case(#Name, Value)
 #include "llvm/BinaryFormat/ELFRelocs/AMDGPU.def"
 #undef ELF_RELOC
-      .Default(std::nullopt);
+                  .Case("BFD_RELOC_NONE", ELF::R_AMDGPU_NONE)
+                  .Case("BFD_RELOC_32", ELF::R_AMDGPU_ABS32)
+                  .Case("BFD_RELOC_64", ELF::R_AMDGPU_ABS64)
----------------
jdoerfert wrote:

@arsenm This is how the other backends do it (https://github.com/llvm/llvm-project/commit/4f7562d52fe40fb5974360f391d5ed8bbbcdbd60), would you prefer it this way or added to the .def file?

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


More information about the llvm-commits mailing list