Mercurial > projects > ldc
comparison gen/toobj.cpp @ 675:bfe5229f9d8e
Disable bc output by default. Remove -dis. Add -output-bc, -output-ll, -output-s.
Call to gcc to convert assembly to object file still required.
author | Christian Kamm <kamm incasoftware de> |
---|---|
date | Sat, 11 Oct 2008 13:07:59 +0200 |
parents | db6a7e574cbd |
children | 1f0a78174598 |
comparison
equal
deleted
inserted
replaced
674:db6a7e574cbd | 675:bfe5229f9d8e |
---|---|
177 } | 177 } |
178 } | 178 } |
179 | 179 |
180 // eventually do our own path stuff, dmd's is a bit strange. | 180 // eventually do our own path stuff, dmd's is a bit strange. |
181 typedef llvm::sys::Path LLPath; | 181 typedef llvm::sys::Path LLPath; |
182 LLPath bcpath = LLPath(objfile->name->toChars()); | 182 |
183 LLPath llpath = bcpath; | 183 // write LLVM bitcode |
184 llpath.eraseSuffix(); | 184 if (global.params.output_bc) { |
185 llpath.appendSuffix(std::string(global.ll_ext)); | 185 LLPath bcpath = LLPath(objfile->name->toChars()); |
186 | 186 bcpath.eraseSuffix(); |
187 // write bytecode | 187 bcpath.appendSuffix(std::string(global.bc_ext)); |
188 { | |
189 Logger::println("Writing LLVM bitcode to: %s\n", bcpath.c_str()); | 188 Logger::println("Writing LLVM bitcode to: %s\n", bcpath.c_str()); |
190 std::ofstream bos(bcpath.c_str(), std::ios::binary); | 189 std::ofstream bos(bcpath.c_str(), std::ios::binary); |
191 llvm::WriteBitcodeToFile(ir.module, bos); | 190 llvm::WriteBitcodeToFile(ir.module, bos); |
192 } | 191 } |
193 | 192 |
194 // disassemble ? | 193 // write LLVM IR |
195 if (global.params.disassemble) { | 194 if (global.params.output_ll) { |
195 LLPath llpath = LLPath(objfile->name->toChars()); | |
196 llpath.eraseSuffix(); | |
197 llpath.appendSuffix(std::string(global.ll_ext)); | |
196 Logger::println("Writing LLVM asm to: %s\n", llpath.c_str()); | 198 Logger::println("Writing LLVM asm to: %s\n", llpath.c_str()); |
197 std::ofstream aos(llpath.c_str()); | 199 std::ofstream aos(llpath.c_str()); |
198 ir.module->print(aos, NULL); | 200 ir.module->print(aos, NULL); |
199 } | 201 } |
200 | 202 |
201 //TODO: command line switch | 203 // write native assembly |
202 if(false) | 204 LLPath spath = LLPath(objfile->name->toChars()); |
203 { | 205 spath.eraseSuffix(); |
204 //FIXME: Proper out file name. | 206 spath.appendSuffix(std::string(global.s_ext)); |
205 Logger::println("Writing native asm to: %s\n", ""); | 207 if (!global.params.output_s) { |
206 std::string err; | 208 spath.createTemporaryFileOnDisk(); |
207 llvm::raw_fd_ostream out("test.s", err); | 209 } |
208 write_asm_to_file(*ir.module, out); | 210 Logger::println("Writing native asm to: %s\n", spath.c_str()); |
211 std::string err; | |
212 llvm::raw_fd_ostream out(spath.c_str(), err); | |
213 write_asm_to_file(*ir.module, out); | |
214 | |
215 //TODO: call gcc to convert assembly to object file | |
216 | |
217 if (!global.params.output_s) { | |
218 spath.eraseFromDisk(); | |
209 } | 219 } |
210 | 220 |
211 delete ir.module; | 221 delete ir.module; |
212 gTargetData = 0; | 222 gTargetData = 0; |
213 gIR = NULL; | 223 gIR = NULL; |