diff options
| author | Chris Lattner <sabre@nondot.org> | 2001-07-20 19:14:41 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2001-07-20 19:14:41 +0000 |
| commit | a137f870513d59ba4759ef5e6069a075f4934898 (patch) | |
| tree | e7bab84527b97e764ebff5d76d0515d14bc57c30 /lib | |
| parent | e3ad3575b0ab0852f3a52f5a5f0cba3d45f05b43 (diff) | |
| download | external_llvm-a137f870513d59ba4759ef5e6069a075f4934898.zip external_llvm-a137f870513d59ba4759ef5e6069a075f4934898.tar.gz external_llvm-a137f870513d59ba4759ef5e6069a075f4934898.tar.bz2 | |
Add multiply as a supported constant propogation operation
Include the LevelChange.h header in AllOpts.h
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/VMCore/ConstantFold.h | 7 | ||||
| -rw-r--r-- | lib/VMCore/ConstantFolding.h | 7 |
2 files changed, 14 insertions, 0 deletions
diff --git a/lib/VMCore/ConstantFold.h b/lib/VMCore/ConstantFold.h index 79dd21c..de79ab3 100644 --- a/lib/VMCore/ConstantFold.h +++ b/lib/VMCore/ConstantFold.h @@ -67,6 +67,8 @@ public: const ConstPoolVal *V2) const = 0; virtual ConstPoolVal *sub(const ConstPoolVal *V1, const ConstPoolVal *V2) const = 0; + virtual ConstPoolVal *mul(const ConstPoolVal *V1, + const ConstPoolVal *V2) const = 0; virtual ConstPoolBool *lessthan(const ConstPoolVal *V1, const ConstPoolVal *V2) const = 0; @@ -103,6 +105,11 @@ inline ConstPoolVal *operator-(const ConstPoolVal &V1, const ConstPoolVal &V2) { return ConstRules::get(V1)->sub(&V1, &V2); } +inline ConstPoolVal *operator*(const ConstPoolVal &V1, const ConstPoolVal &V2) { + assert(V1.getType() == V2.getType() && "Constant types must be identical!"); + return ConstRules::get(V1)->mul(&V1, &V2); +} + inline ConstPoolBool *operator<(const ConstPoolVal &V1, const ConstPoolVal &V2) { assert(V1.getType() == V2.getType() && "Constant types must be identical!"); diff --git a/lib/VMCore/ConstantFolding.h b/lib/VMCore/ConstantFolding.h index 79dd21c..de79ab3 100644 --- a/lib/VMCore/ConstantFolding.h +++ b/lib/VMCore/ConstantFolding.h @@ -67,6 +67,8 @@ public: const ConstPoolVal *V2) const = 0; virtual ConstPoolVal *sub(const ConstPoolVal *V1, const ConstPoolVal *V2) const = 0; + virtual ConstPoolVal *mul(const ConstPoolVal *V1, + const ConstPoolVal *V2) const = 0; virtual ConstPoolBool *lessthan(const ConstPoolVal *V1, const ConstPoolVal *V2) const = 0; @@ -103,6 +105,11 @@ inline ConstPoolVal *operator-(const ConstPoolVal &V1, const ConstPoolVal &V2) { return ConstRules::get(V1)->sub(&V1, &V2); } +inline ConstPoolVal *operator*(const ConstPoolVal &V1, const ConstPoolVal &V2) { + assert(V1.getType() == V2.getType() && "Constant types must be identical!"); + return ConstRules::get(V1)->mul(&V1, &V2); +} + inline ConstPoolBool *operator<(const ConstPoolVal &V1, const ConstPoolVal &V2) { assert(V1.getType() == V2.getType() && "Constant types must be identical!"); |
