Skip to content

Commit

Permalink
Replace APFloatBase static fltSemantics data members with getter func…
Browse files Browse the repository at this point in the history
…tions

At least the plugin used by the LibreOffice build
(<https://wiki.documentfoundation.org/Development/Clang_plugins>) indirectly
uses those members (through inline functions in LLVM/Clang include files in turn
using them), but they are not exported by utils/extract_symbols.py on Windows,
and accessing data across DLL/EXE boundaries on Windows is generally
problematic.

Differential Revision: https://reviews.llvm.org/D26671

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@289647 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
stbergmann committed Dec 14, 2016
1 parent 1452ff9 commit 20a600c
Show file tree
Hide file tree
Showing 36 changed files with 1,098 additions and 1,076 deletions.
28 changes: 14 additions & 14 deletions include/llvm/ADT/APFloat.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,16 +136,16 @@ struct APFloatBase {
/// \name Floating Point Semantics.
/// @{

static const fltSemantics IEEEhalf;
static const fltSemantics IEEEsingle;
static const fltSemantics IEEEdouble;
static const fltSemantics IEEEquad;
static const fltSemantics PPCDoubleDouble;
static const fltSemantics x87DoubleExtended;
static const fltSemantics &IEEEhalf();
static const fltSemantics &IEEEsingle();
static const fltSemantics &IEEEdouble();
static const fltSemantics &IEEEquad();
static const fltSemantics &PPCDoubleDouble();
static const fltSemantics &x87DoubleExtended();

/// A Pseudo fltsemantic used to construct APFloats that cannot conflict with
/// anything real.
static const fltSemantics Bogus;
static const fltSemantics &Bogus();

/// @}

Expand Down Expand Up @@ -664,7 +664,7 @@ class APFloat : public APFloatBase {
explicit Storage(IEEEFloat F, const fltSemantics &S);
explicit Storage(DoubleAPFloat F, const fltSemantics &S)
: Double(std::move(F)) {
assert(&S == &PPCDoubleDouble);
assert(&S == &PPCDoubleDouble());
}

template <typename... ArgTypes>
Expand Down Expand Up @@ -741,9 +741,9 @@ class APFloat : public APFloatBase {
static_assert(std::is_same<T, IEEEFloat>::value ||
std::is_same<T, DoubleAPFloat>::value, "");
if (std::is_same<T, DoubleAPFloat>::value) {
return &Semantics == &PPCDoubleDouble;
return &Semantics == &PPCDoubleDouble();
}
return &Semantics != &PPCDoubleDouble;
return &Semantics != &PPCDoubleDouble();
}

IEEEFloat &getIEEE() {
Expand Down Expand Up @@ -793,7 +793,7 @@ class APFloat : public APFloatBase {
// FIXME: This is due to clang 3.3 (or older version) always checks for the
// default constructor in an array aggregate initialization, even if no
// elements in the array is default initialized.
APFloat() : U(IEEEdouble) {
APFloat() : U(IEEEdouble()) {
llvm_unreachable("This is a workaround for old clang.");
}

Expand All @@ -820,8 +820,8 @@ class APFloat : public APFloatBase {
APFloat(const fltSemantics &Semantics, uninitializedTag)
: U(Semantics, uninitialized) {}
APFloat(const fltSemantics &Semantics, const APInt &I) : U(Semantics, I) {}
explicit APFloat(double d) : U(IEEEFloat(d), IEEEdouble) {}
explicit APFloat(float f) : U(IEEEFloat(f), IEEEsingle) {}
explicit APFloat(double d) : U(IEEEFloat(d), IEEEdouble()) {}
explicit APFloat(float f) : U(IEEEFloat(f), IEEEsingle()) {}
APFloat(const APFloat &RHS) = default;
APFloat(APFloat &&RHS) = default;

Expand Down Expand Up @@ -1073,7 +1073,7 @@ class APFloat : public APFloatBase {
// This is for internal test only.
// TODO: Remove it after the PPCDoubleDouble transition.
const APFloat &getSecondFloat() const {
assert(&getSemantics() == &PPCDoubleDouble);
assert(&getSemantics() == &PPCDoubleDouble());
return U.Double.getSecond();
}

Expand Down
12 changes: 6 additions & 6 deletions include/llvm/CodeGen/SelectionDAG.h
Original file line number Diff line number Diff line change
Expand Up @@ -1180,12 +1180,12 @@ class SelectionDAG {
static const fltSemantics &EVTToAPFloatSemantics(EVT VT) {
switch (VT.getScalarType().getSimpleVT().SimpleTy) {
default: llvm_unreachable("Unknown FP format");
case MVT::f16: return APFloat::IEEEhalf;
case MVT::f32: return APFloat::IEEEsingle;
case MVT::f64: return APFloat::IEEEdouble;
case MVT::f80: return APFloat::x87DoubleExtended;
case MVT::f128: return APFloat::IEEEquad;
case MVT::ppcf128: return APFloat::PPCDoubleDouble;
case MVT::f16: return APFloat::IEEEhalf();
case MVT::f32: return APFloat::IEEEsingle();
case MVT::f64: return APFloat::IEEEdouble();
case MVT::f80: return APFloat::x87DoubleExtended();
case MVT::f128: return APFloat::IEEEquad();
case MVT::ppcf128: return APFloat::PPCDoubleDouble();
}
}

Expand Down
12 changes: 6 additions & 6 deletions include/llvm/IR/Type.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,12 +166,12 @@ class Type {

const fltSemantics &getFltSemantics() const {
switch (getTypeID()) {
case HalfTyID: return APFloat::IEEEhalf;
case FloatTyID: return APFloat::IEEEsingle;
case DoubleTyID: return APFloat::IEEEdouble;
case X86_FP80TyID: return APFloat::x87DoubleExtended;
case FP128TyID: return APFloat::IEEEquad;
case PPC_FP128TyID: return APFloat::PPCDoubleDouble;
case HalfTyID: return APFloat::IEEEhalf();
case FloatTyID: return APFloat::IEEEsingle();
case DoubleTyID: return APFloat::IEEEdouble();
case X86_FP80TyID: return APFloat::x87DoubleExtended();
case FP128TyID: return APFloat::IEEEquad();
case PPC_FP128TyID: return APFloat::PPCDoubleDouble();
default: llvm_unreachable("Invalid floating type");
}
}
Expand Down
8 changes: 4 additions & 4 deletions lib/Analysis/ConstantFolding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1442,7 +1442,7 @@ Constant *GetConstantFoldFPValue(double V, Type *Ty) {
if (Ty->isHalfTy()) {
APFloat APF(V);
bool unused;
APF.convert(APFloat::IEEEhalf, APFloat::rmNearestTiesToEven, &unused);
APF.convert(APFloat::IEEEhalf(), APFloat::rmNearestTiesToEven, &unused);
return ConstantFP::get(Ty->getContext(), APF);
}
if (Ty->isFloatTy())
Expand Down Expand Up @@ -1533,7 +1533,7 @@ double getValueAsDouble(ConstantFP *Op) {

bool unused;
APFloat APF = Op->getValueAPF();
APF.convert(APFloat::IEEEdouble, APFloat::rmNearestTiesToEven, &unused);
APF.convert(APFloat::IEEEdouble(), APFloat::rmNearestTiesToEven, &unused);
return APF.convertToDouble();
}

Expand All @@ -1551,7 +1551,7 @@ Constant *ConstantFoldScalarCall(StringRef Name, unsigned IntrinsicID, Type *Ty,
APFloat Val(Op->getValueAPF());

bool lost = false;
Val.convert(APFloat::IEEEhalf, APFloat::rmNearestTiesToEven, &lost);
Val.convert(APFloat::IEEEhalf(), APFloat::rmNearestTiesToEven, &lost);

return ConstantInt::get(Ty->getContext(), Val.bitcastToAPInt());
}
Expand Down Expand Up @@ -1726,7 +1726,7 @@ Constant *ConstantFoldScalarCall(StringRef Name, unsigned IntrinsicID, Type *Ty,
case Intrinsic::bitreverse:
return ConstantInt::get(Ty->getContext(), Op->getValue().reverseBits());
case Intrinsic::convert_from_fp16: {
APFloat Val(APFloat::IEEEhalf, Op->getValue());
APFloat Val(APFloat::IEEEhalf(), Op->getValue());

bool lost = false;
APFloat::opStatus status = Val.convert(
Expand Down
14 changes: 7 additions & 7 deletions lib/AsmParser/LLLexer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -876,7 +876,7 @@ lltok::Kind LLLexer::Lex0x() {
// HexFPConstant - Floating point constant represented in IEEE format as a
// hexadecimal number for when exponential notation is not precise enough.
// Half, Float, and double only.
APFloatVal = APFloat(APFloat::IEEEdouble,
APFloatVal = APFloat(APFloat::IEEEdouble(),
APInt(64, HexIntToVal(TokStart + 2, CurPtr)));
return lltok::APFloat;
}
Expand All @@ -887,20 +887,20 @@ lltok::Kind LLLexer::Lex0x() {
case 'K':
// F80HexFPConstant - x87 long double in hexadecimal format (10 bytes)
FP80HexToIntPair(TokStart+3, CurPtr, Pair);
APFloatVal = APFloat(APFloat::x87DoubleExtended, APInt(80, Pair));
APFloatVal = APFloat(APFloat::x87DoubleExtended(), APInt(80, Pair));
return lltok::APFloat;
case 'L':
// F128HexFPConstant - IEEE 128-bit in hexadecimal format (16 bytes)
HexToIntPair(TokStart+3, CurPtr, Pair);
APFloatVal = APFloat(APFloat::IEEEquad, APInt(128, Pair));
APFloatVal = APFloat(APFloat::IEEEquad(), APInt(128, Pair));
return lltok::APFloat;
case 'M':
// PPC128HexFPConstant - PowerPC 128-bit in hexadecimal format (16 bytes)
HexToIntPair(TokStart+3, CurPtr, Pair);
APFloatVal = APFloat(APFloat::PPCDoubleDouble, APInt(128, Pair));
APFloatVal = APFloat(APFloat::PPCDoubleDouble(), APInt(128, Pair));
return lltok::APFloat;
case 'H':
APFloatVal = APFloat(APFloat::IEEEhalf,
APFloatVal = APFloat(APFloat::IEEEhalf(),
APInt(16,HexIntToVal(TokStart+3, CurPtr)));
return lltok::APFloat;
}
Expand Down Expand Up @@ -967,7 +967,7 @@ lltok::Kind LLLexer::LexDigitOrNegative() {
}
}

APFloatVal = APFloat(APFloat::IEEEdouble,
APFloatVal = APFloat(APFloat::IEEEdouble(),
StringRef(TokStart, CurPtr - TokStart));
return lltok::APFloat;
}
Expand Down Expand Up @@ -1004,7 +1004,7 @@ lltok::Kind LLLexer::LexPositive() {
}
}

APFloatVal = APFloat(APFloat::IEEEdouble,
APFloatVal = APFloat(APFloat::IEEEdouble(),
StringRef(TokStart, CurPtr - TokStart));
return lltok::APFloat;
}
6 changes: 3 additions & 3 deletions lib/AsmParser/LLParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4460,13 +4460,13 @@ bool LLParser::ConvertValIDToValue(Type *Ty, ValID &ID, Value *&V,

// The lexer has no type info, so builds all half, float, and double FP
// constants as double. Fix this here. Long double does not need this.
if (&ID.APFloatVal.getSemantics() == &APFloat::IEEEdouble) {
if (&ID.APFloatVal.getSemantics() == &APFloat::IEEEdouble()) {
bool Ignored;
if (Ty->isHalfTy())
ID.APFloatVal.convert(APFloat::IEEEhalf, APFloat::rmNearestTiesToEven,
ID.APFloatVal.convert(APFloat::IEEEhalf(), APFloat::rmNearestTiesToEven,
&Ignored);
else if (Ty->isFloatTy())
ID.APFloatVal.convert(APFloat::IEEEsingle, APFloat::rmNearestTiesToEven,
ID.APFloatVal.convert(APFloat::IEEEsingle(), APFloat::rmNearestTiesToEven,
&Ignored);
}
V = ConstantFP::get(Context, ID.APFloatVal);
Expand Down
12 changes: 6 additions & 6 deletions lib/Bitcode/Reader/BitcodeReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1996,26 +1996,26 @@ Error BitcodeReader::parseConstants() {
if (Record.empty())
return error("Invalid record");
if (CurTy->isHalfTy())
V = ConstantFP::get(Context, APFloat(APFloat::IEEEhalf,
V = ConstantFP::get(Context, APFloat(APFloat::IEEEhalf(),
APInt(16, (uint16_t)Record[0])));
else if (CurTy->isFloatTy())
V = ConstantFP::get(Context, APFloat(APFloat::IEEEsingle,
V = ConstantFP::get(Context, APFloat(APFloat::IEEEsingle(),
APInt(32, (uint32_t)Record[0])));
else if (CurTy->isDoubleTy())
V = ConstantFP::get(Context, APFloat(APFloat::IEEEdouble,
V = ConstantFP::get(Context, APFloat(APFloat::IEEEdouble(),
APInt(64, Record[0])));
else if (CurTy->isX86_FP80Ty()) {
// Bits are not stored the same way as a normal i80 APInt, compensate.
uint64_t Rearrange[2];
Rearrange[0] = (Record[1] & 0xffffLL) | (Record[0] << 16);
Rearrange[1] = Record[0] >> 48;
V = ConstantFP::get(Context, APFloat(APFloat::x87DoubleExtended,
V = ConstantFP::get(Context, APFloat(APFloat::x87DoubleExtended(),
APInt(80, Rearrange)));
} else if (CurTy->isFP128Ty())
V = ConstantFP::get(Context, APFloat(APFloat::IEEEquad,
V = ConstantFP::get(Context, APFloat(APFloat::IEEEquad(),
APInt(128, Record)));
else if (CurTy->isPPC_FP128Ty())
V = ConstantFP::get(Context, APFloat(APFloat::PPCDoubleDouble,
V = ConstantFP::get(Context, APFloat(APFloat::PPCDoubleDouble(),
APInt(128, Record)));
else
V = UndefValue::get(CurTy);
Expand Down
2 changes: 1 addition & 1 deletion lib/CodeGen/AsmPrinter/AsmPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -758,7 +758,7 @@ static bool emitDebugValueComment(const MachineInstr *MI, AsmPrinter &AP) {
// There is no good way to print long double. Convert a copy to
// double. Ah well, it's only a comment.
bool ignored;
APF.convert(APFloat::IEEEdouble, APFloat::rmNearestTiesToEven,
APF.convert(APFloat::IEEEdouble(), APFloat::rmNearestTiesToEven,
&ignored);
OS << "(long double) " << APF.convertToDouble();
}
Expand Down
2 changes: 1 addition & 1 deletion lib/CodeGen/MachineInstr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ void MachineOperand::print(raw_ostream &OS, ModuleSlotTracker &MST,
} else if (getFPImm()->getType()->isHalfTy()) {
APFloat APF = getFPImm()->getValueAPF();
bool Unused;
APF.convert(APFloat::IEEEsingle, APFloat::rmNearestTiesToEven, &Unused);
APF.convert(APFloat::IEEEsingle(), APFloat::rmNearestTiesToEven, &Unused);
OS << "half " << APF.convertToFloat();
} else {
OS << getFPImm()->getValueAPF().convertToDouble();
Expand Down
4 changes: 2 additions & 2 deletions lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1466,7 +1466,7 @@ void DAGTypeLegalizer::ExpandFloatRes_XINT_TO_FP(SDNode *N, SDValue &Lo,

// TODO: Are there fast-math-flags to propagate to this FADD?
Lo = DAG.getNode(ISD::FADD, dl, VT, Hi,
DAG.getConstantFP(APFloat(APFloat::PPCDoubleDouble,
DAG.getConstantFP(APFloat(APFloat::PPCDoubleDouble(),
APInt(128, Parts)),
dl, MVT::ppcf128));
Lo = DAG.getSelectCC(dl, Src, DAG.getConstant(0, dl, SrcVT),
Expand Down Expand Up @@ -1631,7 +1631,7 @@ SDValue DAGTypeLegalizer::ExpandFloatOp_FP_TO_UINT(SDNode *N) {
assert(N->getOperand(0).getValueType() == MVT::ppcf128 &&
"Logic only correct for ppcf128!");
const uint64_t TwoE31[] = {0x41e0000000000000LL, 0};
APFloat APF = APFloat(APFloat::PPCDoubleDouble, APInt(128, TwoE31));
APFloat APF = APFloat(APFloat::PPCDoubleDouble(), APInt(128, TwoE31));
SDValue Tmp = DAG.getConstantFP(APF, dl, MVT::ppcf128);
// X>=2^31 ? (int)(X-2^31)+0x80000000 : (int)X
// FIXME: generated code sucks.
Expand Down
8 changes: 4 additions & 4 deletions lib/CodeGen/SelectionDAG/SelectionDAG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3191,13 +3191,13 @@ SDValue SelectionDAG::getNode(unsigned Opcode, const SDLoc &DL, EVT VT,
}
case ISD::BITCAST:
if (VT == MVT::f16 && C->getValueType(0) == MVT::i16)
return getConstantFP(APFloat(APFloat::IEEEhalf, Val), DL, VT);
return getConstantFP(APFloat(APFloat::IEEEhalf(), Val), DL, VT);
if (VT == MVT::f32 && C->getValueType(0) == MVT::i32)
return getConstantFP(APFloat(APFloat::IEEEsingle, Val), DL, VT);
return getConstantFP(APFloat(APFloat::IEEEsingle(), Val), DL, VT);
if (VT == MVT::f64 && C->getValueType(0) == MVT::i64)
return getConstantFP(APFloat(APFloat::IEEEdouble, Val), DL, VT);
return getConstantFP(APFloat(APFloat::IEEEdouble(), Val), DL, VT);
if (VT == MVT::f128 && C->getValueType(0) == MVT::i128)
return getConstantFP(APFloat(APFloat::IEEEquad, Val), DL, VT);
return getConstantFP(APFloat(APFloat::IEEEquad(), Val), DL, VT);
break;
case ISD::BSWAP:
return getConstant(Val.byteSwap(), DL, VT, C->isTargetOpcode(),
Expand Down
2 changes: 1 addition & 1 deletion lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4172,7 +4172,7 @@ static SDValue GetExponent(SelectionDAG &DAG, SDValue Op,
/// getF32Constant - Get 32-bit floating point constant.
static SDValue getF32Constant(SelectionDAG &DAG, unsigned Flt,
const SDLoc &dl) {
return DAG.getConstantFP(APFloat(APFloat::IEEEsingle, APInt(32, Flt)), dl,
return DAG.getConstantFP(APFloat(APFloat::IEEEsingle(), APInt(32, Flt)), dl,
MVT::f32);
}

Expand Down
4 changes: 2 additions & 2 deletions lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -425,9 +425,9 @@ void SDNode::print_details(raw_ostream &OS, const SelectionDAG *G) const {
} else if (const ConstantSDNode *CSDN = dyn_cast<ConstantSDNode>(this)) {
OS << '<' << CSDN->getAPIntValue() << '>';
} else if (const ConstantFPSDNode *CSDN = dyn_cast<ConstantFPSDNode>(this)) {
if (&CSDN->getValueAPF().getSemantics()==&APFloat::IEEEsingle)
if (&CSDN->getValueAPF().getSemantics()==&APFloat::IEEEsingle())
OS << '<' << CSDN->getValueAPF().convertToFloat() << '>';
else if (&CSDN->getValueAPF().getSemantics()==&APFloat::IEEEdouble)
else if (&CSDN->getValueAPF().getSemantics()==&APFloat::IEEEdouble())
OS << '<' << CSDN->getValueAPF().convertToDouble() << '>';
else {
OS << "<APFloat(";
Expand Down
6 changes: 3 additions & 3 deletions lib/ExecutionEngine/ExecutionEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,7 @@ GenericValue ExecutionEngine::getConstantValue(const Constant *C) {
else if (CE->getType()->isDoubleTy())
GV.DoubleVal = GV.IntVal.roundToDouble();
else if (CE->getType()->isX86_FP80Ty()) {
APFloat apf = APFloat::getZero(APFloat::x87DoubleExtended);
APFloat apf = APFloat::getZero(APFloat::x87DoubleExtended());
(void)apf.convertFromAPInt(GV.IntVal,
false,
APFloat::rmNearestTiesToEven);
Expand All @@ -707,7 +707,7 @@ GenericValue ExecutionEngine::getConstantValue(const Constant *C) {
else if (CE->getType()->isDoubleTy())
GV.DoubleVal = GV.IntVal.signedRoundToDouble();
else if (CE->getType()->isX86_FP80Ty()) {
APFloat apf = APFloat::getZero(APFloat::x87DoubleExtended);
APFloat apf = APFloat::getZero(APFloat::x87DoubleExtended());
(void)apf.convertFromAPInt(GV.IntVal,
true,
APFloat::rmNearestTiesToEven);
Expand All @@ -724,7 +724,7 @@ GenericValue ExecutionEngine::getConstantValue(const Constant *C) {
else if (Op0->getType()->isDoubleTy())
GV.IntVal = APIntOps::RoundDoubleToAPInt(GV.DoubleVal, BitWidth);
else if (Op0->getType()->isX86_FP80Ty()) {
APFloat apf = APFloat(APFloat::x87DoubleExtended, GV.IntVal);
APFloat apf = APFloat(APFloat::x87DoubleExtended(), GV.IntVal);
uint64_t v;
bool ignored;
(void)apf.convertToInteger(&v, BitWidth,
Expand Down
Loading

0 comments on commit 20a600c

Please sign in to comment.