Chromium Code Reviews

Side by Side Diff: src/PNaClTranslator.cpp

Issue 1575873006: Subzero: Fix g++ warnings. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Code review changes Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
« src/IceUtils.h ('K') | « src/IceUtils.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 //===- subzero/src/PNaClTranslator.cpp - ICE from bitcode -----------------===// 1 //===- subzero/src/PNaClTranslator.cpp - ICE from bitcode -----------------===//
2 // 2 //
3 // The Subzero Code Generator 3 // The Subzero Code Generator
4 // 4 //
5 // This file is distributed under the University of Illinois Open Source 5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details. 6 // License. See LICENSE.TXT for details.
7 // 7 //
8 //===----------------------------------------------------------------------===// 8 //===----------------------------------------------------------------------===//
9 /// 9 ///
10 /// \file 10 /// \file
11 /// \brief Implements the interface for translation from PNaCl bitcode files to 11 /// \brief Implements the interface for translation from PNaCl bitcode files to
12 /// ICE to machine code. 12 /// ICE to machine code.
13 /// 13 ///
14 //===----------------------------------------------------------------------===// 14 //===----------------------------------------------------------------------===//
15 15
16 #include "PNaClTranslator.h" 16 #include "PNaClTranslator.h"
17 17
18 #include "IceCfg.h" 18 #include "IceCfg.h"
19 #include "IceCfgNode.h" 19 #include "IceCfgNode.h"
20 #include "IceClFlags.h" 20 #include "IceClFlags.h"
21 #include "IceDefs.h" 21 #include "IceDefs.h"
22 #include "IceGlobalInits.h" 22 #include "IceGlobalInits.h"
23 #include "IceInst.h" 23 #include "IceInst.h"
24 #include "IceOperand.h" 24 #include "IceOperand.h"
25 25
26 #ifdef __clang__
26 #pragma clang diagnostic push 27 #pragma clang diagnostic push
27 #pragma clang diagnostic ignored "-Wunused-parameter" 28 #pragma clang diagnostic ignored "-Wunused-parameter"
29 #endif // __clang__
30
28 #include "llvm/ADT/Hashing.h" 31 #include "llvm/ADT/Hashing.h"
29 #include "llvm/ADT/SmallString.h" 32 #include "llvm/ADT/SmallString.h"
30 #include "llvm/Bitcode/NaCl/NaClBitcodeDecoders.h" 33 #include "llvm/Bitcode/NaCl/NaClBitcodeDecoders.h"
31 #include "llvm/Bitcode/NaCl/NaClBitcodeDefs.h" 34 #include "llvm/Bitcode/NaCl/NaClBitcodeDefs.h"
32 #include "llvm/Bitcode/NaCl/NaClBitcodeHeader.h" 35 #include "llvm/Bitcode/NaCl/NaClBitcodeHeader.h"
33 #include "llvm/Bitcode/NaCl/NaClBitcodeParser.h" 36 #include "llvm/Bitcode/NaCl/NaClBitcodeParser.h"
34 #include "llvm/Bitcode/NaCl/NaClReaderWriter.h" 37 #include "llvm/Bitcode/NaCl/NaClReaderWriter.h"
35 #include "llvm/Support/Format.h" 38 #include "llvm/Support/Format.h"
36 #include "llvm/Support/MemoryBuffer.h" 39 #include "llvm/Support/MemoryBuffer.h"
37 #include "llvm/Support/raw_ostream.h" 40 #include "llvm/Support/raw_ostream.h"
41
42 #ifdef __clang__
43 #pragma clang diagnostic pop
44 #endif // __clang__
45
38 #include <unordered_set> 46 #include <unordered_set>
39 #pragma clang diagnostic pop
40 47
41 // Define a hash function for SmallString's, so that it can be used in hash 48 // Define a hash function for SmallString's, so that it can be used in hash
42 // tables. 49 // tables.
43 namespace std { 50 namespace std {
44 template <unsigned InternalLen> struct hash<llvm::SmallString<InternalLen>> { 51 template <unsigned InternalLen> struct hash<llvm::SmallString<InternalLen>> {
45 size_t operator()(const llvm::SmallString<InternalLen> &Key) const { 52 size_t operator()(const llvm::SmallString<InternalLen> &Key) const {
46 return llvm::hash_combine_range(Key.begin(), Key.end()); 53 return llvm::hash_combine_range(Key.begin(), Key.end());
47 } 54 }
48 }; 55 };
49 } // end of namespace std 56 } // end of namespace std
(...skipping 133 matching lines...)
183 return static_cast<int64_t>(Val << (BITS_PER_WORD - BitWidth)) >> 190 return static_cast<int64_t>(Val << (BITS_PER_WORD - BitWidth)) >>
184 (BITS_PER_WORD - BitWidth); 191 (BITS_PER_WORD - BitWidth);
185 } 192 }
186 193
187 template <typename IntType, typename FpType> 194 template <typename IntType, typename FpType>
188 inline FpType convertToFp() const { 195 inline FpType convertToFp() const {
189 static_assert(sizeof(IntType) == sizeof(FpType), 196 static_assert(sizeof(IntType) == sizeof(FpType),
190 "IntType and FpType should be the same width"); 197 "IntType and FpType should be the same width");
191 assert(BitWidth == sizeof(IntType) * CHAR_BIT); 198 assert(BitWidth == sizeof(IntType) * CHAR_BIT);
192 auto V = static_cast<IntType>(Val); 199 auto V = static_cast<IntType>(Val);
193 return reinterpret_cast<FpType &>(V); 200 return Ice::Utils::bitCopy<FpType>(V);
194 } 201 }
195 202
196 private: 203 private:
197 /// Bits in the (internal) value. 204 /// Bits in the (internal) value.
198 static const Ice::SizeT BITS_PER_WORD = sizeof(uint64_t) * CHAR_BIT; 205 static const Ice::SizeT BITS_PER_WORD = sizeof(uint64_t) * CHAR_BIT;
199 206
200 uint32_t BitWidth; /// The number of bits in the floating point number. 207 uint32_t BitWidth; /// The number of bits in the floating point number.
201 uint64_t Val; /// The (64-bit) equivalent integer value. 208 uint64_t Val; /// The (64-bit) equivalent integer value.
202 209
203 /// Clear unused high order bits. 210 /// Clear unused high order bits.
(...skipping 2991 matching lines...)
3195 raw_string_ostream StrBuf(Buffer); 3202 raw_string_ostream StrBuf(Buffer);
3196 StrBuf << IRFilename << ": Does not contain a module!"; 3203 StrBuf << IRFilename << ": Does not contain a module!";
3197 llvm::report_fatal_error(StrBuf.str()); 3204 llvm::report_fatal_error(StrBuf.str());
3198 } 3205 }
3199 if (InputStreamFile.getBitcodeBytes().getExtent() % 4 != 0) { 3206 if (InputStreamFile.getBitcodeBytes().getExtent() % 4 != 0) {
3200 llvm::report_fatal_error("Bitcode stream should be a multiple of 4 bytes"); 3207 llvm::report_fatal_error("Bitcode stream should be a multiple of 4 bytes");
3201 } 3208 }
3202 } 3209 }
3203 3210
3204 } // end of namespace Ice 3211 } // end of namespace Ice
OLDNEW
« src/IceUtils.h ('K') | « src/IceUtils.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine