[llvm] 51f743d - TableGen: sort SearchableTable emission order by fields, not top-level name
Tim Northover via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 18 04:59:46 PST 2022
Author: Tim Northover
Date: 2022-01-18T12:59:41Z
New Revision: 51f743db08f3721fa955296fcef81cfd0c760c9b
URL: https://github.com/llvm/llvm-project/commit/51f743db08f3721fa955296fcef81cfd0c760c9b
DIFF: https://github.com/llvm/llvm-project/commit/51f743db08f3721fa955296fcef81cfd0c760c9b.diff
LOG: TableGen: sort SearchableTable emission order by fields, not top-level name
This is often used for anonymous definitions, so we were sorting by
"anonymous_1234" record names, which while less bad than pointers can be easily
perturbed by adding code even in completely unrelated systems. That causes test
failures on AArch64 when sysregs with multiple valid names suddenly start
printing a different one.
Added:
Modified:
llvm/test/MC/AArch64/armv8r-sysreg.s
llvm/utils/TableGen/SearchableTableEmitter.cpp
Removed:
################################################################################
diff --git a/llvm/test/MC/AArch64/armv8r-sysreg.s b/llvm/test/MC/AArch64/armv8r-sysreg.s
index 8d0fcb4a45e38..7de43b7c2e848 100644
--- a/llvm/test/MC/AArch64/armv8r-sysreg.s
+++ b/llvm/test/MC/AArch64/armv8r-sysreg.s
@@ -310,11 +310,11 @@ msr CONTEXTIDR_EL2, x0
# CHECK-NEXT: mrs x0, PRENR_EL2 // encoding: [0x20,0x61,0x3c,0xd5]
# CHECK-NEXT: mrs x0, PRSELR_EL1 // encoding: [0x20,0x62,0x38,0xd5]
# CHECK-NEXT: mrs x0, PRSELR_EL2 // encoding: [0x20,0x62,0x3c,0xd5]
-# CHECK-NEXT: mrs x0, PRBAR_EL1 // encoding: [0x00,0x68,0x38,0xd5]
-# CHECK-NEXT: mrs x0, PRBAR_EL2 // encoding: [0x00,0x68,0x3c,0xd5]
-# CHECK-NEXT: mrs x0, PRLAR_EL1 // encoding: [0x20,0x68,0x38,0xd5]
-# CHECK-NEXT: mrs x0, {{PRLAR[0]?_EL2}} // encoding: [0x20,0x68,0x3c,0xd5]
-# CHECK-NEXT: mrs x0, PRBAR_EL1 // encoding: [0x00,0x68,0x38,0xd5]
+# CHECK-NEXT: mrs x0, PRBAR0_EL1 // encoding: [0x00,0x68,0x38,0xd5]
+# CHECK-NEXT: mrs x0, PRBAR0_EL2 // encoding: [0x00,0x68,0x3c,0xd5]
+# CHECK-NEXT: mrs x0, PRLAR0_EL1 // encoding: [0x20,0x68,0x38,0xd5]
+# CHECK-NEXT: mrs x0, PRLAR0_EL2 // encoding: [0x20,0x68,0x3c,0xd5]
+# CHECK-NEXT: mrs x0, PRBAR0_EL1 // encoding: [0x00,0x68,0x38,0xd5]
# CHECK-NEXT: mrs x0, PRBAR1_EL1 // encoding: [0x80,0x68,0x38,0xd5]
# CHECK-NEXT: mrs x0, PRBAR2_EL1 // encoding: [0x00,0x69,0x38,0xd5]
# CHECK-NEXT: mrs x0, PRBAR3_EL1 // encoding: [0x80,0x69,0x38,0xd5]
@@ -330,7 +330,7 @@ msr CONTEXTIDR_EL2, x0
# CHECK-NEXT: mrs x0, PRBAR13_EL1 // encoding: [0x80,0x6e,0x38,0xd5]
# CHECK-NEXT: mrs x0, PRBAR14_EL1 // encoding: [0x00,0x6f,0x38,0xd5]
# CHECK-NEXT: mrs x0, PRBAR15_EL1 // encoding: [0x80,0x6f,0x38,0xd5]
-# CHECK-NEXT: mrs x0, PRLAR_EL1 // encoding: [0x20,0x68,0x38,0xd5]
+# CHECK-NEXT: mrs x0, PRLAR0_EL1 // encoding: [0x20,0x68,0x38,0xd5]
# CHECK-NEXT: mrs x0, PRLAR1_EL1 // encoding: [0xa0,0x68,0x38,0xd5]
# CHECK-NEXT: mrs x0, PRLAR2_EL1 // encoding: [0x20,0x69,0x38,0xd5]
# CHECK-NEXT: mrs x0, PRLAR3_EL1 // encoding: [0xa0,0x69,0x38,0xd5]
@@ -346,7 +346,7 @@ msr CONTEXTIDR_EL2, x0
# CHECK-NEXT: mrs x0, PRLAR13_EL1 // encoding: [0xa0,0x6e,0x38,0xd5]
# CHECK-NEXT: mrs x0, PRLAR14_EL1 // encoding: [0x20,0x6f,0x38,0xd5]
# CHECK-NEXT: mrs x0, PRLAR15_EL1 // encoding: [0xa0,0x6f,0x38,0xd5]
-# CHECK-NEXT: mrs x0, PRBAR_EL2 // encoding: [0x00,0x68,0x3c,0xd5]
+# CHECK-NEXT: mrs x0, PRBAR0_EL2 // encoding: [0x00,0x68,0x3c,0xd5]
# CHECK-NEXT: mrs x0, PRBAR1_EL2 // encoding: [0x80,0x68,0x3c,0xd5]
# CHECK-NEXT: mrs x0, PRBAR2_EL2 // encoding: [0x00,0x69,0x3c,0xd5]
# CHECK-NEXT: mrs x0, PRBAR3_EL2 // encoding: [0x80,0x69,0x3c,0xd5]
@@ -362,7 +362,7 @@ msr CONTEXTIDR_EL2, x0
# CHECK-NEXT: mrs x0, PRBAR13_EL2 // encoding: [0x80,0x6e,0x3c,0xd5]
# CHECK-NEXT: mrs x0, PRBAR14_EL2 // encoding: [0x00,0x6f,0x3c,0xd5]
# CHECK-NEXT: mrs x0, PRBAR15_EL2 // encoding: [0x80,0x6f,0x3c,0xd5]
-# CHECK-NEXT: mrs x0, {{PRLAR[0]?_EL2}} // encoding: [0x20,0x68,0x3c,0xd5]
+# CHECK-NEXT: mrs x0, PRLAR0_EL2 // encoding: [0x20,0x68,0x3c,0xd5]
# CHECK-NEXT: mrs x0, PRLAR1_EL2 // encoding: [0xa0,0x68,0x3c,0xd5]
# CHECK-NEXT: mrs x0, PRLAR2_EL2 // encoding: [0x20,0x69,0x3c,0xd5]
# CHECK-NEXT: mrs x0, PRLAR3_EL2 // encoding: [0xa0,0x69,0x3c,0xd5]
@@ -385,11 +385,11 @@ msr CONTEXTIDR_EL2, x0
# CHECK-NEXT: mrs x30, PRENR_EL2 // encoding: [0x3e,0x61,0x3c,0xd5]
# CHECK-NEXT: mrs x30, PRSELR_EL1 // encoding: [0x3e,0x62,0x38,0xd5]
# CHECK-NEXT: mrs x30, PRSELR_EL2 // encoding: [0x3e,0x62,0x3c,0xd5]
-# CHECK-NEXT: mrs x30, PRBAR_EL1 // encoding: [0x1e,0x68,0x38,0xd5]
-# CHECK-NEXT: mrs x30, PRBAR_EL2 // encoding: [0x1e,0x68,0x3c,0xd5]
-# CHECK-NEXT: mrs x30, PRLAR_EL1 // encoding: [0x3e,0x68,0x38,0xd5]
-# CHECK-NEXT: mrs x30, {{PRLAR[0]?_EL2}} // encoding: [0x3e,0x68,0x3c,0xd5]
-# CHECK-NEXT: mrs x30, PRBAR_EL1 // encoding: [0x1e,0x68,0x38,0xd5]
+# CHECK-NEXT: mrs x30, PRBAR0_EL1 // encoding: [0x1e,0x68,0x38,0xd5]
+# CHECK-NEXT: mrs x30, PRBAR0_EL2 // encoding: [0x1e,0x68,0x3c,0xd5]
+# CHECK-NEXT: mrs x30, PRLAR0_EL1 // encoding: [0x3e,0x68,0x38,0xd5]
+# CHECK-NEXT: mrs x30, PRLAR0_EL2 // encoding: [0x3e,0x68,0x3c,0xd5]
+# CHECK-NEXT: mrs x30, PRBAR0_EL1 // encoding: [0x1e,0x68,0x38,0xd5]
# CHECK-NEXT: mrs x30, PRBAR1_EL1 // encoding: [0x9e,0x68,0x38,0xd5]
# CHECK-NEXT: mrs x30, PRBAR2_EL1 // encoding: [0x1e,0x69,0x38,0xd5]
# CHECK-NEXT: mrs x30, PRBAR3_EL1 // encoding: [0x9e,0x69,0x38,0xd5]
@@ -405,7 +405,7 @@ msr CONTEXTIDR_EL2, x0
# CHECK-NEXT: mrs x30, PRBAR13_EL1 // encoding: [0x9e,0x6e,0x38,0xd5]
# CHECK-NEXT: mrs x30, PRBAR14_EL1 // encoding: [0x1e,0x6f,0x38,0xd5]
# CHECK-NEXT: mrs x30, PRBAR15_EL1 // encoding: [0x9e,0x6f,0x38,0xd5]
-# CHECK-NEXT: mrs x30, PRLAR_EL1 // encoding: [0x3e,0x68,0x38,0xd5]
+# CHECK-NEXT: mrs x30, PRLAR0_EL1 // encoding: [0x3e,0x68,0x38,0xd5]
# CHECK-NEXT: mrs x30, PRLAR1_EL1 // encoding: [0xbe,0x68,0x38,0xd5]
# CHECK-NEXT: mrs x30, PRLAR2_EL1 // encoding: [0x3e,0x69,0x38,0xd5]
# CHECK-NEXT: mrs x30, PRLAR3_EL1 // encoding: [0xbe,0x69,0x38,0xd5]
@@ -421,7 +421,7 @@ msr CONTEXTIDR_EL2, x0
# CHECK-NEXT: mrs x30, PRLAR13_EL1 // encoding: [0xbe,0x6e,0x38,0xd5]
# CHECK-NEXT: mrs x30, PRLAR14_EL1 // encoding: [0x3e,0x6f,0x38,0xd5]
# CHECK-NEXT: mrs x30, PRLAR15_EL1 // encoding: [0xbe,0x6f,0x38,0xd5]
-# CHECK-NEXT: mrs x30, PRBAR_EL2 // encoding: [0x1e,0x68,0x3c,0xd5]
+# CHECK-NEXT: mrs x30, PRBAR0_EL2 // encoding: [0x1e,0x68,0x3c,0xd5]
# CHECK-NEXT: mrs x30, PRBAR1_EL2 // encoding: [0x9e,0x68,0x3c,0xd5]
# CHECK-NEXT: mrs x30, PRBAR2_EL2 // encoding: [0x1e,0x69,0x3c,0xd5]
# CHECK-NEXT: mrs x30, PRBAR3_EL2 // encoding: [0x9e,0x69,0x3c,0xd5]
@@ -437,7 +437,7 @@ msr CONTEXTIDR_EL2, x0
# CHECK-NEXT: mrs x30, PRBAR13_EL2 // encoding: [0x9e,0x6e,0x3c,0xd5]
# CHECK-NEXT: mrs x30, PRBAR14_EL2 // encoding: [0x1e,0x6f,0x3c,0xd5]
# CHECK-NEXT: mrs x30, PRBAR15_EL2 // encoding: [0x9e,0x6f,0x3c,0xd5]
-# CHECK-NEXT: mrs x30, {{PRLAR[0]?_EL2}} // encoding: [0x3e,0x68,0x3c,0xd5]
+# CHECK-NEXT: mrs x30, PRLAR0_EL2 // encoding: [0x3e,0x68,0x3c,0xd5]
# CHECK-NEXT: mrs x30, PRLAR1_EL2 // encoding: [0xbe,0x68,0x3c,0xd5]
# CHECK-NEXT: mrs x30, PRLAR2_EL2 // encoding: [0x3e,0x69,0x3c,0xd5]
# CHECK-NEXT: mrs x30, PRLAR3_EL2 // encoding: [0xbe,0x69,0x3c,0xd5]
@@ -460,11 +460,11 @@ msr CONTEXTIDR_EL2, x0
# CHECK-NEXT: msr PRENR_EL2, x0 // encoding: [0x20,0x61,0x1c,0xd5]
# CHECK-NEXT: msr PRSELR_EL1, x0 // encoding: [0x20,0x62,0x18,0xd5]
# CHECK-NEXT: msr PRSELR_EL2, x0 // encoding: [0x20,0x62,0x1c,0xd5]
-# CHECK-NEXT: msr PRBAR_EL1, x0 // encoding: [0x00,0x68,0x18,0xd5]
-# CHECK-NEXT: msr PRBAR_EL2, x0 // encoding: [0x00,0x68,0x1c,0xd5]
-# CHECK-NEXT: msr PRLAR_EL1, x0 // encoding: [0x20,0x68,0x18,0xd5]
-# CHECK-NEXT: msr {{PRLAR[0]?_EL2}}, x0 // encoding: [0x20,0x68,0x1c,0xd5]
-# CHECK-NEXT: msr PRBAR_EL1, x0 // encoding: [0x00,0x68,0x18,0xd5]
+# CHECK-NEXT: msr PRBAR0_EL1, x0 // encoding: [0x00,0x68,0x18,0xd5]
+# CHECK-NEXT: msr PRBAR0_EL2, x0 // encoding: [0x00,0x68,0x1c,0xd5]
+# CHECK-NEXT: msr PRLAR0_EL1, x0 // encoding: [0x20,0x68,0x18,0xd5]
+# CHECK-NEXT: msr PRLAR0_EL2, x0 // encoding: [0x20,0x68,0x1c,0xd5]
+# CHECK-NEXT: msr PRBAR0_EL1, x0 // encoding: [0x00,0x68,0x18,0xd5]
# CHECK-NEXT: msr PRBAR1_EL1, x0 // encoding: [0x80,0x68,0x18,0xd5]
# CHECK-NEXT: msr PRBAR2_EL1, x0 // encoding: [0x00,0x69,0x18,0xd5]
# CHECK-NEXT: msr PRBAR3_EL1, x0 // encoding: [0x80,0x69,0x18,0xd5]
@@ -480,7 +480,7 @@ msr CONTEXTIDR_EL2, x0
# CHECK-NEXT: msr PRBAR13_EL1, x0 // encoding: [0x80,0x6e,0x18,0xd5]
# CHECK-NEXT: msr PRBAR14_EL1, x0 // encoding: [0x00,0x6f,0x18,0xd5]
# CHECK-NEXT: msr PRBAR15_EL1, x0 // encoding: [0x80,0x6f,0x18,0xd5]
-# CHECK-NEXT: msr PRLAR_EL1, x0 // encoding: [0x20,0x68,0x18,0xd5]
+# CHECK-NEXT: msr PRLAR0_EL1, x0 // encoding: [0x20,0x68,0x18,0xd5]
# CHECK-NEXT: msr PRLAR1_EL1, x0 // encoding: [0xa0,0x68,0x18,0xd5]
# CHECK-NEXT: msr PRLAR2_EL1, x0 // encoding: [0x20,0x69,0x18,0xd5]
# CHECK-NEXT: msr PRLAR3_EL1, x0 // encoding: [0xa0,0x69,0x18,0xd5]
@@ -496,7 +496,7 @@ msr CONTEXTIDR_EL2, x0
# CHECK-NEXT: msr PRLAR13_EL1, x0 // encoding: [0xa0,0x6e,0x18,0xd5]
# CHECK-NEXT: msr PRLAR14_EL1, x0 // encoding: [0x20,0x6f,0x18,0xd5]
# CHECK-NEXT: msr PRLAR15_EL1, x0 // encoding: [0xa0,0x6f,0x18,0xd5]
-# CHECK-NEXT: msr PRBAR_EL2, x0 // encoding: [0x00,0x68,0x1c,0xd5]
+# CHECK-NEXT: msr PRBAR0_EL2, x0 // encoding: [0x00,0x68,0x1c,0xd5]
# CHECK-NEXT: msr PRBAR1_EL2, x0 // encoding: [0x80,0x68,0x1c,0xd5]
# CHECK-NEXT: msr PRBAR2_EL2, x0 // encoding: [0x00,0x69,0x1c,0xd5]
# CHECK-NEXT: msr PRBAR3_EL2, x0 // encoding: [0x80,0x69,0x1c,0xd5]
@@ -512,7 +512,7 @@ msr CONTEXTIDR_EL2, x0
# CHECK-NEXT: msr PRBAR13_EL2, x0 // encoding: [0x80,0x6e,0x1c,0xd5]
# CHECK-NEXT: msr PRBAR14_EL2, x0 // encoding: [0x00,0x6f,0x1c,0xd5]
# CHECK-NEXT: msr PRBAR15_EL2, x0 // encoding: [0x80,0x6f,0x1c,0xd5]
-# CHECK-NEXT: msr {{PRLAR[0]?_EL2}}, x0 // encoding: [0x20,0x68,0x1c,0xd5]
+# CHECK-NEXT: msr PRLAR0_EL2, x0 // encoding: [0x20,0x68,0x1c,0xd5]
# CHECK-NEXT: msr PRLAR1_EL2, x0 // encoding: [0xa0,0x68,0x1c,0xd5]
# CHECK-NEXT: msr PRLAR2_EL2, x0 // encoding: [0x20,0x69,0x1c,0xd5]
# CHECK-NEXT: msr PRLAR3_EL2, x0 // encoding: [0xa0,0x69,0x1c,0xd5]
@@ -535,11 +535,11 @@ msr CONTEXTIDR_EL2, x0
# CHECK-NEXT: msr PRENR_EL2, x30 // encoding: [0x3e,0x61,0x1c,0xd5]
# CHECK-NEXT: msr PRSELR_EL1, x30 // encoding: [0x3e,0x62,0x18,0xd5]
# CHECK-NEXT: msr PRSELR_EL2, x30 // encoding: [0x3e,0x62,0x1c,0xd5]
-# CHECK-NEXT: msr PRBAR_EL1, x30 // encoding: [0x1e,0x68,0x18,0xd5]
-# CHECK-NEXT: msr PRBAR_EL2, x30 // encoding: [0x1e,0x68,0x1c,0xd5]
-# CHECK-NEXT: msr PRLAR_EL1, x30 // encoding: [0x3e,0x68,0x18,0xd5]
-# CHECK-NEXT: msr {{PRLAR[0]?_EL2}}, x30 // encoding: [0x3e,0x68,0x1c,0xd5]
-# CHECK-NEXT: msr PRBAR_EL1, x30 // encoding: [0x1e,0x68,0x18,0xd5]
+# CHECK-NEXT: msr PRBAR0_EL1, x30 // encoding: [0x1e,0x68,0x18,0xd5]
+# CHECK-NEXT: msr PRBAR0_EL2, x30 // encoding: [0x1e,0x68,0x1c,0xd5]
+# CHECK-NEXT: msr PRLAR0_EL1, x30 // encoding: [0x3e,0x68,0x18,0xd5]
+# CHECK-NEXT: msr PRLAR0_EL2, x30 // encoding: [0x3e,0x68,0x1c,0xd5]
+# CHECK-NEXT: msr PRBAR0_EL1, x30 // encoding: [0x1e,0x68,0x18,0xd5]
# CHECK-NEXT: msr PRBAR1_EL1, x30 // encoding: [0x9e,0x68,0x18,0xd5]
# CHECK-NEXT: msr PRBAR2_EL1, x30 // encoding: [0x1e,0x69,0x18,0xd5]
# CHECK-NEXT: msr PRBAR3_EL1, x30 // encoding: [0x9e,0x69,0x18,0xd5]
@@ -555,7 +555,7 @@ msr CONTEXTIDR_EL2, x0
# CHECK-NEXT: msr PRBAR13_EL1, x30 // encoding: [0x9e,0x6e,0x18,0xd5]
# CHECK-NEXT: msr PRBAR14_EL1, x30 // encoding: [0x1e,0x6f,0x18,0xd5]
# CHECK-NEXT: msr PRBAR15_EL1, x30 // encoding: [0x9e,0x6f,0x18,0xd5]
-# CHECK-NEXT: msr PRLAR_EL1, x30 // encoding: [0x3e,0x68,0x18,0xd5]
+# CHECK-NEXT: msr PRLAR0_EL1, x30 // encoding: [0x3e,0x68,0x18,0xd5]
# CHECK-NEXT: msr PRLAR1_EL1, x30 // encoding: [0xbe,0x68,0x18,0xd5]
# CHECK-NEXT: msr PRLAR2_EL1, x30 // encoding: [0x3e,0x69,0x18,0xd5]
# CHECK-NEXT: msr PRLAR3_EL1, x30 // encoding: [0xbe,0x69,0x18,0xd5]
@@ -571,7 +571,7 @@ msr CONTEXTIDR_EL2, x0
# CHECK-NEXT: msr PRLAR13_EL1, x30 // encoding: [0xbe,0x6e,0x18,0xd5]
# CHECK-NEXT: msr PRLAR14_EL1, x30 // encoding: [0x3e,0x6f,0x18,0xd5]
# CHECK-NEXT: msr PRLAR15_EL1, x30 // encoding: [0xbe,0x6f,0x18,0xd5]
-# CHECK-NEXT: msr PRBAR_EL2, x30 // encoding: [0x1e,0x68,0x1c,0xd5]
+# CHECK-NEXT: msr PRBAR0_EL2, x30 // encoding: [0x1e,0x68,0x1c,0xd5]
# CHECK-NEXT: msr PRBAR1_EL2, x30 // encoding: [0x9e,0x68,0x1c,0xd5]
# CHECK-NEXT: msr PRBAR2_EL2, x30 // encoding: [0x1e,0x69,0x1c,0xd5]
# CHECK-NEXT: msr PRBAR3_EL2, x30 // encoding: [0x9e,0x69,0x1c,0xd5]
@@ -587,7 +587,7 @@ msr CONTEXTIDR_EL2, x0
# CHECK-NEXT: msr PRBAR13_EL2, x30 // encoding: [0x9e,0x6e,0x1c,0xd5]
# CHECK-NEXT: msr PRBAR14_EL2, x30 // encoding: [0x1e,0x6f,0x1c,0xd5]
# CHECK-NEXT: msr PRBAR15_EL2, x30 // encoding: [0x9e,0x6f,0x1c,0xd5]
-# CHECK-NEXT: msr {{PRLAR[0]?_EL2}}, x30 // encoding: [0x3e,0x68,0x1c,0xd5]
+# CHECK-NEXT: msr PRLAR0_EL2, x30 // encoding: [0x3e,0x68,0x1c,0xd5]
# CHECK-NEXT: msr PRLAR1_EL2, x30 // encoding: [0xbe,0x68,0x1c,0xd5]
# CHECK-NEXT: msr PRLAR2_EL2, x30 // encoding: [0x3e,0x69,0x1c,0xd5]
# CHECK-NEXT: msr PRLAR3_EL2, x30 // encoding: [0xbe,0x69,0x1c,0xd5]
diff --git a/llvm/utils/TableGen/SearchableTableEmitter.cpp b/llvm/utils/TableGen/SearchableTableEmitter.cpp
index 7803848aafc4c..327b90d59db62 100644
--- a/llvm/utils/TableGen/SearchableTableEmitter.cpp
+++ b/llvm/utils/TableGen/SearchableTableEmitter.cpp
@@ -649,6 +649,12 @@ void SearchableTableEmitter::collectTableEntries(
Field.IsInstruction = true;
}
}
+
+ SearchIndex Idx;
+ std::copy(Table.Fields.begin(), Table.Fields.end(),
+ std::back_inserter(Idx.Fields));
+ std::sort(Table.Entries.begin(), Table.Entries.end(),
+ [&](Record *LHS, Record *RHS) { return compareBy(LHS, RHS, Idx); });
}
void SearchableTableEmitter::run(raw_ostream &OS) {
More information about the llvm-commits
mailing list