mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-16 01:16:36 +00:00
Add support for constant propogation of multiplies
llvm-svn: 214
This commit is contained in:
parent
5e5abe3eaa
commit
4f6031f3e7
@ -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();
|
||||
|
Loading…
x
Reference in New Issue
Block a user