[llvm] [BPF] Support Jump Table (PR #149715)

via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 23 23:51:00 PDT 2025


================
@@ -150,6 +133,115 @@ void BPFAsmPrinter::emitInstruction(const MachineInstr *MI) {
   EmitToStreamer(*OutStreamer, TmpInst);
 }
 
+MCSymbol *BPFAsmPrinter::getJTPublicSymbol(unsigned JTI) {
+  SmallString<60> Name;
+  raw_svector_ostream(Name)
+      << "BPF.JT." << MF->getFunctionNumber() << '.' << JTI;
+  MCSymbol *S = OutContext.getOrCreateSymbol(Name);
+  if (auto *ES = dyn_cast<MCSymbolELF>(S)) {
+    ES->setBinding(ELF::STB_GLOBAL);
+    ES->setType(ELF::STT_OBJECT);
+  }
+  return S;
+}
+
+MCSymbol *BPFAsmPrinter::lowerBlockAddress(const BlockAddress *BA) {
----------------
yonghong-song wrote:

Okay, I just uploaded a new version to fix Example 1 case (i.e., LD_imm64 <blockaddress> case).
I added one transformation in MIPeephole to convert <blockaddress> as an one element array and its behavior will be the same as other arrays with more than 2 elements (e.g. Example 3).

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


More information about the llvm-commits mailing list