[llvm] [BPF] support indirect branch (callx) in AsmParser (PR #74988)

via llvm-commits llvm-commits at lists.llvm.org
Sun Dec 10 02:30:43 PST 2023


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-mc

Author: Yingchi Long (inclyc)

<details>
<summary>Changes</summary>

Simply mark `callx` as a valid ID, so it can be recognized.

Previously this valid asm triggers an error:

    # clang local/callx.s -target bpf
    local/callx.s:8:2: error: invalid register/token name
            callx r1
            ^

---
Full diff: https://github.com/llvm/llvm-project/pull/74988.diff


2 Files Affected:

- (modified) llvm/lib/Target/BPF/AsmParser/BPFAsmParser.cpp (+1) 
- (added) llvm/test/MC/BPF/callx.s (+4) 


``````````diff
diff --git a/llvm/lib/Target/BPF/AsmParser/BPFAsmParser.cpp b/llvm/lib/Target/BPF/AsmParser/BPFAsmParser.cpp
index 90697c6645be2f..0d1eef60c3b550 100644
--- a/llvm/lib/Target/BPF/AsmParser/BPFAsmParser.cpp
+++ b/llvm/lib/Target/BPF/AsmParser/BPFAsmParser.cpp
@@ -229,6 +229,7 @@ struct BPFOperand : public MCParsedAsmOperand {
     return StringSwitch<bool>(Name.lower())
         .Case("if", true)
         .Case("call", true)
+        .Case("callx", true)
         .Case("goto", true)
         .Case("gotol", true)
         .Case("*", true)
diff --git a/llvm/test/MC/BPF/callx.s b/llvm/test/MC/BPF/callx.s
new file mode 100644
index 00000000000000..3df616b2f4c923
--- /dev/null
+++ b/llvm/test/MC/BPF/callx.s
@@ -0,0 +1,4 @@
+# RUN: llvm-mc -triple bpfel -show-encoding < %s
+
+# CHECK: callx r1                                # encoding: [0x8d,0x00,0x00,0x00,0x01,0x00,0x00,0x00]
+callx r1

``````````

</details>


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


More information about the llvm-commits mailing list