summaryrefslogtreecommitdiff
path: root/utils/TableGen/CodeGenRegisters.h
diff options
context:
space:
mode:
authorEric Christopher <echristo@apple.com>2010-08-25 00:41:18 +0000
committerEric Christopher <echristo@apple.com>2010-08-25 00:41:18 +0000
commita2c9188560eb9a7d494960fefd28cf0998d9a78f (patch)
tree11ff59ce46ca910da450b0a235f48049f7fdef35 /utils/TableGen/CodeGenRegisters.h
parent2cfcad97b766068a20f3715ed3b4beb9143f329f (diff)
downloadllvm-a2c9188560eb9a7d494960fefd28cf0998d9a78f.tar.gz
llvm-a2c9188560eb9a7d494960fefd28cf0998d9a78f.tar.bz2
llvm-a2c9188560eb9a7d494960fefd28cf0998d9a78f.tar.xz
Split out register class subclassing to a separate function and clean up
accordingly. No functional change. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@112008 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils/TableGen/CodeGenRegisters.h')
-rw-r--r--utils/TableGen/CodeGenRegisters.h32
1 files changed, 32 insertions, 0 deletions
diff --git a/utils/TableGen/CodeGenRegisters.h b/utils/TableGen/CodeGenRegisters.h
index 344f77f1fe..ccd3d222bb 100644
--- a/utils/TableGen/CodeGenRegisters.h
+++ b/utils/TableGen/CodeGenRegisters.h
@@ -19,6 +19,7 @@
#include "llvm/ADT/DenseMap.h"
#include <string>
#include <vector>
+#include <set>
#include <cstdlib>
namespace llvm {
@@ -55,6 +56,37 @@ namespace llvm {
assert(0 && "VTNum greater than number of ValueTypes in RegClass!");
abort();
}
+
+ // Returns true if RC is a strict subclass.
+ // RC is a sub-class of this class if it is a valid replacement for any
+ // instruction operand where a register of this classis required. It must
+ // satisfy these conditions:
+ //
+ // 1. All RC registers are also in this.
+ // 2. The RC spill size must not be smaller than our spill size.
+ // 3. RC spill alignment must be compatible with ours.
+ //
+ bool hasSubClass(const CodeGenRegisterClass *RC) const {
+
+ if (RC->Elements.size() > Elements.size() ||
+ (SpillAlignment && RC->SpillAlignment % SpillAlignment) ||
+ SpillSize > RC->SpillSize)
+ return false;
+
+ std::set<Record*> RegSet;
+ for (unsigned i = 0, e = Elements.size(); i != e; ++i) {
+ Record *Reg = Elements[i];
+ RegSet.insert(Reg);
+ }
+
+ for (unsigned i = 0, e = RC->Elements.size(); i != e; ++i) {
+ Record *Reg = RC->Elements[i];
+ if (!RegSet.count(Reg))
+ return false;
+ }
+
+ return true;
+ }
CodeGenRegisterClass(Record *R);
};