[llvm] [Xtensa] Implement Code Density Option. (PR #119639)

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 18 23:38:42 PST 2024


================
@@ -0,0 +1,64 @@
+# RUN: llvm-mc -triple=xtensa -mattr=+density -disassemble < %s | FileCheck -check-prefixes=CHECK-DENSITY %s
+# RUN: llvm-mc -triple=xtensa -disassemble %s &> %t
+# RUN: FileCheck -check-prefixes=CHECK-CORE < %t %s
+
+#------------------------------------------------------------------------------
+# Verify that binary code is correctly disassembled with
+# code density option enabled. Also verify that dissasembling without
+# density option generates warnings.
+#------------------------------------------------------------------------------
+
+0x4a 0x23
+# CHECK-DENSITY: add.n  a2, a3, a4
+# CHECK-CORE: [[#@LINE-2]]:1: warning: invalid instruction encoding
----------------
MaskRay wrote:

The test fails at HEAD. It's recommended to use `[0x4a 0x23]` so that llvm-mc will disassemble the bytes as a whole and not fallback (skip one byte and continue disassembling), leading to weird diagnostics.

You could utilize the recent `--hex` so that you can do `[4a23]`

For llvm-mc, `s/< %s/%s/`

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


More information about the llvm-commits mailing list