Implement test/Regression/TableGen/ListSlices.td

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@15249 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner
2004-07-27 01:01:21 +00:00
parent 3aa965fbf4
commit 1dba7abdd7
2 changed files with 142 additions and 29 deletions

View File

@@ -48,6 +48,7 @@ class TypedInit;
class VarInit;
class FieldInit;
class VarBitInit;
class VarListElementInit;
// Other classes...
class Record;
@@ -481,6 +482,13 @@ public:
return Ty->convertValue(this);
}
/// resolveReferences - This method is used by classes that refer to other
/// variables which may not be defined at the time they expression is formed.
/// If a value is set for the variable later, this method will be called on
/// users of the value to allow the value to propagate out.
///
virtual Init *resolveReferences(Record &R);
virtual void print(std::ostream &OS) const;
};
@@ -495,11 +503,19 @@ public:
RecTy *getType() const { return Ty; }
virtual Init *convertInitializerBitRange(const std::vector<unsigned> &Bits);
virtual Init *convertInitListSlice(const std::vector<unsigned> &Elements);
/// resolveBitReference - This method is used to implement
/// VarBitInit::resolveReferences. If the bit is able to be resolved, we
/// simply return the resolved value, otherwise we return this.
/// simply return the resolved value, otherwise we return null.
///
virtual Init *resolveBitReference(Record &R, unsigned Bit) = 0;
/// resolveListElementReference - This method is used to implement
/// VarListElementInit::resolveReferences. If the list element is resolvable
/// now, we return the resolved value, otherwise we return null.
virtual Init *resolveListElementReference(Record &R, unsigned Elt) = 0;
};
/// VarInit - 'Opcode' - Represent a reference to an entire variable object.
@@ -515,9 +531,8 @@ public:
const std::string &getName() const { return VarName; }
virtual Init *convertInitializerBitRange(const std::vector<unsigned> &Bits);
virtual Init *resolveBitReference(Record &R, unsigned Bit);
virtual Init *resolveListElementReference(Record &R, unsigned Elt);
virtual RecTy *getFieldType(const std::string &FieldName) const;
virtual Init *getFieldInit(Record &R, const std::string &FieldName) const;
@@ -558,6 +573,38 @@ public:
virtual Init *resolveReferences(Record &R);
};
/// VarListElementInit - List[4] - Represent access to one element of a var or
/// field.
class VarListElementInit : public TypedInit {
TypedInit *TI;
unsigned Element;
public:
VarListElementInit(TypedInit *T, unsigned E)
: TypedInit(dynamic_cast<ListRecTy*>(T->getType())->getElementType()),
TI(T), Element(E) {
assert(T->getType() && dynamic_cast<ListRecTy*>(T->getType()) &&
"Illegal VarBitInit expression!");
}
virtual Init *convertInitializerTo(RecTy *Ty) {
return Ty->convertValue(this);
}
TypedInit *getVariable() const { return TI; }
unsigned getElementNum() const { return Element; }
virtual Init *resolveBitReference(Record &R, unsigned Bit);
/// resolveListElementReference - This method is used to implement
/// VarListElementInit::resolveReferences. If the list element is resolvable
/// now, we return the resolved value, otherwise we return null.
virtual Init *resolveListElementReference(Record &R, unsigned Elt);
virtual void print(std::ostream &OS) const {
TI->print(OS); OS << "[" << Element << "]";
}
virtual Init *resolveReferences(Record &R);
};
/// DefInit - AL - Represent a reference to a 'def' in the description
///
@@ -596,9 +643,8 @@ public:
return Ty->convertValue(this);
}
virtual Init *convertInitializerBitRange(const std::vector<unsigned> &Bits);
virtual Init *resolveBitReference(Record &R, unsigned Bit);
virtual Init *resolveListElementReference(Record &R, unsigned Elt);
virtual Init *resolveReferences(Record &R);