1 //===- CodeGenTarget.cpp - CodeGen Target Class Wrapper ---------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file was developed by the LLVM research group and is distributed under
6 // the University of Illinois Open Source License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This class wrap 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.
15 //===----------------------------------------------------------------------===//
17 #include "CodeGenTarget.h"
18 #include "CodeGenIntrinsics.h"
20 #include "llvm/ADT/StringExtras.h"
21 #include "llvm/Support/CommandLine.h"
22 #include "llvm/Support/Streams.h"
27 static cl::opt<unsigned>
28 AsmWriterNum("asmwriternum", cl::init(0),
29 cl::desc("Make -gen-asm-writer emit assembly writer #N"));
31 /// getValueType - Return the MCV::ValueType that the specified TableGen record
33 MVT::ValueType llvm::getValueType(Record *Rec, const CodeGenTarget *CGT) {
34 return (MVT::ValueType)Rec->getValueAsInt("Value");
37 std::string llvm::getName(MVT::ValueType T) {
39 case MVT::Other: return "UNKNOWN";
40 case MVT::i1: return "MVT::i1";
41 case MVT::i8: return "MVT::i8";
42 case MVT::i16: return "MVT::i16";
43 case MVT::i32: return "MVT::i32";
44 case MVT::i64: return "MVT::i64";
45 case MVT::i128: return "MVT::i128";
46 case MVT::f32: return "MVT::f32";
47 case MVT::f64: return "MVT::f64";
48 case MVT::f80: return "MVT::f80";
49 case MVT::f128: return "MVT::f128";
50 case MVT::Flag: return "MVT::Flag";
51 case MVT::isVoid:return "MVT::void";
52 case MVT::v8i8: return "MVT::v8i8";
53 case MVT::v4i16: return "MVT::v4i16";
54 case MVT::v2i32: return "MVT::v2i32";
55 case MVT::v1i64: return "MVT::v1i64";
56 case MVT::v16i8: return "MVT::v16i8";
57 case MVT::v8i16: return "MVT::v8i16";
58 case MVT::v4i32: return "MVT::v4i32";
59 case MVT::v2i64: return "MVT::v2i64";
60 case MVT::v2f32: return "MVT::v2f32";
61 case MVT::v4f32: return "MVT::v4f32";
62 case MVT::v2f64: return "MVT::v2f64";
63 case MVT::iPTR: return "TLI.getPointerTy()";
64 default: assert(0 && "ILLEGAL VALUE TYPE!"); return "";
68 std::string llvm::getEnumName(MVT::ValueType T) {
70 case MVT::Other: return "MVT::Other";
71 case MVT::i1: return "MVT::i1";
72 case MVT::i8: return "MVT::i8";
73 case MVT::i16: return "MVT::i16";
74 case MVT::i32: return "MVT::i32";
75 case MVT::i64: return "MVT::i64";
76 case MVT::i128: return "MVT::i128";
77 case MVT::f32: return "MVT::f32";
78 case MVT::f64: return "MVT::f64";
79 case MVT::f80: return "MVT::f80";
80 case MVT::f128: return "MVT::f128";
81 case MVT::Flag: return "MVT::Flag";
82 case MVT::isVoid:return "MVT::isVoid";
83 case MVT::v8i8: return "MVT::v8i8";
84 case MVT::v4i16: return "MVT::v4i16";
85 case MVT::v2i32: return "MVT::v2i32";
86 case MVT::v1i64: return "MVT::v1i64";
87 case MVT::v16i8: return "MVT::v16i8";
88 case MVT::v8i16: return "MVT::v8i16";
89 case MVT::v4i32: return "MVT::v4i32";
90 case MVT::v2i64: return "MVT::v2i64";
91 case MVT::v2f32: return "MVT::v2f32";
92 case MVT::v4f32: return "MVT::v4f32";
93 case MVT::v2f64: return "MVT::v2f64";
94 case MVT::iPTR: return "TLI.getPointerTy()";
95 default: assert(0 && "ILLEGAL VALUE TYPE!"); return "";
100 std::ostream &llvm::operator<<(std::ostream &OS, MVT::ValueType T) {
101 return OS << getName(T);
105 /// getTarget - Return the current instance of the Target class.
107 CodeGenTarget::CodeGenTarget() {
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];
117 const std::string &CodeGenTarget::getName() const {
118 return TargetRec->getName();
121 Record *CodeGenTarget::getInstructionSet() const {
122 return TargetRec->getValueAsDef("InstructionSet");
125 /// getAsmWriter - Return the AssemblyWriter definition for this target.
127 Record *CodeGenTarget::getAsmWriter() const {
128 std::vector<Record*> LI = TargetRec->getValueAsListOfDefs("AssemblyWriters");
129 if (AsmWriterNum >= LI.size())
130 throw "Target does not have an AsmWriter #" + utostr(AsmWriterNum) + "!";
131 return LI[AsmWriterNum];
134 void CodeGenTarget::ReadRegisters() const {
135 std::vector<Record*> Regs = Records.getAllDerivedDefinitions("Register");
137 throw std::string("No 'Register' subclasses defined!");
139 Registers.reserve(Regs.size());
140 Registers.assign(Regs.begin(), Regs.end());
143 CodeGenRegister::CodeGenRegister(Record *R) : TheDef(R) {
144 DeclaredSpillSize = R->getValueAsInt("SpillSize");
145 DeclaredSpillAlignment = R->getValueAsInt("SpillAlignment");
148 const std::string &CodeGenRegister::getName() const {
149 return TheDef->getName();
152 void CodeGenTarget::ReadRegisterClasses() const {
153 std::vector<Record*> RegClasses =
154 Records.getAllDerivedDefinitions("RegisterClass");
155 if (RegClasses.empty())
156 throw std::string("No 'RegisterClass' subclasses defined!");
158 RegisterClasses.reserve(RegClasses.size());
159 RegisterClasses.assign(RegClasses.begin(), RegClasses.end());
162 std::vector<unsigned char> CodeGenTarget::getRegisterVTs(Record *R) const {
163 std::vector<unsigned char> Result;
164 const std::vector<CodeGenRegisterClass> &RCs = getRegisterClasses();
165 for (unsigned i = 0, e = RCs.size(); i != e; ++i) {
166 const CodeGenRegisterClass &RC = RegisterClasses[i];
167 for (unsigned ei = 0, ee = RC.Elements.size(); ei != ee; ++ei) {
168 if (R == RC.Elements[ei]) {
169 const std::vector<MVT::ValueType> &InVTs = RC.getValueTypes();
170 for (unsigned i = 0, e = InVTs.size(); i != e; ++i)
171 Result.push_back(InVTs[i]);
179 CodeGenRegisterClass::CodeGenRegisterClass(Record *R) : TheDef(R) {
180 // Rename anonymous register classes.
181 if (R->getName().size() > 9 && R->getName()[9] == '.') {
182 static unsigned AnonCounter = 0;
183 R->setName("AnonRegClass_"+utostr(AnonCounter++));
186 std::vector<Record*> TypeList = R->getValueAsListOfDefs("RegTypes");
187 for (unsigned i = 0, e = TypeList.size(); i != e; ++i) {
188 Record *Type = TypeList[i];
189 if (!Type->isSubClassOf("ValueType"))
190 throw "RegTypes list member '" + Type->getName() +
191 "' does not derive from the ValueType class!";
192 VTs.push_back(getValueType(Type));
194 assert(!VTs.empty() && "RegisterClass must contain at least one ValueType!");
196 std::vector<Record*> RegList = R->getValueAsListOfDefs("MemberList");
197 for (unsigned i = 0, e = RegList.size(); i != e; ++i) {
198 Record *Reg = RegList[i];
199 if (!Reg->isSubClassOf("Register"))
200 throw "Register Class member '" + Reg->getName() +
201 "' does not derive from the Register class!";
202 Elements.push_back(Reg);
205 // Allow targets to override the size in bits of the RegisterClass.
206 unsigned Size = R->getValueAsInt("Size");
208 Namespace = R->getValueAsString("Namespace");
209 SpillSize = Size ? Size : MVT::getSizeInBits(VTs[0]);
210 SpillAlignment = R->getValueAsInt("Alignment");
211 MethodBodies = R->getValueAsCode("MethodBodies");
212 MethodProtos = R->getValueAsCode("MethodProtos");
215 const std::string &CodeGenRegisterClass::getName() const {
216 return TheDef->getName();
219 void CodeGenTarget::ReadLegalValueTypes() const {
220 const std::vector<CodeGenRegisterClass> &RCs = getRegisterClasses();
221 for (unsigned i = 0, e = RCs.size(); i != e; ++i)
222 for (unsigned ri = 0, re = RCs[i].VTs.size(); ri != re; ++ri)
223 LegalValueTypes.push_back(RCs[i].VTs[ri]);
225 // Remove duplicates.
226 std::sort(LegalValueTypes.begin(), LegalValueTypes.end());
227 LegalValueTypes.erase(std::unique(LegalValueTypes.begin(),
228 LegalValueTypes.end()),
229 LegalValueTypes.end());
233 void CodeGenTarget::ReadInstructions() const {
234 std::vector<Record*> Insts = Records.getAllDerivedDefinitions("Instruction");
235 if (Insts.size() <= 2)
236 throw std::string("No 'Instruction' subclasses defined!");
238 // Parse the instructions defined in the .td file.
239 std::string InstFormatName =
240 getAsmWriter()->getValueAsString("InstFormatName");
242 for (unsigned i = 0, e = Insts.size(); i != e; ++i) {
243 std::string AsmStr = Insts[i]->getValueAsString(InstFormatName);
244 Instructions.insert(std::make_pair(Insts[i]->getName(),
245 CodeGenInstruction(Insts[i], AsmStr)));
249 /// getInstructionsByEnumValue - Return all of the instructions defined by the
250 /// target, ordered by their enum value.
252 getInstructionsByEnumValue(std::vector<const CodeGenInstruction*>
253 &NumberedInstructions) {
254 std::map<std::string, CodeGenInstruction>::const_iterator I;
255 I = getInstructions().find("PHI");
256 if (I == Instructions.end()) throw "Could not find 'PHI' instruction!";
257 const CodeGenInstruction *PHI = &I->second;
259 I = getInstructions().find("INLINEASM");
260 if (I == Instructions.end()) throw "Could not find 'INLINEASM' instruction!";
261 const CodeGenInstruction *INLINEASM = &I->second;
263 I = getInstructions().find("LABEL");
264 if (I == Instructions.end()) throw "Could not find 'LABEL' instruction!";
265 const CodeGenInstruction *LABEL = &I->second;
267 // Print out the rest of the instructions now.
268 NumberedInstructions.push_back(PHI);
269 NumberedInstructions.push_back(INLINEASM);
270 NumberedInstructions.push_back(LABEL);
271 for (inst_iterator II = inst_begin(), E = inst_end(); II != E; ++II)
272 if (&II->second != PHI &&
273 &II->second != INLINEASM &&
274 &II->second != LABEL)
275 NumberedInstructions.push_back(&II->second);
279 /// isLittleEndianEncoding - Return whether this target encodes its instruction
280 /// in little-endian format, i.e. bits laid out in the order [0..n]
282 bool CodeGenTarget::isLittleEndianEncoding() const {
283 return getInstructionSet()->getValueAsBit("isLittleEndianEncoding");
288 static void ParseConstraint(const std::string &CStr, CodeGenInstruction *I) {
289 // FIXME: Only supports TIED_TO for now.
290 std::string::size_type pos = CStr.find_first_of('=');
291 assert(pos != std::string::npos && "Unrecognized constraint");
292 std::string Name = CStr.substr(0, pos);
294 // TIED_TO: $src1 = $dst
295 std::string::size_type wpos = Name.find_first_of(" \t");
296 if (wpos == std::string::npos)
297 throw "Illegal format for tied-to constraint: '" + CStr + "'";
298 std::string DestOpName = Name.substr(0, wpos);
299 std::pair<unsigned,unsigned> DestOp = I->ParseOperandName(DestOpName, false);
301 Name = CStr.substr(pos+1);
302 wpos = Name.find_first_not_of(" \t");
303 if (wpos == std::string::npos)
304 throw "Illegal format for tied-to constraint: '" + CStr + "'";
306 std::pair<unsigned,unsigned> SrcOp =
307 I->ParseOperandName(Name.substr(wpos), false);
309 throw "Illegal tied-to operand constraint '" + CStr + "'";
312 unsigned FlatOpNo = I->getFlattenedOperandNumber(SrcOp);
313 // Build the string for the operand.
314 std::string OpConstraint =
315 "((" + utostr(FlatOpNo) + " << 16) | (1 << TOI::TIED_TO))";
318 if (!I->OperandList[DestOp.first].Constraints[DestOp.second].empty())
319 throw "Operand '" + DestOpName + "' cannot have multiple constraints!";
320 I->OperandList[DestOp.first].Constraints[DestOp.second] = OpConstraint;
323 static void ParseConstraints(const std::string &CStr, CodeGenInstruction *I) {
324 // Make sure the constraints list for each operand is large enough to hold
325 // constraint info, even if none is present.
326 for (unsigned i = 0, e = I->OperandList.size(); i != e; ++i)
327 I->OperandList[i].Constraints.resize(I->OperandList[i].MINumOperands);
329 if (CStr.empty()) return;
331 const std::string delims(",");
332 std::string::size_type bidx, eidx;
334 bidx = CStr.find_first_not_of(delims);
335 while (bidx != std::string::npos) {
336 eidx = CStr.find_first_of(delims, bidx);
337 if (eidx == std::string::npos)
338 eidx = CStr.length();
340 ParseConstraint(CStr.substr(bidx, eidx), I);
341 bidx = CStr.find_first_not_of(delims, eidx);
345 CodeGenInstruction::CodeGenInstruction(Record *R, const std::string &AsmStr)
346 : TheDef(R), AsmString(AsmStr) {
347 Name = R->getValueAsString("Name");
348 Namespace = R->getValueAsString("Namespace");
350 isReturn = R->getValueAsBit("isReturn");
351 isBranch = R->getValueAsBit("isBranch");
352 isBarrier = R->getValueAsBit("isBarrier");
353 isCall = R->getValueAsBit("isCall");
354 isLoad = R->getValueAsBit("isLoad");
355 isStore = R->getValueAsBit("isStore");
356 bool isTwoAddress = R->getValueAsBit("isTwoAddress");
357 isPredicated = false; // set below.
358 isConvertibleToThreeAddress = R->getValueAsBit("isConvertibleToThreeAddress");
359 isCommutable = R->getValueAsBit("isCommutable");
360 isTerminator = R->getValueAsBit("isTerminator");
361 isReMaterializable = R->getValueAsBit("isReMaterializable");
362 hasDelaySlot = R->getValueAsBit("hasDelaySlot");
363 usesCustomDAGSchedInserter = R->getValueAsBit("usesCustomDAGSchedInserter");
364 hasCtrlDep = R->getValueAsBit("hasCtrlDep");
365 noResults = R->getValueAsBit("noResults");
366 hasVariableNumberOfOperands = false;
370 DI = R->getValueAsDag("OperandList");
372 // Error getting operand list, just ignore it (sparcv9).
378 unsigned MIOperandNo = 0;
379 std::set<std::string> OperandNames;
380 for (unsigned i = 0, e = DI->getNumArgs(); i != e; ++i) {
381 DefInit *Arg = dynamic_cast<DefInit*>(DI->getArg(i));
383 throw "Illegal operand for the '" + R->getName() + "' instruction!";
385 Record *Rec = Arg->getDef();
386 std::string PrintMethod = "printOperand";
388 DagInit *MIOpInfo = 0;
389 if (Rec->isSubClassOf("Operand")) {
390 PrintMethod = Rec->getValueAsString("PrintMethod");
391 MIOpInfo = Rec->getValueAsDag("MIOperandInfo");
393 // Verify that MIOpInfo has an 'ops' root value.
394 if (!dynamic_cast<DefInit*>(MIOpInfo->getOperator()) ||
395 dynamic_cast<DefInit*>(MIOpInfo->getOperator())
396 ->getDef()->getName() != "ops")
397 throw "Bad value for MIOperandInfo in operand '" + Rec->getName() +
400 // If we have MIOpInfo, then we have #operands equal to number of entries
402 if (unsigned NumArgs = MIOpInfo->getNumArgs())
405 isPredicated |= Rec->isSubClassOf("PredicateOperand");
406 } else if (Rec->getName() == "variable_ops") {
407 hasVariableNumberOfOperands = true;
409 } else if (!Rec->isSubClassOf("RegisterClass") &&
410 Rec->getName() != "ptr_rc")
411 throw "Unknown operand class '" + Rec->getName() +
412 "' in instruction '" + R->getName() + "' instruction!";
414 // Check that the operand has a name and that it's unique.
415 if (DI->getArgName(i).empty())
416 throw "In instruction '" + R->getName() + "', operand #" + utostr(i) +
418 if (!OperandNames.insert(DI->getArgName(i)).second)
419 throw "In instruction '" + R->getName() + "', operand #" + utostr(i) +
420 " has the same name as a previous operand!";
422 OperandList.push_back(OperandInfo(Rec, DI->getArgName(i), PrintMethod,
423 MIOperandNo, NumOps, MIOpInfo));
424 MIOperandNo += NumOps;
427 // Parse Constraints.
428 ParseConstraints(R->getValueAsString("Constraints"), this);
430 // For backward compatibility: isTwoAddress means operand 1 is tied to
433 if (!OperandList[1].Constraints[0].empty())
434 throw R->getName() + ": cannot use isTwoAddress property: instruction "
435 "already has constraint set!";
436 OperandList[1].Constraints[0] = "((0 << 16) | (1 << TOI::TIED_TO))";
439 // Any operands with unset constraints get 0 as their constraint.
440 for (unsigned op = 0, e = OperandList.size(); op != e; ++op)
441 for (unsigned j = 0, e = OperandList[op].MINumOperands; j != e; ++j)
442 if (OperandList[op].Constraints[j].empty())
443 OperandList[op].Constraints[j] = "0";
445 // Parse the DisableEncoding field.
446 std::string DisableEncoding = R->getValueAsString("DisableEncoding");
448 std::string OpName = getToken(DisableEncoding, " ,\t");
449 if (OpName.empty()) break;
451 // Figure out which operand this is.
452 std::pair<unsigned,unsigned> Op = ParseOperandName(OpName, false);
454 // Mark the operand as not-to-be encoded.
455 if (Op.second >= OperandList[Op.first].DoNotEncode.size())
456 OperandList[Op.first].DoNotEncode.resize(Op.second+1);
457 OperandList[Op.first].DoNotEncode[Op.second] = true;
463 /// getOperandNamed - Return the index of the operand with the specified
464 /// non-empty name. If the instruction does not have an operand with the
465 /// specified name, throw an exception.
467 unsigned CodeGenInstruction::getOperandNamed(const std::string &Name) const {
468 assert(!Name.empty() && "Cannot search for operand with no name!");
469 for (unsigned i = 0, e = OperandList.size(); i != e; ++i)
470 if (OperandList[i].Name == Name) return i;
471 throw "Instruction '" + TheDef->getName() +
472 "' does not have an operand named '$" + Name + "'!";
475 std::pair<unsigned,unsigned>
476 CodeGenInstruction::ParseOperandName(const std::string &Op,
478 if (Op.empty() || Op[0] != '$')
479 throw TheDef->getName() + ": Illegal operand name: '" + Op + "'";
481 std::string OpName = Op.substr(1);
482 std::string SubOpName;
484 // Check to see if this is $foo.bar.
485 std::string::size_type DotIdx = OpName.find_first_of(".");
486 if (DotIdx != std::string::npos) {
487 SubOpName = OpName.substr(DotIdx+1);
488 if (SubOpName.empty())
489 throw TheDef->getName() + ": illegal empty suboperand name in '" +Op +"'";
490 OpName = OpName.substr(0, DotIdx);
493 unsigned OpIdx = getOperandNamed(OpName);
495 if (SubOpName.empty()) { // If no suboperand name was specified:
496 // If one was needed, throw.
497 if (OperandList[OpIdx].MINumOperands > 1 && !AllowWholeOp &&
499 throw TheDef->getName() + ": Illegal to refer to"
500 " whole operand part of complex operand '" + Op + "'";
502 // Otherwise, return the operand.
503 return std::make_pair(OpIdx, 0U);
506 // Find the suboperand number involved.
507 DagInit *MIOpInfo = OperandList[OpIdx].MIOperandInfo;
509 throw TheDef->getName() + ": unknown suboperand name in '" + Op + "'";
511 // Find the operand with the right name.
512 for (unsigned i = 0, e = MIOpInfo->getNumArgs(); i != e; ++i)
513 if (MIOpInfo->getArgName(i) == SubOpName)
514 return std::make_pair(OpIdx, i);
516 // Otherwise, didn't find it!
517 throw TheDef->getName() + ": unknown suboperand name in '" + Op + "'";
523 //===----------------------------------------------------------------------===//
524 // ComplexPattern implementation
526 ComplexPattern::ComplexPattern(Record *R) {
527 Ty = ::getValueType(R->getValueAsDef("Ty"));
528 NumOperands = R->getValueAsInt("NumOperands");
529 SelectFunc = R->getValueAsString("SelectFunc");
530 RootNodes = R->getValueAsListOfDefs("RootNodes");
532 // Parse the properties.
534 std::vector<Record*> PropList = R->getValueAsListOfDefs("Properties");
535 for (unsigned i = 0, e = PropList.size(); i != e; ++i)
536 if (PropList[i]->getName() == "SDNPHasChain") {
537 Properties |= 1 << SDNPHasChain;
538 } else if (PropList[i]->getName() == "SDNPOptInFlag") {
539 Properties |= 1 << SDNPOptInFlag;
541 cerr << "Unsupported SD Node property '" << PropList[i]->getName()
542 << "' on ComplexPattern '" << R->getName() << "'!\n";
547 //===----------------------------------------------------------------------===//
548 // CodeGenIntrinsic Implementation
549 //===----------------------------------------------------------------------===//
551 std::vector<CodeGenIntrinsic> llvm::LoadIntrinsics(const RecordKeeper &RC) {
552 std::vector<Record*> I = RC.getAllDerivedDefinitions("Intrinsic");
554 std::vector<CodeGenIntrinsic> Result;
556 // If we are in the context of a target .td file, get the target info so that
557 // we can decode the current intptr_t.
558 CodeGenTarget *CGT = 0;
559 if (Records.getClass("Target") &&
560 Records.getAllDerivedDefinitions("Target").size() == 1)
561 CGT = new CodeGenTarget();
563 for (unsigned i = 0, e = I.size(); i != e; ++i)
564 Result.push_back(CodeGenIntrinsic(I[i], CGT));
569 CodeGenIntrinsic::CodeGenIntrinsic(Record *R, CodeGenTarget *CGT) {
571 std::string DefName = R->getName();
574 if (DefName.size() <= 4 ||
575 std::string(DefName.begin(), DefName.begin()+4) != "int_")
576 throw "Intrinsic '" + DefName + "' does not start with 'int_'!";
577 EnumName = std::string(DefName.begin()+4, DefName.end());
578 if (R->getValue("GCCBuiltinName")) // Ignore a missing GCCBuiltinName field.
579 GCCBuiltinName = R->getValueAsString("GCCBuiltinName");
580 TargetPrefix = R->getValueAsString("TargetPrefix");
581 Name = R->getValueAsString("LLVMName");
583 // If an explicit name isn't specified, derive one from the DefName.
585 for (unsigned i = 0, e = EnumName.size(); i != e; ++i)
586 if (EnumName[i] == '_')
591 // Verify it starts with "llvm.".
592 if (Name.size() <= 5 ||
593 std::string(Name.begin(), Name.begin()+5) != "llvm.")
594 throw "Intrinsic '" + DefName + "'s name does not start with 'llvm.'!";
597 // If TargetPrefix is specified, make sure that Name starts with
598 // "llvm.<targetprefix>.".
599 if (!TargetPrefix.empty()) {
600 if (Name.size() < 6+TargetPrefix.size() ||
601 std::string(Name.begin()+5, Name.begin()+6+TargetPrefix.size())
602 != (TargetPrefix+"."))
603 throw "Intrinsic '" + DefName + "' does not start with 'llvm." +
604 TargetPrefix + ".'!";
607 // Parse the list of argument types.
608 ListInit *TypeList = R->getValueAsListInit("Types");
609 for (unsigned i = 0, e = TypeList->getSize(); i != e; ++i) {
610 Record *TyEl = TypeList->getElementAsRecord(i);
611 assert(TyEl->isSubClassOf("LLVMType") && "Expected a type!");
612 ArgTypes.push_back(TyEl->getValueAsString("TypeVal"));
615 ArgVTs.push_back(getValueType(TyEl->getValueAsDef("VT"), CGT));
616 ArgTypeDefs.push_back(TyEl);
618 if (ArgTypes.size() == 0)
619 throw "Intrinsic '"+DefName+"' needs at least a type for the ret value!";
621 // Parse the intrinsic properties.
622 ListInit *PropList = R->getValueAsListInit("Properties");
623 for (unsigned i = 0, e = PropList->getSize(); i != e; ++i) {
624 Record *Property = PropList->getElementAsRecord(i);
625 assert(Property->isSubClassOf("IntrinsicProperty") &&
626 "Expected a property!");
628 if (Property->getName() == "IntrNoMem")
630 else if (Property->getName() == "IntrReadArgMem")
632 else if (Property->getName() == "IntrReadMem")
634 else if (Property->getName() == "IntrWriteArgMem")
635 ModRef = WriteArgMem;
636 else if (Property->getName() == "IntrWriteMem")
639 assert(0 && "Unknown property!");