CodeGenTarget.cpp 19 KB

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