mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-14 11:32:34 +00:00
Generalize getFieldType to work on all TypedInits. Add a couple of testcases from
Amaury Pouly. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@113010 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
190d0a54c1
commit
9703843dfa
14
test/TableGen/FieldAccess.td
Normal file
14
test/TableGen/FieldAccess.td
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
// RUN: tblgen %s
|
||||||
|
class Bla<string t>
|
||||||
|
{
|
||||||
|
string blu = t;
|
||||||
|
}
|
||||||
|
|
||||||
|
class Bli<Bla t>
|
||||||
|
{
|
||||||
|
Bla bla = t;
|
||||||
|
}
|
||||||
|
|
||||||
|
def a : Bli<Bla<"">>;
|
||||||
|
def b : Bla<!cast<Bla>(a.bla).blu>; // works
|
||||||
|
def c : Bla<a.bla.blu>; // doesn't work: Cannot access field 'blu' of value 'a.bla'
|
10
test/TableGen/ListManip.td
Normal file
10
test/TableGen/ListManip.td
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
// RUN: tblgen %s
|
||||||
|
class Bli<string _t>
|
||||||
|
{
|
||||||
|
string t = _t;
|
||||||
|
}
|
||||||
|
|
||||||
|
class Bla<list<Bli> _bli>
|
||||||
|
: Bli<!car(_bli).t>
|
||||||
|
{
|
||||||
|
}
|
@ -628,23 +628,6 @@ std::string UnOpInit::getAsString() const {
|
|||||||
return Result + "(" + LHS->getAsString() + ")";
|
return Result + "(" + LHS->getAsString() + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
RecTy *UnOpInit::getFieldType(const std::string &FieldName) const {
|
|
||||||
switch (getOpcode()) {
|
|
||||||
default: assert(0 && "Unknown unop");
|
|
||||||
case CAST: {
|
|
||||||
RecordRecTy *RecordType = dynamic_cast<RecordRecTy *>(getType());
|
|
||||||
if (RecordType) {
|
|
||||||
RecordVal *Field = RecordType->getRecord()->getValue(FieldName);
|
|
||||||
if (Field) {
|
|
||||||
return Field->getType();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
Init *BinOpInit::Fold(Record *CurRec, MultiClass *CurMultiClass) {
|
Init *BinOpInit::Fold(Record *CurRec, MultiClass *CurMultiClass) {
|
||||||
switch (getOpcode()) {
|
switch (getOpcode()) {
|
||||||
default: assert(0 && "Unknown binop");
|
default: assert(0 && "Unknown binop");
|
||||||
@ -1046,6 +1029,17 @@ std::string TernOpInit::getAsString() const {
|
|||||||
+ RHS->getAsString() + ")";
|
+ RHS->getAsString() + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RecTy *TypedInit::getFieldType(const std::string &FieldName) const {
|
||||||
|
RecordRecTy *RecordType = dynamic_cast<RecordRecTy *>(getType());
|
||||||
|
if (RecordType) {
|
||||||
|
RecordVal *Field = RecordType->getRecord()->getValue(FieldName);
|
||||||
|
if (Field) {
|
||||||
|
return Field->getType();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
Init *TypedInit::convertInitializerBitRange(const std::vector<unsigned> &Bits) {
|
Init *TypedInit::convertInitializerBitRange(const std::vector<unsigned> &Bits) {
|
||||||
BitsRecTy *T = dynamic_cast<BitsRecTy*>(getType());
|
BitsRecTy *T = dynamic_cast<BitsRecTy*>(getType());
|
||||||
if (T == 0) return 0; // Cannot subscript a non-bits variable...
|
if (T == 0) return 0; // Cannot subscript a non-bits variable...
|
||||||
|
@ -535,6 +535,12 @@ public:
|
|||||||
virtual Init *convertInitializerBitRange(const std::vector<unsigned> &Bits);
|
virtual Init *convertInitializerBitRange(const std::vector<unsigned> &Bits);
|
||||||
virtual Init *convertInitListSlice(const std::vector<unsigned> &Elements);
|
virtual Init *convertInitListSlice(const std::vector<unsigned> &Elements);
|
||||||
|
|
||||||
|
/// getFieldType - This method is used to implement the FieldInit class.
|
||||||
|
/// Implementors of this method should return the type of the named field if
|
||||||
|
/// they are of record type.
|
||||||
|
///
|
||||||
|
virtual RecTy *getFieldType(const std::string &FieldName) const;
|
||||||
|
|
||||||
/// resolveBitReference - This method is used to implement
|
/// resolveBitReference - This method is used to implement
|
||||||
/// VarBitInit::resolveReferences. If the bit is able to be resolved, we
|
/// VarBitInit::resolveReferences. If the bit is able to be resolved, we
|
||||||
/// simply return the resolved value, otherwise we return null.
|
/// simply return the resolved value, otherwise we return null.
|
||||||
@ -835,12 +841,6 @@ public:
|
|||||||
|
|
||||||
virtual Init *resolveReferences(Record &R, const RecordVal *RV);
|
virtual Init *resolveReferences(Record &R, const RecordVal *RV);
|
||||||
|
|
||||||
/// getFieldType - This method is used to implement the FieldInit class.
|
|
||||||
/// Implementors of this method should return the type of the named field if
|
|
||||||
/// they are of record type.
|
|
||||||
///
|
|
||||||
virtual RecTy *getFieldType(const std::string &FieldName) const;
|
|
||||||
|
|
||||||
virtual std::string getAsString() const;
|
virtual std::string getAsString() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user