Chris Lattner | 6cc654b | 2008-01-06 01:35:39 +0000 | [diff] [blame] | 1 | //===- CodeGenInstruction.cpp - CodeGen Instruction Class Wrapper ---------===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This file implements the CodeGenInstruction class. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | #include "CodeGenInstruction.h" |
| 15 | #include "Record.h" |
| 16 | #include "llvm/ADT/StringExtras.h" |
Benjamin Kramer | d4f1959 | 2010-01-11 18:03:24 +0000 | [diff] [blame] | 17 | #include "llvm/ADT/STLExtras.h" |
Chris Lattner | 6cc654b | 2008-01-06 01:35:39 +0000 | [diff] [blame] | 18 | #include <set> |
| 19 | using namespace llvm; |
| 20 | |
| 21 | static void ParseConstraint(const std::string &CStr, CodeGenInstruction *I) { |
Jim Grosbach | 0680172 | 2009-12-16 19:43:02 +0000 | [diff] [blame] | 22 | // EARLY_CLOBBER: @early $reg |
| 23 | std::string::size_type wpos = CStr.find_first_of(" \t"); |
| 24 | std::string::size_type start = CStr.find_first_not_of(" \t"); |
| 25 | std::string Tok = CStr.substr(start, wpos - start); |
| 26 | if (Tok == "@earlyclobber") { |
| 27 | std::string Name = CStr.substr(wpos+1); |
| 28 | wpos = Name.find_first_not_of(" \t"); |
| 29 | if (wpos == std::string::npos) |
| 30 | throw "Illegal format for @earlyclobber constraint: '" + CStr + "'"; |
| 31 | Name = Name.substr(wpos); |
| 32 | std::pair<unsigned,unsigned> Op = |
| 33 | I->ParseOperandName(Name, false); |
| 34 | |
| 35 | // Build the string for the operand |
Chris Lattner | a7d479c | 2010-02-10 01:45:28 +0000 | [diff] [blame] | 36 | if (!I->OperandList[Op.first].Constraints[Op.second].isNone()) |
Jim Grosbach | 0680172 | 2009-12-16 19:43:02 +0000 | [diff] [blame] | 37 | throw "Operand '" + Name + "' cannot have multiple constraints!"; |
Chris Lattner | a7d479c | 2010-02-10 01:45:28 +0000 | [diff] [blame] | 38 | I->OperandList[Op.first].Constraints[Op.second] = |
| 39 | CodeGenInstruction::ConstraintInfo::getEarlyClobber(); |
Jim Grosbach | 0680172 | 2009-12-16 19:43:02 +0000 | [diff] [blame] | 40 | return; |
| 41 | } |
| 42 | |
| 43 | // Only other constraint is "TIED_TO" for now. |
Chris Lattner | 6cc654b | 2008-01-06 01:35:39 +0000 | [diff] [blame] | 44 | std::string::size_type pos = CStr.find_first_of('='); |
| 45 | assert(pos != std::string::npos && "Unrecognized constraint"); |
Jim Grosbach | 0680172 | 2009-12-16 19:43:02 +0000 | [diff] [blame] | 46 | start = CStr.find_first_not_of(" \t"); |
Bob Wilson | fd87e6a | 2009-08-26 22:50:39 +0000 | [diff] [blame] | 47 | std::string Name = CStr.substr(start, pos - start); |
Jim Grosbach | f0a4fad | 2009-12-15 19:28:13 +0000 | [diff] [blame] | 48 | |
Chris Lattner | 6cc654b | 2008-01-06 01:35:39 +0000 | [diff] [blame] | 49 | // TIED_TO: $src1 = $dst |
Jim Grosbach | 0680172 | 2009-12-16 19:43:02 +0000 | [diff] [blame] | 50 | wpos = Name.find_first_of(" \t"); |
Chris Lattner | 6cc654b | 2008-01-06 01:35:39 +0000 | [diff] [blame] | 51 | if (wpos == std::string::npos) |
| 52 | throw "Illegal format for tied-to constraint: '" + CStr + "'"; |
| 53 | std::string DestOpName = Name.substr(0, wpos); |
| 54 | std::pair<unsigned,unsigned> DestOp = I->ParseOperandName(DestOpName, false); |
Jim Grosbach | f0a4fad | 2009-12-15 19:28:13 +0000 | [diff] [blame] | 55 | |
Chris Lattner | 6cc654b | 2008-01-06 01:35:39 +0000 | [diff] [blame] | 56 | Name = CStr.substr(pos+1); |
| 57 | wpos = Name.find_first_not_of(" \t"); |
| 58 | if (wpos == std::string::npos) |
| 59 | throw "Illegal format for tied-to constraint: '" + CStr + "'"; |
Jim Grosbach | f0a4fad | 2009-12-15 19:28:13 +0000 | [diff] [blame] | 60 | |
Chris Lattner | 6cc654b | 2008-01-06 01:35:39 +0000 | [diff] [blame] | 61 | std::pair<unsigned,unsigned> SrcOp = |
| 62 | I->ParseOperandName(Name.substr(wpos), false); |
| 63 | if (SrcOp > DestOp) |
| 64 | throw "Illegal tied-to operand constraint '" + CStr + "'"; |
Jim Grosbach | f0a4fad | 2009-12-15 19:28:13 +0000 | [diff] [blame] | 65 | |
| 66 | |
Chris Lattner | 6cc654b | 2008-01-06 01:35:39 +0000 | [diff] [blame] | 67 | unsigned FlatOpNo = I->getFlattenedOperandNumber(SrcOp); |
Jim Grosbach | f0a4fad | 2009-12-15 19:28:13 +0000 | [diff] [blame] | 68 | |
Chris Lattner | a7d479c | 2010-02-10 01:45:28 +0000 | [diff] [blame] | 69 | if (!I->OperandList[DestOp.first].Constraints[DestOp.second].isNone()) |
Chris Lattner | 6cc654b | 2008-01-06 01:35:39 +0000 | [diff] [blame] | 70 | throw "Operand '" + DestOpName + "' cannot have multiple constraints!"; |
Chris Lattner | a7d479c | 2010-02-10 01:45:28 +0000 | [diff] [blame] | 71 | I->OperandList[DestOp.first].Constraints[DestOp.second] = |
| 72 | CodeGenInstruction::ConstraintInfo::getTied(FlatOpNo); |
Chris Lattner | 6cc654b | 2008-01-06 01:35:39 +0000 | [diff] [blame] | 73 | } |
| 74 | |
| 75 | static void ParseConstraints(const std::string &CStr, CodeGenInstruction *I) { |
| 76 | // Make sure the constraints list for each operand is large enough to hold |
| 77 | // constraint info, even if none is present. |
Jim Grosbach | f0a4fad | 2009-12-15 19:28:13 +0000 | [diff] [blame] | 78 | for (unsigned i = 0, e = I->OperandList.size(); i != e; ++i) |
Chris Lattner | 6cc654b | 2008-01-06 01:35:39 +0000 | [diff] [blame] | 79 | I->OperandList[i].Constraints.resize(I->OperandList[i].MINumOperands); |
Jim Grosbach | f0a4fad | 2009-12-15 19:28:13 +0000 | [diff] [blame] | 80 | |
Chris Lattner | 6cc654b | 2008-01-06 01:35:39 +0000 | [diff] [blame] | 81 | if (CStr.empty()) return; |
Jim Grosbach | f0a4fad | 2009-12-15 19:28:13 +0000 | [diff] [blame] | 82 | |
Chris Lattner | 6cc654b | 2008-01-06 01:35:39 +0000 | [diff] [blame] | 83 | const std::string delims(","); |
| 84 | std::string::size_type bidx, eidx; |
Jim Grosbach | f0a4fad | 2009-12-15 19:28:13 +0000 | [diff] [blame] | 85 | |
Chris Lattner | 6cc654b | 2008-01-06 01:35:39 +0000 | [diff] [blame] | 86 | bidx = CStr.find_first_not_of(delims); |
| 87 | while (bidx != std::string::npos) { |
| 88 | eidx = CStr.find_first_of(delims, bidx); |
| 89 | if (eidx == std::string::npos) |
| 90 | eidx = CStr.length(); |
Jim Grosbach | f0a4fad | 2009-12-15 19:28:13 +0000 | [diff] [blame] | 91 | |
Bob Wilson | fd87e6a | 2009-08-26 22:50:39 +0000 | [diff] [blame] | 92 | ParseConstraint(CStr.substr(bidx, eidx - bidx), I); |
Chris Lattner | 6cc654b | 2008-01-06 01:35:39 +0000 | [diff] [blame] | 93 | bidx = CStr.find_first_not_of(delims, eidx); |
| 94 | } |
| 95 | } |
| 96 | |
| 97 | CodeGenInstruction::CodeGenInstruction(Record *R, const std::string &AsmStr) |
| 98 | : TheDef(R), AsmString(AsmStr) { |
Chris Lattner | 6cc654b | 2008-01-06 01:35:39 +0000 | [diff] [blame] | 99 | Namespace = R->getValueAsString("Namespace"); |
| 100 | |
| 101 | isReturn = R->getValueAsBit("isReturn"); |
| 102 | isBranch = R->getValueAsBit("isBranch"); |
| 103 | isIndirectBranch = R->getValueAsBit("isIndirectBranch"); |
| 104 | isBarrier = R->getValueAsBit("isBarrier"); |
| 105 | isCall = R->getValueAsBit("isCall"); |
Dan Gohman | 15511cf | 2008-12-03 18:15:48 +0000 | [diff] [blame] | 106 | canFoldAsLoad = R->getValueAsBit("canFoldAsLoad"); |
Chris Lattner | dcc8b4f | 2008-01-08 18:05:21 +0000 | [diff] [blame] | 107 | mayLoad = R->getValueAsBit("mayLoad"); |
Chris Lattner | 2e48a70 | 2008-01-06 08:36:04 +0000 | [diff] [blame] | 108 | mayStore = R->getValueAsBit("mayStore"); |
Chris Lattner | 6cc654b | 2008-01-06 01:35:39 +0000 | [diff] [blame] | 109 | bool isTwoAddress = R->getValueAsBit("isTwoAddress"); |
| 110 | isPredicable = R->getValueAsBit("isPredicable"); |
| 111 | isConvertibleToThreeAddress = R->getValueAsBit("isConvertibleToThreeAddress"); |
| 112 | isCommutable = R->getValueAsBit("isCommutable"); |
| 113 | isTerminator = R->getValueAsBit("isTerminator"); |
| 114 | isReMaterializable = R->getValueAsBit("isReMaterializable"); |
| 115 | hasDelaySlot = R->getValueAsBit("hasDelaySlot"); |
Dan Gohman | 533297b | 2009-10-29 18:10:34 +0000 | [diff] [blame] | 116 | usesCustomInserter = R->getValueAsBit("usesCustomInserter"); |
Chris Lattner | 6cc654b | 2008-01-06 01:35:39 +0000 | [diff] [blame] | 117 | hasCtrlDep = R->getValueAsBit("hasCtrlDep"); |
| 118 | isNotDuplicable = R->getValueAsBit("isNotDuplicable"); |
Chris Lattner | ba7e756 | 2008-01-10 07:59:24 +0000 | [diff] [blame] | 119 | hasSideEffects = R->getValueAsBit("hasSideEffects"); |
Chris Lattner | 6cc654b | 2008-01-06 01:35:39 +0000 | [diff] [blame] | 120 | neverHasSideEffects = R->getValueAsBit("neverHasSideEffects"); |
Bill Wendling | 8370d38 | 2008-05-28 22:54:52 +0000 | [diff] [blame] | 121 | isAsCheapAsAMove = R->getValueAsBit("isAsCheapAsAMove"); |
Evan Cheng | 799d697 | 2009-10-01 08:21:18 +0000 | [diff] [blame] | 122 | hasExtraSrcRegAllocReq = R->getValueAsBit("hasExtraSrcRegAllocReq"); |
| 123 | hasExtraDefRegAllocReq = R->getValueAsBit("hasExtraDefRegAllocReq"); |
Chris Lattner | 6cc654b | 2008-01-06 01:35:39 +0000 | [diff] [blame] | 124 | hasOptionalDef = false; |
Chris Lattner | 8f707e1 | 2008-01-07 05:19:29 +0000 | [diff] [blame] | 125 | isVariadic = false; |
Chris Lattner | 6cc654b | 2008-01-06 01:35:39 +0000 | [diff] [blame] | 126 | |
Dan Gohman | bc9d98b | 2010-02-27 23:47:46 +0000 | [diff] [blame] | 127 | if (neverHasSideEffects + hasSideEffects > 1) |
Chris Lattner | ba7e756 | 2008-01-10 07:59:24 +0000 | [diff] [blame] | 128 | throw R->getName() + ": multiple conflicting side-effect flags set!"; |
Chris Lattner | 6cc654b | 2008-01-06 01:35:39 +0000 | [diff] [blame] | 129 | |
Chris Lattner | cedef1c | 2010-03-18 20:50:52 +0000 | [diff] [blame^] | 130 | DagInit *DI = R->getValueAsDag("OutOperandList"); |
Chris Lattner | 6cc654b | 2008-01-06 01:35:39 +0000 | [diff] [blame] | 131 | |
Chris Lattner | cedef1c | 2010-03-18 20:50:52 +0000 | [diff] [blame^] | 132 | if (DefInit *Init = dynamic_cast<DefInit*>(DI->getOperator())) { |
| 133 | if (Init->getDef()->getName() != "ops" && |
| 134 | Init->getDef()->getName() != "outs") |
| 135 | throw R->getName() + ": invalid def name for output list: use 'outs'"; |
| 136 | } else |
| 137 | throw R->getName() + ": invalid output list: use 'outs'"; |
| 138 | |
| 139 | NumDefs = DI->getNumArgs(); |
| 140 | |
| 141 | DagInit *IDI = R->getValueAsDag("InOperandList"); |
| 142 | if (DefInit *Init = dynamic_cast<DefInit*>(IDI->getOperator())) { |
| 143 | if (Init->getDef()->getName() != "ops" && |
| 144 | Init->getDef()->getName() != "ins") |
| 145 | throw R->getName() + ": invalid def name for input list: use 'ins'"; |
| 146 | } else |
| 147 | throw R->getName() + ": invalid input list: use 'ins'"; |
| 148 | |
| 149 | DI = (DagInit*)(new BinOpInit(BinOpInit::CONCAT, |
| 150 | DI, IDI, new DagRecTy))->Fold(R, 0); |
Chris Lattner | 6cc654b | 2008-01-06 01:35:39 +0000 | [diff] [blame] | 151 | |
| 152 | unsigned MIOperandNo = 0; |
| 153 | std::set<std::string> OperandNames; |
| 154 | for (unsigned i = 0, e = DI->getNumArgs(); i != e; ++i) { |
| 155 | DefInit *Arg = dynamic_cast<DefInit*>(DI->getArg(i)); |
| 156 | if (!Arg) |
| 157 | throw "Illegal operand for the '" + R->getName() + "' instruction!"; |
| 158 | |
| 159 | Record *Rec = Arg->getDef(); |
| 160 | std::string PrintMethod = "printOperand"; |
| 161 | unsigned NumOps = 1; |
| 162 | DagInit *MIOpInfo = 0; |
| 163 | if (Rec->isSubClassOf("Operand")) { |
| 164 | PrintMethod = Rec->getValueAsString("PrintMethod"); |
| 165 | MIOpInfo = Rec->getValueAsDag("MIOperandInfo"); |
Jim Grosbach | f0a4fad | 2009-12-15 19:28:13 +0000 | [diff] [blame] | 166 | |
Chris Lattner | 6cc654b | 2008-01-06 01:35:39 +0000 | [diff] [blame] | 167 | // Verify that MIOpInfo has an 'ops' root value. |
| 168 | if (!dynamic_cast<DefInit*>(MIOpInfo->getOperator()) || |
| 169 | dynamic_cast<DefInit*>(MIOpInfo->getOperator()) |
| 170 | ->getDef()->getName() != "ops") |
| 171 | throw "Bad value for MIOperandInfo in operand '" + Rec->getName() + |
| 172 | "'\n"; |
| 173 | |
| 174 | // If we have MIOpInfo, then we have #operands equal to number of entries |
| 175 | // in MIOperandInfo. |
| 176 | if (unsigned NumArgs = MIOpInfo->getNumArgs()) |
| 177 | NumOps = NumArgs; |
| 178 | |
| 179 | if (Rec->isSubClassOf("PredicateOperand")) |
| 180 | isPredicable = true; |
| 181 | else if (Rec->isSubClassOf("OptionalDefOperand")) |
| 182 | hasOptionalDef = true; |
| 183 | } else if (Rec->getName() == "variable_ops") { |
Chris Lattner | 8f707e1 | 2008-01-07 05:19:29 +0000 | [diff] [blame] | 184 | isVariadic = true; |
Chris Lattner | 6cc654b | 2008-01-06 01:35:39 +0000 | [diff] [blame] | 185 | continue; |
Jim Grosbach | f0a4fad | 2009-12-15 19:28:13 +0000 | [diff] [blame] | 186 | } else if (!Rec->isSubClassOf("RegisterClass") && |
Dan Gohman | e4c67cd | 2008-05-31 02:11:25 +0000 | [diff] [blame] | 187 | Rec->getName() != "ptr_rc" && Rec->getName() != "unknown") |
Chris Lattner | 6cc654b | 2008-01-06 01:35:39 +0000 | [diff] [blame] | 188 | throw "Unknown operand class '" + Rec->getName() + |
Matthijs Kooijman | 677fbfa | 2008-10-27 15:59:43 +0000 | [diff] [blame] | 189 | "' in '" + R->getName() + "' instruction!"; |
Chris Lattner | 6cc654b | 2008-01-06 01:35:39 +0000 | [diff] [blame] | 190 | |
| 191 | // Check that the operand has a name and that it's unique. |
| 192 | if (DI->getArgName(i).empty()) |
| 193 | throw "In instruction '" + R->getName() + "', operand #" + utostr(i) + |
| 194 | " has no name!"; |
| 195 | if (!OperandNames.insert(DI->getArgName(i)).second) |
| 196 | throw "In instruction '" + R->getName() + "', operand #" + utostr(i) + |
| 197 | " has the same name as a previous operand!"; |
Jim Grosbach | f0a4fad | 2009-12-15 19:28:13 +0000 | [diff] [blame] | 198 | |
| 199 | OperandList.push_back(OperandInfo(Rec, DI->getArgName(i), PrintMethod, |
Chris Lattner | 6cc654b | 2008-01-06 01:35:39 +0000 | [diff] [blame] | 200 | MIOperandNo, NumOps, MIOpInfo)); |
| 201 | MIOperandNo += NumOps; |
| 202 | } |
| 203 | |
| 204 | // Parse Constraints. |
| 205 | ParseConstraints(R->getValueAsString("Constraints"), this); |
Jim Grosbach | f0a4fad | 2009-12-15 19:28:13 +0000 | [diff] [blame] | 206 | |
Chris Lattner | 6cc654b | 2008-01-06 01:35:39 +0000 | [diff] [blame] | 207 | // For backward compatibility: isTwoAddress means operand 1 is tied to |
| 208 | // operand 0. |
| 209 | if (isTwoAddress) { |
Chris Lattner | a7d479c | 2010-02-10 01:45:28 +0000 | [diff] [blame] | 210 | if (!OperandList[1].Constraints[0].isNone()) |
Chris Lattner | 6cc654b | 2008-01-06 01:35:39 +0000 | [diff] [blame] | 211 | throw R->getName() + ": cannot use isTwoAddress property: instruction " |
| 212 | "already has constraint set!"; |
Chris Lattner | a7d479c | 2010-02-10 01:45:28 +0000 | [diff] [blame] | 213 | OperandList[1].Constraints[0] = |
| 214 | CodeGenInstruction::ConstraintInfo::getTied(0); |
Chris Lattner | 6cc654b | 2008-01-06 01:35:39 +0000 | [diff] [blame] | 215 | } |
Jim Grosbach | f0a4fad | 2009-12-15 19:28:13 +0000 | [diff] [blame] | 216 | |
Chris Lattner | 6cc654b | 2008-01-06 01:35:39 +0000 | [diff] [blame] | 217 | // Parse the DisableEncoding field. |
| 218 | std::string DisableEncoding = R->getValueAsString("DisableEncoding"); |
| 219 | while (1) { |
Benjamin Kramer | d4f1959 | 2010-01-11 18:03:24 +0000 | [diff] [blame] | 220 | std::string OpName; |
| 221 | tie(OpName, DisableEncoding) = getToken(DisableEncoding, " ,\t"); |
Chris Lattner | 6cc654b | 2008-01-06 01:35:39 +0000 | [diff] [blame] | 222 | if (OpName.empty()) break; |
| 223 | |
| 224 | // Figure out which operand this is. |
| 225 | std::pair<unsigned,unsigned> Op = ParseOperandName(OpName, false); |
| 226 | |
| 227 | // Mark the operand as not-to-be encoded. |
| 228 | if (Op.second >= OperandList[Op.first].DoNotEncode.size()) |
| 229 | OperandList[Op.first].DoNotEncode.resize(Op.second+1); |
| 230 | OperandList[Op.first].DoNotEncode[Op.second] = true; |
| 231 | } |
| 232 | } |
| 233 | |
Chris Lattner | 6cc654b | 2008-01-06 01:35:39 +0000 | [diff] [blame] | 234 | /// getOperandNamed - Return the index of the operand with the specified |
| 235 | /// non-empty name. If the instruction does not have an operand with the |
| 236 | /// specified name, throw an exception. |
| 237 | /// |
| 238 | unsigned CodeGenInstruction::getOperandNamed(const std::string &Name) const { |
| 239 | assert(!Name.empty() && "Cannot search for operand with no name!"); |
| 240 | for (unsigned i = 0, e = OperandList.size(); i != e; ++i) |
| 241 | if (OperandList[i].Name == Name) return i; |
| 242 | throw "Instruction '" + TheDef->getName() + |
| 243 | "' does not have an operand named '$" + Name + "'!"; |
| 244 | } |
| 245 | |
Jim Grosbach | f0a4fad | 2009-12-15 19:28:13 +0000 | [diff] [blame] | 246 | std::pair<unsigned,unsigned> |
Chris Lattner | 6cc654b | 2008-01-06 01:35:39 +0000 | [diff] [blame] | 247 | CodeGenInstruction::ParseOperandName(const std::string &Op, |
| 248 | bool AllowWholeOp) { |
| 249 | if (Op.empty() || Op[0] != '$') |
| 250 | throw TheDef->getName() + ": Illegal operand name: '" + Op + "'"; |
Jim Grosbach | f0a4fad | 2009-12-15 19:28:13 +0000 | [diff] [blame] | 251 | |
Chris Lattner | 6cc654b | 2008-01-06 01:35:39 +0000 | [diff] [blame] | 252 | std::string OpName = Op.substr(1); |
| 253 | std::string SubOpName; |
Jim Grosbach | f0a4fad | 2009-12-15 19:28:13 +0000 | [diff] [blame] | 254 | |
Chris Lattner | 6cc654b | 2008-01-06 01:35:39 +0000 | [diff] [blame] | 255 | // Check to see if this is $foo.bar. |
| 256 | std::string::size_type DotIdx = OpName.find_first_of("."); |
| 257 | if (DotIdx != std::string::npos) { |
| 258 | SubOpName = OpName.substr(DotIdx+1); |
| 259 | if (SubOpName.empty()) |
| 260 | throw TheDef->getName() + ": illegal empty suboperand name in '" +Op +"'"; |
| 261 | OpName = OpName.substr(0, DotIdx); |
| 262 | } |
Jim Grosbach | f0a4fad | 2009-12-15 19:28:13 +0000 | [diff] [blame] | 263 | |
Chris Lattner | 6cc654b | 2008-01-06 01:35:39 +0000 | [diff] [blame] | 264 | unsigned OpIdx = getOperandNamed(OpName); |
| 265 | |
| 266 | if (SubOpName.empty()) { // If no suboperand name was specified: |
| 267 | // If one was needed, throw. |
| 268 | if (OperandList[OpIdx].MINumOperands > 1 && !AllowWholeOp && |
| 269 | SubOpName.empty()) |
| 270 | throw TheDef->getName() + ": Illegal to refer to" |
| 271 | " whole operand part of complex operand '" + Op + "'"; |
Jim Grosbach | f0a4fad | 2009-12-15 19:28:13 +0000 | [diff] [blame] | 272 | |
Chris Lattner | 6cc654b | 2008-01-06 01:35:39 +0000 | [diff] [blame] | 273 | // Otherwise, return the operand. |
| 274 | return std::make_pair(OpIdx, 0U); |
| 275 | } |
Jim Grosbach | f0a4fad | 2009-12-15 19:28:13 +0000 | [diff] [blame] | 276 | |
Chris Lattner | 6cc654b | 2008-01-06 01:35:39 +0000 | [diff] [blame] | 277 | // Find the suboperand number involved. |
| 278 | DagInit *MIOpInfo = OperandList[OpIdx].MIOperandInfo; |
| 279 | if (MIOpInfo == 0) |
| 280 | throw TheDef->getName() + ": unknown suboperand name in '" + Op + "'"; |
Jim Grosbach | f0a4fad | 2009-12-15 19:28:13 +0000 | [diff] [blame] | 281 | |
Chris Lattner | 6cc654b | 2008-01-06 01:35:39 +0000 | [diff] [blame] | 282 | // Find the operand with the right name. |
| 283 | for (unsigned i = 0, e = MIOpInfo->getNumArgs(); i != e; ++i) |
| 284 | if (MIOpInfo->getArgName(i) == SubOpName) |
| 285 | return std::make_pair(OpIdx, i); |
| 286 | |
| 287 | // Otherwise, didn't find it! |
| 288 | throw TheDef->getName() + ": unknown suboperand name in '" + Op + "'"; |
| 289 | } |