1 //===- CodeGenTarget.cpp - CodeGen Target 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 class wraps target description classes used by the various code 11 // generation TableGen backends. This makes it easier to access the data and 12 // provides a single place that needs to check it for validity. All of these 13 // classes abort on error conditions. 14 // 15 //===----------------------------------------------------------------------===// 16 17 #include "CodeGenTarget.h" 18 #include "CodeGenIntrinsics.h" 19 #include "CodeGenSchedule.h" 20 #include "llvm/ADT/STLExtras.h" 21 #include "llvm/ADT/StringExtras.h" 22 #include "llvm/Support/CommandLine.h" 23 #include "llvm/TableGen/Error.h" 24 #include "llvm/TableGen/Record.h" 25 #include <algorithm> 26 using namespace llvm; 27 28 static cl::opt<unsigned> 29 AsmParserNum("asmparsernum", cl::init(0), 30 cl::desc("Make -gen-asm-parser emit assembly parser #N")); 31 32 static cl::opt<unsigned> 33 AsmWriterNum("asmwriternum", cl::init(0), 34 cl::desc("Make -gen-asm-writer emit assembly writer #N")); 35 36 /// getValueType - Return the MVT::SimpleValueType that the specified TableGen 37 /// record corresponds to. 38 MVT::SimpleValueType llvm::getValueType(Record *Rec) { 39 return (MVT::SimpleValueType)Rec->getValueAsInt("Value"); 40 } 41 42 std::string llvm::getName(MVT::SimpleValueType T) { 43 switch (T) { 44 case MVT::Other: return "UNKNOWN"; 45 case MVT::iPTR: return "TLI.getPointerTy()"; 46 case MVT::iPTRAny: return "TLI.getPointerTy()"; 47 default: return getEnumName(T); 48 } 49 } 50 51 std::string llvm::getEnumName(MVT::SimpleValueType T) { 52 switch (T) { 53 case MVT::Other: return "MVT::Other"; 54 case MVT::i1: return "MVT::i1"; 55 case MVT::i8: return "MVT::i8"; 56 case MVT::i16: return "MVT::i16"; 57 case MVT::i32: return "MVT::i32"; 58 case MVT::i64: return "MVT::i64"; 59 case MVT::i128: return "MVT::i128"; 60 case MVT::iAny: return "MVT::iAny"; 61 case MVT::fAny: return "MVT::fAny"; 62 case MVT::vAny: return "MVT::vAny"; 63 case MVT::f16: return "MVT::f16"; 64 case MVT::f32: return "MVT::f32"; 65 case MVT::f64: return "MVT::f64"; 66 case MVT::f80: return "MVT::f80"; 67 case MVT::f128: return "MVT::f128"; 68 case MVT::ppcf128: return "MVT::ppcf128"; 69 case MVT::x86mmx: return "MVT::x86mmx"; 70 case MVT::Glue: return "MVT::Glue"; 71 case MVT::isVoid: return "MVT::isVoid"; 72 case MVT::v2i1: return "MVT::v2i1"; 73 case MVT::v4i1: return "MVT::v4i1"; 74 case MVT::v8i1: return "MVT::v8i1"; 75 case MVT::v16i1: return "MVT::v16i1"; 76 case MVT::v32i1: return "MVT::v32i1"; 77 case MVT::v64i1: return "MVT::v64i1"; 78 case MVT::v2i8: return "MVT::v2i8"; 79 case MVT::v4i8: return "MVT::v4i8"; 80 case MVT::v8i8: return "MVT::v8i8"; 81 case MVT::v16i8: return "MVT::v16i8"; 82 case MVT::v32i8: return "MVT::v32i8"; 83 case MVT::v64i8: return "MVT::v64i8"; 84 case MVT::v1i16: return "MVT::v1i16"; 85 case MVT::v2i16: return "MVT::v2i16"; 86 case MVT::v4i16: return "MVT::v4i16"; 87 case MVT::v8i16: return "MVT::v8i16"; 88 case MVT::v16i16: return "MVT::v16i16"; 89 case MVT::v32i16: return "MVT::v32i16"; 90 case MVT::v1i32: return "MVT::v1i32"; 91 case MVT::v2i32: return "MVT::v2i32"; 92 case MVT::v4i32: return "MVT::v4i32"; 93 case MVT::v8i32: return "MVT::v8i32"; 94 case MVT::v16i32: return "MVT::v16i32"; 95 case MVT::v1i64: return "MVT::v1i64"; 96 case MVT::v2i64: return "MVT::v2i64"; 97 case MVT::v4i64: return "MVT::v4i64"; 98 case MVT::v8i64: return "MVT::v8i64"; 99 case MVT::v16i64: return "MVT::v16i64"; 100 case MVT::v2f16: return "MVT::v2f16"; 101 case MVT::v8f16: return "MVT::v8f16"; 102 case MVT::v2f32: return "MVT::v2f32"; 103 case MVT::v4f32: return "MVT::v4f32"; 104 case MVT::v8f32: return "MVT::v8f32"; 105 case MVT::v16f32: return "MVT::v16f32"; 106 case MVT::v2f64: return "MVT::v2f64"; 107 case MVT::v4f64: return "MVT::v4f64"; 108 case MVT::v8f64: return "MVT::v8f64"; 109 case MVT::Metadata: return "MVT::Metadata"; 110 case MVT::iPTR: return "MVT::iPTR"; 111 case MVT::iPTRAny: return "MVT::iPTRAny"; 112 case MVT::Untyped: return "MVT::Untyped"; 113 default: llvm_unreachable("ILLEGAL VALUE TYPE!"); 114 } 115 } 116 117 /// getQualifiedName - Return the name of the specified record, with a 118 /// namespace qualifier if the record contains one. 119 /// 120 std::string llvm::getQualifiedName(const Record *R) { 121 std::string Namespace; 122 if (R->getValue("Namespace")) 123 Namespace = R->getValueAsString("Namespace"); 124 if (Namespace.empty()) return R->getName(); 125 return Namespace + "::" + R->getName(); 126 } 127 128 129 /// getTarget - Return the current instance of the Target class. 130 /// 131 CodeGenTarget::CodeGenTarget(RecordKeeper &records) 132 : Records(records), RegBank(0), SchedModels(0) { 133 std::vector<Record*> Targets = Records.getAllDerivedDefinitions("Target"); 134 if (Targets.size() == 0) 135 PrintFatalError("ERROR: No 'Target' subclasses defined!"); 136 if (Targets.size() != 1) 137 PrintFatalError("ERROR: Multiple subclasses of Target defined!"); 138 TargetRec = Targets[0]; 139 } 140 141 CodeGenTarget::~CodeGenTarget() { 142 delete RegBank; 143 delete SchedModels; 144 } 145 146 const std::string &CodeGenTarget::getName() const { 147 return TargetRec->getName(); 148 } 149 150 std::string CodeGenTarget::getInstNamespace() const { 151 for (inst_iterator i = inst_begin(), e = inst_end(); i != e; ++i) { 152 // Make sure not to pick up "TargetOpcode" by accidentally getting 153 // the namespace off the PHI instruction or something. 154 if ((*i)->Namespace != "TargetOpcode") 155 return (*i)->Namespace; 156 } 157 158 return ""; 159 } 160 161 Record *CodeGenTarget::getInstructionSet() const { 162 return TargetRec->getValueAsDef("InstructionSet"); 163 } 164 165 166 /// getAsmParser - Return the AssemblyParser definition for this target. 167 /// 168 Record *CodeGenTarget::getAsmParser() const { 169 std::vector<Record*> LI = TargetRec->getValueAsListOfDefs("AssemblyParsers"); 170 if (AsmParserNum >= LI.size()) 171 PrintFatalError("Target does not have an AsmParser #" + utostr(AsmParserNum) + "!"); 172 return LI[AsmParserNum]; 173 } 174 175 /// getAsmParserVariant - Return the AssmblyParserVariant definition for 176 /// this target. 177 /// 178 Record *CodeGenTarget::getAsmParserVariant(unsigned i) const { 179 std::vector<Record*> LI = 180 TargetRec->getValueAsListOfDefs("AssemblyParserVariants"); 181 if (i >= LI.size()) 182 PrintFatalError("Target does not have an AsmParserVariant #" + utostr(i) + "!"); 183 return LI[i]; 184 } 185 186 /// getAsmParserVariantCount - Return the AssmblyParserVariant definition 187 /// available for this target. 188 /// 189 unsigned CodeGenTarget::getAsmParserVariantCount() const { 190 std::vector<Record*> LI = 191 TargetRec->getValueAsListOfDefs("AssemblyParserVariants"); 192 return LI.size(); 193 } 194 195 /// getAsmWriter - Return the AssemblyWriter definition for this target. 196 /// 197 Record *CodeGenTarget::getAsmWriter() const { 198 std::vector<Record*> LI = TargetRec->getValueAsListOfDefs("AssemblyWriters"); 199 if (AsmWriterNum >= LI.size()) 200 PrintFatalError("Target does not have an AsmWriter #" + utostr(AsmWriterNum) + "!"); 201 return LI[AsmWriterNum]; 202 } 203 204 CodeGenRegBank &CodeGenTarget::getRegBank() const { 205 if (!RegBank) 206 RegBank = new CodeGenRegBank(Records); 207 return *RegBank; 208 } 209 210 void CodeGenTarget::ReadRegAltNameIndices() const { 211 RegAltNameIndices = Records.getAllDerivedDefinitions("RegAltNameIndex"); 212 std::sort(RegAltNameIndices.begin(), RegAltNameIndices.end(), LessRecord()); 213 } 214 215 /// getRegisterByName - If there is a register with the specific AsmName, 216 /// return it. 217 const CodeGenRegister *CodeGenTarget::getRegisterByName(StringRef Name) const { 218 const StringMap<CodeGenRegister*> &Regs = getRegBank().getRegistersByName(); 219 StringMap<CodeGenRegister*>::const_iterator I = Regs.find(Name); 220 if (I == Regs.end()) 221 return 0; 222 return I->second; 223 } 224 225 std::vector<MVT::SimpleValueType> CodeGenTarget:: 226 getRegisterVTs(Record *R) const { 227 const CodeGenRegister *Reg = getRegBank().getReg(R); 228 std::vector<MVT::SimpleValueType> Result; 229 ArrayRef<CodeGenRegisterClass*> RCs = getRegBank().getRegClasses(); 230 for (unsigned i = 0, e = RCs.size(); i != e; ++i) { 231 const CodeGenRegisterClass &RC = *RCs[i]; 232 if (RC.contains(Reg)) { 233 ArrayRef<MVT::SimpleValueType> InVTs = RC.getValueTypes(); 234 Result.insert(Result.end(), InVTs.begin(), InVTs.end()); 235 } 236 } 237 238 // Remove duplicates. 239 array_pod_sort(Result.begin(), Result.end()); 240 Result.erase(std::unique(Result.begin(), Result.end()), Result.end()); 241 return Result; 242 } 243 244 245 void CodeGenTarget::ReadLegalValueTypes() const { 246 ArrayRef<CodeGenRegisterClass*> RCs = getRegBank().getRegClasses(); 247 for (unsigned i = 0, e = RCs.size(); i != e; ++i) 248 for (unsigned ri = 0, re = RCs[i]->VTs.size(); ri != re; ++ri) 249 LegalValueTypes.push_back(RCs[i]->VTs[ri]); 250 251 // Remove duplicates. 252 std::sort(LegalValueTypes.begin(), LegalValueTypes.end()); 253 LegalValueTypes.erase(std::unique(LegalValueTypes.begin(), 254 LegalValueTypes.end()), 255 LegalValueTypes.end()); 256 } 257 258 CodeGenSchedModels &CodeGenTarget::getSchedModels() const { 259 if (!SchedModels) 260 SchedModels = new CodeGenSchedModels(Records, *this); 261 return *SchedModels; 262 } 263 264 void CodeGenTarget::ReadInstructions() const { 265 std::vector<Record*> Insts = Records.getAllDerivedDefinitions("Instruction"); 266 if (Insts.size() <= 2) 267 PrintFatalError("No 'Instruction' subclasses defined!"); 268 269 // Parse the instructions defined in the .td file. 270 for (unsigned i = 0, e = Insts.size(); i != e; ++i) 271 Instructions[Insts[i]] = new CodeGenInstruction(Insts[i]); 272 } 273 274 static const CodeGenInstruction * 275 GetInstByName(const char *Name, 276 const DenseMap<const Record*, CodeGenInstruction*> &Insts, 277 RecordKeeper &Records) { 278 const Record *Rec = Records.getDef(Name); 279 280 DenseMap<const Record*, CodeGenInstruction*>::const_iterator 281 I = Insts.find(Rec); 282 if (Rec == 0 || I == Insts.end()) 283 PrintFatalError(std::string("Could not find '") + Name + "' instruction!"); 284 return I->second; 285 } 286 287 namespace { 288 /// SortInstByName - Sorting predicate to sort instructions by name. 289 /// 290 struct SortInstByName { 291 bool operator()(const CodeGenInstruction *Rec1, 292 const CodeGenInstruction *Rec2) const { 293 return Rec1->TheDef->getName() < Rec2->TheDef->getName(); 294 } 295 }; 296 } 297 298 /// getInstructionsByEnumValue - Return all of the instructions defined by the 299 /// target, ordered by their enum value. 300 void CodeGenTarget::ComputeInstrsByEnum() const { 301 // The ordering here must match the ordering in TargetOpcodes.h. 302 static const char *const FixedInstrs[] = { 303 "PHI", 304 "INLINEASM", 305 "PROLOG_LABEL", 306 "EH_LABEL", 307 "GC_LABEL", 308 "KILL", 309 "EXTRACT_SUBREG", 310 "INSERT_SUBREG", 311 "IMPLICIT_DEF", 312 "SUBREG_TO_REG", 313 "COPY_TO_REGCLASS", 314 "DBG_VALUE", 315 "REG_SEQUENCE", 316 "COPY", 317 "BUNDLE", 318 "LIFETIME_START", 319 "LIFETIME_END", 320 0 321 }; 322 const DenseMap<const Record*, CodeGenInstruction*> &Insts = getInstructions(); 323 for (const char *const *p = FixedInstrs; *p; ++p) { 324 const CodeGenInstruction *Instr = GetInstByName(*p, Insts, Records); 325 assert(Instr && "Missing target independent instruction"); 326 assert(Instr->Namespace == "TargetOpcode" && "Bad namespace"); 327 InstrsByEnum.push_back(Instr); 328 } 329 unsigned EndOfPredefines = InstrsByEnum.size(); 330 331 for (DenseMap<const Record*, CodeGenInstruction*>::const_iterator 332 I = Insts.begin(), E = Insts.end(); I != E; ++I) { 333 const CodeGenInstruction *CGI = I->second; 334 if (CGI->Namespace != "TargetOpcode") 335 InstrsByEnum.push_back(CGI); 336 } 337 338 assert(InstrsByEnum.size() == Insts.size() && "Missing predefined instr"); 339 340 // All of the instructions are now in random order based on the map iteration. 341 // Sort them by name. 342 std::sort(InstrsByEnum.begin()+EndOfPredefines, InstrsByEnum.end(), 343 SortInstByName()); 344 } 345 346 347 /// isLittleEndianEncoding - Return whether this target encodes its instruction 348 /// in little-endian format, i.e. bits laid out in the order [0..n] 349 /// 350 bool CodeGenTarget::isLittleEndianEncoding() const { 351 return getInstructionSet()->getValueAsBit("isLittleEndianEncoding"); 352 } 353 354 /// guessInstructionProperties - Return true if it's OK to guess instruction 355 /// properties instead of raising an error. 356 /// 357 /// This is configurable as a temporary migration aid. It will eventually be 358 /// permanently false. 359 bool CodeGenTarget::guessInstructionProperties() const { 360 return getInstructionSet()->getValueAsBit("guessInstructionProperties"); 361 } 362 363 //===----------------------------------------------------------------------===// 364 // ComplexPattern implementation 365 // 366 ComplexPattern::ComplexPattern(Record *R) { 367 Ty = ::getValueType(R->getValueAsDef("Ty")); 368 NumOperands = R->getValueAsInt("NumOperands"); 369 SelectFunc = R->getValueAsString("SelectFunc"); 370 RootNodes = R->getValueAsListOfDefs("RootNodes"); 371 372 // Parse the properties. 373 Properties = 0; 374 std::vector<Record*> PropList = R->getValueAsListOfDefs("Properties"); 375 for (unsigned i = 0, e = PropList.size(); i != e; ++i) 376 if (PropList[i]->getName() == "SDNPHasChain") { 377 Properties |= 1 << SDNPHasChain; 378 } else if (PropList[i]->getName() == "SDNPOptInGlue") { 379 Properties |= 1 << SDNPOptInGlue; 380 } else if (PropList[i]->getName() == "SDNPMayStore") { 381 Properties |= 1 << SDNPMayStore; 382 } else if (PropList[i]->getName() == "SDNPMayLoad") { 383 Properties |= 1 << SDNPMayLoad; 384 } else if (PropList[i]->getName() == "SDNPSideEffect") { 385 Properties |= 1 << SDNPSideEffect; 386 } else if (PropList[i]->getName() == "SDNPMemOperand") { 387 Properties |= 1 << SDNPMemOperand; 388 } else if (PropList[i]->getName() == "SDNPVariadic") { 389 Properties |= 1 << SDNPVariadic; 390 } else if (PropList[i]->getName() == "SDNPWantRoot") { 391 Properties |= 1 << SDNPWantRoot; 392 } else if (PropList[i]->getName() == "SDNPWantParent") { 393 Properties |= 1 << SDNPWantParent; 394 } else { 395 errs() << "Unsupported SD Node property '" << PropList[i]->getName() 396 << "' on ComplexPattern '" << R->getName() << "'!\n"; 397 exit(1); 398 } 399 } 400 401 //===----------------------------------------------------------------------===// 402 // CodeGenIntrinsic Implementation 403 //===----------------------------------------------------------------------===// 404 405 std::vector<CodeGenIntrinsic> llvm::LoadIntrinsics(const RecordKeeper &RC, 406 bool TargetOnly) { 407 std::vector<Record*> I = RC.getAllDerivedDefinitions("Intrinsic"); 408 409 std::vector<CodeGenIntrinsic> Result; 410 411 for (unsigned i = 0, e = I.size(); i != e; ++i) { 412 bool isTarget = I[i]->getValueAsBit("isTarget"); 413 if (isTarget == TargetOnly) 414 Result.push_back(CodeGenIntrinsic(I[i])); 415 } 416 return Result; 417 } 418 419 CodeGenIntrinsic::CodeGenIntrinsic(Record *R) { 420 TheDef = R; 421 std::string DefName = R->getName(); 422 ModRef = ReadWriteMem; 423 isOverloaded = false; 424 isCommutative = false; 425 canThrow = false; 426 isNoReturn = false; 427 428 if (DefName.size() <= 4 || 429 std::string(DefName.begin(), DefName.begin() + 4) != "int_") 430 PrintFatalError("Intrinsic '" + DefName + "' does not start with 'int_'!"); 431 432 EnumName = std::string(DefName.begin()+4, DefName.end()); 433 434 if (R->getValue("GCCBuiltinName")) // Ignore a missing GCCBuiltinName field. 435 GCCBuiltinName = R->getValueAsString("GCCBuiltinName"); 436 437 TargetPrefix = R->getValueAsString("TargetPrefix"); 438 Name = R->getValueAsString("LLVMName"); 439 440 if (Name == "") { 441 // If an explicit name isn't specified, derive one from the DefName. 442 Name = "llvm."; 443 444 for (unsigned i = 0, e = EnumName.size(); i != e; ++i) 445 Name += (EnumName[i] == '_') ? '.' : EnumName[i]; 446 } else { 447 // Verify it starts with "llvm.". 448 if (Name.size() <= 5 || 449 std::string(Name.begin(), Name.begin() + 5) != "llvm.") 450 PrintFatalError("Intrinsic '" + DefName + "'s name does not start with 'llvm.'!"); 451 } 452 453 // If TargetPrefix is specified, make sure that Name starts with 454 // "llvm.<targetprefix>.". 455 if (!TargetPrefix.empty()) { 456 if (Name.size() < 6+TargetPrefix.size() || 457 std::string(Name.begin() + 5, Name.begin() + 6 + TargetPrefix.size()) 458 != (TargetPrefix + ".")) 459 PrintFatalError("Intrinsic '" + DefName + "' does not start with 'llvm." + 460 TargetPrefix + ".'!"); 461 } 462 463 // Parse the list of return types. 464 std::vector<MVT::SimpleValueType> OverloadedVTs; 465 ListInit *TypeList = R->getValueAsListInit("RetTypes"); 466 for (unsigned i = 0, e = TypeList->getSize(); i != e; ++i) { 467 Record *TyEl = TypeList->getElementAsRecord(i); 468 assert(TyEl->isSubClassOf("LLVMType") && "Expected a type!"); 469 MVT::SimpleValueType VT; 470 if (TyEl->isSubClassOf("LLVMMatchType")) { 471 unsigned MatchTy = TyEl->getValueAsInt("Number"); 472 assert(MatchTy < OverloadedVTs.size() && 473 "Invalid matching number!"); 474 VT = OverloadedVTs[MatchTy]; 475 // It only makes sense to use the extended and truncated vector element 476 // variants with iAny types; otherwise, if the intrinsic is not 477 // overloaded, all the types can be specified directly. 478 assert(((!TyEl->isSubClassOf("LLVMExtendedElementVectorType") && 479 !TyEl->isSubClassOf("LLVMTruncatedElementVectorType")) || 480 VT == MVT::iAny || VT == MVT::vAny) && 481 "Expected iAny or vAny type"); 482 } else { 483 VT = getValueType(TyEl->getValueAsDef("VT")); 484 } 485 if (EVT(VT).isOverloaded()) { 486 OverloadedVTs.push_back(VT); 487 isOverloaded = true; 488 } 489 490 // Reject invalid types. 491 if (VT == MVT::isVoid) 492 PrintFatalError("Intrinsic '" + DefName + " has void in result type list!"); 493 494 IS.RetVTs.push_back(VT); 495 IS.RetTypeDefs.push_back(TyEl); 496 } 497 498 // Parse the list of parameter types. 499 TypeList = R->getValueAsListInit("ParamTypes"); 500 for (unsigned i = 0, e = TypeList->getSize(); i != e; ++i) { 501 Record *TyEl = TypeList->getElementAsRecord(i); 502 assert(TyEl->isSubClassOf("LLVMType") && "Expected a type!"); 503 MVT::SimpleValueType VT; 504 if (TyEl->isSubClassOf("LLVMMatchType")) { 505 unsigned MatchTy = TyEl->getValueAsInt("Number"); 506 assert(MatchTy < OverloadedVTs.size() && 507 "Invalid matching number!"); 508 VT = OverloadedVTs[MatchTy]; 509 // It only makes sense to use the extended and truncated vector element 510 // variants with iAny types; otherwise, if the intrinsic is not 511 // overloaded, all the types can be specified directly. 512 assert(((!TyEl->isSubClassOf("LLVMExtendedElementVectorType") && 513 !TyEl->isSubClassOf("LLVMTruncatedElementVectorType")) || 514 VT == MVT::iAny || VT == MVT::vAny) && 515 "Expected iAny or vAny type"); 516 } else 517 VT = getValueType(TyEl->getValueAsDef("VT")); 518 519 if (EVT(VT).isOverloaded()) { 520 OverloadedVTs.push_back(VT); 521 isOverloaded = true; 522 } 523 524 // Reject invalid types. 525 if (VT == MVT::isVoid && i != e-1 /*void at end means varargs*/) 526 PrintFatalError("Intrinsic '" + DefName + " has void in result type list!"); 527 528 IS.ParamVTs.push_back(VT); 529 IS.ParamTypeDefs.push_back(TyEl); 530 } 531 532 // Parse the intrinsic properties. 533 ListInit *PropList = R->getValueAsListInit("Properties"); 534 for (unsigned i = 0, e = PropList->getSize(); i != e; ++i) { 535 Record *Property = PropList->getElementAsRecord(i); 536 assert(Property->isSubClassOf("IntrinsicProperty") && 537 "Expected a property!"); 538 539 if (Property->getName() == "IntrNoMem") 540 ModRef = NoMem; 541 else if (Property->getName() == "IntrReadArgMem") 542 ModRef = ReadArgMem; 543 else if (Property->getName() == "IntrReadMem") 544 ModRef = ReadMem; 545 else if (Property->getName() == "IntrReadWriteArgMem") 546 ModRef = ReadWriteArgMem; 547 else if (Property->getName() == "Commutative") 548 isCommutative = true; 549 else if (Property->getName() == "Throws") 550 canThrow = true; 551 else if (Property->getName() == "IntrNoReturn") 552 isNoReturn = true; 553 else if (Property->isSubClassOf("NoCapture")) { 554 unsigned ArgNo = Property->getValueAsInt("ArgNo"); 555 ArgumentAttributes.push_back(std::make_pair(ArgNo, NoCapture)); 556 } else if (Property->isSubClassOf("ReadOnly")) { 557 unsigned ArgNo = Property->getValueAsInt("ArgNo"); 558 ArgumentAttributes.push_back(std::make_pair(ArgNo, ReadOnly)); 559 } else if (Property->isSubClassOf("ReadNone")) { 560 unsigned ArgNo = Property->getValueAsInt("ArgNo"); 561 ArgumentAttributes.push_back(std::make_pair(ArgNo, ReadNone)); 562 } else 563 llvm_unreachable("Unknown property!"); 564 } 565 566 // Sort the argument attributes for later benefit. 567 std::sort(ArgumentAttributes.begin(), ArgumentAttributes.end()); 568 } 569