1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-26 04:32:44 +01:00

Add support for constant propogation of multiplies

llvm-svn: 214
This commit is contained in:
Chris Lattner 2001-07-20 19:15:36 +00:00
parent a2122c28d0
commit 510fc61456

View File

@ -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();