From f1e37d9d037bb5f7beb688822beddd2340cd871e Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Mon, 2 Dec 2002 16:57:01 +0000 Subject: [PATCH] Add comments, factor out common code git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@4851 91177308-0d34-0410-b5e6-96231b3b80d8 --- support/tools/TableGen/Record.h | 32 ++++++++++++++++++++++---------- utils/TableGen/Record.h | 32 ++++++++++++++++++++++---------- 2 files changed, 44 insertions(+), 20 deletions(-) diff --git a/support/tools/TableGen/Record.h b/support/tools/TableGen/Record.h index 9b3fb2d827f..3272265c5e3 100644 --- a/support/tools/TableGen/Record.h +++ b/support/tools/TableGen/Record.h @@ -141,11 +141,27 @@ public: struct Init { virtual ~Init() {} - virtual bool isComplete() const = 0; + /// isComplete - This virtual method should be overridden by values that may + /// not be completely specified yet. + virtual bool isComplete() const { return true; } + + /// print - Print out this value. virtual void print(std::ostream &OS) const = 0; + + /// dump - Debugging method that may be called through a debugger, just + /// invokes print on cerr. void dump() const; + /// convertInitializerTo - This virtual function is a simple call-back + /// function that should be overridden to call the appropriate + /// RecTy::convertValue method. + /// virtual Init *convertInitializerTo(RecTy *Ty) = 0; + + /// convertInitializerBitRange - This method is used to implement the bitrange + /// selection operator. Given an initializer, it selects the specified bits + /// out, returning them as a new init of bits type. + /// virtual Init *convertInitializerBitRange(const std::vector &Bits) { return 0; } @@ -156,6 +172,11 @@ struct Init { /// virtual RecTy *getFieldType(const std::string &FieldName) const { return 0; } + /// 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) { return this; } }; @@ -189,7 +210,6 @@ public: return Ty->convertValue(this); } - virtual bool isComplete() const { return true; } virtual void print(std::ostream &OS) const { OS << (Value ? "1" : "0"); } }; @@ -248,7 +268,6 @@ public: } virtual Init *convertInitializerBitRange(const std::vector &Bits); - virtual bool isComplete() const { return true; } virtual void print(std::ostream &OS) const { OS << Value; } }; @@ -264,7 +283,6 @@ public: return Ty->convertValue(this); } - virtual bool isComplete() const { return true; } virtual void print(std::ostream &OS) const { OS << "\"" << Value << "\""; } }; @@ -287,7 +305,6 @@ public: return Ty->convertValue(this); } - virtual bool isComplete() const { return true; } virtual void print(std::ostream &OS) const; }; @@ -310,7 +327,6 @@ public: virtual RecTy *getFieldType(const std::string &FieldName) const; - virtual bool isComplete() const { return true; } virtual void print(std::ostream &OS) const { OS << VarName; } }; @@ -330,7 +346,6 @@ public: VarInit *getVariable() const { return VI; } unsigned getBitNum() const { return Bit; } - virtual bool isComplete() const { return true; } virtual void print(std::ostream &OS) const { VI->print(OS); OS << "{" << Bit << "}"; } @@ -353,7 +368,6 @@ public: //virtual Init *convertInitializerBitRange(const std::vector &Bits); - virtual bool isComplete() const { return true; } virtual void print(std::ostream &OS) const; }; @@ -374,7 +388,6 @@ public: return Ty->convertValue(this); } - virtual bool isComplete() const { return true; } virtual void print(std::ostream &OS) const { Rec->print(OS); OS << "." << FieldName; } @@ -392,7 +405,6 @@ class RecordVal { Init *Value; public: RecordVal(const std::string &N, RecTy *T, unsigned P); - ~RecordVal() { /*delete Ty; delete Value; Bad for copy ctor!*/ } const std::string &getName() const { return Name; } diff --git a/utils/TableGen/Record.h b/utils/TableGen/Record.h index 9b3fb2d827f..3272265c5e3 100644 --- a/utils/TableGen/Record.h +++ b/utils/TableGen/Record.h @@ -141,11 +141,27 @@ public: struct Init { virtual ~Init() {} - virtual bool isComplete() const = 0; + /// isComplete - This virtual method should be overridden by values that may + /// not be completely specified yet. + virtual bool isComplete() const { return true; } + + /// print - Print out this value. virtual void print(std::ostream &OS) const = 0; + + /// dump - Debugging method that may be called through a debugger, just + /// invokes print on cerr. void dump() const; + /// convertInitializerTo - This virtual function is a simple call-back + /// function that should be overridden to call the appropriate + /// RecTy::convertValue method. + /// virtual Init *convertInitializerTo(RecTy *Ty) = 0; + + /// convertInitializerBitRange - This method is used to implement the bitrange + /// selection operator. Given an initializer, it selects the specified bits + /// out, returning them as a new init of bits type. + /// virtual Init *convertInitializerBitRange(const std::vector &Bits) { return 0; } @@ -156,6 +172,11 @@ struct Init { /// virtual RecTy *getFieldType(const std::string &FieldName) const { return 0; } + /// 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) { return this; } }; @@ -189,7 +210,6 @@ public: return Ty->convertValue(this); } - virtual bool isComplete() const { return true; } virtual void print(std::ostream &OS) const { OS << (Value ? "1" : "0"); } }; @@ -248,7 +268,6 @@ public: } virtual Init *convertInitializerBitRange(const std::vector &Bits); - virtual bool isComplete() const { return true; } virtual void print(std::ostream &OS) const { OS << Value; } }; @@ -264,7 +283,6 @@ public: return Ty->convertValue(this); } - virtual bool isComplete() const { return true; } virtual void print(std::ostream &OS) const { OS << "\"" << Value << "\""; } }; @@ -287,7 +305,6 @@ public: return Ty->convertValue(this); } - virtual bool isComplete() const { return true; } virtual void print(std::ostream &OS) const; }; @@ -310,7 +327,6 @@ public: virtual RecTy *getFieldType(const std::string &FieldName) const; - virtual bool isComplete() const { return true; } virtual void print(std::ostream &OS) const { OS << VarName; } }; @@ -330,7 +346,6 @@ public: VarInit *getVariable() const { return VI; } unsigned getBitNum() const { return Bit; } - virtual bool isComplete() const { return true; } virtual void print(std::ostream &OS) const { VI->print(OS); OS << "{" << Bit << "}"; } @@ -353,7 +368,6 @@ public: //virtual Init *convertInitializerBitRange(const std::vector &Bits); - virtual bool isComplete() const { return true; } virtual void print(std::ostream &OS) const; }; @@ -374,7 +388,6 @@ public: return Ty->convertValue(this); } - virtual bool isComplete() const { return true; } virtual void print(std::ostream &OS) const { Rec->print(OS); OS << "." << FieldName; } @@ -392,7 +405,6 @@ class RecordVal { Init *Value; public: RecordVal(const std::string &N, RecTy *T, unsigned P); - ~RecordVal() { /*delete Ty; delete Value; Bad for copy ctor!*/ } const std::string &getName() const { return Name; } -- 2.11.0