Chris Lattner | 6cc654b | 2008-01-06 01:35:39 +0000 | [diff] [blame] | 1 | //===- CodeGenTarget.cpp - CodeGen Target Class Wrapper -------------------===// |
Misha Brukman | 3da94ae | 2005-04-22 00:00:37 +0000 | [diff] [blame] | 2 | // |
John Criswell | 01d4582 | 2003-10-20 20:20:30 +0000 | [diff] [blame] | 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
Chris Lattner | 3060910 | 2007-12-29 20:37:13 +0000 | [diff] [blame] | 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
Misha Brukman | 3da94ae | 2005-04-22 00:00:37 +0000 | [diff] [blame] | 7 | // |
John Criswell | 01d4582 | 2003-10-20 20:20:30 +0000 | [diff] [blame] | 8 | //===----------------------------------------------------------------------===// |
Chris Lattner | 4587207 | 2003-08-07 05:38:11 +0000 | [diff] [blame] | 9 | // |
Chris Lattner | 6cc654b | 2008-01-06 01:35:39 +0000 | [diff] [blame] | 10 | // This class wraps target description classes used by the various code |
Chris Lattner | 4587207 | 2003-08-07 05:38:11 +0000 | [diff] [blame] | 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 | |
Chris Lattner | 803a5f6 | 2004-08-01 04:04:35 +0000 | [diff] [blame] | 17 | #include "CodeGenTarget.h" |
Chris Lattner | 43fbbc3 | 2006-03-24 19:49:31 +0000 | [diff] [blame] | 18 | #include "CodeGenIntrinsics.h" |
Chris Lattner | 4587207 | 2003-08-07 05:38:11 +0000 | [diff] [blame] | 19 | #include "Record.h" |
Chris Lattner | 560a79f | 2004-10-03 19:34:31 +0000 | [diff] [blame] | 20 | #include "llvm/ADT/StringExtras.h" |
| 21 | #include "llvm/Support/CommandLine.h" |
Bill Wendling | f5da133 | 2006-12-07 22:21:48 +0000 | [diff] [blame] | 22 | #include "llvm/Support/Streams.h" |
Chris Lattner | 75ee2eb | 2005-10-14 03:54:49 +0000 | [diff] [blame] | 23 | #include <algorithm> |
Chris Lattner | 2082ebe | 2004-08-01 03:55:39 +0000 | [diff] [blame] | 24 | using namespace llvm; |
Brian Gaeke | d0fde30 | 2003-11-11 22:41:34 +0000 | [diff] [blame] | 25 | |
Chris Lattner | 560a79f | 2004-10-03 19:34:31 +0000 | [diff] [blame] | 26 | static cl::opt<unsigned> |
| 27 | AsmWriterNum("asmwriternum", cl::init(0), |
| 28 | cl::desc("Make -gen-asm-writer emit assembly writer #N")); |
| 29 | |
Duncan Sands | 83ec4b6 | 2008-06-06 12:08:01 +0000 | [diff] [blame] | 30 | /// getValueType - Return the MVT::SimpleValueType that the specified TableGen |
| 31 | /// record corresponds to. |
| 32 | MVT::SimpleValueType llvm::getValueType(Record *Rec) { |
| 33 | return (MVT::SimpleValueType)Rec->getValueAsInt("Value"); |
Chris Lattner | 4587207 | 2003-08-07 05:38:11 +0000 | [diff] [blame] | 34 | } |
| 35 | |
Duncan Sands | 83ec4b6 | 2008-06-06 12:08:01 +0000 | [diff] [blame] | 36 | std::string llvm::getName(MVT::SimpleValueType T) { |
Chris Lattner | 4587207 | 2003-08-07 05:38:11 +0000 | [diff] [blame] | 37 | switch (T) { |
Chris Lattner | d3464c1 | 2003-08-07 23:15:21 +0000 | [diff] [blame] | 38 | case MVT::Other: return "UNKNOWN"; |
Evan Cheng | d7c2c86 | 2006-06-15 00:16:37 +0000 | [diff] [blame] | 39 | case MVT::i1: return "MVT::i1"; |
| 40 | case MVT::i8: return "MVT::i8"; |
| 41 | case MVT::i16: return "MVT::i16"; |
| 42 | case MVT::i32: return "MVT::i32"; |
| 43 | case MVT::i64: return "MVT::i64"; |
| 44 | case MVT::i128: return "MVT::i128"; |
Reid Spencer | c4de3de | 2007-04-01 07:20:02 +0000 | [diff] [blame] | 45 | case MVT::iAny: return "MVT::iAny"; |
Dan Gohman | 0fee3ff | 2007-08-16 21:57:19 +0000 | [diff] [blame] | 46 | case MVT::fAny: return "MVT::fAny"; |
Evan Cheng | d7c2c86 | 2006-06-15 00:16:37 +0000 | [diff] [blame] | 47 | case MVT::f32: return "MVT::f32"; |
| 48 | case MVT::f64: return "MVT::f64"; |
| 49 | case MVT::f80: return "MVT::f80"; |
| 50 | case MVT::f128: return "MVT::f128"; |
Dale Johannesen | 317096a | 2007-09-28 01:08:20 +0000 | [diff] [blame] | 51 | case MVT::ppcf128: return "MVT::ppcf128"; |
Evan Cheng | d7c2c86 | 2006-06-15 00:16:37 +0000 | [diff] [blame] | 52 | case MVT::Flag: return "MVT::Flag"; |
Dan Gohman | ba6783e | 2008-08-20 01:44:30 +0000 | [diff] [blame] | 53 | case MVT::isVoid:return "MVT::isVoid"; |
Mon P Wang | 87c8a8f | 2008-12-18 20:03:17 +0000 | [diff] [blame] | 54 | case MVT::v2i8: return "MVT::v2i8"; |
| 55 | case MVT::v4i8: return "MVT::v4i8"; |
| 56 | case MVT::v2i16: return "MVT::v2i16"; |
Evan Cheng | d7c2c86 | 2006-06-15 00:16:37 +0000 | [diff] [blame] | 57 | case MVT::v8i8: return "MVT::v8i8"; |
| 58 | case MVT::v4i16: return "MVT::v4i16"; |
| 59 | case MVT::v2i32: return "MVT::v2i32"; |
Bill Wendling | eebc8a1 | 2007-03-26 07:53:08 +0000 | [diff] [blame] | 60 | case MVT::v1i64: return "MVT::v1i64"; |
Evan Cheng | d7c2c86 | 2006-06-15 00:16:37 +0000 | [diff] [blame] | 61 | case MVT::v16i8: return "MVT::v16i8"; |
| 62 | case MVT::v8i16: return "MVT::v8i16"; |
| 63 | case MVT::v4i32: return "MVT::v4i32"; |
| 64 | case MVT::v2i64: return "MVT::v2i64"; |
| 65 | case MVT::v2f32: return "MVT::v2f32"; |
| 66 | case MVT::v4f32: return "MVT::v4f32"; |
| 67 | case MVT::v2f64: return "MVT::v2f64"; |
Christopher Lamb | 8245510 | 2007-07-26 06:41:18 +0000 | [diff] [blame] | 68 | case MVT::v3i32: return "MVT::v3i32"; |
| 69 | case MVT::v3f32: return "MVT::v3f32"; |
Evan Cheng | 6b12516 | 2006-05-17 20:55:51 +0000 | [diff] [blame] | 70 | case MVT::iPTR: return "TLI.getPointerTy()"; |
Mon P Wang | e3b3a72 | 2008-07-30 04:36:53 +0000 | [diff] [blame] | 71 | case MVT::iPTRAny: return "TLI.getPointerTy()"; |
Chris Lattner | d3464c1 | 2003-08-07 23:15:21 +0000 | [diff] [blame] | 72 | default: assert(0 && "ILLEGAL VALUE TYPE!"); return ""; |
Chris Lattner | 4587207 | 2003-08-07 05:38:11 +0000 | [diff] [blame] | 73 | } |
Chris Lattner | d3464c1 | 2003-08-07 23:15:21 +0000 | [diff] [blame] | 74 | } |
| 75 | |
Duncan Sands | 83ec4b6 | 2008-06-06 12:08:01 +0000 | [diff] [blame] | 76 | std::string llvm::getEnumName(MVT::SimpleValueType T) { |
Chris Lattner | b72fb7e | 2003-08-10 19:50:32 +0000 | [diff] [blame] | 77 | switch (T) { |
Evan Cheng | 2618d07 | 2006-05-17 20:37:59 +0000 | [diff] [blame] | 78 | case MVT::Other: return "MVT::Other"; |
| 79 | case MVT::i1: return "MVT::i1"; |
| 80 | case MVT::i8: return "MVT::i8"; |
| 81 | case MVT::i16: return "MVT::i16"; |
| 82 | case MVT::i32: return "MVT::i32"; |
| 83 | case MVT::i64: return "MVT::i64"; |
| 84 | case MVT::i128: return "MVT::i128"; |
Reid Spencer | c4de3de | 2007-04-01 07:20:02 +0000 | [diff] [blame] | 85 | case MVT::iAny: return "MVT::iAny"; |
Dan Gohman | 0fee3ff | 2007-08-16 21:57:19 +0000 | [diff] [blame] | 86 | case MVT::fAny: return "MVT::fAny"; |
Evan Cheng | 2618d07 | 2006-05-17 20:37:59 +0000 | [diff] [blame] | 87 | case MVT::f32: return "MVT::f32"; |
| 88 | case MVT::f64: return "MVT::f64"; |
| 89 | case MVT::f80: return "MVT::f80"; |
| 90 | case MVT::f128: return "MVT::f128"; |
Dale Johannesen | 317096a | 2007-09-28 01:08:20 +0000 | [diff] [blame] | 91 | case MVT::ppcf128: return "MVT::ppcf128"; |
Evan Cheng | 2618d07 | 2006-05-17 20:37:59 +0000 | [diff] [blame] | 92 | case MVT::Flag: return "MVT::Flag"; |
| 93 | case MVT::isVoid:return "MVT::isVoid"; |
Mon P Wang | 87c8a8f | 2008-12-18 20:03:17 +0000 | [diff] [blame] | 94 | case MVT::v2i8: return "MVT::v2i8"; |
| 95 | case MVT::v4i8: return "MVT::v4i8"; |
| 96 | case MVT::v2i16: return "MVT::v2i16"; |
Evan Cheng | 2618d07 | 2006-05-17 20:37:59 +0000 | [diff] [blame] | 97 | case MVT::v8i8: return "MVT::v8i8"; |
| 98 | case MVT::v4i16: return "MVT::v4i16"; |
| 99 | case MVT::v2i32: return "MVT::v2i32"; |
Bill Wendling | eebc8a1 | 2007-03-26 07:53:08 +0000 | [diff] [blame] | 100 | case MVT::v1i64: return "MVT::v1i64"; |
Evan Cheng | 2618d07 | 2006-05-17 20:37:59 +0000 | [diff] [blame] | 101 | case MVT::v16i8: return "MVT::v16i8"; |
| 102 | case MVT::v8i16: return "MVT::v8i16"; |
| 103 | case MVT::v4i32: return "MVT::v4i32"; |
| 104 | case MVT::v2i64: return "MVT::v2i64"; |
| 105 | case MVT::v2f32: return "MVT::v2f32"; |
| 106 | case MVT::v4f32: return "MVT::v4f32"; |
| 107 | case MVT::v2f64: return "MVT::v2f64"; |
Christopher Lamb | 8245510 | 2007-07-26 06:41:18 +0000 | [diff] [blame] | 108 | case MVT::v3i32: return "MVT::v3i32"; |
| 109 | case MVT::v3f32: return "MVT::v3f32"; |
Chandler Carruth | 6994040 | 2007-08-04 01:51:18 +0000 | [diff] [blame] | 110 | case MVT::iPTR: return "MVT::iPTR"; |
Mon P Wang | e3b3a72 | 2008-07-30 04:36:53 +0000 | [diff] [blame] | 111 | case MVT::iPTRAny: return "MVT::iPTRAny"; |
Chris Lattner | b72fb7e | 2003-08-10 19:50:32 +0000 | [diff] [blame] | 112 | default: assert(0 && "ILLEGAL VALUE TYPE!"); return ""; |
| 113 | } |
| 114 | } |
| 115 | |
Chris Lattner | 6cefb77 | 2008-01-05 22:25:12 +0000 | [diff] [blame] | 116 | /// getQualifiedName - Return the name of the specified record, with a |
| 117 | /// namespace qualifier if the record contains one. |
| 118 | /// |
| 119 | std::string llvm::getQualifiedName(const Record *R) { |
| 120 | std::string Namespace = R->getValueAsString("Namespace"); |
| 121 | if (Namespace.empty()) return R->getName(); |
| 122 | return Namespace + "::" + R->getName(); |
| 123 | } |
| 124 | |
| 125 | |
| 126 | |
Chris Lattner | d3464c1 | 2003-08-07 23:15:21 +0000 | [diff] [blame] | 127 | |
Chris Lattner | 4587207 | 2003-08-07 05:38:11 +0000 | [diff] [blame] | 128 | /// getTarget - Return the current instance of the Target class. |
| 129 | /// |
Evan Cheng | 2618d07 | 2006-05-17 20:37:59 +0000 | [diff] [blame] | 130 | CodeGenTarget::CodeGenTarget() { |
Chris Lattner | 4587207 | 2003-08-07 05:38:11 +0000 | [diff] [blame] | 131 | std::vector<Record*> Targets = Records.getAllDerivedDefinitions("Target"); |
Misha Brukman | bebdb20 | 2004-06-04 14:59:42 +0000 | [diff] [blame] | 132 | if (Targets.size() == 0) |
Misha Brukman | 3da94ae | 2005-04-22 00:00:37 +0000 | [diff] [blame] | 133 | throw std::string("ERROR: No 'Target' subclasses defined!"); |
Chris Lattner | 4587207 | 2003-08-07 05:38:11 +0000 | [diff] [blame] | 134 | if (Targets.size() != 1) |
| 135 | throw std::string("ERROR: Multiple subclasses of Target defined!"); |
| 136 | TargetRec = Targets[0]; |
Chris Lattner | 4587207 | 2003-08-07 05:38:11 +0000 | [diff] [blame] | 137 | } |
| 138 | |
| 139 | |
| 140 | const std::string &CodeGenTarget::getName() const { |
| 141 | return TargetRec->getName(); |
| 142 | } |
| 143 | |
Dan Gohman | 1e0ee4b | 2008-08-20 21:45:57 +0000 | [diff] [blame] | 144 | std::string CodeGenTarget::getInstNamespace() const { |
| 145 | std::string InstNS; |
| 146 | |
| 147 | for (inst_iterator i = inst_begin(), e = inst_end(); i != e; ++i) { |
| 148 | InstNS = i->second.Namespace; |
| 149 | |
| 150 | // Make sure not to pick up "TargetInstrInfo" by accidentally getting |
| 151 | // the namespace off the PHI instruction or something. |
| 152 | if (InstNS != "TargetInstrInfo") |
| 153 | break; |
| 154 | } |
| 155 | |
| 156 | return InstNS; |
| 157 | } |
| 158 | |
Chris Lattner | 4587207 | 2003-08-07 05:38:11 +0000 | [diff] [blame] | 159 | Record *CodeGenTarget::getInstructionSet() const { |
| 160 | return TargetRec->getValueAsDef("InstructionSet"); |
| 161 | } |
Brian Gaeke | d0fde30 | 2003-11-11 22:41:34 +0000 | [diff] [blame] | 162 | |
Chris Lattner | 175580c | 2004-08-14 22:50:53 +0000 | [diff] [blame] | 163 | /// getAsmWriter - Return the AssemblyWriter definition for this target. |
| 164 | /// |
| 165 | Record *CodeGenTarget::getAsmWriter() const { |
Chris Lattner | b0e103d | 2005-10-28 22:49:02 +0000 | [diff] [blame] | 166 | std::vector<Record*> LI = TargetRec->getValueAsListOfDefs("AssemblyWriters"); |
| 167 | if (AsmWriterNum >= LI.size()) |
Chris Lattner | 560a79f | 2004-10-03 19:34:31 +0000 | [diff] [blame] | 168 | throw "Target does not have an AsmWriter #" + utostr(AsmWriterNum) + "!"; |
Chris Lattner | b0e103d | 2005-10-28 22:49:02 +0000 | [diff] [blame] | 169 | return LI[AsmWriterNum]; |
Chris Lattner | 175580c | 2004-08-14 22:50:53 +0000 | [diff] [blame] | 170 | } |
| 171 | |
Chris Lattner | 2669311 | 2004-08-16 01:10:21 +0000 | [diff] [blame] | 172 | void CodeGenTarget::ReadRegisters() const { |
| 173 | std::vector<Record*> Regs = Records.getAllDerivedDefinitions("Register"); |
| 174 | if (Regs.empty()) |
| 175 | throw std::string("No 'Register' subclasses defined!"); |
| 176 | |
| 177 | Registers.reserve(Regs.size()); |
| 178 | Registers.assign(Regs.begin(), Regs.end()); |
| 179 | } |
| 180 | |
Chris Lattner | 7a680c6 | 2004-08-21 02:24:57 +0000 | [diff] [blame] | 181 | CodeGenRegister::CodeGenRegister(Record *R) : TheDef(R) { |
| 182 | DeclaredSpillSize = R->getValueAsInt("SpillSize"); |
| 183 | DeclaredSpillAlignment = R->getValueAsInt("SpillAlignment"); |
| 184 | } |
| 185 | |
Chris Lattner | 2669311 | 2004-08-16 01:10:21 +0000 | [diff] [blame] | 186 | const std::string &CodeGenRegister::getName() const { |
| 187 | return TheDef->getName(); |
| 188 | } |
| 189 | |
Chris Lattner | 056afef | 2004-08-21 04:05:00 +0000 | [diff] [blame] | 190 | void CodeGenTarget::ReadRegisterClasses() const { |
| 191 | std::vector<Record*> RegClasses = |
| 192 | Records.getAllDerivedDefinitions("RegisterClass"); |
| 193 | if (RegClasses.empty()) |
| 194 | throw std::string("No 'RegisterClass' subclasses defined!"); |
| 195 | |
| 196 | RegisterClasses.reserve(RegClasses.size()); |
| 197 | RegisterClasses.assign(RegClasses.begin(), RegClasses.end()); |
| 198 | } |
| 199 | |
Evan Cheng | 44a65fa | 2006-05-16 07:05:30 +0000 | [diff] [blame] | 200 | std::vector<unsigned char> CodeGenTarget::getRegisterVTs(Record *R) const { |
| 201 | std::vector<unsigned char> Result; |
| 202 | const std::vector<CodeGenRegisterClass> &RCs = getRegisterClasses(); |
| 203 | for (unsigned i = 0, e = RCs.size(); i != e; ++i) { |
| 204 | const CodeGenRegisterClass &RC = RegisterClasses[i]; |
| 205 | for (unsigned ei = 0, ee = RC.Elements.size(); ei != ee; ++ei) { |
| 206 | if (R == RC.Elements[ei]) { |
Duncan Sands | 83ec4b6 | 2008-06-06 12:08:01 +0000 | [diff] [blame] | 207 | const std::vector<MVT::SimpleValueType> &InVTs = RC.getValueTypes(); |
Evan Cheng | 44a65fa | 2006-05-16 07:05:30 +0000 | [diff] [blame] | 208 | for (unsigned i = 0, e = InVTs.size(); i != e; ++i) |
| 209 | Result.push_back(InVTs[i]); |
| 210 | } |
| 211 | } |
| 212 | } |
| 213 | return Result; |
| 214 | } |
| 215 | |
| 216 | |
Chris Lattner | 056afef | 2004-08-21 04:05:00 +0000 | [diff] [blame] | 217 | CodeGenRegisterClass::CodeGenRegisterClass(Record *R) : TheDef(R) { |
Chris Lattner | c67c18f | 2005-08-19 18:45:20 +0000 | [diff] [blame] | 218 | // Rename anonymous register classes. |
| 219 | if (R->getName().size() > 9 && R->getName()[9] == '.') { |
| 220 | static unsigned AnonCounter = 0; |
| 221 | R->setName("AnonRegClass_"+utostr(AnonCounter++)); |
| 222 | } |
| 223 | |
Nate Begeman | 6510b22 | 2005-12-01 04:51:06 +0000 | [diff] [blame] | 224 | std::vector<Record*> TypeList = R->getValueAsListOfDefs("RegTypes"); |
| 225 | for (unsigned i = 0, e = TypeList.size(); i != e; ++i) { |
| 226 | Record *Type = TypeList[i]; |
| 227 | if (!Type->isSubClassOf("ValueType")) |
| 228 | throw "RegTypes list member '" + Type->getName() + |
| 229 | "' does not derive from the ValueType class!"; |
| 230 | VTs.push_back(getValueType(Type)); |
| 231 | } |
| 232 | assert(!VTs.empty() && "RegisterClass must contain at least one ValueType!"); |
Chris Lattner | ac46893 | 2005-08-19 19:12:51 +0000 | [diff] [blame] | 233 | |
Chris Lattner | b0e103d | 2005-10-28 22:49:02 +0000 | [diff] [blame] | 234 | std::vector<Record*> RegList = R->getValueAsListOfDefs("MemberList"); |
| 235 | for (unsigned i = 0, e = RegList.size(); i != e; ++i) { |
| 236 | Record *Reg = RegList[i]; |
Chris Lattner | 056afef | 2004-08-21 04:05:00 +0000 | [diff] [blame] | 237 | if (!Reg->isSubClassOf("Register")) |
| 238 | throw "Register Class member '" + Reg->getName() + |
| 239 | "' does not derive from the Register class!"; |
| 240 | Elements.push_back(Reg); |
| 241 | } |
Nate Begeman | 6510b22 | 2005-12-01 04:51:06 +0000 | [diff] [blame] | 242 | |
Christopher Lamb | a321125 | 2007-06-13 22:20:15 +0000 | [diff] [blame] | 243 | std::vector<Record*> SubRegClassList = |
| 244 | R->getValueAsListOfDefs("SubRegClassList"); |
| 245 | for (unsigned i = 0, e = SubRegClassList.size(); i != e; ++i) { |
| 246 | Record *SubRegClass = SubRegClassList[i]; |
| 247 | if (!SubRegClass->isSubClassOf("RegisterClass")) |
| 248 | throw "Register Class member '" + SubRegClass->getName() + |
| 249 | "' does not derive from the RegisterClass class!"; |
| 250 | SubRegClasses.push_back(SubRegClass); |
| 251 | } |
| 252 | |
Nate Begeman | 6510b22 | 2005-12-01 04:51:06 +0000 | [diff] [blame] | 253 | // Allow targets to override the size in bits of the RegisterClass. |
| 254 | unsigned Size = R->getValueAsInt("Size"); |
| 255 | |
| 256 | Namespace = R->getValueAsString("Namespace"); |
Duncan Sands | 83ec4b6 | 2008-06-06 12:08:01 +0000 | [diff] [blame] | 257 | SpillSize = Size ? Size : MVT(VTs[0]).getSizeInBits(); |
Nate Begeman | 6510b22 | 2005-12-01 04:51:06 +0000 | [diff] [blame] | 258 | SpillAlignment = R->getValueAsInt("Alignment"); |
Evan Cheng | a3ca314 | 2007-09-19 01:35:01 +0000 | [diff] [blame] | 259 | CopyCost = R->getValueAsInt("CopyCost"); |
Nate Begeman | 6510b22 | 2005-12-01 04:51:06 +0000 | [diff] [blame] | 260 | MethodBodies = R->getValueAsCode("MethodBodies"); |
| 261 | MethodProtos = R->getValueAsCode("MethodProtos"); |
Chris Lattner | 056afef | 2004-08-21 04:05:00 +0000 | [diff] [blame] | 262 | } |
| 263 | |
| 264 | const std::string &CodeGenRegisterClass::getName() const { |
| 265 | return TheDef->getName(); |
| 266 | } |
| 267 | |
Chris Lattner | e9f4ba8 | 2005-09-08 21:43:21 +0000 | [diff] [blame] | 268 | void CodeGenTarget::ReadLegalValueTypes() const { |
| 269 | const std::vector<CodeGenRegisterClass> &RCs = getRegisterClasses(); |
| 270 | for (unsigned i = 0, e = RCs.size(); i != e; ++i) |
Nate Begeman | 6510b22 | 2005-12-01 04:51:06 +0000 | [diff] [blame] | 271 | for (unsigned ri = 0, re = RCs[i].VTs.size(); ri != re; ++ri) |
| 272 | LegalValueTypes.push_back(RCs[i].VTs[ri]); |
Chris Lattner | 75ee2eb | 2005-10-14 03:54:49 +0000 | [diff] [blame] | 273 | |
| 274 | // Remove duplicates. |
| 275 | std::sort(LegalValueTypes.begin(), LegalValueTypes.end()); |
| 276 | LegalValueTypes.erase(std::unique(LegalValueTypes.begin(), |
| 277 | LegalValueTypes.end()), |
| 278 | LegalValueTypes.end()); |
Chris Lattner | e9f4ba8 | 2005-09-08 21:43:21 +0000 | [diff] [blame] | 279 | } |
Chris Lattner | 056afef | 2004-08-21 04:05:00 +0000 | [diff] [blame] | 280 | |
Chris Lattner | 175580c | 2004-08-14 22:50:53 +0000 | [diff] [blame] | 281 | |
Chris Lattner | ec35240 | 2004-08-01 05:04:00 +0000 | [diff] [blame] | 282 | void CodeGenTarget::ReadInstructions() const { |
| 283 | std::vector<Record*> Insts = Records.getAllDerivedDefinitions("Instruction"); |
Chris Lattner | aa77d77 | 2006-01-27 01:45:06 +0000 | [diff] [blame] | 284 | if (Insts.size() <= 2) |
Chris Lattner | ec35240 | 2004-08-01 05:04:00 +0000 | [diff] [blame] | 285 | throw std::string("No 'Instruction' subclasses defined!"); |
| 286 | |
Chris Lattner | aa77d77 | 2006-01-27 01:45:06 +0000 | [diff] [blame] | 287 | // Parse the instructions defined in the .td file. |
Chris Lattner | 175580c | 2004-08-14 22:50:53 +0000 | [diff] [blame] | 288 | std::string InstFormatName = |
| 289 | getAsmWriter()->getValueAsString("InstFormatName"); |
| 290 | |
| 291 | for (unsigned i = 0, e = Insts.size(); i != e; ++i) { |
| 292 | std::string AsmStr = Insts[i]->getValueAsString(InstFormatName); |
| 293 | Instructions.insert(std::make_pair(Insts[i]->getName(), |
| 294 | CodeGenInstruction(Insts[i], AsmStr))); |
| 295 | } |
Chris Lattner | ec35240 | 2004-08-01 05:04:00 +0000 | [diff] [blame] | 296 | } |
| 297 | |
Chris Lattner | d648867 | 2005-01-22 18:58:51 +0000 | [diff] [blame] | 298 | /// getInstructionsByEnumValue - Return all of the instructions defined by the |
| 299 | /// target, ordered by their enum value. |
| 300 | void CodeGenTarget:: |
| 301 | getInstructionsByEnumValue(std::vector<const CodeGenInstruction*> |
| 302 | &NumberedInstructions) { |
Chris Lattner | aa77d77 | 2006-01-27 01:45:06 +0000 | [diff] [blame] | 303 | std::map<std::string, CodeGenInstruction>::const_iterator I; |
| 304 | I = getInstructions().find("PHI"); |
| 305 | if (I == Instructions.end()) throw "Could not find 'PHI' instruction!"; |
| 306 | const CodeGenInstruction *PHI = &I->second; |
| 307 | |
| 308 | I = getInstructions().find("INLINEASM"); |
| 309 | if (I == Instructions.end()) throw "Could not find 'INLINEASM' instruction!"; |
| 310 | const CodeGenInstruction *INLINEASM = &I->second; |
| 311 | |
Dan Gohman | 4406604 | 2008-07-01 00:05:16 +0000 | [diff] [blame] | 312 | I = getInstructions().find("DBG_LABEL"); |
| 313 | if (I == Instructions.end()) throw "Could not find 'DBG_LABEL' instruction!"; |
| 314 | const CodeGenInstruction *DBG_LABEL = &I->second; |
| 315 | |
| 316 | I = getInstructions().find("EH_LABEL"); |
| 317 | if (I == Instructions.end()) throw "Could not find 'EH_LABEL' instruction!"; |
| 318 | const CodeGenInstruction *EH_LABEL = &I->second; |
| 319 | |
| 320 | I = getInstructions().find("GC_LABEL"); |
| 321 | if (I == Instructions.end()) throw "Could not find 'GC_LABEL' instruction!"; |
| 322 | const CodeGenInstruction *GC_LABEL = &I->second; |
Jim Laskey | a683f9b | 2007-01-26 17:29:20 +0000 | [diff] [blame] | 323 | |
Evan Cheng | a844bde | 2008-02-02 04:07:54 +0000 | [diff] [blame] | 324 | I = getInstructions().find("DECLARE"); |
| 325 | if (I == Instructions.end()) throw "Could not find 'DECLARE' instruction!"; |
| 326 | const CodeGenInstruction *DECLARE = &I->second; |
| 327 | |
Christopher Lamb | 08d5207 | 2007-07-26 07:48:21 +0000 | [diff] [blame] | 328 | I = getInstructions().find("EXTRACT_SUBREG"); |
| 329 | if (I == Instructions.end()) |
| 330 | throw "Could not find 'EXTRACT_SUBREG' instruction!"; |
| 331 | const CodeGenInstruction *EXTRACT_SUBREG = &I->second; |
| 332 | |
| 333 | I = getInstructions().find("INSERT_SUBREG"); |
| 334 | if (I == Instructions.end()) |
| 335 | throw "Could not find 'INSERT_SUBREG' instruction!"; |
| 336 | const CodeGenInstruction *INSERT_SUBREG = &I->second; |
| 337 | |
Evan Cheng | da47e6e | 2008-03-15 00:03:38 +0000 | [diff] [blame] | 338 | I = getInstructions().find("IMPLICIT_DEF"); |
| 339 | if (I == Instructions.end()) |
| 340 | throw "Could not find 'IMPLICIT_DEF' instruction!"; |
| 341 | const CodeGenInstruction *IMPLICIT_DEF = &I->second; |
| 342 | |
Christopher Lamb | c929823 | 2008-03-16 03:12:01 +0000 | [diff] [blame] | 343 | I = getInstructions().find("SUBREG_TO_REG"); |
| 344 | if (I == Instructions.end()) |
| 345 | throw "Could not find 'SUBREG_TO_REG' instruction!"; |
| 346 | const CodeGenInstruction *SUBREG_TO_REG = &I->second; |
| 347 | |
Chris Lattner | d648867 | 2005-01-22 18:58:51 +0000 | [diff] [blame] | 348 | // Print out the rest of the instructions now. |
Chris Lattner | d648867 | 2005-01-22 18:58:51 +0000 | [diff] [blame] | 349 | NumberedInstructions.push_back(PHI); |
Chris Lattner | aa77d77 | 2006-01-27 01:45:06 +0000 | [diff] [blame] | 350 | NumberedInstructions.push_back(INLINEASM); |
Dan Gohman | 4406604 | 2008-07-01 00:05:16 +0000 | [diff] [blame] | 351 | NumberedInstructions.push_back(DBG_LABEL); |
| 352 | NumberedInstructions.push_back(EH_LABEL); |
| 353 | NumberedInstructions.push_back(GC_LABEL); |
Evan Cheng | a844bde | 2008-02-02 04:07:54 +0000 | [diff] [blame] | 354 | NumberedInstructions.push_back(DECLARE); |
Christopher Lamb | 08d5207 | 2007-07-26 07:48:21 +0000 | [diff] [blame] | 355 | NumberedInstructions.push_back(EXTRACT_SUBREG); |
| 356 | NumberedInstructions.push_back(INSERT_SUBREG); |
Evan Cheng | da47e6e | 2008-03-15 00:03:38 +0000 | [diff] [blame] | 357 | NumberedInstructions.push_back(IMPLICIT_DEF); |
Christopher Lamb | c929823 | 2008-03-16 03:12:01 +0000 | [diff] [blame] | 358 | NumberedInstructions.push_back(SUBREG_TO_REG); |
Chris Lattner | d648867 | 2005-01-22 18:58:51 +0000 | [diff] [blame] | 359 | for (inst_iterator II = inst_begin(), E = inst_end(); II != E; ++II) |
Jim Laskey | a683f9b | 2007-01-26 17:29:20 +0000 | [diff] [blame] | 360 | if (&II->second != PHI && |
| 361 | &II->second != INLINEASM && |
Dan Gohman | 4406604 | 2008-07-01 00:05:16 +0000 | [diff] [blame] | 362 | &II->second != DBG_LABEL && |
| 363 | &II->second != EH_LABEL && |
| 364 | &II->second != GC_LABEL && |
Evan Cheng | a844bde | 2008-02-02 04:07:54 +0000 | [diff] [blame] | 365 | &II->second != DECLARE && |
Christopher Lamb | 08d5207 | 2007-07-26 07:48:21 +0000 | [diff] [blame] | 366 | &II->second != EXTRACT_SUBREG && |
Evan Cheng | da47e6e | 2008-03-15 00:03:38 +0000 | [diff] [blame] | 367 | &II->second != INSERT_SUBREG && |
Christopher Lamb | c929823 | 2008-03-16 03:12:01 +0000 | [diff] [blame] | 368 | &II->second != IMPLICIT_DEF && |
| 369 | &II->second != SUBREG_TO_REG) |
Chris Lattner | d648867 | 2005-01-22 18:58:51 +0000 | [diff] [blame] | 370 | NumberedInstructions.push_back(&II->second); |
| 371 | } |
| 372 | |
| 373 | |
Misha Brukman | 35e83cc | 2004-10-14 05:50:43 +0000 | [diff] [blame] | 374 | /// isLittleEndianEncoding - Return whether this target encodes its instruction |
| 375 | /// in little-endian format, i.e. bits laid out in the order [0..n] |
| 376 | /// |
| 377 | bool CodeGenTarget::isLittleEndianEncoding() const { |
| 378 | return getInstructionSet()->getValueAsBit("isLittleEndianEncoding"); |
| 379 | } |
| 380 | |
Evan Cheng | 0fc7198 | 2005-12-08 02:00:36 +0000 | [diff] [blame] | 381 | //===----------------------------------------------------------------------===// |
| 382 | // ComplexPattern implementation |
| 383 | // |
| 384 | ComplexPattern::ComplexPattern(Record *R) { |
Evan Cheng | 3aa39f4 | 2005-12-08 02:14:08 +0000 | [diff] [blame] | 385 | Ty = ::getValueType(R->getValueAsDef("Ty")); |
| 386 | NumOperands = R->getValueAsInt("NumOperands"); |
| 387 | SelectFunc = R->getValueAsString("SelectFunc"); |
| 388 | RootNodes = R->getValueAsListOfDefs("RootNodes"); |
Evan Cheng | 94b3040 | 2006-10-11 21:02:01 +0000 | [diff] [blame] | 389 | |
| 390 | // Parse the properties. |
| 391 | Properties = 0; |
| 392 | std::vector<Record*> PropList = R->getValueAsListOfDefs("Properties"); |
| 393 | for (unsigned i = 0, e = PropList.size(); i != e; ++i) |
| 394 | if (PropList[i]->getName() == "SDNPHasChain") { |
| 395 | Properties |= 1 << SDNPHasChain; |
| 396 | } else if (PropList[i]->getName() == "SDNPOptInFlag") { |
| 397 | Properties |= 1 << SDNPOptInFlag; |
Chris Lattner | ba7e756 | 2008-01-10 07:59:24 +0000 | [diff] [blame] | 398 | } else if (PropList[i]->getName() == "SDNPMayStore") { |
| 399 | Properties |= 1 << SDNPMayStore; |
| 400 | } else if (PropList[i]->getName() == "SDNPMayLoad") { |
| 401 | Properties |= 1 << SDNPMayLoad; |
| 402 | } else if (PropList[i]->getName() == "SDNPSideEffect") { |
| 403 | Properties |= 1 << SDNPSideEffect; |
Mon P Wang | 2887310 | 2008-06-25 08:15:39 +0000 | [diff] [blame] | 404 | } else if (PropList[i]->getName() == "SDNPMemOperand") { |
| 405 | Properties |= 1 << SDNPMemOperand; |
Evan Cheng | 94b3040 | 2006-10-11 21:02:01 +0000 | [diff] [blame] | 406 | } else { |
Bill Wendling | f5da133 | 2006-12-07 22:21:48 +0000 | [diff] [blame] | 407 | cerr << "Unsupported SD Node property '" << PropList[i]->getName() |
| 408 | << "' on ComplexPattern '" << R->getName() << "'!\n"; |
Evan Cheng | 94b3040 | 2006-10-11 21:02:01 +0000 | [diff] [blame] | 409 | exit(1); |
| 410 | } |
Christopher Lamb | 8535624 | 2008-01-31 07:27:46 +0000 | [diff] [blame] | 411 | |
| 412 | // Parse the attributes. |
| 413 | Attributes = 0; |
| 414 | PropList = R->getValueAsListOfDefs("Attributes"); |
| 415 | for (unsigned i = 0, e = PropList.size(); i != e; ++i) |
| 416 | if (PropList[i]->getName() == "CPAttrParentAsRoot") { |
| 417 | Attributes |= 1 << CPAttrParentAsRoot; |
| 418 | } else { |
| 419 | cerr << "Unsupported pattern attribute '" << PropList[i]->getName() |
| 420 | << "' on ComplexPattern '" << R->getName() << "'!\n"; |
| 421 | exit(1); |
| 422 | } |
Evan Cheng | 0fc7198 | 2005-12-08 02:00:36 +0000 | [diff] [blame] | 423 | } |
Evan Cheng | 3aa39f4 | 2005-12-08 02:14:08 +0000 | [diff] [blame] | 424 | |
Chris Lattner | 43fbbc3 | 2006-03-24 19:49:31 +0000 | [diff] [blame] | 425 | //===----------------------------------------------------------------------===// |
| 426 | // CodeGenIntrinsic Implementation |
| 427 | //===----------------------------------------------------------------------===// |
| 428 | |
| 429 | std::vector<CodeGenIntrinsic> llvm::LoadIntrinsics(const RecordKeeper &RC) { |
| 430 | std::vector<Record*> I = RC.getAllDerivedDefinitions("Intrinsic"); |
Chris Lattner | 8850a1b | 2006-03-27 22:48:18 +0000 | [diff] [blame] | 431 | |
| 432 | std::vector<CodeGenIntrinsic> Result; |
Chris Lattner | 6a160fb | 2006-03-28 00:15:00 +0000 | [diff] [blame] | 433 | |
Chris Lattner | 8850a1b | 2006-03-27 22:48:18 +0000 | [diff] [blame] | 434 | for (unsigned i = 0, e = I.size(); i != e; ++i) |
Dan Gohman | ee4fa19 | 2008-04-03 00:02:49 +0000 | [diff] [blame] | 435 | Result.push_back(CodeGenIntrinsic(I[i])); |
Chris Lattner | 8850a1b | 2006-03-27 22:48:18 +0000 | [diff] [blame] | 436 | return Result; |
Chris Lattner | 43fbbc3 | 2006-03-24 19:49:31 +0000 | [diff] [blame] | 437 | } |
| 438 | |
Dan Gohman | ee4fa19 | 2008-04-03 00:02:49 +0000 | [diff] [blame] | 439 | CodeGenIntrinsic::CodeGenIntrinsic(Record *R) { |
Chris Lattner | 2ca956f | 2006-03-24 20:25:01 +0000 | [diff] [blame] | 440 | TheDef = R; |
Chris Lattner | 43fbbc3 | 2006-03-24 19:49:31 +0000 | [diff] [blame] | 441 | std::string DefName = R->getName(); |
| 442 | ModRef = WriteMem; |
Reid Spencer | c4de3de | 2007-04-01 07:20:02 +0000 | [diff] [blame] | 443 | isOverloaded = false; |
Evan Cheng | 6bd9567 | 2008-06-16 20:29:38 +0000 | [diff] [blame] | 444 | isCommutative = false; |
Chris Lattner | 43fbbc3 | 2006-03-24 19:49:31 +0000 | [diff] [blame] | 445 | |
| 446 | if (DefName.size() <= 4 || |
Bill Wendling | cdcc3e6 | 2008-11-13 09:08:33 +0000 | [diff] [blame] | 447 | std::string(DefName.begin(), DefName.begin() + 4) != "int_") |
Chris Lattner | 43fbbc3 | 2006-03-24 19:49:31 +0000 | [diff] [blame] | 448 | throw "Intrinsic '" + DefName + "' does not start with 'int_'!"; |
Bill Wendling | cdcc3e6 | 2008-11-13 09:08:33 +0000 | [diff] [blame] | 449 | |
Chris Lattner | 43fbbc3 | 2006-03-24 19:49:31 +0000 | [diff] [blame] | 450 | EnumName = std::string(DefName.begin()+4, DefName.end()); |
Bill Wendling | cdcc3e6 | 2008-11-13 09:08:33 +0000 | [diff] [blame] | 451 | |
Chris Lattner | 43fbbc3 | 2006-03-24 19:49:31 +0000 | [diff] [blame] | 452 | if (R->getValue("GCCBuiltinName")) // Ignore a missing GCCBuiltinName field. |
| 453 | GCCBuiltinName = R->getValueAsString("GCCBuiltinName"); |
Bill Wendling | cdcc3e6 | 2008-11-13 09:08:33 +0000 | [diff] [blame] | 454 | |
| 455 | TargetPrefix = R->getValueAsString("TargetPrefix"); |
Chris Lattner | 43fbbc3 | 2006-03-24 19:49:31 +0000 | [diff] [blame] | 456 | Name = R->getValueAsString("LLVMName"); |
Bill Wendling | cdcc3e6 | 2008-11-13 09:08:33 +0000 | [diff] [blame] | 457 | |
Chris Lattner | 43fbbc3 | 2006-03-24 19:49:31 +0000 | [diff] [blame] | 458 | if (Name == "") { |
| 459 | // If an explicit name isn't specified, derive one from the DefName. |
| 460 | Name = "llvm."; |
Bill Wendling | cdcc3e6 | 2008-11-13 09:08:33 +0000 | [diff] [blame] | 461 | |
Chris Lattner | 43fbbc3 | 2006-03-24 19:49:31 +0000 | [diff] [blame] | 462 | for (unsigned i = 0, e = EnumName.size(); i != e; ++i) |
Bill Wendling | cdcc3e6 | 2008-11-13 09:08:33 +0000 | [diff] [blame] | 463 | Name += (EnumName[i] == '_') ? '.' : EnumName[i]; |
Chris Lattner | 43fbbc3 | 2006-03-24 19:49:31 +0000 | [diff] [blame] | 464 | } else { |
| 465 | // Verify it starts with "llvm.". |
| 466 | if (Name.size() <= 5 || |
Bill Wendling | cdcc3e6 | 2008-11-13 09:08:33 +0000 | [diff] [blame] | 467 | std::string(Name.begin(), Name.begin() + 5) != "llvm.") |
Chris Lattner | 43fbbc3 | 2006-03-24 19:49:31 +0000 | [diff] [blame] | 468 | throw "Intrinsic '" + DefName + "'s name does not start with 'llvm.'!"; |
| 469 | } |
| 470 | |
| 471 | // If TargetPrefix is specified, make sure that Name starts with |
| 472 | // "llvm.<targetprefix>.". |
| 473 | if (!TargetPrefix.empty()) { |
| 474 | if (Name.size() < 6+TargetPrefix.size() || |
Bill Wendling | cdcc3e6 | 2008-11-13 09:08:33 +0000 | [diff] [blame] | 475 | std::string(Name.begin() + 5, Name.begin() + 6 + TargetPrefix.size()) |
| 476 | != (TargetPrefix + ".")) |
| 477 | throw "Intrinsic '" + DefName + "' does not start with 'llvm." + |
Chris Lattner | 43fbbc3 | 2006-03-24 19:49:31 +0000 | [diff] [blame] | 478 | TargetPrefix + ".'!"; |
| 479 | } |
| 480 | |
Bill Wendling | cdcc3e6 | 2008-11-13 09:08:33 +0000 | [diff] [blame] | 481 | // Parse the list of return types. |
| 482 | ListInit *TypeList = R->getValueAsListInit("RetTypes"); |
Chris Lattner | 43fbbc3 | 2006-03-24 19:49:31 +0000 | [diff] [blame] | 483 | for (unsigned i = 0, e = TypeList->getSize(); i != e; ++i) { |
Chris Lattner | 50d4565 | 2007-02-27 22:08:27 +0000 | [diff] [blame] | 484 | Record *TyEl = TypeList->getElementAsRecord(i); |
Chris Lattner | 43fbbc3 | 2006-03-24 19:49:31 +0000 | [diff] [blame] | 485 | assert(TyEl->isSubClassOf("LLVMType") && "Expected a type!"); |
Bob Wilson | bc03979 | 2009-01-07 00:09:01 +0000 | [diff] [blame^] | 486 | MVT::SimpleValueType VT; |
| 487 | if (TyEl->isSubClassOf("LLVMMatchType")) { |
| 488 | VT = IS.RetVTs[TyEl->getValueAsInt("Number")]; |
| 489 | // It only makes sense to use the extended and truncated vector element |
| 490 | // variants with iAny types; otherwise, if the intrinsic is not |
| 491 | // overloaded, all the types can be specified directly. |
| 492 | assert(((!TyEl->isSubClassOf("LLVMExtendedElementVectorType") && |
| 493 | !TyEl->isSubClassOf("LLVMTruncatedElementVectorType")) || |
| 494 | VT == MVT::iAny) && "Expected iAny type"); |
| 495 | } else |
| 496 | VT = getValueType(TyEl->getValueAsDef("VT")); |
Mon P Wang | e3b3a72 | 2008-07-30 04:36:53 +0000 | [diff] [blame] | 497 | isOverloaded |= VT == MVT::iAny || VT == MVT::fAny || VT == MVT::iPTRAny; |
Bill Wendling | cdcc3e6 | 2008-11-13 09:08:33 +0000 | [diff] [blame] | 498 | IS.RetVTs.push_back(VT); |
| 499 | IS.RetTypeDefs.push_back(TyEl); |
Chris Lattner | 43fbbc3 | 2006-03-24 19:49:31 +0000 | [diff] [blame] | 500 | } |
Bill Wendling | cdcc3e6 | 2008-11-13 09:08:33 +0000 | [diff] [blame] | 501 | |
| 502 | if (IS.RetVTs.size() == 0) |
Chris Lattner | 43fbbc3 | 2006-03-24 19:49:31 +0000 | [diff] [blame] | 503 | throw "Intrinsic '"+DefName+"' needs at least a type for the ret value!"; |
Reid Spencer | c4de3de | 2007-04-01 07:20:02 +0000 | [diff] [blame] | 504 | |
Bill Wendling | cdcc3e6 | 2008-11-13 09:08:33 +0000 | [diff] [blame] | 505 | // Parse the list of parameter types. |
| 506 | TypeList = R->getValueAsListInit("ParamTypes"); |
| 507 | for (unsigned i = 0, e = TypeList->getSize(); i != e; ++i) { |
| 508 | Record *TyEl = TypeList->getElementAsRecord(i); |
| 509 | assert(TyEl->isSubClassOf("LLVMType") && "Expected a type!"); |
Bob Wilson | bc03979 | 2009-01-07 00:09:01 +0000 | [diff] [blame^] | 510 | MVT::SimpleValueType VT; |
| 511 | if (TyEl->isSubClassOf("LLVMMatchType")) { |
| 512 | unsigned MatchTy = TyEl->getValueAsInt("Number"); |
| 513 | if (MatchTy < IS.RetVTs.size()) |
| 514 | VT = IS.RetVTs[MatchTy]; |
| 515 | else |
| 516 | VT = IS.ParamVTs[MatchTy - IS.RetVTs.size()]; |
| 517 | // It only makes sense to use the extended and truncated vector element |
| 518 | // variants with iAny types; otherwise, if the intrinsic is not |
| 519 | // overloaded, all the types can be specified directly. |
| 520 | assert(((!TyEl->isSubClassOf("LLVMExtendedElementVectorType") && |
| 521 | !TyEl->isSubClassOf("LLVMTruncatedElementVectorType")) || |
| 522 | VT == MVT::iAny) && "Expected iAny type"); |
| 523 | } else |
| 524 | VT = getValueType(TyEl->getValueAsDef("VT")); |
Bill Wendling | cdcc3e6 | 2008-11-13 09:08:33 +0000 | [diff] [blame] | 525 | isOverloaded |= VT == MVT::iAny || VT == MVT::fAny || VT == MVT::iPTRAny; |
| 526 | IS.ParamVTs.push_back(VT); |
| 527 | IS.ParamTypeDefs.push_back(TyEl); |
| 528 | } |
| 529 | |
Chris Lattner | 43fbbc3 | 2006-03-24 19:49:31 +0000 | [diff] [blame] | 530 | // Parse the intrinsic properties. |
| 531 | ListInit *PropList = R->getValueAsListInit("Properties"); |
| 532 | for (unsigned i = 0, e = PropList->getSize(); i != e; ++i) { |
Chris Lattner | 50d4565 | 2007-02-27 22:08:27 +0000 | [diff] [blame] | 533 | Record *Property = PropList->getElementAsRecord(i); |
Chris Lattner | 43fbbc3 | 2006-03-24 19:49:31 +0000 | [diff] [blame] | 534 | assert(Property->isSubClassOf("IntrinsicProperty") && |
| 535 | "Expected a property!"); |
| 536 | |
Chris Lattner | 4b2362e | 2006-04-10 22:02:59 +0000 | [diff] [blame] | 537 | if (Property->getName() == "IntrNoMem") |
Chris Lattner | 43fbbc3 | 2006-03-24 19:49:31 +0000 | [diff] [blame] | 538 | ModRef = NoMem; |
Chris Lattner | 4b2362e | 2006-04-10 22:02:59 +0000 | [diff] [blame] | 539 | else if (Property->getName() == "IntrReadArgMem") |
Chris Lattner | 43fbbc3 | 2006-03-24 19:49:31 +0000 | [diff] [blame] | 540 | ModRef = ReadArgMem; |
| 541 | else if (Property->getName() == "IntrReadMem") |
| 542 | ModRef = ReadMem; |
Chris Lattner | 4b2362e | 2006-04-10 22:02:59 +0000 | [diff] [blame] | 543 | else if (Property->getName() == "IntrWriteArgMem") |
Chris Lattner | 43fbbc3 | 2006-03-24 19:49:31 +0000 | [diff] [blame] | 544 | ModRef = WriteArgMem; |
| 545 | else if (Property->getName() == "IntrWriteMem") |
| 546 | ModRef = WriteMem; |
Evan Cheng | 6bd9567 | 2008-06-16 20:29:38 +0000 | [diff] [blame] | 547 | else if (Property->getName() == "Commutative") |
| 548 | isCommutative = true; |
Chris Lattner | 43fbbc3 | 2006-03-24 19:49:31 +0000 | [diff] [blame] | 549 | else |
| 550 | assert(0 && "Unknown property!"); |
| 551 | } |
| 552 | } |