[llvm-commits] CVS: llvm/utils/TableGen/Record.h
Chris Lattner
lattner at cs.uiuc.edu
Mon Dec 2 10:44:00 PST 2002
Changes in directory llvm/utils/TableGen:
Record.h updated: 1.2 -> 1.3
---
Log message:
Initial support for Field Expressions
---
Diffs of the changes:
Index: llvm/utils/TableGen/Record.h
diff -u llvm/utils/TableGen/Record.h:1.2 llvm/utils/TableGen/Record.h:1.3
--- llvm/utils/TableGen/Record.h:1.2 Mon Dec 2 10:13:23 2002
+++ llvm/utils/TableGen/Record.h Mon Dec 2 10:42:52 2002
@@ -20,6 +20,7 @@
class VarInit;
class VarBitInit;
class DefInit;
+class FieldInit;
class Record;
//===----------------------------------------------------------------------===//
@@ -38,6 +39,7 @@
virtual Init *convertValue( VarInit *VI) { return 0; }
virtual Init *convertValue(VarBitInit *VB) { return 0; }
virtual Init *convertValue( DefInit *DI) { return 0; }
+ virtual Init *convertValue( FieldInit *FI) { return 0; }
virtual void print(std::ostream &OS) const = 0;
void dump() const;
@@ -122,6 +124,8 @@
public:
RecordRecTy(Record *R) : Rec(R) {}
+ Record *getRecord() const { return Rec; }
+
Init *convertValue(UnsetInit *UI) { return (Init*)UI; }
Init *convertValue( DefInit *DI);
@@ -146,6 +150,12 @@
return 0;
}
+ /// 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 { return 0; }
+
virtual Init *resolveReferences(Record &R) { return this; }
};
@@ -297,6 +307,8 @@
RecTy *getType() const { return Ty; }
virtual Init *convertInitializerBitRange(const std::vector<unsigned> &Bits);
+
+ virtual RecTy *getFieldType(const std::string &FieldName) const;
virtual bool isComplete() const { return true; }
virtual void print(std::ostream &OS) const { OS << VarName; }
@@ -345,6 +357,28 @@
virtual void print(std::ostream &OS) const;
};
+
+/// FieldInit - X.Y - Represent a reference to a subfield of a variable
+///
+class FieldInit : public Init {
+ Init *Rec; // Record we are referring to
+ std::string FieldName; // Field we are accessing
+ RecTy *Ty; // The type of this expression
+public:
+ FieldInit(Init *R, const std::string &FN)
+ : Rec(R), FieldName(FN), Ty(R->getFieldType(FN)) {
+ assert(Ty && "FieldInit with non-record type!");
+ }
+
+ virtual Init *convertInitializerTo(RecTy *Ty) {
+ return Ty->convertValue(this);
+ }
+
+ virtual bool isComplete() const { return true; }
+ virtual void print(std::ostream &OS) const {
+ Rec->print(OS); OS << "." << FieldName;
+ }
+};
//===----------------------------------------------------------------------===//
More information about the llvm-commits
mailing list