OLD | NEW |
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 |
(...skipping 19 matching lines...) Expand all Loading... |
30 #pragma clang diagnostic pop | 30 #pragma clang diagnostic pop |
31 | 31 |
32 #include <fstream> | 32 #include <fstream> |
33 #include <iostream> | 33 #include <iostream> |
34 #include <thread> | 34 #include <thread> |
35 | 35 |
36 namespace Ice { | 36 namespace Ice { |
37 | 37 |
38 namespace { | 38 namespace { |
39 | 39 |
40 // Define a SmallVector backed buffer as a data stream, so that it | 40 // Define a SmallVector backed buffer as a data stream, so that it can hold the |
41 // can hold the generated binary version of the textual bitcode in the | 41 // generated binary version of the textual bitcode in the input file. |
42 // input file. | |
43 class TextDataStreamer : public llvm::DataStreamer { | 42 class TextDataStreamer : public llvm::DataStreamer { |
44 public: | 43 public: |
45 TextDataStreamer() = default; | 44 TextDataStreamer() = default; |
46 ~TextDataStreamer() final = default; | 45 ~TextDataStreamer() final = default; |
47 static TextDataStreamer *create(const IceString &Filename, std::string *Err); | 46 static TextDataStreamer *create(const IceString &Filename, std::string *Err); |
48 size_t GetBytes(unsigned char *Buf, size_t Len) final; | 47 size_t GetBytes(unsigned char *Buf, size_t Len) final; |
49 | 48 |
50 private: | 49 private: |
51 llvm::SmallVector<char, 1024> BitcodeBuffer; | 50 llvm::SmallVector<char, 1024> BitcodeBuffer; |
52 size_t Cursor = 0; | 51 size_t Cursor = 0; |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 } | 121 } |
123 std::unique_ptr<llvm::raw_fd_ostream> FdOs(new llvm::raw_fd_ostream( | 122 std::unique_ptr<llvm::raw_fd_ostream> FdOs(new llvm::raw_fd_ostream( |
124 ExtraFlags.getOutputFilename(), EC, llvm::sys::fs::F_None)); | 123 ExtraFlags.getOutputFilename(), EC, llvm::sys::fs::F_None)); |
125 if (EC) { | 124 if (EC) { |
126 *Ls << "Failed to open output file: " << ExtraFlags.getOutputFilename() | 125 *Ls << "Failed to open output file: " << ExtraFlags.getOutputFilename() |
127 << ":\n" << EC.message() << "\n"; | 126 << ":\n" << EC.message() << "\n"; |
128 return transferErrorCode(getReturnValue(ExtraFlags, Ice::EC_Args)); | 127 return transferErrorCode(getReturnValue(ExtraFlags, Ice::EC_Args)); |
129 } | 128 } |
130 ELFStr.reset(new ELFStreamer(*FdOs.get())); | 129 ELFStr.reset(new ELFStreamer(*FdOs.get())); |
131 Os.reset(FdOs.release()); | 130 Os.reset(FdOs.release()); |
132 // NaCl sets st_blksize to 0, and LLVM uses that to pick the | 131 // NaCl sets st_blksize to 0, and LLVM uses that to pick the default |
133 // default preferred buffer size. Set to something non-zero. | 132 // preferred buffer size. Set to something non-zero. |
134 Os->SetBufferSize(1 << 14); | 133 Os->SetBufferSize(1 << 14); |
135 } break; | 134 } break; |
136 case FT_Asm: | 135 case FT_Asm: |
137 case FT_Iasm: { | 136 case FT_Iasm: { |
138 Os = makeStream(ExtraFlags.getOutputFilename(), EC); | 137 Os = makeStream(ExtraFlags.getOutputFilename(), EC); |
139 if (EC) { | 138 if (EC) { |
140 *Ls << "Failed to open output file: " << ExtraFlags.getOutputFilename() | 139 *Ls << "Failed to open output file: " << ExtraFlags.getOutputFilename() |
141 << ":\n" << EC.message() << "\n"; | 140 << ":\n" << EC.message() << "\n"; |
142 return transferErrorCode(getReturnValue(ExtraFlags, Ice::EC_Args)); | 141 return transferErrorCode(getReturnValue(ExtraFlags, Ice::EC_Args)); |
143 } | 142 } |
(...skipping 26 matching lines...) Expand all Loading... |
170 }); | 169 }); |
171 CompileThread.join(); | 170 CompileThread.join(); |
172 } else { | 171 } else { |
173 getCompiler().run(ExtraFlags, *Ctx.get(), std::move(InputStream)); | 172 getCompiler().run(ExtraFlags, *Ctx.get(), std::move(InputStream)); |
174 } | 173 } |
175 transferErrorCode(getReturnValue( | 174 transferErrorCode(getReturnValue( |
176 ExtraFlags, static_cast<ErrorCodes>(Ctx->getErrorStatus()->value()))); | 175 ExtraFlags, static_cast<ErrorCodes>(Ctx->getErrorStatus()->value()))); |
177 } | 176 } |
178 | 177 |
179 } // end of namespace Ice | 178 } // end of namespace Ice |
OLD | NEW |