CodeGenTarget.h revision 825b72b0571821bf2d378749f69d6c4cfb52d2f9
1803a5f6ecb1823280f80e3c4459aa58627d0484cChris Lattner//===- CodeGenTarget.h - Target Class Wrapper -------------------*- C++ -*-===// 23da94aec4d429b2ba0f65fa040c33650cade196bMisha Brukman// 301d45827a1e512f3b19ba857772bf02baa3c0c4eJohn Criswell// The LLVM Compiler Infrastructure 401d45827a1e512f3b19ba857772bf02baa3c0c4eJohn Criswell// 53060910e290949a9ac5eda8726d030790c4d60ffChris Lattner// This file is distributed under the University of Illinois Open Source 63060910e290949a9ac5eda8726d030790c4d60ffChris Lattner// License. See LICENSE.TXT for details. 73da94aec4d429b2ba0f65fa040c33650cade196bMisha Brukman// 801d45827a1e512f3b19ba857772bf02baa3c0c4eJohn Criswell//===----------------------------------------------------------------------===// 945872079672a4fb500fdcb9c77b23e3e550c8f97Chris Lattner// 10803a5f6ecb1823280f80e3c4459aa58627d0484cChris Lattner// This file defines wrappers for the Target class and related global 11803a5f6ecb1823280f80e3c4459aa58627d0484cChris Lattner// functionality. This makes it easier to access the data and provides a single 12803a5f6ecb1823280f80e3c4459aa58627d0484cChris Lattner// place that needs to check it for validity. All of these classes throw 13803a5f6ecb1823280f80e3c4459aa58627d0484cChris Lattner// exceptions on error conditions. 1445872079672a4fb500fdcb9c77b23e3e550c8f97Chris Lattner// 1545872079672a4fb500fdcb9c77b23e3e550c8f97Chris Lattner//===----------------------------------------------------------------------===// 1645872079672a4fb500fdcb9c77b23e3e550c8f97Chris Lattner 17803a5f6ecb1823280f80e3c4459aa58627d0484cChris Lattner#ifndef CODEGEN_TARGET_H 18803a5f6ecb1823280f80e3c4459aa58627d0484cChris Lattner#define CODEGEN_TARGET_H 1945872079672a4fb500fdcb9c77b23e3e550c8f97Chris Lattner 201a55180238dbcf11113f610aea010447e51f595bDaniel Dunbar#include "llvm/Support/raw_ostream.h" 2126693113201f4c9d441678e50d96f38d3288798eChris Lattner#include "CodeGenRegisters.h" 22ec3524064c57fbc2c5976ca301bbaadc94006d07Chris Lattner#include "CodeGenInstruction.h" 238a17870da491b9598418fce180857515208b7393Dan Gohman#include <algorithm> 24ec3524064c57fbc2c5976ca301bbaadc94006d07Chris Lattner#include <map> 25d0fde30ce850b78371fd1386338350591f9ff494Brian Gaeke 26d0fde30ce850b78371fd1386338350591f9ff494Brian Gaekenamespace llvm { 27d0fde30ce850b78371fd1386338350591f9ff494Brian Gaeke 2845872079672a4fb500fdcb9c77b23e3e550c8f97Chris Lattnerclass Record; 2945872079672a4fb500fdcb9c77b23e3e550c8f97Chris Lattnerclass RecordKeeper; 301fca5ff62bb2ecb5bfc8974f4dbfc56e9d3ca721Chris Lattnerstruct CodeGenRegister; 318850a1bcef0c2a785f918395fe0a05054914b349Chris Lattnerclass CodeGenTarget; 3245872079672a4fb500fdcb9c77b23e3e550c8f97Chris Lattner 3394b3040fef9475c74b877fb32cb45200cea273bbEvan Cheng// SelectionDAG node properties. 3428873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang// SDNPMemOperand: indicates that a node touches memory and therefore must 3528873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang// have an associated memory operand that describes the access. 36c8478d8b12c2d7e4cea32d0c9940f5cac2baa4ddChris Lattnerenum SDNP { 37c8478d8b12c2d7e4cea32d0c9940f5cac2baa4ddChris Lattner SDNPCommutative, 38c8478d8b12c2d7e4cea32d0c9940f5cac2baa4ddChris Lattner SDNPAssociative, 39c8478d8b12c2d7e4cea32d0c9940f5cac2baa4ddChris Lattner SDNPHasChain, 40c8478d8b12c2d7e4cea32d0c9940f5cac2baa4ddChris Lattner SDNPOutFlag, 41c8478d8b12c2d7e4cea32d0c9940f5cac2baa4ddChris Lattner SDNPInFlag, 42c8478d8b12c2d7e4cea32d0c9940f5cac2baa4ddChris Lattner SDNPOptInFlag, 43710e995889c71812743f3f33861c24273f4569a7Chris Lattner SDNPMayLoad, 44bc0b9f70ae072d695e0eb7ceb729b3306b0679feChris Lattner SDNPMayStore, 4528873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang SDNPSideEffect, 46874ae251c317788391f9c3f113957802d390a063Dale Johannesen SDNPMemOperand 47c8478d8b12c2d7e4cea32d0c9940f5cac2baa4ddChris Lattner}; 4894b3040fef9475c74b877fb32cb45200cea273bbEvan Cheng 498535624739e55ab7424eadf792e1a3b4123421c7Christopher Lamb// ComplexPattern attributes. 508535624739e55ab7424eadf792e1a3b4123421c7Christopher Lambenum CPAttr { CPAttrParentAsRoot }; 518535624739e55ab7424eadf792e1a3b4123421c7Christopher Lamb 52825b72b0571821bf2d378749f69d6c4cfb52d2f9Owen Anderson/// getValueType - Return the MVT::SimpleValueType that the specified TableGen 5383ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands/// record corresponds to. 54825b72b0571821bf2d378749f69d6c4cfb52d2f9Owen AndersonMVT::SimpleValueType getValueType(Record *Rec); 5545872079672a4fb500fdcb9c77b23e3e550c8f97Chris Lattner 56825b72b0571821bf2d378749f69d6c4cfb52d2f9Owen Andersonstd::string getName(MVT::SimpleValueType T); 57825b72b0571821bf2d378749f69d6c4cfb52d2f9Owen Andersonstd::string getEnumName(MVT::SimpleValueType T); 5845872079672a4fb500fdcb9c77b23e3e550c8f97Chris Lattner 596cefb77a7073057fecd721ae141140d75ce76512Chris Lattner/// getQualifiedName - Return the name of the specified record, with a 606cefb77a7073057fecd721ae141140d75ce76512Chris Lattner/// namespace qualifier if the record contains one. 616cefb77a7073057fecd721ae141140d75ce76512Chris Lattnerstd::string getQualifiedName(const Record *R); 626cefb77a7073057fecd721ae141140d75ce76512Chris Lattner 6345872079672a4fb500fdcb9c77b23e3e550c8f97Chris Lattner/// CodeGenTarget - This class corresponds to the Target class in the .td files. 6445872079672a4fb500fdcb9c77b23e3e550c8f97Chris Lattner/// 6545872079672a4fb500fdcb9c77b23e3e550c8f97Chris Lattnerclass CodeGenTarget { 6645872079672a4fb500fdcb9c77b23e3e550c8f97Chris Lattner Record *TargetRec; 6745872079672a4fb500fdcb9c77b23e3e550c8f97Chris Lattner 68ec3524064c57fbc2c5976ca301bbaadc94006d07Chris Lattner mutable std::map<std::string, CodeGenInstruction> Instructions; 6926693113201f4c9d441678e50d96f38d3288798eChris Lattner mutable std::vector<CodeGenRegister> Registers; 70056afeface2ac98664ed8fa4799b46178a4a6fe3Chris Lattner mutable std::vector<CodeGenRegisterClass> RegisterClasses; 71825b72b0571821bf2d378749f69d6c4cfb52d2f9Owen Anderson mutable std::vector<MVT::SimpleValueType> LegalValueTypes; 7226693113201f4c9d441678e50d96f38d3288798eChris Lattner void ReadRegisters() const; 73056afeface2ac98664ed8fa4799b46178a4a6fe3Chris Lattner void ReadRegisterClasses() const; 74056afeface2ac98664ed8fa4799b46178a4a6fe3Chris Lattner void ReadInstructions() const; 75e9f4ba8dd47de9da2a98db3bbe25b54d5a9607f1Chris Lattner void ReadLegalValueTypes() const; 7645872079672a4fb500fdcb9c77b23e3e550c8f97Chris Lattnerpublic: 7745872079672a4fb500fdcb9c77b23e3e550c8f97Chris Lattner CodeGenTarget(); 7845872079672a4fb500fdcb9c77b23e3e550c8f97Chris Lattner 7945872079672a4fb500fdcb9c77b23e3e550c8f97Chris Lattner Record *getTargetRecord() const { return TargetRec; } 8045872079672a4fb500fdcb9c77b23e3e550c8f97Chris Lattner const std::string &getName() const; 8145872079672a4fb500fdcb9c77b23e3e550c8f97Chris Lattner 821e0ee4bc38e9cdc7e7ac49968527e2c05f927904Dan Gohman /// getInstNamespace - Return the target-specific instruction namespace. 831e0ee4bc38e9cdc7e7ac49968527e2c05f927904Dan Gohman /// 841e0ee4bc38e9cdc7e7ac49968527e2c05f927904Dan Gohman std::string getInstNamespace() const; 851e0ee4bc38e9cdc7e7ac49968527e2c05f927904Dan Gohman 86175580c0f36b026daf9de0adabdb7ddcf7619db6Chris Lattner /// getInstructionSet - Return the InstructionSet object. 87ec3524064c57fbc2c5976ca301bbaadc94006d07Chris Lattner /// 8845872079672a4fb500fdcb9c77b23e3e550c8f97Chris Lattner Record *getInstructionSet() const; 8945872079672a4fb500fdcb9c77b23e3e550c8f97Chris Lattner 900e2771f4c4a6e1ffc664eb23487087f824340255Daniel Dunbar /// getAsmParser - Return the AssemblyParser definition for this target. 910e2771f4c4a6e1ffc664eb23487087f824340255Daniel Dunbar /// 920e2771f4c4a6e1ffc664eb23487087f824340255Daniel Dunbar Record *getAsmParser() const; 930e2771f4c4a6e1ffc664eb23487087f824340255Daniel Dunbar 94175580c0f36b026daf9de0adabdb7ddcf7619db6Chris Lattner /// getAsmWriter - Return the AssemblyWriter definition for this target. 95175580c0f36b026daf9de0adabdb7ddcf7619db6Chris Lattner /// 96175580c0f36b026daf9de0adabdb7ddcf7619db6Chris Lattner Record *getAsmWriter() const; 97175580c0f36b026daf9de0adabdb7ddcf7619db6Chris Lattner 98e9f4ba8dd47de9da2a98db3bbe25b54d5a9607f1Chris Lattner const std::vector<CodeGenRegister> &getRegisters() const { 9926693113201f4c9d441678e50d96f38d3288798eChris Lattner if (Registers.empty()) ReadRegisters(); 10026693113201f4c9d441678e50d96f38d3288798eChris Lattner return Registers; 10126693113201f4c9d441678e50d96f38d3288798eChris Lattner } 102ec3524064c57fbc2c5976ca301bbaadc94006d07Chris Lattner 103e9f4ba8dd47de9da2a98db3bbe25b54d5a9607f1Chris Lattner const std::vector<CodeGenRegisterClass> &getRegisterClasses() const { 104056afeface2ac98664ed8fa4799b46178a4a6fe3Chris Lattner if (RegisterClasses.empty()) ReadRegisterClasses(); 105056afeface2ac98664ed8fa4799b46178a4a6fe3Chris Lattner return RegisterClasses; 106056afeface2ac98664ed8fa4799b46178a4a6fe3Chris Lattner } 107ddb395463c08b39090bbee4ed22433f5990a6331Nate Begeman 108ddb395463c08b39090bbee4ed22433f5990a6331Nate Begeman const CodeGenRegisterClass &getRegisterClass(Record *R) const { 109ddb395463c08b39090bbee4ed22433f5990a6331Nate Begeman const std::vector<CodeGenRegisterClass> &RC = getRegisterClasses(); 110ddb395463c08b39090bbee4ed22433f5990a6331Nate Begeman for (unsigned i = 0, e = RC.size(); i != e; ++i) 111ddb395463c08b39090bbee4ed22433f5990a6331Nate Begeman if (RC[i].TheDef == R) 112ddb395463c08b39090bbee4ed22433f5990a6331Nate Begeman return RC[i]; 113ddb395463c08b39090bbee4ed22433f5990a6331Nate Begeman assert(0 && "Didn't find the register class"); 114ddb395463c08b39090bbee4ed22433f5990a6331Nate Begeman abort(); 115ddb395463c08b39090bbee4ed22433f5990a6331Nate Begeman } 1165c4736a3da04795ba8d04e152e151afd6942e2f1Chris Lattner 1175c4736a3da04795ba8d04e152e151afd6942e2f1Chris Lattner /// getRegisterClassForRegister - Find the register class that contains the 1188a17870da491b9598418fce180857515208b7393Dan Gohman /// specified physical register. If the register is not in a register 1198a17870da491b9598418fce180857515208b7393Dan Gohman /// class, return null. If the register is in multiple classes, and the 1208a17870da491b9598418fce180857515208b7393Dan Gohman /// classes have a superset-subset relationship and the same set of 1218a17870da491b9598418fce180857515208b7393Dan Gohman /// types, return the superclass. Otherwise return null. 1225c4736a3da04795ba8d04e152e151afd6942e2f1Chris Lattner const CodeGenRegisterClass *getRegisterClassForRegister(Record *R) const { 1235c4736a3da04795ba8d04e152e151afd6942e2f1Chris Lattner const std::vector<CodeGenRegisterClass> &RCs = getRegisterClasses(); 1245c4736a3da04795ba8d04e152e151afd6942e2f1Chris Lattner const CodeGenRegisterClass *FoundRC = 0; 1255c4736a3da04795ba8d04e152e151afd6942e2f1Chris Lattner for (unsigned i = 0, e = RCs.size(); i != e; ++i) { 1265c4736a3da04795ba8d04e152e151afd6942e2f1Chris Lattner const CodeGenRegisterClass &RC = RegisterClasses[i]; 1275c4736a3da04795ba8d04e152e151afd6942e2f1Chris Lattner for (unsigned ei = 0, ee = RC.Elements.size(); ei != ee; ++ei) { 1288a17870da491b9598418fce180857515208b7393Dan Gohman if (R != RC.Elements[ei]) 1298a17870da491b9598418fce180857515208b7393Dan Gohman continue; 1308a17870da491b9598418fce180857515208b7393Dan Gohman 1318a17870da491b9598418fce180857515208b7393Dan Gohman // If a register's classes have different types, return null. 1328a17870da491b9598418fce180857515208b7393Dan Gohman if (FoundRC && RC.getValueTypes() != FoundRC->getValueTypes()) 1338a17870da491b9598418fce180857515208b7393Dan Gohman return 0; 1348a17870da491b9598418fce180857515208b7393Dan Gohman 1358a17870da491b9598418fce180857515208b7393Dan Gohman // If this is the first class that contains the register, 1368a17870da491b9598418fce180857515208b7393Dan Gohman // make a note of it and go on to the next class. 1378a17870da491b9598418fce180857515208b7393Dan Gohman if (!FoundRC) { 1388a17870da491b9598418fce180857515208b7393Dan Gohman FoundRC = &RC; 1398a17870da491b9598418fce180857515208b7393Dan Gohman break; 1408a17870da491b9598418fce180857515208b7393Dan Gohman } 1418a17870da491b9598418fce180857515208b7393Dan Gohman 1428a17870da491b9598418fce180857515208b7393Dan Gohman std::vector<Record *> Elements(RC.Elements); 1438a17870da491b9598418fce180857515208b7393Dan Gohman std::vector<Record *> FoundElements(FoundRC->Elements); 1448a17870da491b9598418fce180857515208b7393Dan Gohman std::sort(Elements.begin(), Elements.end()); 1458a17870da491b9598418fce180857515208b7393Dan Gohman std::sort(FoundElements.begin(), FoundElements.end()); 1468a17870da491b9598418fce180857515208b7393Dan Gohman 1478a17870da491b9598418fce180857515208b7393Dan Gohman // Check to see if the previously found class that contains 1488a17870da491b9598418fce180857515208b7393Dan Gohman // the register is a subclass of the current class. If so, 1498a17870da491b9598418fce180857515208b7393Dan Gohman // prefer the superclass. 1508a17870da491b9598418fce180857515208b7393Dan Gohman if (std::includes(Elements.begin(), Elements.end(), 1518a17870da491b9598418fce180857515208b7393Dan Gohman FoundElements.begin(), FoundElements.end())) { 1525c4736a3da04795ba8d04e152e151afd6942e2f1Chris Lattner FoundRC = &RC; 1535c4736a3da04795ba8d04e152e151afd6942e2f1Chris Lattner break; 1545c4736a3da04795ba8d04e152e151afd6942e2f1Chris Lattner } 1558a17870da491b9598418fce180857515208b7393Dan Gohman 1568a17870da491b9598418fce180857515208b7393Dan Gohman // Check to see if the previously found class that contains 1578a17870da491b9598418fce180857515208b7393Dan Gohman // the register is a superclass of the current class. If so, 1588a17870da491b9598418fce180857515208b7393Dan Gohman // prefer the superclass. 1598a17870da491b9598418fce180857515208b7393Dan Gohman if (std::includes(FoundElements.begin(), FoundElements.end(), 1608a17870da491b9598418fce180857515208b7393Dan Gohman Elements.begin(), Elements.end())) 1618a17870da491b9598418fce180857515208b7393Dan Gohman break; 1628a17870da491b9598418fce180857515208b7393Dan Gohman 1638a17870da491b9598418fce180857515208b7393Dan Gohman // Multiple classes, and neither is a superclass of the other. 1648a17870da491b9598418fce180857515208b7393Dan Gohman // Return null. 1658a17870da491b9598418fce180857515208b7393Dan Gohman return 0; 1665c4736a3da04795ba8d04e152e151afd6942e2f1Chris Lattner } 1675c4736a3da04795ba8d04e152e151afd6942e2f1Chris Lattner } 1685c4736a3da04795ba8d04e152e151afd6942e2f1Chris Lattner return FoundRC; 1695c4736a3da04795ba8d04e152e151afd6942e2f1Chris Lattner } 17044a65fa552ed61cf9dba8f68f59b05e5137e6b01Evan Cheng 17183ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands /// getRegisterVTs - Find the union of all possible SimpleValueTypes for the 17244a65fa552ed61cf9dba8f68f59b05e5137e6b01Evan Cheng /// specified physical register. 17344a65fa552ed61cf9dba8f68f59b05e5137e6b01Evan Cheng std::vector<unsigned char> getRegisterVTs(Record *R) const; 1745c4736a3da04795ba8d04e152e151afd6942e2f1Chris Lattner 175825b72b0571821bf2d378749f69d6c4cfb52d2f9Owen Anderson const std::vector<MVT::SimpleValueType> &getLegalValueTypes() const { 176e9f4ba8dd47de9da2a98db3bbe25b54d5a9607f1Chris Lattner if (LegalValueTypes.empty()) ReadLegalValueTypes(); 177e9f4ba8dd47de9da2a98db3bbe25b54d5a9607f1Chris Lattner return LegalValueTypes; 178e9f4ba8dd47de9da2a98db3bbe25b54d5a9607f1Chris Lattner } 179e9f4ba8dd47de9da2a98db3bbe25b54d5a9607f1Chris Lattner 180e9f4ba8dd47de9da2a98db3bbe25b54d5a9607f1Chris Lattner /// isLegalValueType - Return true if the specified value type is natively 181e9f4ba8dd47de9da2a98db3bbe25b54d5a9607f1Chris Lattner /// supported by the target (i.e. there are registers that directly hold it). 182825b72b0571821bf2d378749f69d6c4cfb52d2f9Owen Anderson bool isLegalValueType(MVT::SimpleValueType VT) const { 183825b72b0571821bf2d378749f69d6c4cfb52d2f9Owen Anderson const std::vector<MVT::SimpleValueType> &LegalVTs = getLegalValueTypes(); 184e9f4ba8dd47de9da2a98db3bbe25b54d5a9607f1Chris Lattner for (unsigned i = 0, e = LegalVTs.size(); i != e; ++i) 185e9f4ba8dd47de9da2a98db3bbe25b54d5a9607f1Chris Lattner if (LegalVTs[i] == VT) return true; 186e9f4ba8dd47de9da2a98db3bbe25b54d5a9607f1Chris Lattner return false; 187e9f4ba8dd47de9da2a98db3bbe25b54d5a9607f1Chris Lattner } 188056afeface2ac98664ed8fa4799b46178a4a6fe3Chris Lattner 189ec3524064c57fbc2c5976ca301bbaadc94006d07Chris Lattner /// getInstructions - Return all of the instructions defined for this target. 190ec3524064c57fbc2c5976ca301bbaadc94006d07Chris Lattner /// 191ec3524064c57fbc2c5976ca301bbaadc94006d07Chris Lattner const std::map<std::string, CodeGenInstruction> &getInstructions() const { 192ec3524064c57fbc2c5976ca301bbaadc94006d07Chris Lattner if (Instructions.empty()) ReadInstructions(); 193ec3524064c57fbc2c5976ca301bbaadc94006d07Chris Lattner return Instructions; 194ec3524064c57fbc2c5976ca301bbaadc94006d07Chris Lattner } 195ee4fa1977dd3a495a8857eef924ee5961db765c6Dan Gohman std::map<std::string, CodeGenInstruction> &getInstructions() { 196ee4fa1977dd3a495a8857eef924ee5961db765c6Dan Gohman if (Instructions.empty()) ReadInstructions(); 197ee4fa1977dd3a495a8857eef924ee5961db765c6Dan Gohman return Instructions; 198ee4fa1977dd3a495a8857eef924ee5961db765c6Dan Gohman } 199ec3524064c57fbc2c5976ca301bbaadc94006d07Chris Lattner 200a974b20cae7691361f2be5b27fbc1658855ed96cChris Lattner CodeGenInstruction &getInstruction(const std::string &Name) const { 201a974b20cae7691361f2be5b27fbc1658855ed96cChris Lattner const std::map<std::string, CodeGenInstruction> &Insts = getInstructions(); 202a974b20cae7691361f2be5b27fbc1658855ed96cChris Lattner assert(Insts.count(Name) && "Not an instruction!"); 203a974b20cae7691361f2be5b27fbc1658855ed96cChris Lattner return const_cast<CodeGenInstruction&>(Insts.find(Name)->second); 204a974b20cae7691361f2be5b27fbc1658855ed96cChris Lattner } 205a974b20cae7691361f2be5b27fbc1658855ed96cChris Lattner 206ec3524064c57fbc2c5976ca301bbaadc94006d07Chris Lattner typedef std::map<std::string, 207ec3524064c57fbc2c5976ca301bbaadc94006d07Chris Lattner CodeGenInstruction>::const_iterator inst_iterator; 208ec3524064c57fbc2c5976ca301bbaadc94006d07Chris Lattner inst_iterator inst_begin() const { return getInstructions().begin(); } 209ec3524064c57fbc2c5976ca301bbaadc94006d07Chris Lattner inst_iterator inst_end() const { return Instructions.end(); } 21026693113201f4c9d441678e50d96f38d3288798eChris Lattner 211d6488671736d0a5aaee1218748b94d8c68f33716Chris Lattner /// getInstructionsByEnumValue - Return all of the instructions defined by the 212d6488671736d0a5aaee1218748b94d8c68f33716Chris Lattner /// target, ordered by their enum value. 213d6488671736d0a5aaee1218748b94d8c68f33716Chris Lattner void getInstructionsByEnumValue(std::vector<const CodeGenInstruction*> 214d6488671736d0a5aaee1218748b94d8c68f33716Chris Lattner &NumberedInstructions); 215d6488671736d0a5aaee1218748b94d8c68f33716Chris Lattner 216874ae251c317788391f9c3f113957802d390a063Dale Johannesen 21735e83cc970e2ed99c8087e0c6b99f8a3618c279bMisha Brukman /// isLittleEndianEncoding - are instruction bit patterns defined as [0..n]? 21835e83cc970e2ed99c8087e0c6b99f8a3618c279bMisha Brukman /// 21935e83cc970e2ed99c8087e0c6b99f8a3618c279bMisha Brukman bool isLittleEndianEncoding() const; 22045872079672a4fb500fdcb9c77b23e3e550c8f97Chris Lattner}; 22145872079672a4fb500fdcb9c77b23e3e550c8f97Chris Lattner 2220fc71988900e600f3ef5b13d9682e2bbab92811dEvan Cheng/// ComplexPattern - ComplexPattern info, corresponding to the ComplexPattern 2230fc71988900e600f3ef5b13d9682e2bbab92811dEvan Cheng/// tablegen class in TargetSelectionDAG.td 2240fc71988900e600f3ef5b13d9682e2bbab92811dEvan Chengclass ComplexPattern { 225825b72b0571821bf2d378749f69d6c4cfb52d2f9Owen Anderson MVT::SimpleValueType Ty; 2260fc71988900e600f3ef5b13d9682e2bbab92811dEvan Cheng unsigned NumOperands; 2270fc71988900e600f3ef5b13d9682e2bbab92811dEvan Cheng std::string SelectFunc; 2283aa39f439a0971a2502b2c728a8006becaf96601Evan Cheng std::vector<Record*> RootNodes; 2298535624739e55ab7424eadf792e1a3b4123421c7Christopher Lamb unsigned Properties; // Node properties 2308535624739e55ab7424eadf792e1a3b4123421c7Christopher Lamb unsigned Attributes; // Pattern attributes 2310fc71988900e600f3ef5b13d9682e2bbab92811dEvan Chengpublic: 2320fc71988900e600f3ef5b13d9682e2bbab92811dEvan Cheng ComplexPattern() : NumOperands(0) {}; 2330fc71988900e600f3ef5b13d9682e2bbab92811dEvan Cheng ComplexPattern(Record *R); 2340fc71988900e600f3ef5b13d9682e2bbab92811dEvan Cheng 235825b72b0571821bf2d378749f69d6c4cfb52d2f9Owen Anderson MVT::SimpleValueType getValueType() const { return Ty; } 2360fc71988900e600f3ef5b13d9682e2bbab92811dEvan Cheng unsigned getNumOperands() const { return NumOperands; } 2370fc71988900e600f3ef5b13d9682e2bbab92811dEvan Cheng const std::string &getSelectFunc() const { return SelectFunc; } 2383aa39f439a0971a2502b2c728a8006becaf96601Evan Cheng const std::vector<Record*> &getRootNodes() const { 2393aa39f439a0971a2502b2c728a8006becaf96601Evan Cheng return RootNodes; 2400fc71988900e600f3ef5b13d9682e2bbab92811dEvan Cheng } 24194b3040fef9475c74b877fb32cb45200cea273bbEvan Cheng bool hasProperty(enum SDNP Prop) const { return Properties & (1 << Prop); } 2428535624739e55ab7424eadf792e1a3b4123421c7Christopher Lamb bool hasAttribute(enum CPAttr Attr) const { return Attributes & (1 << Attr); } 2430fc71988900e600f3ef5b13d9682e2bbab92811dEvan Cheng}; 2440fc71988900e600f3ef5b13d9682e2bbab92811dEvan Cheng 245d0fde30ce850b78371fd1386338350591f9ff494Brian Gaeke} // End llvm namespace 246d0fde30ce850b78371fd1386338350591f9ff494Brian Gaeke 24745872079672a4fb500fdcb9c77b23e3e550c8f97Chris Lattner#endif 248