mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-18 11:24:01 +00:00
Added serialization support for APInt.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43405 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -16,6 +16,7 @@
|
|||||||
#define LLVM_APINT_H
|
#define LLVM_APINT_H
|
||||||
|
|
||||||
#include "llvm/Support/DataTypes.h"
|
#include "llvm/Support/DataTypes.h"
|
||||||
|
#include "llvm/Bitcode/SerializationFwd.h"
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
@ -203,6 +204,16 @@ public:
|
|||||||
|
|
||||||
/// @brief Destructor.
|
/// @brief Destructor.
|
||||||
~APInt();
|
~APInt();
|
||||||
|
|
||||||
|
/// Default constructor that creates an uninitialized APInt. This is useful
|
||||||
|
/// for object deserialization (pair this with the static method Read).
|
||||||
|
explicit APInt() {}
|
||||||
|
|
||||||
|
/// @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.
|
||||||
|
void Read(Deserializer& D);
|
||||||
|
|
||||||
/// @}
|
/// @}
|
||||||
/// @name Value Tests
|
/// @name Value Tests
|
||||||
|
33
lib/Bitcode/Reader/DeserializeAPInt.cpp
Normal file
33
lib/Bitcode/Reader/DeserializeAPInt.cpp
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
//===-- DeserializeAPInt.cpp - Deserialization for APInts ------*- 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 APInts.
|
||||||
|
//
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
#include "llvm/ADT/APInt.h"
|
||||||
|
#include "llvm/Bitcode/Deserialize.h"
|
||||||
|
#include <cassert>
|
||||||
|
|
||||||
|
using namespace llvm;
|
||||||
|
|
||||||
|
void APInt::Read(Deserializer& D) {
|
||||||
|
BitWidth = D.ReadInt();
|
||||||
|
|
||||||
|
if (isSingleWord())
|
||||||
|
VAL = D.ReadInt();
|
||||||
|
else {
|
||||||
|
uint32_t NumWords = D.ReadInt();
|
||||||
|
assert (NumWords > 1);
|
||||||
|
pVal = new uint64_t[NumWords];
|
||||||
|
assert (pVal && "Allocation in deserialization of APInt failed.");
|
||||||
|
for (unsigned i = 0; i < NumWords; ++i)
|
||||||
|
pVal[i] = D.ReadInt();
|
||||||
|
}
|
||||||
|
}
|
31
lib/Bitcode/Writer/SerializeAPInt.cpp
Normal file
31
lib/Bitcode/Writer/SerializeAPInt.cpp
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
//===-- SerializeAPInt.cpp - Serialization for APInts ----------*- 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 APInts.
|
||||||
|
//
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
#include "llvm/ADT/APInt.h"
|
||||||
|
#include "llvm/Bitcode/Serialize.h"
|
||||||
|
#include <cassert>
|
||||||
|
|
||||||
|
using namespace llvm;
|
||||||
|
|
||||||
|
void APInt::Emit(Serializer& S) const {
|
||||||
|
S.EmitInt(BitWidth);
|
||||||
|
|
||||||
|
if (isSingleWord())
|
||||||
|
S.EmitInt(VAL);
|
||||||
|
else {
|
||||||
|
uint32_t NumWords = getNumWords();
|
||||||
|
S.EmitInt(NumWords);
|
||||||
|
for (unsigned i = 0; i < NumWords; ++i)
|
||||||
|
S.EmitInt(pVal[i]);
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user