Add some methods

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@24596 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2005-12-05 02:35:08 +00:00
parent b5d01436e3
commit 5c4736a3da
2 changed files with 22 additions and 1 deletions

View File

@ -42,6 +42,8 @@ namespace llvm {
const std::string &getName() const;
unsigned getNumValueTypes() const { return VTs.size(); }
const MVT::ValueType getValueTypeNum(unsigned VTNum) const {
if (VTNum < VTs.size())
return VTs[VTNum];

View File

@ -90,7 +90,26 @@ public:
assert(0 && "Didn't find the register class");
abort();
}
/// getRegisterClassForRegister - Find the register class that contains the
/// specified physical register. If there register exists in multiple
/// register classes or is not in a register class, return null.
const CodeGenRegisterClass *getRegisterClassForRegister(Record *R) const {
const std::vector<CodeGenRegisterClass> &RCs = getRegisterClasses();
const CodeGenRegisterClass *FoundRC = 0;
for (unsigned i = 0, e = RCs.size(); i != e; ++i) {
const CodeGenRegisterClass &RC = RegisterClasses[i];
for (unsigned ei = 0, ee = RC.Elements.size(); ei != ee; ++ei) {
if (R == RC.Elements[ei]) {
if (FoundRC) return 0; // In multiple RC's
FoundRC = &RC;
break;
}
}
}
return FoundRC;
}
const std::vector<MVT::ValueType> &getLegalValueTypes() const {
if (LegalValueTypes.empty()) ReadLegalValueTypes();
return LegalValueTypes;