llvm.org GIT mirror llvm / f64f9a4
Remove the isTwoAddress property from the CodeGenInstruction class. It should not be used for anything other than backwards compat constraint handling. Add support for a new DisableEncoding property which contains a list of registers that should not be encoded by the generated code emitter. Convert the codeemitter generator to use this, fixing some PPC JIT regressions. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31769 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 14 years ago
4 changed file(s) with 53 addition(s) and 19 deletion(s). Raw diff Collapse all Expand all
219219 unsigned OpNo = CGI.getOperandNamed(VarName);
220220 CodeGenInstruction::OperandInfo OpInfo = CGI.OperandList[OpNo];
221221
222 // If this is a two-address instruction, verify the second operand isn't
223 // used.
224 unsigned MIOp = OpInfo.MIOperandNo;
225 if (CGI.isTwoAddress && MIOp == 1)
226 throw "Should refer to operand #0 instead of #1 for two-address"
227 " instruction '" + CGI.TheDef->getName() + "'!";
228
229 if (CurVariant == Variant || CurVariant == ~0U)
222 if (CurVariant == Variant || CurVariant == ~0U) {
223 unsigned MIOp = OpInfo.MIOperandNo;
230224 Operands.push_back(AsmWriterOperand(OpInfo.PrinterMethodName, MIOp,
231225 Modifier));
226 }
232227 }
233228 LastEmitted = VarEnd;
234229 }
124124
125125 BitsInit *BI = R->getValueAsBitsInit("Inst");
126126 const std::vector &Vals = R->getValues();
127
127 CodeGenInstruction &CGI = Target.getInstruction(InstName);
128
128129 // Loop over all of the fields in the instruction, determining which are the
129130 // operands to the instruction.
130131 unsigned op = 0;
153154 }
154155
155156 if (!gotOp) {
157 /// If this operand is not supposed to be emitted by the generated
158 /// emitter, skip it.
159 while (CGI.isFlatOperandNotEmitted(op))
160 ++op;
161
156162 Case += " // op: " + VarName + "\n"
157163 + " op = getMachineOpValue(MI, MI.getOperand("
158 + utostr(op++)
159 + "));\n";
164 + utostr(op++) + "));\n";
160165 gotOp = true;
161
162 // If this is a two-address instruction and we just got the dest
163 // op, skip the src op.
164 if (op == 1 && Target.getInstruction(InstName).isTwoAddress)
165 ++op;
166166 }
167167
168168 unsigned opMask = (1 << N) - 1;
184184 }
185185 }
186186
187 std::vector &InstList = CaseMap[Case];
187 std::vector &InstList = CaseMap[Case];
188188 InstList.push_back(InstName);
189189 }
190190
5656 unsigned MIOperandNo;
5757 unsigned MINumOperands; // The number of operands.
5858
59 /// DoNotEncode - Bools are set to true in this vector for each operand in
60 /// the DisableEncoding list. These should not be emitted by the code
61 /// emitter.
62 std::vector DoNotEncode;
63
5964 /// MIOperandInfo - Default MI operand type. Note an operand may be made
6065 /// up of multiple MI operands.
6166 DagInit *MIOperandInfo;
8186 bool isCall;
8287 bool isLoad;
8388 bool isStore;
84 bool isTwoAddress;
8589 bool isPredicated;
8690 bool isConvertibleToThreeAddress;
8791 bool isCommutable;
106110 return OperandList[Op.first].MIOperandNo + Op.second;
107111 }
108112
113 /// getSubOperandNumber - Unflatten a operand number into an
114 /// operand/suboperand pair.
115 std::pair getSubOperandNumber(unsigned Op) const {
116 for (unsigned i = 0; ; ++i) {
117 assert(i < OperandList.size() && "Invalid flat operand #");
118 if (OperandList[i].MIOperandNo+OperandList[i].MINumOperands > Op)
119 return std::make_pair(i, Op-OperandList[i].MIOperandNo);
120 }
121 }
122
123
124 /// isFlatOperandNotEmitted - Return true if the specified flat operand #
125 /// should not be emitted with the code emitter.
126 bool isFlatOperandNotEmitted(unsigned FlatOpNo) const {
127 std::pair Op = getSubOperandNumber(FlatOpNo);
128 if (OperandList[Op.first].DoNotEncode.size() > Op.second)
129 return OperandList[Op.first].DoNotEncode[Op.second];
130 return false;
131 }
109132
110133 CodeGenInstruction(Record *R, const std::string &AsmStr);
111134
342342 isCall = R->getValueAsBit("isCall");
343343 isLoad = R->getValueAsBit("isLoad");
344344 isStore = R->getValueAsBit("isStore");
345 isTwoAddress = R->getValueAsBit("isTwoAddress");
345 bool isTwoAddress = R->getValueAsBit("isTwoAddress");
346346 isPredicated = false; // set below.
347347 isConvertibleToThreeAddress = R->getValueAsBit("isConvertibleToThreeAddress");
348348 isCommutable = R->getValueAsBit("isCommutable");
412412 MIOperandNo += NumOps;
413413 }
414414
415 // Parse Constraints.
415416 ParseConstraints(R->getValueAsString("Constraints"), this);
416417
417418 // For backward compatibility: isTwoAddress means operand 1 is tied to
429430 for (unsigned j = 0, e = OperandList[op].MINumOperands; j != e; ++j)
430431 if (OperandList[op].Constraints[j].empty())
431432 OperandList[op].Constraints[j] = "0";
433
434 // Parse the DisableEncoding field.
435 std::string DisableEncoding = R->getValueAsString("DisableEncoding");
436 while (1) {
437 std::string OpName = getToken(DisableEncoding, " ,\t");
438 if (OpName.empty()) break;
439
440 // Figure out which operand this is.
441 std::pair Op = ParseOperandName(OpName, false);
442
443 // Mark the operand as not-to-be encoded.
444 if (Op.second >= OperandList[Op.first].DoNotEncode.size())
445 OperandList[Op.first].DoNotEncode.resize(Op.second+1);
446 OperandList[Op.first].DoNotEncode[Op.second] = true;
447 }
432448 }
433449
434450