summaryrefslogtreecommitdiffstats
path: root/llvm/lib/VMCore/ConstantHandling.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2001-09-07 16:40:34 +0000
committerChris Lattner <sabre@nondot.org>2001-09-07 16:40:34 +0000
commitbbb229655bef964966e535e8160061e1b0bbaed6 (patch)
treed45fd2030dec9e660cd686ea029a8941fcf51953 /llvm/lib/VMCore/ConstantHandling.cpp
parent4eb6d9fd8581184379190837e75fdc2b4eea6b7c (diff)
downloadbcm5719-llvm-bbb229655bef964966e535e8160061e1b0bbaed6.tar.gz
bcm5719-llvm-bbb229655bef964966e535e8160061e1b0bbaed6.zip
* Support global constants
* Eliminate need for constant pool llvm-svn: 451
Diffstat (limited to 'llvm/lib/VMCore/ConstantHandling.cpp')
-rw-r--r--llvm/lib/VMCore/ConstantHandling.cpp24
1 files changed, 11 insertions, 13 deletions
diff --git a/llvm/lib/VMCore/ConstantHandling.cpp b/llvm/lib/VMCore/ConstantHandling.cpp
index 5ffe0f46ca5..1a8def42e6d 100644
--- a/llvm/lib/VMCore/ConstantHandling.cpp
+++ b/llvm/lib/VMCore/ConstantHandling.cpp
@@ -144,19 +144,17 @@ static // BoolTyInst is static...
struct BoolRules : public TemplateRules<ConstPoolBool, BoolRules> {
inline static ConstPoolVal *Not(const ConstPoolBool *V) {
- return new ConstPoolBool(!V->getValue());
+ return ConstPoolBool::get(!V->getValue());
}
- inline static ConstPoolVal *Or(const ConstPoolBool *V1,
- const ConstPoolBool *V2) {
- bool Result = V1->getValue() | V2->getValue();
- return new ConstPoolBool(Result);
+ inline static ConstPoolVal *Or(const ConstPoolBool *V1,
+ const ConstPoolBool *V2) {
+ return ConstPoolBool::get(V1->getValue() | V2->getValue());
}
inline static ConstPoolVal *And(const ConstPoolBool *V1,
const ConstPoolBool *V2) {
- bool Result = V1->getValue() & V2->getValue();
- return new ConstPoolBool(Result);
+ return ConstPoolBool::get(V1->getValue() & V2->getValue());
}
} BoolTyInst;
@@ -175,40 +173,40 @@ struct DirectRules
DirectRules<ConstPoolClass, BuiltinType, Ty> > {
inline static ConstPoolVal *Not(const ConstPoolClass *V) {
- return new ConstPoolClass(*Ty, !(BuiltinType)V->getValue());;
+ return ConstPoolClass::get(*Ty, !(BuiltinType)V->getValue());;
}
inline static ConstPoolVal *Add(const ConstPoolClass *V1,
const ConstPoolClass *V2) {
BuiltinType Result = (BuiltinType)V1->getValue() +
(BuiltinType)V2->getValue();
- return new ConstPoolClass(*Ty, Result);
+ return ConstPoolClass::get(*Ty, Result);
}
inline static ConstPoolVal *Sub(const ConstPoolClass *V1,
const ConstPoolClass *V2) {
BuiltinType Result = (BuiltinType)V1->getValue() -
(BuiltinType)V2->getValue();
- return new ConstPoolClass(*Ty, Result);
+ return ConstPoolClass::get(*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);
+ return ConstPoolClass::get(*Ty, Result);
}
inline static ConstPoolBool *LessThan(const ConstPoolClass *V1,
const ConstPoolClass *V2) {
bool Result = (BuiltinType)V1->getValue() < (BuiltinType)V2->getValue();
- return new ConstPoolBool(Result);
+ return ConstPoolBool::get(Result);
}
// Casting operators. ick
#define DEF_CAST(TYPE, CLASS, CTYPE) \
inline static CLASS *CastTo##TYPE (const ConstPoolClass *V) { \
- return new CLASS(Type::TYPE##Ty, (CTYPE)(BuiltinType)V->getValue()); \
+ return CLASS::get(Type::TYPE##Ty, (CTYPE)(BuiltinType)V->getValue()); \
}
DEF_CAST(Bool , ConstPoolBool, bool)
OpenPOWER on IntegriCloud