[llvm] [bolt][aarch64] simplify rodata/literal load for X86 & AArch64 (PR #165723)

YongKang Zhu via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 5 09:13:17 PST 2025


================
@@ -2770,6 +2770,52 @@ class AArch64MCPlusBuilder : public MCPlusBuilder {
     return Insts;
   }
 
+  InstructionListType materializeConstant(const MCInst &Inst,
+                                          StringRef ConstantData,
+                                          uint64_t Offset) const override {
+    struct InstInfo {
+      // Size in bytes that Inst loads from memory.
+      uint8_t DataSize;
+      // Number of instructions needed to materialize the constant.
+      uint8_t numInstrs;
+      // Opcode to use for materializing the constant.
+      unsigned Opcode;
+    };
+
+    InstInfo I;
+    InstructionListType Insts(0);
+    switch (Inst.getOpcode()) {
+    case AArch64::LDRWl:
+      I = {4, 2, AArch64::MOVKWi};
+      break;
+    case AArch64::LDRXl:
+      I = {8, 4, AArch64::MOVKXi};
+      break;
+    default:
+      return InstructionListType{};
----------------
yozhu wrote:

nit: maybe `return Instrs`, same as what is on Line 2799.

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


More information about the llvm-commits mailing list