//
//===----------------------------------------------------------------------===//
-#include "llvm/Opt/ConstantHandling.h"
+#include "llvm/Optimizations/ConstantHandling.h"
+
+namespace opt {
//===----------------------------------------------------------------------===//
// TemplateRules Class
// Redirecting functions that cast to the appropriate types
//===--------------------------------------------------------------------===//
- virtual ConstPoolVal *neg(const ConstPoolVal *V) const {
- return SubClassName::Neg((const ArgType *)V);
- }
-
virtual ConstPoolVal *not(const ConstPoolVal *V) const {
return SubClassName::Not((const ArgType *)V);
}
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);
// Default "noop" implementations
//===--------------------------------------------------------------------===//
- inline static ConstPoolVal *Neg(const ArgType *V) { return 0; }
inline static ConstPoolVal *Not(const ArgType *V) { return 0; }
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;
}
: public TemplateRules<ConstPoolClass,
DirectRules<ConstPoolClass, BuiltinType, Ty> > {
- inline static ConstPoolVal *Neg(const ConstPoolClass *V) {
- return new ConstPoolClass(*Ty, -(BuiltinType)V->getValue());;
- }
inline static ConstPoolVal *Not(const ConstPoolClass *V) {
return new ConstPoolClass(*Ty, !(BuiltinType)V->getValue());;
}
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();
Ty->setConstRules(Result); // Cache the value for future short circuiting!
return Result;
}
+
+
+} // End namespace opt