Skip to content

Conversation

s-barannikov
Copy link
Contributor

@s-barannikov s-barannikov commented Sep 1, 2025

TSB instruction has one operand, but the generated disassembler is unable to decode it since the operand is not encoded into the instruction. AArch64InstPrinter has a special case for this -- if the instruction being printed is TSB, it prints the only possible operand value, regardless of whether the operand is present or not.

With the changes proposed by #156358, the operand can now be decoded automatically and the workaround is no longer required.

@s-barannikov s-barannikov force-pushed the users/s.barannikov/decoder-operands-4-aarch64-tsb branch from fa1e14d to fe7aa77 Compare September 1, 2025 18:19
@s-barannikov s-barannikov force-pushed the users/s.barannikov/decoder-operands-3-avr branch from a2f1143 to 067f93e Compare September 1, 2025 18:19
@s-barannikov s-barannikov force-pushed the users/s.barannikov/decoder-operands-4-aarch64-tsb branch from fe7aa77 to 8b1424a Compare September 1, 2025 19:11
@s-barannikov s-barannikov force-pushed the users/s.barannikov/decoder-operands-3-avr branch from 067f93e to 235b15d Compare September 1, 2025 19:11
@s-barannikov s-barannikov force-pushed the users/s.barannikov/decoder-operands-4-aarch64-tsb branch from 8b1424a to c82858d Compare September 1, 2025 21:05
@s-barannikov s-barannikov force-pushed the users/s.barannikov/decoder-operands-3-avr branch 2 times, most recently from b1cd999 to 6ff221b Compare September 2, 2025 16:08
@s-barannikov s-barannikov force-pushed the users/s.barannikov/decoder-operands-4-aarch64-tsb branch 2 times, most recently from f7326ba to b62d843 Compare September 2, 2025 16:40
@s-barannikov s-barannikov force-pushed the users/s.barannikov/decoder-operands-3-avr branch from 6ff221b to d3e77cd Compare September 2, 2025 16:40
@s-barannikov s-barannikov force-pushed the users/s.barannikov/decoder-operands-4-aarch64-tsb branch from b62d843 to d80acf2 Compare September 3, 2025 19:51
@s-barannikov s-barannikov force-pushed the users/s.barannikov/decoder-operands-3-avr branch 2 times, most recently from 1346d77 to f88e35a Compare September 3, 2025 20:17
@s-barannikov s-barannikov force-pushed the users/s.barannikov/decoder-operands-4-aarch64-tsb branch from d80acf2 to f8f5688 Compare September 3, 2025 20:17
@s-barannikov s-barannikov marked this pull request as ready for review September 3, 2025 21:27
@llvmbot
Copy link
Member

llvmbot commented Sep 3, 2025

@llvm/pr-subscribers-backend-aarch64

Author: Sergei Barannikov (s-barannikov)

Changes

TSB instruction has one operand, but the generated disassembler is unable to decode it since the operand is not encoded into the instruction. AArch64InstPrinter has a special case for this instruction.

With the changes proposed by #156358, the operand can now be decoded automatically and the workaround is no longer required.


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

3 Files Affected:

  • (modified) llvm/lib/Target/AArch64/AArch64SystemOperands.td (+1-1)
  • (modified) llvm/lib/Target/AArch64/CMakeLists.txt (+1-2)
  • (modified) llvm/lib/Target/AArch64/MCTargetDesc/AArch64InstPrinter.cpp (-7)
diff --git a/llvm/lib/Target/AArch64/AArch64SystemOperands.td b/llvm/lib/Target/AArch64/AArch64SystemOperands.td
index 1b0e90b0e0dc3..65b752ed40c90 100644
--- a/llvm/lib/Target/AArch64/AArch64SystemOperands.td
+++ b/llvm/lib/Target/AArch64/AArch64SystemOperands.td
@@ -362,7 +362,7 @@ def lookupTSBByName : SearchIndex {
   let Key = ["Name"];
 }
 
-def : TSB<"csync", 0>;
+def : TSB<"csync", 2>;
 
 //===----------------------------------------------------------------------===//
 // PRFM (prefetch) instruction options.
diff --git a/llvm/lib/Target/AArch64/CMakeLists.txt b/llvm/lib/Target/AArch64/CMakeLists.txt
index 833ce48ea1d7a..79b56ea9cf850 100644
--- a/llvm/lib/Target/AArch64/CMakeLists.txt
+++ b/llvm/lib/Target/AArch64/CMakeLists.txt
@@ -8,8 +8,7 @@ tablegen(LLVM AArch64GenAsmWriter1.inc -gen-asm-writer -asmwriternum=1)
 tablegen(LLVM AArch64GenCallingConv.inc -gen-callingconv)
 tablegen(LLVM AArch64GenDAGISel.inc -gen-dag-isel)
 tablegen(LLVM AArch64GenDisassemblerTables.inc -gen-disassembler
-              -ignore-non-decodable-operands
-              -ignore-fully-defined-operands)
+              -ignore-non-decodable-operands)
 tablegen(LLVM AArch64GenFastISel.inc -gen-fast-isel)
 tablegen(LLVM AArch64GenGlobalISel.inc -gen-global-isel)
 tablegen(LLVM AArch64GenO0PreLegalizeGICombiner.inc -gen-global-isel-combiner
diff --git a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64InstPrinter.cpp b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64InstPrinter.cpp
index 54b58e948daf2..2552ee3009338 100644
--- a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64InstPrinter.cpp
+++ b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64InstPrinter.cpp
@@ -365,13 +365,6 @@ void AArch64InstPrinter::printInst(const MCInst *MI, uint64_t Address,
     return;
   }
 
-  // Instruction TSB is specified as a one operand instruction, but 'csync' is
-  // not encoded, so for printing it is treated as a special case here:
-  if (Opcode == AArch64::TSB) {
-    O << "\ttsb\tcsync";
-    return;
-  }
-
   if (!PrintAliases || !printAliasInstr(MI, Address, STI, O))
     printInstruction(MI, Address, STI, O);
 

@s-barannikov s-barannikov force-pushed the users/s.barannikov/decoder-operands-4-aarch64-tsb branch from f8f5688 to 914f19d Compare September 4, 2025 13:37
@s-barannikov s-barannikov force-pushed the users/s.barannikov/decoder-operands-3-avr branch from f88e35a to 55e234b Compare September 4, 2025 13:37
@s-barannikov s-barannikov requested a review from MacDue September 4, 2025 14:10
@s-barannikov s-barannikov force-pushed the users/s.barannikov/decoder-operands-3-avr branch from 55e234b to ff4fc23 Compare September 4, 2025 14:14
@s-barannikov s-barannikov force-pushed the users/s.barannikov/decoder-operands-4-aarch64-tsb branch 2 times, most recently from 4789335 to a233e69 Compare September 4, 2025 14:59
@s-barannikov s-barannikov force-pushed the users/s.barannikov/decoder-operands-3-avr branch 2 times, most recently from e488057 to 15d65d9 Compare September 4, 2025 15:25
Base automatically changed from users/s.barannikov/decoder-operands-3-avr to main September 4, 2025 16:04
TSB instruction has one operand, but the generated disassembler didn't
decode this operand. AArch64InstPrinter had a workaround for this.

This instruction can now be disassembled correctly.
@s-barannikov s-barannikov force-pushed the users/s.barannikov/decoder-operands-4-aarch64-tsb branch from a233e69 to cefa6c8 Compare September 4, 2025 16:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants