diff options
| author | Chris Lattner <sabre@nondot.org> | 2002-05-06 03:00:54 +0000 | 
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2002-05-06 03:00:54 +0000 | 
| commit | 6670d86b0bd9938d2d500411869f26a757304596 (patch) | |
| tree | 9839b02d47ee189b66a536ffd3a325e7e7d152b2 /llvm/lib/VMCore/ConstantHandling.cpp | |
| parent | b2f02e5952c34da3d15d0323fede4c6ef977e1db (diff) | |
| download | bcm5719-llvm-6670d86b0bd9938d2d500411869f26a757304596.tar.gz bcm5719-llvm-6670d86b0bd9938d2d500411869f26a757304596.zip | |
Implement constant propogation of shifts
llvm-svn: 2470
Diffstat (limited to 'llvm/lib/VMCore/ConstantHandling.cpp')
| -rw-r--r-- | llvm/lib/VMCore/ConstantHandling.cpp | 28 | 
1 files changed, 28 insertions, 0 deletions
| diff --git a/llvm/lib/VMCore/ConstantHandling.cpp b/llvm/lib/VMCore/ConstantHandling.cpp index 5fd11c3a2ec..ee7d43e9190 100644 --- a/llvm/lib/VMCore/ConstantHandling.cpp +++ b/llvm/lib/VMCore/ConstantHandling.cpp @@ -56,6 +56,14 @@ class TemplateRules : public ConstRules {                          const Constant *V2) const {       return SubClassName::Rem((const ArgType *)V1, (const ArgType *)V2);      } +  virtual Constant *shl(const Constant *V1,  +                        const Constant *V2) const {  +    return SubClassName::Shl((const ArgType *)V1, (const ArgType *)V2);   +  } +  virtual Constant *shr(const Constant *V1,  +                        const Constant *V2) const {  +    return SubClassName::Shr((const ArgType *)V1, (const ArgType *)V2);   +  }    virtual ConstantBool *lessthan(const Constant *V1,                                    const Constant *V2) const {  @@ -122,6 +130,12 @@ class TemplateRules : public ConstRules {    inline static Constant *Rem(const ArgType *V1, const ArgType *V2) {      return 0;    } +  inline static Constant *Shl(const ArgType *V1, const ArgType *V2) { +    return 0; +  } +  inline static Constant *Shr(const ArgType *V1, const ArgType *V2) { +    return 0; +  }    inline static ConstantBool *LessThan(const ArgType *V1, const ArgType *V2) {      return 0;    } @@ -337,6 +351,20 @@ struct DirectIntRules                           (BuiltinType)V2->getValue();      return ConstantClass::get(*Ty, Result);    } + +  inline static Constant *Shl(const ConstantClass *V1, +                              const ConstantClass *V2) { +    BuiltinType Result = (BuiltinType)V1->getValue() << +                         (BuiltinType)V2->getValue(); +    return ConstantClass::get(*Ty, Result); +  } + +  inline static Constant *Shr(const ConstantClass *V1, +                              const ConstantClass *V2) { +    BuiltinType Result = (BuiltinType)V1->getValue() >> +                         (BuiltinType)V2->getValue(); +    return ConstantClass::get(*Ty, Result); +  }  }; | 

