diff --git a/include/llvm/ADT/APFloat.h b/include/llvm/ADT/APFloat.h index 09a9ece1402..e4d4c8eb420 100644 --- a/include/llvm/ADT/APFloat.h +++ b/include/llvm/ADT/APFloat.h @@ -102,6 +102,7 @@ // APInt contains static functions implementing bignum arithmetic. #include "llvm/ADT/APInt.h" +#include "llvm/Bitcode/SerializationFwd.h" #include "llvm/CodeGen/ValueTypes.h" namespace llvm { @@ -181,6 +182,12 @@ namespace llvm { explicit APFloat(const APInt &, bool isIEEE = false); APFloat(const APFloat &); ~APFloat(); + + /// @brief Used by the Bitcode serializer to emit APInts to Bitcode. + void Emit(Serializer& S) const; + + /// @brief Used by the Bitcode deserializer to deserialize APInts. + static APFloat ReadVal(Deserializer& D); /* Arithmetic. */ opStatus add(const APFloat &, roundingMode); diff --git a/lib/Bitcode/Reader/DeserializeAPFloat.cpp b/lib/Bitcode/Reader/DeserializeAPFloat.cpp new file mode 100644 index 00000000000..c2fe01bfb75 --- /dev/null +++ b/lib/Bitcode/Reader/DeserializeAPFloat.cpp @@ -0,0 +1,24 @@ +//===-- SerializeAPInt.cpp - Serialization for APFloat ---------*- C++ -*--===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by Ted Kremenek and is distributed under the +// University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file implements deserialization of APFloat. +// +//===----------------------------------------------------------------------===// + +#include "llvm/ADT/APFloat.h" +#include "llvm/Bitcode/Deserialize.h" + +using namespace llvm; + +APFloat APFloat::ReadVal(Deserializer& D) { + APInt x; + D.Read(x); + return APFloat(x); +} + diff --git a/lib/Bitcode/Writer/SerializeAPFloat.cpp b/lib/Bitcode/Writer/SerializeAPFloat.cpp new file mode 100644 index 00000000000..6482a474ef9 --- /dev/null +++ b/lib/Bitcode/Writer/SerializeAPFloat.cpp @@ -0,0 +1,21 @@ +//===-- SerializeAPInt.cpp - Serialization for APFloat ---------*- C++ -*--===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by Ted Kremenek and is distributed under the +// University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file implements serialization of APFloat. +// +//===----------------------------------------------------------------------===// + +#include "llvm/ADT/APFloat.h" +#include "llvm/Bitcode/Serialize.h" + +using namespace llvm; + +void APFloat::Emit(Serializer& S) const { + S.Emit(convertToAPInt()); +}