1 //===- CodeGenInstruction.cpp - CodeGen Instruction Class Wrapper ---------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file implements the CodeGenInstruction class.
12 //===----------------------------------------------------------------------===//
14 #include "CodeGenInstruction.h"
15 #include "CodeGenTarget.h"
16 #include "llvm/TableGen/Error.h"
17 #include "llvm/TableGen/Record.h"
18 #include "llvm/ADT/StringExtras.h"
19 #include "llvm/ADT/StringMap.h"
20 #include "llvm/ADT/STLExtras.h"
24 //===----------------------------------------------------------------------===//
25 // CGIOperandList Implementation
26 //===----------------------------------------------------------------------===//
28 CGIOperandList::CGIOperandList(Record *R) : TheDef(R) {
30 hasOptionalDef = false;
33 DagInit *OutDI = R->getValueAsDag("OutOperandList");
35 if (DefInit *Init = dyn_cast<DefInit>(OutDI->getOperator())) {
36 if (Init->getDef()->getName() != "outs")
37 throw R->getName() + ": invalid def name for output list: use 'outs'";
39 throw R->getName() + ": invalid output list: use 'outs'";
41 NumDefs = OutDI->getNumArgs();
43 DagInit *InDI = R->getValueAsDag("InOperandList");
44 if (DefInit *Init = dyn_cast<DefInit>(InDI->getOperator())) {
45 if (Init->getDef()->getName() != "ins")
46 throw R->getName() + ": invalid def name for input list: use 'ins'";
48 throw R->getName() + ": invalid input list: use 'ins'";
50 unsigned MIOperandNo = 0;
51 std::set<std::string> OperandNames;
52 for (unsigned i = 0, e = InDI->getNumArgs()+OutDI->getNumArgs(); i != e; ++i){
56 ArgInit = OutDI->getArg(i);
57 ArgName = OutDI->getArgName(i);
59 ArgInit = InDI->getArg(i-NumDefs);
60 ArgName = InDI->getArgName(i-NumDefs);
63 DefInit *Arg = dyn_cast<DefInit>(ArgInit);
65 throw "Illegal operand for the '" + R->getName() + "' instruction!";
67 Record *Rec = Arg->getDef();
68 std::string PrintMethod = "printOperand";
69 std::string EncoderMethod;
70 std::string OperandType = "OPERAND_UNKNOWN";
72 DagInit *MIOpInfo = 0;
73 if (Rec->isSubClassOf("RegisterOperand")) {
74 PrintMethod = Rec->getValueAsString("PrintMethod");
75 } else if (Rec->isSubClassOf("Operand")) {
76 PrintMethod = Rec->getValueAsString("PrintMethod");
77 OperandType = Rec->getValueAsString("OperandType");
78 // If there is an explicit encoder method, use it.
79 EncoderMethod = Rec->getValueAsString("EncoderMethod");
80 MIOpInfo = Rec->getValueAsDag("MIOperandInfo");
82 // Verify that MIOpInfo has an 'ops' root value.
83 if (!isa<DefInit>(MIOpInfo->getOperator()) ||
84 cast<DefInit>(MIOpInfo->getOperator())->getDef()->getName() != "ops")
85 throw "Bad value for MIOperandInfo in operand '" + Rec->getName() +
88 // If we have MIOpInfo, then we have #operands equal to number of entries
90 if (unsigned NumArgs = MIOpInfo->getNumArgs())
93 if (Rec->isSubClassOf("PredicateOperand"))
95 else if (Rec->isSubClassOf("OptionalDefOperand"))
96 hasOptionalDef = true;
97 } else if (Rec->getName() == "variable_ops") {
100 } else if (Rec->isSubClassOf("RegisterClass")) {
101 OperandType = "OPERAND_REGISTER";
102 } else if (!Rec->isSubClassOf("PointerLikeRegClass") &&
103 !Rec->isSubClassOf("unknown_class"))
104 throw "Unknown operand class '" + Rec->getName() +
105 "' in '" + R->getName() + "' instruction!";
107 // Check that the operand has a name and that it's unique.
109 throw "In instruction '" + R->getName() + "', operand #" + utostr(i) +
111 if (!OperandNames.insert(ArgName).second)
112 throw "In instruction '" + R->getName() + "', operand #" + utostr(i) +
113 " has the same name as a previous operand!";
115 OperandList.push_back(OperandInfo(Rec, ArgName, PrintMethod, EncoderMethod,
116 OperandType, MIOperandNo, NumOps,
118 MIOperandNo += NumOps;
122 // Make sure the constraints list for each operand is large enough to hold
123 // constraint info, even if none is present.
124 for (unsigned i = 0, e = OperandList.size(); i != e; ++i)
125 OperandList[i].Constraints.resize(OperandList[i].MINumOperands);
129 /// getOperandNamed - Return the index of the operand with the specified
130 /// non-empty name. If the instruction does not have an operand with the
131 /// specified name, throw an exception.
133 unsigned CGIOperandList::getOperandNamed(StringRef Name) const {
135 if (hasOperandNamed(Name, OpIdx)) return OpIdx;
136 throw "'" + TheDef->getName() + "' does not have an operand named '$" +
140 /// hasOperandNamed - Query whether the instruction has an operand of the
141 /// given name. If so, return true and set OpIdx to the index of the
142 /// operand. Otherwise, return false.
143 bool CGIOperandList::hasOperandNamed(StringRef Name, unsigned &OpIdx) const {
144 assert(!Name.empty() && "Cannot search for operand with no name!");
145 for (unsigned i = 0, e = OperandList.size(); i != e; ++i)
146 if (OperandList[i].Name == Name) {
153 std::pair<unsigned,unsigned>
154 CGIOperandList::ParseOperandName(const std::string &Op, bool AllowWholeOp) {
155 if (Op.empty() || Op[0] != '$')
156 throw TheDef->getName() + ": Illegal operand name: '" + Op + "'";
158 std::string OpName = Op.substr(1);
159 std::string SubOpName;
161 // Check to see if this is $foo.bar.
162 std::string::size_type DotIdx = OpName.find_first_of(".");
163 if (DotIdx != std::string::npos) {
164 SubOpName = OpName.substr(DotIdx+1);
165 if (SubOpName.empty())
166 throw TheDef->getName() + ": illegal empty suboperand name in '" +Op +"'";
167 OpName = OpName.substr(0, DotIdx);
170 unsigned OpIdx = getOperandNamed(OpName);
172 if (SubOpName.empty()) { // If no suboperand name was specified:
173 // If one was needed, throw.
174 if (OperandList[OpIdx].MINumOperands > 1 && !AllowWholeOp &&
176 throw TheDef->getName() + ": Illegal to refer to"
177 " whole operand part of complex operand '" + Op + "'";
179 // Otherwise, return the operand.
180 return std::make_pair(OpIdx, 0U);
183 // Find the suboperand number involved.
184 DagInit *MIOpInfo = OperandList[OpIdx].MIOperandInfo;
186 throw TheDef->getName() + ": unknown suboperand name in '" + Op + "'";
188 // Find the operand with the right name.
189 for (unsigned i = 0, e = MIOpInfo->getNumArgs(); i != e; ++i)
190 if (MIOpInfo->getArgName(i) == SubOpName)
191 return std::make_pair(OpIdx, i);
193 // Otherwise, didn't find it!
194 throw TheDef->getName() + ": unknown suboperand name in '" + Op + "'";
197 static void ParseConstraint(const std::string &CStr, CGIOperandList &Ops) {
198 // EARLY_CLOBBER: @early $reg
199 std::string::size_type wpos = CStr.find_first_of(" \t");
200 std::string::size_type start = CStr.find_first_not_of(" \t");
201 std::string Tok = CStr.substr(start, wpos - start);
202 if (Tok == "@earlyclobber") {
203 std::string Name = CStr.substr(wpos+1);
204 wpos = Name.find_first_not_of(" \t");
205 if (wpos == std::string::npos)
206 throw "Illegal format for @earlyclobber constraint: '" + CStr + "'";
207 Name = Name.substr(wpos);
208 std::pair<unsigned,unsigned> Op = Ops.ParseOperandName(Name, false);
210 // Build the string for the operand
211 if (!Ops[Op.first].Constraints[Op.second].isNone())
212 throw "Operand '" + Name + "' cannot have multiple constraints!";
213 Ops[Op.first].Constraints[Op.second] =
214 CGIOperandList::ConstraintInfo::getEarlyClobber();
218 // Only other constraint is "TIED_TO" for now.
219 std::string::size_type pos = CStr.find_first_of('=');
220 assert(pos != std::string::npos && "Unrecognized constraint");
221 start = CStr.find_first_not_of(" \t");
222 std::string Name = CStr.substr(start, pos - start);
224 // TIED_TO: $src1 = $dst
225 wpos = Name.find_first_of(" \t");
226 if (wpos == std::string::npos)
227 throw "Illegal format for tied-to constraint: '" + CStr + "'";
228 std::string DestOpName = Name.substr(0, wpos);
229 std::pair<unsigned,unsigned> DestOp = Ops.ParseOperandName(DestOpName, false);
231 Name = CStr.substr(pos+1);
232 wpos = Name.find_first_not_of(" \t");
233 if (wpos == std::string::npos)
234 throw "Illegal format for tied-to constraint: '" + CStr + "'";
236 std::pair<unsigned,unsigned> SrcOp =
237 Ops.ParseOperandName(Name.substr(wpos), false);
239 throw "Illegal tied-to operand constraint '" + CStr + "'";
242 unsigned FlatOpNo = Ops.getFlattenedOperandNumber(SrcOp);
244 if (!Ops[DestOp.first].Constraints[DestOp.second].isNone())
245 throw "Operand '" + DestOpName + "' cannot have multiple constraints!";
246 Ops[DestOp.first].Constraints[DestOp.second] =
247 CGIOperandList::ConstraintInfo::getTied(FlatOpNo);
250 static void ParseConstraints(const std::string &CStr, CGIOperandList &Ops) {
251 if (CStr.empty()) return;
253 const std::string delims(",");
254 std::string::size_type bidx, eidx;
256 bidx = CStr.find_first_not_of(delims);
257 while (bidx != std::string::npos) {
258 eidx = CStr.find_first_of(delims, bidx);
259 if (eidx == std::string::npos)
260 eidx = CStr.length();
262 ParseConstraint(CStr.substr(bidx, eidx - bidx), Ops);
263 bidx = CStr.find_first_not_of(delims, eidx);
267 void CGIOperandList::ProcessDisableEncoding(std::string DisableEncoding) {
269 std::pair<StringRef, StringRef> P = getToken(DisableEncoding, " ,\t");
270 std::string OpName = P.first;
271 DisableEncoding = P.second;
272 if (OpName.empty()) break;
274 // Figure out which operand this is.
275 std::pair<unsigned,unsigned> Op = ParseOperandName(OpName, false);
277 // Mark the operand as not-to-be encoded.
278 if (Op.second >= OperandList[Op.first].DoNotEncode.size())
279 OperandList[Op.first].DoNotEncode.resize(Op.second+1);
280 OperandList[Op.first].DoNotEncode[Op.second] = true;
285 //===----------------------------------------------------------------------===//
286 // CodeGenInstruction Implementation
287 //===----------------------------------------------------------------------===//
289 CodeGenInstruction::CodeGenInstruction(Record *R)
290 : TheDef(R), Operands(R), InferredFrom(0) {
291 Namespace = R->getValueAsString("Namespace");
292 AsmString = R->getValueAsString("AsmString");
294 isReturn = R->getValueAsBit("isReturn");
295 isBranch = R->getValueAsBit("isBranch");
296 isIndirectBranch = R->getValueAsBit("isIndirectBranch");
297 isCompare = R->getValueAsBit("isCompare");
298 isMoveImm = R->getValueAsBit("isMoveImm");
299 isBitcast = R->getValueAsBit("isBitcast");
300 isSelect = R->getValueAsBit("isSelect");
301 isBarrier = R->getValueAsBit("isBarrier");
302 isCall = R->getValueAsBit("isCall");
303 canFoldAsLoad = R->getValueAsBit("canFoldAsLoad");
304 isPredicable = Operands.isPredicable || R->getValueAsBit("isPredicable");
305 isConvertibleToThreeAddress = R->getValueAsBit("isConvertibleToThreeAddress");
306 isCommutable = R->getValueAsBit("isCommutable");
307 isTerminator = R->getValueAsBit("isTerminator");
308 isReMaterializable = R->getValueAsBit("isReMaterializable");
309 hasDelaySlot = R->getValueAsBit("hasDelaySlot");
310 usesCustomInserter = R->getValueAsBit("usesCustomInserter");
311 hasPostISelHook = R->getValueAsBit("hasPostISelHook");
312 hasCtrlDep = R->getValueAsBit("hasCtrlDep");
313 isNotDuplicable = R->getValueAsBit("isNotDuplicable");
315 mayLoad = R->getValueAsBitOrUnset("mayLoad", mayLoad_Unset);
316 mayStore = R->getValueAsBitOrUnset("mayStore", mayStore_Unset);
317 hasSideEffects = R->getValueAsBitOrUnset("hasSideEffects",
318 hasSideEffects_Unset);
319 neverHasSideEffects = R->getValueAsBit("neverHasSideEffects");
321 isAsCheapAsAMove = R->getValueAsBit("isAsCheapAsAMove");
322 hasExtraSrcRegAllocReq = R->getValueAsBit("hasExtraSrcRegAllocReq");
323 hasExtraDefRegAllocReq = R->getValueAsBit("hasExtraDefRegAllocReq");
324 isCodeGenOnly = R->getValueAsBit("isCodeGenOnly");
325 isPseudo = R->getValueAsBit("isPseudo");
326 ImplicitDefs = R->getValueAsListOfDefs("Defs");
327 ImplicitUses = R->getValueAsListOfDefs("Uses");
329 if (neverHasSideEffects + hasSideEffects > 1)
330 throw R->getName() + ": multiple conflicting side-effect flags set!";
332 // Parse Constraints.
333 ParseConstraints(R->getValueAsString("Constraints"), Operands);
335 // Parse the DisableEncoding field.
336 Operands.ProcessDisableEncoding(R->getValueAsString("DisableEncoding"));
339 /// HasOneImplicitDefWithKnownVT - If the instruction has at least one
340 /// implicit def and it has a known VT, return the VT, otherwise return
342 MVT::SimpleValueType CodeGenInstruction::
343 HasOneImplicitDefWithKnownVT(const CodeGenTarget &TargetInfo) const {
344 if (ImplicitDefs.empty()) return MVT::Other;
346 // Check to see if the first implicit def has a resolvable type.
347 Record *FirstImplicitDef = ImplicitDefs[0];
348 assert(FirstImplicitDef->isSubClassOf("Register"));
349 const std::vector<MVT::SimpleValueType> &RegVTs =
350 TargetInfo.getRegisterVTs(FirstImplicitDef);
351 if (RegVTs.size() == 1)
357 /// FlattenAsmStringVariants - Flatten the specified AsmString to only
358 /// include text from the specified variant, returning the new string.
359 std::string CodeGenInstruction::
360 FlattenAsmStringVariants(StringRef Cur, unsigned Variant) {
361 std::string Res = "";
364 // Find the start of the next variant string.
365 size_t VariantsStart = 0;
366 for (size_t e = Cur.size(); VariantsStart != e; ++VariantsStart)
367 if (Cur[VariantsStart] == '{' &&
368 (VariantsStart == 0 || (Cur[VariantsStart-1] != '$' &&
369 Cur[VariantsStart-1] != '\\')))
372 // Add the prefix to the result.
373 Res += Cur.slice(0, VariantsStart);
374 if (VariantsStart == Cur.size())
377 ++VariantsStart; // Skip the '{'.
379 // Scan to the end of the variants string.
380 size_t VariantsEnd = VariantsStart;
381 unsigned NestedBraces = 1;
382 for (size_t e = Cur.size(); VariantsEnd != e; ++VariantsEnd) {
383 if (Cur[VariantsEnd] == '}' && Cur[VariantsEnd-1] != '\\') {
384 if (--NestedBraces == 0)
386 } else if (Cur[VariantsEnd] == '{')
390 // Select the Nth variant (or empty).
391 StringRef Selection = Cur.slice(VariantsStart, VariantsEnd);
392 for (unsigned i = 0; i != Variant; ++i)
393 Selection = Selection.split('|').second;
394 Res += Selection.split('|').first;
396 assert(VariantsEnd != Cur.size() &&
397 "Unterminated variants in assembly string!");
398 Cur = Cur.substr(VariantsEnd + 1);
405 //===----------------------------------------------------------------------===//
406 /// CodeGenInstAlias Implementation
407 //===----------------------------------------------------------------------===//
409 /// tryAliasOpMatch - This is a helper function for the CodeGenInstAlias
410 /// constructor. It checks if an argument in an InstAlias pattern matches
411 /// the corresponding operand of the instruction. It returns true on a
412 /// successful match, with ResOp set to the result operand to be used.
413 bool CodeGenInstAlias::tryAliasOpMatch(DagInit *Result, unsigned AliasOpNo,
414 Record *InstOpRec, bool hasSubOps,
415 ArrayRef<SMLoc> Loc, CodeGenTarget &T,
416 ResultOperand &ResOp) {
417 Init *Arg = Result->getArg(AliasOpNo);
418 DefInit *ADI = dyn_cast<DefInit>(Arg);
420 if (ADI && ADI->getDef() == InstOpRec) {
421 // If the operand is a record, it must have a name, and the record type
422 // must match up with the instruction's argument type.
423 if (Result->getArgName(AliasOpNo).empty())
424 throw TGError(Loc, "result argument #" + utostr(AliasOpNo) +
425 " must have a name!");
426 ResOp = ResultOperand(Result->getArgName(AliasOpNo), ADI->getDef());
430 // For register operands, the source register class can be a subclass
431 // of the instruction register class, not just an exact match.
432 if (ADI && ADI->getDef()->isSubClassOf("RegisterClass")) {
433 if (!InstOpRec->isSubClassOf("RegisterClass"))
435 if (!T.getRegisterClass(InstOpRec)
436 .hasSubClass(&T.getRegisterClass(ADI->getDef())))
438 ResOp = ResultOperand(Result->getArgName(AliasOpNo), ADI->getDef());
442 // Handle explicit registers.
443 if (ADI && ADI->getDef()->isSubClassOf("Register")) {
444 if (InstOpRec->isSubClassOf("OptionalDefOperand")) {
445 DagInit *DI = InstOpRec->getValueAsDag("MIOperandInfo");
446 // The operand info should only have a single (register) entry. We
447 // want the register class of it.
448 InstOpRec = cast<DefInit>(DI->getArg(0))->getDef();
451 if (InstOpRec->isSubClassOf("RegisterOperand"))
452 InstOpRec = InstOpRec->getValueAsDef("RegClass");
454 if (!InstOpRec->isSubClassOf("RegisterClass"))
457 if (!T.getRegisterClass(InstOpRec)
458 .contains(T.getRegBank().getReg(ADI->getDef())))
459 throw TGError(Loc, "fixed register " + ADI->getDef()->getName() +
460 " is not a member of the " + InstOpRec->getName() +
463 if (!Result->getArgName(AliasOpNo).empty())
464 throw TGError(Loc, "result fixed register argument must "
467 ResOp = ResultOperand(ADI->getDef());
471 // Handle "zero_reg" for optional def operands.
472 if (ADI && ADI->getDef()->getName() == "zero_reg") {
474 // Check if this is an optional def.
475 // Tied operands where the source is a sub-operand of a complex operand
476 // need to represent both operands in the alias destination instruction.
477 // Allow zero_reg for the tied portion. This can and should go away once
478 // the MC representation of things doesn't use tied operands at all.
479 //if (!InstOpRec->isSubClassOf("OptionalDefOperand"))
480 // throw TGError(Loc, "reg0 used for result that is not an "
481 // "OptionalDefOperand!");
483 ResOp = ResultOperand(static_cast<Record*>(0));
488 if (IntInit *II = dyn_cast<IntInit>(Arg)) {
489 if (hasSubOps || !InstOpRec->isSubClassOf("Operand"))
491 // Integer arguments can't have names.
492 if (!Result->getArgName(AliasOpNo).empty())
493 throw TGError(Loc, "result argument #" + utostr(AliasOpNo) +
494 " must not have a name!");
495 ResOp = ResultOperand(II->getValue());
499 // If both are Operands with the same MVT, allow the conversion. It's
500 // up to the user to make sure the values are appropriate, just like
502 if (InstOpRec->isSubClassOf("Operand") &&
503 ADI->getDef()->isSubClassOf("Operand")) {
504 // FIXME: What other attributes should we check here? Identical
505 // MIOperandInfo perhaps?
506 if (InstOpRec->getValueInit("Type") != ADI->getDef()->getValueInit("Type"))
508 ResOp = ResultOperand(Result->getArgName(AliasOpNo), ADI->getDef());
515 CodeGenInstAlias::CodeGenInstAlias(Record *R, CodeGenTarget &T) : TheDef(R) {
516 AsmString = R->getValueAsString("AsmString");
517 Result = R->getValueAsDag("ResultInst");
519 // Verify that the root of the result is an instruction.
520 DefInit *DI = dyn_cast<DefInit>(Result->getOperator());
521 if (DI == 0 || !DI->getDef()->isSubClassOf("Instruction"))
522 throw TGError(R->getLoc(), "result of inst alias should be an instruction");
524 ResultInst = &T.getInstruction(DI->getDef());
526 // NameClass - If argument names are repeated, we need to verify they have
528 StringMap<Record*> NameClass;
529 for (unsigned i = 0, e = Result->getNumArgs(); i != e; ++i) {
530 DefInit *ADI = dyn_cast<DefInit>(Result->getArg(i));
531 if (!ADI || Result->getArgName(i).empty())
533 // Verify we don't have something like: (someinst GR16:$foo, GR32:$foo)
534 // $foo can exist multiple times in the result list, but it must have the
536 Record *&Entry = NameClass[Result->getArgName(i)];
537 if (Entry && Entry != ADI->getDef())
538 throw TGError(R->getLoc(), "result value $" + Result->getArgName(i) +
539 " is both " + Entry->getName() + " and " +
540 ADI->getDef()->getName() + "!");
541 Entry = ADI->getDef();
544 // Decode and validate the arguments of the result.
545 unsigned AliasOpNo = 0;
546 for (unsigned i = 0, e = ResultInst->Operands.size(); i != e; ++i) {
548 // Tied registers don't have an entry in the result dag unless they're part
549 // of a complex operand, in which case we include them anyways, as we
550 // don't have any other way to specify the whole operand.
551 if (ResultInst->Operands[i].MINumOperands == 1 &&
552 ResultInst->Operands[i].getTiedRegister() != -1)
555 if (AliasOpNo >= Result->getNumArgs())
556 throw TGError(R->getLoc(), "not enough arguments for instruction!");
558 Record *InstOpRec = ResultInst->Operands[i].Rec;
559 unsigned NumSubOps = ResultInst->Operands[i].MINumOperands;
560 ResultOperand ResOp(static_cast<int64_t>(0));
561 if (tryAliasOpMatch(Result, AliasOpNo, InstOpRec, (NumSubOps > 1),
562 R->getLoc(), T, ResOp)) {
563 // If this is a simple operand, or a complex operand with a custom match
564 // class, then we can match is verbatim.
565 if (NumSubOps == 1 ||
566 (InstOpRec->getValue("ParserMatchClass") &&
567 InstOpRec->getValueAsDef("ParserMatchClass")
568 ->getValueAsString("Name") != "Imm")) {
569 ResultOperands.push_back(ResOp);
570 ResultInstOperandIndex.push_back(std::make_pair(i, -1));
573 // Otherwise, we need to match each of the suboperands individually.
575 DagInit *MIOI = ResultInst->Operands[i].MIOperandInfo;
576 for (unsigned SubOp = 0; SubOp != NumSubOps; ++SubOp) {
577 Record *SubRec = cast<DefInit>(MIOI->getArg(SubOp))->getDef();
579 // Take care to instantiate each of the suboperands with the correct
580 // nomenclature: $foo.bar
581 ResultOperands.push_back(
582 ResultOperand(Result->getArgName(AliasOpNo) + "." +
583 MIOI->getArgName(SubOp), SubRec));
584 ResultInstOperandIndex.push_back(std::make_pair(i, SubOp));
591 // If the argument did not match the instruction operand, and the operand
592 // is composed of multiple suboperands, try matching the suboperands.
594 DagInit *MIOI = ResultInst->Operands[i].MIOperandInfo;
595 for (unsigned SubOp = 0; SubOp != NumSubOps; ++SubOp) {
596 if (AliasOpNo >= Result->getNumArgs())
597 throw TGError(R->getLoc(), "not enough arguments for instruction!");
598 Record *SubRec = cast<DefInit>(MIOI->getArg(SubOp))->getDef();
599 if (tryAliasOpMatch(Result, AliasOpNo, SubRec, false,
600 R->getLoc(), T, ResOp)) {
601 ResultOperands.push_back(ResOp);
602 ResultInstOperandIndex.push_back(std::make_pair(i, SubOp));
605 throw TGError(R->getLoc(), "result argument #" + utostr(AliasOpNo) +
606 " does not match instruction operand class " +
607 (SubOp == 0 ? InstOpRec->getName() :SubRec->getName()));
612 throw TGError(R->getLoc(), "result argument #" + utostr(AliasOpNo) +
613 " does not match instruction operand class " +
614 InstOpRec->getName());
617 if (AliasOpNo != Result->getNumArgs())
618 throw TGError(R->getLoc(), "too many operands for instruction!");