@@ -73,15 +73,14 @@ void X86CompressEVEXTablesEmitter::printTable(const std::vector<Entry> &Table,
73
73
OS << " };\n\n " ;
74
74
}
75
75
76
- // Return true if the 2 BitsInits are equal
77
- // Calculates the integer value residing BitsInit object
78
- static inline uint64_t getValueFromBitsInit (const BitsInit *B) {
79
- uint64_t Value = 0 ;
80
- for (unsigned i = 0 , e = B->getNumBits (); i != e; ++i) {
81
- if (BitInit *Bit = dyn_cast<BitInit>(B->getBit (i)))
82
- Value |= uint64_t (Bit->getValue ()) << i;
83
- else
84
- PrintFatalError (" Invalid VectSize bit" );
76
+ static uint8_t byteFromBitsInit (const BitsInit *B) {
77
+ unsigned N = B->getNumBits ();
78
+ assert (N <= 8 && " Field is too large for uint8_t!" );
79
+
80
+ uint8_t Value = 0 ;
81
+ for (unsigned I = 0 ; I != N; ++I) {
82
+ BitInit *Bit = cast<BitInit>(B->getBit (I));
83
+ Value |= Bit->getValue () << I;
85
84
}
86
85
return Value;
87
86
}
@@ -105,30 +104,23 @@ class IsMatch {
105
104
NewRI.Form ))
106
105
return false ;
107
106
108
- // This is needed for instructions with intrinsic version (_Int).
109
- // Where the only difference is the size of the operands.
110
- // For example: VUCOMISDZrm and Int_VUCOMISDrm
111
- // Also for instructions that their EVEX version was upgraded to work with
112
- // k-registers. For example VPCMPEQBrm (xmm output register) and
113
- // VPCMPEQBZ128rm (k register output register).
114
- for (unsigned i = 0 , e = OldInst->Operands .size (); i < e; i++) {
115
- Record *OpRec1 = OldInst->Operands [i].Rec ;
116
- Record *OpRec2 = NewInst->Operands [i].Rec ;
117
-
118
- if (OpRec1 == OpRec2)
107
+ for (unsigned I = 0 , E = OldInst->Operands .size (); I < E; ++I) {
108
+ Record *OldOpRec = OldInst->Operands [I].Rec ;
109
+ Record *NewOpRec = NewInst->Operands [I].Rec ;
110
+
111
+ if (OldOpRec == NewOpRec)
119
112
continue ;
120
113
121
- if (isRegisterOperand (OpRec1) && isRegisterOperand (OpRec2)) {
122
- if (getRegOperandSize (OpRec1) != getRegOperandSize (OpRec2))
114
+ if (isRegisterOperand (OldOpRec) && isRegisterOperand (NewOpRec)) {
115
+ if (getRegOperandSize (OldOpRec) != getRegOperandSize (NewOpRec))
116
+ return false ;
117
+ } else if (isMemoryOperand (OldOpRec) && isMemoryOperand (NewOpRec)) {
118
+ if (getMemOperandSize (OldOpRec) != getMemOperandSize (NewOpRec))
123
119
return false ;
124
- } else if (isMemoryOperand (OpRec1) && isMemoryOperand (OpRec2)) {
125
- return false ;
126
- } else if (isImmediateOperand (OpRec1) && isImmediateOperand (OpRec2)) {
127
- if (OpRec1->getValueAsDef (" Type" ) != OpRec2->getValueAsDef (" Type" )) {
120
+ } else if (isImmediateOperand (OldOpRec) && isImmediateOperand (NewOpRec)) {
121
+ if (OldOpRec->getValueAsDef (" Type" ) != NewOpRec->getValueAsDef (" Type" ))
128
122
return false ;
129
- }
130
- } else
131
- return false ;
123
+ }
132
124
}
133
125
134
126
return true ;
@@ -164,8 +156,8 @@ void X86CompressEVEXTablesEmitter::run(raw_ostream &OS) {
164
156
165
157
for (const CodeGenInstruction *Inst : PreCompressionInsts) {
166
158
const Record *Rec = Inst->TheDef ;
167
- uint64_t Opcode =
168
- getValueFromBitsInit (Inst->TheDef ->getValueAsBitsInit (" Opcode" ));
159
+ uint8_t Opcode =
160
+ byteFromBitsInit (Inst->TheDef ->getValueAsBitsInit (" Opcode" ));
169
161
const CodeGenInstruction *NewInst = nullptr ;
170
162
if (ManualMap.find (Rec->getName ()) != ManualMap.end ()) {
171
163
Record *NewRec = Records.getDef (ManualMap.at (Rec->getName ()));
0 commit comments