aboutsummaryrefslogtreecommitdiffstats
path: root/support
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2002-12-02 16:43:30 +0000
committerChris Lattner <sabre@nondot.org>2002-12-02 16:43:30 +0000
commit28520c4b61ed71d6c47ce3f9bfc9e2ed659d51a5 (patch)
treef5a67a90c50517e398781a85b35d951b93e0db3f /support
parenta1651900e1772b05afd2280308e9acc5a58cefb8 (diff)
downloadexternal_llvm-28520c4b61ed71d6c47ce3f9bfc9e2ed659d51a5.zip
external_llvm-28520c4b61ed71d6c47ce3f9bfc9e2ed659d51a5.tar.gz
external_llvm-28520c4b61ed71d6c47ce3f9bfc9e2ed659d51a5.tar.bz2
* Move BitsInit::resolveReferences up with the rest of BitsInit code
* Initial support for field expressions git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@4849 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'support')
-rw-r--r--support/tools/TableGen/Record.cpp44
1 files changed, 25 insertions, 19 deletions
diff --git a/support/tools/TableGen/Record.cpp b/support/tools/TableGen/Record.cpp
index 8324bad..d9cddf8 100644
--- a/support/tools/TableGen/Record.cpp
+++ b/support/tools/TableGen/Record.cpp
@@ -206,6 +206,26 @@ bool BitsInit::printAsUnset(std::ostream &OS) const {
return false;
}
+Init *BitsInit::resolveReferences(Record &R) {
+ bool Changed = false;
+ BitsInit *New = new BitsInit(getNumBits());
+
+ for (unsigned i = 0, e = Bits.size(); i != e; ++i) {
+ Init *B;
+ New->setBit(i, getBit(i));
+ do {
+ B = New->getBit(i);
+ New->setBit(i, B->resolveReferences(R));
+ Changed |= B != New->getBit(i);
+ } while (B != New->getBit(i));
+ }
+
+ if (Changed)
+ return New;
+ delete New;
+ return this;
+}
+
Init *IntInit::convertInitializerBitRange(const std::vector<unsigned> &Bits) {
BitsInit *BI = new BitsInit(Bits.size());
@@ -244,28 +264,14 @@ Init *VarInit::convertInitializerBitRange(const std::vector<unsigned> &Bits) {
return BI;
}
-Init *BitsInit::resolveReferences(Record &R) {
- bool Changed = false;
- BitsInit *New = new BitsInit(getNumBits());
-
- for (unsigned i = 0, e = Bits.size(); i != e; ++i) {
- Init *B;
- New->setBit(i, getBit(i));
- do {
- B = New->getBit(i);
- New->setBit(i, B->resolveReferences(R));
- Changed |= B != New->getBit(i);
- } while (B != New->getBit(i));
- }
-
- if (Changed)
- return New;
- delete New;
- return this;
+RecTy *VarInit::getFieldType(const std::string &FieldName) const {
+ if (RecordRecTy *RTy = dynamic_cast<RecordRecTy*>(Ty))
+ if (const RecordVal *RV = RTy->getRecord()->getValue(FieldName))
+ return RV->getType();
+ return 0;
}
-
Init *VarBitInit::resolveReferences(Record &R) {
if (R.isTemplateArg(getVariable()->getName()))
return this;