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