diff gen/toobj.cpp @ 217:0806379a5eca trunk

[svn r233] Added: -oq command line option for writing fully qualified object names. Added: started support for x86 80bit floating point. Changed: aggregates passed by value now use the llvm 'byval' parameter attribute, also lays ground work for using other attributes. Changed: eliminated a lot more std::vectorS, these showed up pretty much at the top when profiling! Changed: performed other misc. cleanups. Changed: halt expression now call the new llvm trap intrinsic instead of an assert(0). Changed: dstress suite now passes -O0 by default, this only eliminates unreferenced globals, which speeds up linking quite a bit.
author lindquist
date Thu, 05 Jun 2008 06:38:36 +0200
parents 7816aafeea3c
children 9760f54af0b7
line wrap: on
line diff
--- a/gen/toobj.cpp	Tue Jun 03 22:32:59 2008 +0200
+++ b/gen/toobj.cpp	Thu Jun 05 06:38:36 2008 +0200
@@ -16,6 +16,7 @@
 #include "llvm/Bitcode/ReaderWriter.h"
 #include "llvm/Target/TargetMachine.h"
 #include "llvm/Target/TargetMachineRegistry.h"
+#include "llvm/System/Path.h"
 
 #include "mars.h"
 #include "module.h"
@@ -151,17 +152,36 @@
     // run optimizer
     llvmdc_optimize_module(ir.module, global.params.optimizeLevel, global.params.llvmInline);
 
+    // eventually do our own path stuff, dmd's is a bit strange.
+    typedef llvm::sys::Path LLPath;
+    LLPath bcpath;
+    LLPath llpath;
+
+    if (global.params.fqnPaths)
+    {
+        bcpath = LLPath(md->toChars());
+        bcpath.appendSuffix("bc");
+
+        llpath = LLPath(md->toChars());
+        llpath.appendSuffix("ll");
+    }
+    else
+    {
+        bcpath = LLPath(bcfile->name->toChars());
+        llpath = LLPath(llfile->name->toChars());
+    }
+
     // write bytecode
     {
         Logger::println("Writing LLVM bitcode\n");
-        std::ofstream bos(bcfile->name->toChars(), std::ios::binary);
+        std::ofstream bos(bcpath.c_str(), std::ios::binary);
         llvm::WriteBitcodeToFile(ir.module, bos);
     }
 
     // disassemble ?
     if (global.params.disassemble) {
         Logger::println("Writing LLVM asm to: %s\n", llfile->name->toChars());
-        std::ofstream aos(llfile->name->toChars());
+        std::ofstream aos(llpath.c_str());
         ir.module->print(aos);
     }