Mercurial > projects > ldc
comparison gen/toobj.cpp @ 580:7824c21a58e3
Restructure path handling a bit. Fixes #66.
author | Christian Kamm <kamm incasoftware de> |
---|---|
date | Sat, 06 Sep 2008 12:27:27 +0200 |
parents | 3c07287765bc |
children | 12bda38ea366 |
comparison
equal
deleted
inserted
replaced
579:20c065c46b38 | 580:7824c21a58e3 |
---|---|
162 // run optimizer | 162 // run optimizer |
163 llvmdc_optimize_module(ir.module, global.params.optimizeLevel, global.params.llvmInline); | 163 llvmdc_optimize_module(ir.module, global.params.optimizeLevel, global.params.llvmInline); |
164 | 164 |
165 // eventually do our own path stuff, dmd's is a bit strange. | 165 // eventually do our own path stuff, dmd's is a bit strange. |
166 typedef llvm::sys::Path LLPath; | 166 typedef llvm::sys::Path LLPath; |
167 LLPath bcpath; | 167 LLPath bcpath = LLPath(objfile->name->toChars()); |
168 LLPath llpath; | 168 LLPath llpath = bcpath; |
169 | 169 llpath.eraseSuffix(); |
170 if (global.params.fqnPaths) | 170 llpath.appendSuffix(std::string(global.ll_ext)); |
171 { | |
172 bcpath = LLPath(mname); | |
173 bcpath.appendSuffix("bc"); | |
174 | |
175 llpath = LLPath(mname); | |
176 llpath.appendSuffix("ll"); | |
177 } | |
178 else | |
179 { | |
180 bcpath = LLPath(bcfile->name->toChars()); | |
181 llpath = LLPath(llfile->name->toChars()); | |
182 } | |
183 | 171 |
184 // write bytecode | 172 // write bytecode |
185 { | 173 { |
186 Logger::println("Writing LLVM bitcode to: %s\n", bcpath.c_str()); | 174 Logger::println("Writing LLVM bitcode to: %s\n", bcpath.c_str()); |
187 std::ofstream bos(bcpath.c_str(), std::ios::binary); | 175 std::ofstream bos(bcpath.c_str(), std::ios::binary); |
188 llvm::WriteBitcodeToFile(ir.module, bos); | 176 llvm::WriteBitcodeToFile(ir.module, bos); |
189 } | 177 } |
190 | 178 |
191 // disassemble ? | 179 // disassemble ? |
192 if (global.params.disassemble) { | 180 if (global.params.disassemble) { |
193 Logger::println("Writing LLVM asm to: %s\n", llfile->name->toChars()); | 181 Logger::println("Writing LLVM asm to: %s\n", llpath.c_str()); |
194 std::ofstream aos(llpath.c_str()); | 182 std::ofstream aos(llpath.c_str()); |
195 ir.module->print(aos, NULL); | 183 ir.module->print(aos, NULL); |
196 } | 184 } |
197 | 185 |
198 delete ir.module; | 186 delete ir.module; |