Skip to content

Conversation

@inclyc
Copy link
Member

@inclyc inclyc commented Dec 10, 2023

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
        ^

@inclyc inclyc requested a review from yonghong-song December 10, 2023 10:30
@llvmbot llvmbot added the llvm:mc Machine (object) code label Dec 10, 2023
@llvmbot
Copy link
Member

llvmbot commented Dec 10, 2023

@llvm/pr-subscribers-mc

Author: Yingchi Long (inclyc)

Changes

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 --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

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
            ^
@inclyc inclyc marked this pull request as draft December 10, 2023 10:33
@inclyc inclyc force-pushed the users/inclyc/bpf-callx-asm branch from 29bffab to feb2060 Compare December 10, 2023 10:34
@inclyc inclyc marked this pull request as ready for review December 10, 2023 10:34
@TiborGY
Copy link
Contributor

TiborGY commented Feb 27, 2025

@inclyc Was there a reason why this never got merged?

@inclyc inclyc requested a review from 4ast February 28, 2025 01:48
@inclyc
Copy link
Member Author

inclyc commented Feb 28, 2025

Kindly ping @yonghong-song @4ast, could you review this PR?

Copy link
Member

@4ast 4ast left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because callx is a reserved insn. There is no kernel support yet.

@inclyc
Copy link
Member Author

inclyc commented Feb 28, 2025

Because callx is a reserved insn. There is no kernel support yet.

Thanks, I will close the PR :).

@inclyc inclyc closed this Feb 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend:BPF llvm:mc Machine (object) code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants