diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/VMCore/ConstantFold.h | 13 | ||||
-rw-r--r-- | lib/VMCore/ConstantFolding.h | 13 |
2 files changed, 14 insertions, 12 deletions
diff --git a/lib/VMCore/ConstantFold.h b/lib/VMCore/ConstantFold.h index 453c3e88b1..cbb9789fb0 100644 --- a/lib/VMCore/ConstantFold.h +++ b/lib/VMCore/ConstantFold.h @@ -58,10 +58,12 @@ inline ConstPoolBool *operator!=(const ConstPoolVal &V1, // Implement all other operators indirectly through TypeRules system //===----------------------------------------------------------------------===// -class ConstRules { +class ConstRules : public Annotation { protected: - inline ConstRules() {} // Can only be subclassed... + inline ConstRules() : Annotation(AID) {} // Can only be subclassed... public: + static AnnotationID AID; // AnnotationID for this class + // Unary Operators... virtual ConstPoolVal *not(const ConstPoolVal *V) const = 0; @@ -110,12 +112,11 @@ public: // we just want to make sure to hit the cache instead of doing it indirectly, // if possible... // - static inline const ConstRules *get(const ConstPoolVal &V) { - const ConstRules *Result = V.getType()->getConstRules(); - return Result ? Result : find(V.getType()); + static inline ConstRules *get(const ConstPoolVal &V) { + return (ConstRules*)V.getType()->getOrCreateAnnotation(AID); } private : - static const ConstRules *find(const Type *Ty); + static Annotation *find(AnnotationID AID, const Annotable *Ty, void *); ConstRules(const ConstRules &); // Do not implement ConstRules &operator=(const ConstRules &); // Do not implement diff --git a/lib/VMCore/ConstantFolding.h b/lib/VMCore/ConstantFolding.h index 453c3e88b1..cbb9789fb0 100644 --- a/lib/VMCore/ConstantFolding.h +++ b/lib/VMCore/ConstantFolding.h @@ -58,10 +58,12 @@ inline ConstPoolBool *operator!=(const ConstPoolVal &V1, // Implement all other operators indirectly through TypeRules system //===----------------------------------------------------------------------===// -class ConstRules { +class ConstRules : public Annotation { protected: - inline ConstRules() {} // Can only be subclassed... + inline ConstRules() : Annotation(AID) {} // Can only be subclassed... public: + static AnnotationID AID; // AnnotationID for this class + // Unary Operators... virtual ConstPoolVal *not(const ConstPoolVal *V) const = 0; @@ -110,12 +112,11 @@ public: // we just want to make sure to hit the cache instead of doing it indirectly, // if possible... // - static inline const ConstRules *get(const ConstPoolVal &V) { - const ConstRules *Result = V.getType()->getConstRules(); - return Result ? Result : find(V.getType()); + static inline ConstRules *get(const ConstPoolVal &V) { + return (ConstRules*)V.getType()->getOrCreateAnnotation(AID); } private : - static const ConstRules *find(const Type *Ty); + static Annotation *find(AnnotationID AID, const Annotable *Ty, void *); ConstRules(const ConstRules &); // Do not implement ConstRules &operator=(const ConstRules &); // Do not implement |