33cf7f4525ee3056755219e37357550f6e1e9371
[oota-llvm.git] / lib / Bitcode / Writer / SerializeAPInt.cpp
1 //===-- SerializeAPInt.cpp - Serialization for APInts ----------*- C++ -*--===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file was developed by Ted Kremenek and is distributed under the
6 // University of Illinois Open Source License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file implements serialization of APInts.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #include "llvm/ADT/APInt.h"
15 #include "llvm/Bitcode/Serialize.h"
16 #include <cassert>
17
18 using namespace llvm;
19
20 void APInt::Emit(Serializer& S) const {
21   S.EmitInt(BitWidth);
22
23   if (isSingleWord())
24     S.EmitInt(VAL);
25   else {
26     uint32_t NumWords = getNumWords();
27     S.EmitInt(NumWords);
28     for (unsigned i = 0; i < NumWords; ++i)
29       S.EmitInt(pVal[i]);
30   }
31 }