llvm.org GIT mirror llvm / 74ae925
[tablegen] Delete duplicates from a vector without skipping elements Tablegen's -gen-instr-info pass has a bug in its emitEnums() routine. The function intends for values in a vector to be deduplicated, but it accidentally skips over elements after performing a deletion. I think there are smarter ways of doing this deduplication, but we can do that in a follow-up commit if there's interest. See the thread: [PATCH] TableGen InstrMapping Bug fix. Patch by Tyler Kenney! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@288408 91177308-0d34-0410-b5e6-96231b3b80d8 Vedant Kumar 3 years ago
2 changed file(s) with 85 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
0 // RUN: llvm-tblgen -gen-instr-info -I %p/../../include %s | FileCheck %s
1
2 // CHECK: ABCForm_A
3 // CHECK-NOT: ABCForm_A
4
5 //
6 // include Target.td for InstrMapping class and define minimally required objects
7 //
8
9 include "llvm/Target/Target.td"
10
11 class DFVReg : Register {
12 let Namespace = "DFV";
13 }
14
15 def R0 : DFVReg<"r0">;
16 def DFVRegClass : RegisterClass<"DFV",[i32],0,(add R0)>;
17 def DFVInstrInfo : InstrInfo;
18
19 def DFVTest : Target {
20 let InstructionSet = DFVInstrInfo;
21 }
22
23 //
24 // Define a number of a InstrMappings with repeated ValueCol fields
25 //
26
27 class ABCRel;
28
29 def getAFormFromBForm : InstrMapping {
30 let FilterClass = "ABCRel";
31 let RowFields = ["BaseName"];
32 let ColFields = ["ABCForm"];
33 let KeyCol = ["B"];
34 let ValueCols = [["A"]];
35 }
36
37 def getAFormFromCForm : InstrMapping {
38 let FilterClass = "ABCRel";
39 let RowFields = ["BaseName"];
40 let ColFields = ["ABCForm"];
41 let KeyCol = ["C"];
42 let ValueCols = [["A"]];
43 }
44
45 def getAFormFromDForm : InstrMapping {
46 let FilterClass = "ABCRel";
47 let RowFields = ["BaseName"];
48 let ColFields = ["ABCForm"];
49 let KeyCol = ["D"];
50 let ValueCols = [["A"]];
51 }
52
53 def getAFormFromEForm : InstrMapping {
54 let FilterClass = "ABCRel";
55 let RowFields = ["BaseName"];
56 let ColFields = ["ABCForm"];
57 let KeyCol = ["E"];
58 let ValueCols = [["A"]];
59 }
60
61 class I : Instruction {
62 let Namespace = "DFV";
63 let OutOperandList = (outs);
64 let InOperandList = (ins);
65
66 string BaseName = "";
67 string ABCForm = "";
68 }
69
70 class isAForm { string ABCForm = "A"; }
71 class isBForm { string ABCForm = "B"; }
72 class isCForm { string ABCForm = "C"; }
73 class isDForm { string ABCForm = "D"; }
74 class isEForm { string ABCForm = "E"; }
75
76 let BaseName = "0" in {
77 def A0 : I, ABCRel, isAForm;
78 def B0 : I, ABCRel, isBForm;
79 def C0 : I, ABCRel, isCForm;
80 def D0 : I, ABCRel, isDForm;
81 def E0 : I, ABCRel, isEForm;
82 }
83
541541 for (unsigned j = i+1; j < FieldValues.size(); j++) {
542542 if (CurVal == FieldValues[j]) {
543543 FieldValues.erase(FieldValues.begin()+j);
544 --j;
544545 }
545546 }
546547 }