Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Side by Side Diff: src/IceCompileServer.cpp

Issue 1960393002: Subzero: Add necessary PNaCl files for standalone build. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero@master
Patch Set: make format Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/IceBitVector.h ('k') | src/IceCompiler.cpp » ('j') | 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/IceCompileServer.cpp - Compile server ------------------===// 1 //===- subzero/src/IceCompileServer.cpp - Compile server ------------------===//
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 Defines the basic commandline-based compile server. 11 /// \brief Defines the basic commandline-based compile server.
12 /// 12 ///
13 //===----------------------------------------------------------------------===// 13 //===----------------------------------------------------------------------===//
14 14
15 #include "IceCompileServer.h" 15 #include "IceCompileServer.h"
16 16
17 #include "IceClFlags.h" 17 #include "IceClFlags.h"
18 #include "IceELFStreamer.h" 18 #include "IceELFStreamer.h"
19 #include "IceGlobalContext.h" 19 #include "IceGlobalContext.h"
20 #include "LinuxMallocProfiling.h" 20 #include "LinuxMallocProfiling.h"
21 21
22 #ifdef __clang__ 22 #ifdef __clang__
23 #pragma clang diagnostic push 23 #pragma clang diagnostic push
24 #pragma clang diagnostic ignored "-Wunused-parameter" 24 #pragma clang diagnostic ignored "-Wunused-parameter"
25 #endif // __clang__ 25 #endif // __clang__
26 26
27 #ifdef PNACL_LLVM
27 #include "llvm/Bitcode/NaCl/NaClBitcodeMungeUtils.h" 28 #include "llvm/Bitcode/NaCl/NaClBitcodeMungeUtils.h"
29 #endif // PNACL_LLVM
28 #include "llvm/Support/FileSystem.h" 30 #include "llvm/Support/FileSystem.h"
29 #include "llvm/Support/raw_os_ostream.h" 31 #include "llvm/Support/raw_os_ostream.h"
30 #include "llvm/Support/Signals.h" 32 #include "llvm/Support/Signals.h"
31 #include "llvm/Support/SourceMgr.h" 33 #include "llvm/Support/SourceMgr.h"
32 #include "llvm/Support/StreamingMemoryObject.h" 34 #include "llvm/Support/StreamingMemoryObject.h"
33 35
34 #ifdef __clang__ 36 #ifdef __clang__
35 #pragma clang diagnostic pop 37 #pragma clang diagnostic pop
36 #endif // __clang__ 38 #endif // __clang__
37 39
38 #include <cstdio> 40 #include <cstdio>
39 #include <fstream> 41 #include <fstream>
40 #include <iostream> 42 #include <iostream>
41 #include <thread> 43 #include <thread>
42 44
43 namespace Ice { 45 namespace Ice {
44 46
45 namespace { 47 namespace {
46 48
47 // Define a SmallVector backed buffer as a data stream, so that it can hold the 49 // Define a SmallVector backed buffer as a data stream, so that it can hold the
48 // generated binary version of the textual bitcode in the input file. 50 // generated binary version of the textual bitcode in the input file.
49 class TextDataStreamer : public llvm::DataStreamer { 51 class TextDataStreamer : public llvm::DataStreamer {
50 public: 52 public:
51 TextDataStreamer() = default; 53 TextDataStreamer() = default;
52 ~TextDataStreamer() final = default; 54 ~TextDataStreamer() final = default;
53 #ifdef PNACL_LLVM 55 #ifdef PNACL_LLVM
54 using CreateType = TextDataStreamer *; 56 using CreateType = TextDataStreamer *;
55 #else // !PNACL_LLVM 57 #else // !PNACL_LLVM
56 using CreateType = std::unique_ptr<TextDataStreamer>; 58 using CreateType = std::unique_ptr<TextDataStreamer>;
57 #endif // !PNACL_LLVM 59 #endif // !PNACL_LLVM
58 static CreateType create(const std::string &Filename, 60 static CreateType create(const std::string &Filename, std::string *Err);
59 std::string *Err);
60 size_t GetBytes(unsigned char *Buf, size_t Len) final; 61 size_t GetBytes(unsigned char *Buf, size_t Len) final;
61 62
62 private: 63 private:
63 llvm::SmallVector<char, 1024> BitcodeBuffer; 64 llvm::SmallVector<char, 1024> BitcodeBuffer;
64 size_t Cursor = 0; 65 size_t Cursor = 0;
65 }; 66 };
66 67
67 TextDataStreamer::CreateType TextDataStreamer::create(const std::string &Filenam e, 68 TextDataStreamer::CreateType
68 std::string *Err) { 69 TextDataStreamer::create(const std::string &Filename, std::string *Err) {
69 #ifdef PNACL_LLVM 70 #ifdef PNACL_LLVM
70 TextDataStreamer *Streamer = new TextDataStreamer(); 71 TextDataStreamer *Streamer = new TextDataStreamer();
71 llvm::raw_string_ostream ErrStrm(*Err); 72 llvm::raw_string_ostream ErrStrm(*Err);
72 if (std::error_code EC = llvm::readNaClRecordTextAndBuildBitcode( 73 if (std::error_code EC = llvm::readNaClRecordTextAndBuildBitcode(
73 Filename, Streamer->BitcodeBuffer, &ErrStrm)) { 74 Filename, Streamer->BitcodeBuffer, &ErrStrm)) {
74 ErrStrm << EC.message(); 75 ErrStrm << EC.message();
75 ErrStrm.flush(); 76 ErrStrm.flush();
76 delete Streamer; 77 delete Streamer;
77 return nullptr; 78 return nullptr;
78 } 79 }
79 ErrStrm.flush(); 80 ErrStrm.flush();
80 return Streamer; 81 return Streamer;
81 #else // !PNACL_LLVM 82 #else // !PNACL_LLVM
82 return CreateType(); 83 return CreateType();
83 #endif // !PNACL_LLVM 84 #endif // !PNACL_LLVM
84 } 85 }
85 86
86 size_t TextDataStreamer::GetBytes(unsigned char *Buf, size_t Len) { 87 size_t TextDataStreamer::GetBytes(unsigned char *Buf, size_t Len) {
87 if (Cursor >= BitcodeBuffer.size()) 88 if (Cursor >= BitcodeBuffer.size())
88 return 0; 89 return 0;
89 size_t Remaining = BitcodeBuffer.size(); 90 size_t Remaining = BitcodeBuffer.size();
90 Len = std::min(Len, Remaining); 91 Len = std::min(Len, Remaining);
91 for (size_t i = 0; i < Len; ++i) 92 for (size_t i = 0; i < Len; ++i)
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 } else { 250 } else {
250 getCompiler().run(Flags, *Ctx.get(), std::move(InputStream)); 251 getCompiler().run(Flags, *Ctx.get(), std::move(InputStream));
251 } 252 }
252 transferErrorCode( 253 transferErrorCode(
253 getReturnValue(static_cast<ErrorCodes>(Ctx->getErrorStatus()->value()))); 254 getReturnValue(static_cast<ErrorCodes>(Ctx->getErrorStatus()->value())));
254 Ctx->dumpConstantLookupCounts(); 255 Ctx->dumpConstantLookupCounts();
255 Ctx->dumpStrings(); 256 Ctx->dumpStrings();
256 } 257 }
257 258
258 } // end of namespace Ice 259 } // end of namespace Ice
OLDNEW
« no previous file with comments | « src/IceBitVector.h ('k') | src/IceCompiler.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698