Skip to content

Commit 9b5fa4e

Browse files
committed
fixup! Address Comments
Change-Id: I190e56d22e85e8ae5b07931840f879b3e8afb4fe
1 parent 5fce25e commit 9b5fa4e

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

llvm/utils/TableGen/CompressInstEmitter.cpp

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,10 @@ class CompressInstEmitter {
124124
const RecordKeeper &Records;
125125
const CodeGenTarget Target;
126126
std::vector<CompressPat> CompressPatterns;
127-
unsigned SourceLastTiedOp; // postion of the last tied operand in Source Inst
128127
void addDagOperandMapping(const Record *Rec, const DagInit *Dag,
129128
const CodeGenInstruction &Inst,
130-
IndexedMap<OpData> &OperandMap, bool IsSourceInst);
129+
IndexedMap<OpData> &OperandMap, bool IsSourceInst,
130+
unsigned *SourceLastTiedOpPtr);
131131
void evaluateCompressPat(const Record *Compress);
132132
void emitCompressInstEmitter(raw_ostream &OS, EmitterType EType);
133133
bool validateTypes(const Record *DagOpType, const Record *InstOpType,
@@ -144,7 +144,8 @@ class CompressInstEmitter {
144144
IndexedMap<OpData> &SourceOperandMap,
145145
IndexedMap<OpData> &DestOperandMap,
146146
StringMap<unsigned> &SourceOperands,
147-
const CodeGenInstruction &DestInst);
147+
const CodeGenInstruction &DestInst,
148+
unsigned SourceLastTiedOp);
148149

149150
public:
150151
CompressInstEmitter(const RecordKeeper &R) : Records(R), Target(R) {}
@@ -207,7 +208,8 @@ void CompressInstEmitter::addDagOperandMapping(const Record *Rec,
207208
const DagInit *Dag,
208209
const CodeGenInstruction &Inst,
209210
IndexedMap<OpData> &OperandMap,
210-
bool IsSourceInst) {
211+
bool IsSourceInst,
212+
unsigned *SourceLastTiedOpPtr) {
211213
unsigned NumMIOperands = 0;
212214
for (const auto &Op : Inst.Operands)
213215
NumMIOperands += Op.MINumOperands;
@@ -221,15 +223,15 @@ void CompressInstEmitter::addDagOperandMapping(const Record *Rec,
221223
unsigned TiedCount = 0;
222224
unsigned OpNo = 0;
223225
if (IsSourceInst)
224-
SourceLastTiedOp = std::numeric_limits<unsigned int>::max();
226+
*SourceLastTiedOpPtr = std::numeric_limits<unsigned int>::max();
225227
for (const auto &Opnd : Inst.Operands) {
226228
int TiedOpIdx = Opnd.getTiedRegister();
227229
if (-1 != TiedOpIdx) {
228230
// Set the entry in OperandMap for the tied operand we're skipping.
229231
OperandMap[OpNo].Kind = OperandMap[TiedOpIdx].Kind;
230232
OperandMap[OpNo].Data = OperandMap[TiedOpIdx].Data;
231233
if (IsSourceInst)
232-
SourceLastTiedOp = OpNo;
234+
*SourceLastTiedOpPtr = OpNo;
233235
++OpNo;
234236
++TiedCount;
235237
continue;
@@ -308,7 +310,7 @@ static bool verifyDagOpCount(const CodeGenInstruction &Inst, const DagInit *Dag,
308310
if (Dag->getNumArgs() == NumMIOperands)
309311
return true;
310312

311-
// Source instructions are non compressed instructions and have atmost one
313+
// Source instructions are non compressed instructions and have at most one
312314
// tied operand.
313315
if (IsSource && (SourceInstTiedOpCount >= 2))
314316
PrintFatalError(Inst.TheDef->getLoc(),
@@ -394,7 +396,8 @@ void CompressInstEmitter::createDagOperandMapping(
394396
void CompressInstEmitter::createInstOperandMapping(
395397
const Record *Rec, const DagInit *SourceDag, const DagInit *DestDag,
396398
IndexedMap<OpData> &SourceOperandMap, IndexedMap<OpData> &DestOperandMap,
397-
StringMap<unsigned> &SourceOperands, const CodeGenInstruction &DestInst) {
399+
StringMap<unsigned> &SourceOperands, const CodeGenInstruction &DestInst,
400+
unsigned SourceLastTiedOp) {
398401
// TiedCount keeps track of the number of operands skipped in Inst
399402
// operands list to get to the corresponding Dag operand.
400403
unsigned TiedCount = 0;
@@ -505,23 +508,25 @@ void CompressInstEmitter::evaluateCompressPat(const Record *Rec) {
505508
// Fill the mapping from the source to destination instructions.
506509

507510
IndexedMap<OpData> SourceOperandMap;
511+
unsigned SourceLastTiedOp; // postion of the last tied operand in Source Inst
508512
// Create a mapping between source Dag operands and source Inst operands.
509513
addDagOperandMapping(Rec, SourceDag, SourceInst, SourceOperandMap,
510-
/*IsSourceInst*/ true);
514+
/*IsSourceInst*/ true, &SourceLastTiedOp);
511515

512516
IndexedMap<OpData> DestOperandMap;
513517
// Create a mapping between destination Dag operands and destination Inst
514518
// operands.
515519
addDagOperandMapping(Rec, DestDag, DestInst, DestOperandMap,
516-
/*IsSourceInst*/ false);
520+
/*IsSourceInst*/ false, nullptr);
517521

518522
StringMap<unsigned> SourceOperands;
519523
StringMap<unsigned> DestOperands;
520524
createDagOperandMapping(Rec, SourceOperands, DestOperands, SourceDag, DestDag,
521525
SourceOperandMap);
522526
// Create operand mapping between the source and destination instructions.
523527
createInstOperandMapping(Rec, SourceDag, DestDag, SourceOperandMap,
524-
DestOperandMap, SourceOperands, DestInst);
528+
DestOperandMap, SourceOperands, DestInst,
529+
SourceLastTiedOp);
525530

526531
// Get the target features for the CompressPat.
527532
std::vector<const Record *> PatReqFeatures;

0 commit comments

Comments
 (0)