aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorOwen Anderson <resistor@mac.com>2009-07-27 20:59:43 +0000
committerOwen Anderson <resistor@mac.com>2009-07-27 20:59:43 +0000
commit6f83c9c6ef0e7f79825a0a8f22941815e4b684c7 (patch)
treea6b206cab778933e7ebb35788fc3b41e47b57c7c /include
parent9a31254d0e51cfe08bc0e0c63ea04780cbc776f4 (diff)
downloadexternal_llvm-6f83c9c6ef0e7f79825a0a8f22941815e4b684c7.zip
external_llvm-6f83c9c6ef0e7f79825a0a8f22941815e4b684c7.tar.gz
external_llvm-6f83c9c6ef0e7f79825a0a8f22941815e4b684c7.tar.bz2
Move ConstantFP construction back to the 2.5-ish API.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77247 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r--include/llvm/Constants.h14
-rw-r--r--include/llvm/LLVMContext.h16
-rw-r--r--include/llvm/Support/PatternMatch.h4
3 files changed, 16 insertions, 18 deletions
diff --git a/include/llvm/Constants.h b/include/llvm/Constants.h
index d59621a..f7b785a 100644
--- a/include/llvm/Constants.h
+++ b/include/llvm/Constants.h
@@ -50,7 +50,6 @@ class ConstantInt : public Constant {
ConstantInt(const ConstantInt &); // DO NOT IMPLEMENT
ConstantInt(const IntegerType *Ty, const APInt& V);
APInt Val;
- friend class LLVMContextImpl;
protected:
// allocate space for exactly zero operands
void *operator new(size_t s) {
@@ -238,6 +237,19 @@ protected:
return User::operator new(s, 0);
}
public:
+ /// Floating point negation must be implemented with f(x) = -0.0 - x. This
+ /// method returns the negative zero constant for floating point or vector
+ /// floating point types; for all other types, it returns the null value.
+ static Constant* getZeroValueForNegation(const Type* Ty);
+
+ /// get() - This returns a ConstantFP, or a vector containing a splat of a
+ /// ConstantFP, for the specified value in the specified type. This should
+ /// only be used for simple constant values like 2.0/1.0 etc, that are
+ /// known-valid both as host double and as the target format.
+ static Constant* get(const Type* Ty, double V);
+ static ConstantFP* get(LLVMContext &Context, const APFloat& V);
+ static ConstantFP* getNegativeZero(const Type* Ty);
+
/// isValueValidForType - return true if Ty is big enough to represent V.
static bool isValueValidForType(const Type *Ty, const APFloat& V);
inline const APFloat& getValueAPF() const { return Val; }
diff --git a/include/llvm/LLVMContext.h b/include/llvm/LLVMContext.h
index ab81595..37f0cd1 100644
--- a/include/llvm/LLVMContext.h
+++ b/include/llvm/LLVMContext.h
@@ -56,6 +56,7 @@ class LLVMContext {
LLVMContextImpl* pImpl;
friend class ConstantInt;
+ friend class ConstantFP;
public:
LLVMContext();
~LLVMContext();
@@ -180,21 +181,6 @@ public:
///
Constant* getConstantExprSizeOf(const Type* Ty);
- /// Floating point negation must be implemented with f(x) = -0.0 - x. This
- /// method returns the negative zero constant for floating point or vector
- /// floating point types; for all other types, it returns the null value.
- Constant* getZeroValueForNegation(const Type* Ty);
-
- // ConstantFP accessors
- ConstantFP* getConstantFP(const APFloat& V);
-
- /// get() - This returns a ConstantFP, or a vector containing a splat of a
- /// ConstantFP, for the specified value in the specified type. This should
- /// only be used for simple constant values like 2.0/1.0 etc, that are
- /// known-valid both as host double and as the target format.
- Constant* getConstantFP(const Type* Ty, double V);
- ConstantFP* getConstantFPNegativeZero(const Type* Ty);
-
// ConstantVector accessors
Constant* getConstantVector(const VectorType* T,
const std::vector<Constant*>& V);
diff --git a/include/llvm/Support/PatternMatch.h b/include/llvm/Support/PatternMatch.h
index fb8e387..7a93b76 100644
--- a/include/llvm/Support/PatternMatch.h
+++ b/include/llvm/Support/PatternMatch.h
@@ -506,7 +506,7 @@ struct neg_match {
}
private:
bool matchIfNeg(Value *LHS, Value *RHS, LLVMContext &Context) {
- return LHS == Context.getZeroValueForNegation(LHS->getType()) &&
+ return LHS == ConstantFP::getZeroValueForNegation(LHS->getType()) &&
L.match(RHS, Context);
}
};
@@ -535,7 +535,7 @@ struct fneg_match {
}
private:
bool matchIfFNeg(Value *LHS, Value *RHS, LLVMContext &Context) {
- return LHS == Context.getZeroValueForNegation(LHS->getType()) &&
+ return LHS == ConstantFP::getZeroValueForNegation(LHS->getType()) &&
L.match(RHS, Context);
}
};