This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[COMMITTED][AArch64] Fix the bit pattern order in the comments in auto-generated file


Laurent Desnogues reported a AArch64 GAS assembler issue in the auto-generated
file.
The bit pattern comment in "aarch64_opcode_lookup_1" is reversed. This patch fixed this, the change in the comment is something like the
following:

@@ -38,7 +38,7 @@ aarch64_opcode_lookup_1 (uint32_t word)
                     {
                       /* 33222222222211111111110000000000
                          10987654321098765432109876543210
-                         xxxxxxxxxxxxxxxxxxxxxxxx0000xxx0
+                         0xxx0000xxxxxxxxxxxxxxxxxxxxxxxx
                          adr.  */

The generated file is not included in the attached patch as it boost the patch
size.

Build under --enable-maintainer-mode OK. Eyeballed to make sure there is only
comments change in aarch64-dis-2.c, also a quick cross as/ld check OK.
opcodes/
2017-07-24  Laurent Desnogues <laurent.desnogues@arm.com>
            Jiong Wang  <jiong.wang@arm.com>
* aarch64-gen.c (print_decision_tree_1): Reverse the index of PATTERN to
        correct the print.
        * aarch64-dis-2.c: Regenerated.

diff --git a/opcodes/aarch64-gen.c b/opcodes/aarch64-gen.c
index d2685dc..229da21 100644
--- a/opcodes/aarch64-gen.c
+++ b/opcodes/aarch64-gen.c
@@ -393,6 +393,9 @@ print_decision_tree_1 (unsigned int indent, struct bittree* bittree)
 {
   /* PATTERN is only used to generate comment in the code.  */
   static char pattern[33] = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
+  /* Low bits in PATTERN will be printed first which then look as the high
+     bits in comment.  We need to reverse the index to get correct print.  */
+  unsigned int msb = sizeof (pattern) - 2;
   assert (bittree != NULL);
 
   /* Leaf node located.  */
@@ -412,15 +415,15 @@ print_decision_tree_1 (unsigned int indent, struct bittree* bittree)
   /* Walk down the decoder tree.  */
   indented_print (indent, "if (((word >> %d) & 0x1) == 0)\n", bittree->bitno);
   indented_print (indent, "  {\n");
-  pattern[bittree->bitno] = '0';
+  pattern[msb - bittree->bitno] = '0';
   print_decision_tree_1 (indent + 4, bittree->bits[0]);
   indented_print (indent, "  }\n");
   indented_print (indent, "else\n");
   indented_print (indent, "  {\n");
-  pattern[bittree->bitno] = '1';
+  pattern[msb - bittree->bitno] = '1';
   print_decision_tree_1 (indent + 4, bittree->bits[1]);
   indented_print (indent, "  }\n");
-  pattern[bittree->bitno] = 'x';
+  pattern[msb - bittree->bitno] = 'x';
 }
 
 /* Generate aarch64_opcode_lookup in C code to the standard output.  */

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]