add convenience 'constructors'

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52908 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner
2008-06-30 18:02:44 +00:00
parent 687e03b2fa
commit f25381ed35

View File

@@ -152,8 +152,8 @@ namespace llvm {
rmNearestTiesToAway rmNearestTiesToAway
}; };
/* Operation status. opUnderflow or opOverflow are always returned // Operation status. opUnderflow or opOverflow are always returned
or-ed with opInexact. */ // or-ed with opInexact.
enum opStatus { enum opStatus {
opOK = 0x00, opOK = 0x00,
opInvalidOp = 0x01, opInvalidOp = 0x01,
@@ -163,7 +163,7 @@ namespace llvm {
opInexact = 0x10 opInexact = 0x10
}; };
/* Category of internally-represented number. */ // Category of internally-represented number.
enum fltCategory { enum fltCategory {
fcInfinity, fcInfinity,
fcNaN, fcNaN,
@@ -171,7 +171,7 @@ namespace llvm {
fcZero fcZero
}; };
/* Constructors. */ // Constructors.
APFloat(const fltSemantics &, const char *); APFloat(const fltSemantics &, const char *);
APFloat(const fltSemantics &, integerPart); APFloat(const fltSemantics &, integerPart);
APFloat(const fltSemantics &, fltCategory, bool negative); APFloat(const fltSemantics &, fltCategory, bool negative);
@@ -181,6 +181,17 @@ namespace llvm {
APFloat(const APFloat &); APFloat(const APFloat &);
~APFloat(); ~APFloat();
// Convenience "constructors"
static APFloat getZero(const fltSemantics &Sem, bool Negative = false) {
return APFloat(Sem, fcZero, Negative);
}
static APFloat getInf(const fltSemantics &Sem, bool Negative = false) {
return APFloat(Sem, fcInfinity, Negative);
}
static APFloat getNaN(const fltSemantics &Sem, bool Negative = false) {
return APFloat(Sem, fcNaN, Negative);
}
/// Profile - Used to insert APFloat objects, or objects that contain /// Profile - Used to insert APFloat objects, or objects that contain
/// APFloat objects, into FoldingSets. /// APFloat objects, into FoldingSets.
void Profile(FoldingSetNodeID& NID) const; void Profile(FoldingSetNodeID& NID) const;