diff options
| author | Chris Lattner <sabre@nondot.org> | 2001-07-20 19:15:36 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2001-07-20 19:15:36 +0000 |
| commit | 4f6031f3e7ef3d5fab996cfdad3cd708fc4d65b1 (patch) | |
| tree | d3832a923493a6d91148f76030154fcf56ca3923 /llvm/lib | |
| parent | 5e5abe3eaa15df92f6edce4361e947f2c4fa82ab (diff) | |
| download | bcm5719-llvm-4f6031f3e7ef3d5fab996cfdad3cd708fc4d65b1.tar.gz bcm5719-llvm-4f6031f3e7ef3d5fab996cfdad3cd708fc4d65b1.zip | |
Add support for constant propogation of multiplies
llvm-svn: 214
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/VMCore/ConstantHandling.cpp | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/llvm/lib/VMCore/ConstantHandling.cpp b/llvm/lib/VMCore/ConstantHandling.cpp index e0a4ffbfb05..e573c4b82ba 100644 --- a/llvm/lib/VMCore/ConstantHandling.cpp +++ b/llvm/lib/VMCore/ConstantHandling.cpp @@ -42,6 +42,11 @@ class TemplateRules : public ConstRules { return SubClassName::Sub((const ArgType *)V1, (const ArgType *)V2); } + virtual ConstPoolVal *mul(const ConstPoolVal *V1, + const ConstPoolVal *V2) const { + return SubClassName::Mul((const ArgType *)V1, (const ArgType *)V2); + } + virtual ConstPoolBool *lessthan(const ConstPoolVal *V1, const ConstPoolVal *V2) const { return SubClassName::LessThan((const ArgType *)V1, (const ArgType *)V2); @@ -56,11 +61,12 @@ class TemplateRules : public ConstRules { inline static ConstPoolVal *Add(const ArgType *V1, const ArgType *V2) { return 0; } - inline static ConstPoolVal *Sub(const ArgType *V1, const ArgType *V2) { return 0; } - + inline static ConstPoolVal *Mul(const ArgType *V1, const ArgType *V2) { + return 0; + } inline static ConstPoolBool *LessThan(const ArgType *V1, const ArgType *V2) { return 0; } @@ -138,6 +144,13 @@ struct DirectRules return new ConstPoolClass(*Ty, Result); } + inline static ConstPoolVal *Mul(const ConstPoolClass *V1, + const ConstPoolClass *V2) { + BuiltinType Result = (BuiltinType)V1->getValue() * + (BuiltinType)V2->getValue(); + return new ConstPoolClass(*Ty, Result); + } + inline static ConstPoolBool *LessThan(const ConstPoolClass *V1, const ConstPoolClass *V2) { bool Result = (BuiltinType)V1->getValue() < (BuiltinType)V2->getValue(); |

