comparison gen/main.cpp @ 1532:c88b16d4a13c

Remove all of the now unecessary #if LLVM_REV
author Benjamin Kramer <benny.kra@gmail.com>
date Sat, 11 Jul 2009 14:09:33 +0200
parents f19adff18813
children d1652c8fb4f6
comparison
equal deleted inserted replaced
1531:7120a74e9ae2 1532:c88b16d4a13c
5 5
6 #include "gen/llvm.h" 6 #include "gen/llvm.h"
7 #include "gen/llvm-version.h" 7 #include "gen/llvm-version.h"
8 #include "llvm/LinkAllVMCore.h" 8 #include "llvm/LinkAllVMCore.h"
9 #include "llvm/Linker.h" 9 #include "llvm/Linker.h"
10 #if LLVM_REV >= 74640
11 #include "llvm/LLVMContext.h" 10 #include "llvm/LLVMContext.h"
12 #endif
13 #include "llvm/System/Signals.h" 11 #include "llvm/System/Signals.h"
14 #include "llvm/Target/SubtargetFeature.h" 12 #include "llvm/Target/SubtargetFeature.h"
15 #include "llvm/Target/TargetMachine.h" 13 #include "llvm/Target/TargetMachine.h"
16 #include "llvm/Target/TargetOptions.h" 14 #include "llvm/Target/TargetOptions.h"
17 #include "llvm/Target/TargetMachineRegistry.h" 15 #include "llvm/Target/TargetMachineRegistry.h"
18 #if LLVM_REV >= 73610
19 #include "llvm/Target/TargetSelect.h" 16 #include "llvm/Target/TargetSelect.h"
20 #endif
21 17
22 #include <stdio.h> 18 #include <stdio.h>
23 #include <stdlib.h> 19 #include <stdlib.h>
24 #include <assert.h> 20 #include <assert.h>
25 #include <limits.h> 21 #include <limits.h>
404 else if ((m32bits || m64bits) && (mArch != 0 || !mTargetTriple.empty())) 400 else if ((m32bits || m64bits) && (mArch != 0 || !mTargetTriple.empty()))
405 error("-m32 and -m64 switches cannot be used together with -march and -mtriple switches"); 401 error("-m32 and -m64 switches cannot be used together with -march and -mtriple switches");
406 if (global.errors) 402 if (global.errors)
407 fatal(); 403 fatal();
408 404
409 #if LLVM_REV >= 74640
410 llvm::Module mod("dummy", llvm::getGlobalContext()); 405 llvm::Module mod("dummy", llvm::getGlobalContext());
411 #else
412 llvm::Module mod("dummy");
413 #endif
414 406
415 // override triple if needed 407 // override triple if needed
416 const char* defaultTriple = DEFAULT_TARGET_TRIPLE; 408 const char* defaultTriple = DEFAULT_TARGET_TRIPLE;
417 if ((sizeof(void*) == 4 && m64bits) || (sizeof(void*) == 8 && m32bits)) 409 if ((sizeof(void*) == 4 && m64bits) || (sizeof(void*) == 8 && m32bits))
418 { 410 {
437 mod.setTargetTriple(global.params.targetTriple); 429 mod.setTargetTriple(global.params.targetTriple);
438 430
439 // Allocate target machine. 431 // Allocate target machine.
440 432
441 // first initialize llvm 433 // first initialize llvm
442 #if LLVM_REV >= 73610
443 #define LLVM_TARGET(A) LLVMInitialize##A##Target(); LLVMInitialize##A##AsmPrinter(); 434 #define LLVM_TARGET(A) LLVMInitialize##A##Target(); LLVMInitialize##A##AsmPrinter();
444 // this is defined to be LLVM_TARGET(target name 1) LLVM_TARGET(target name 2) ... 435 // this is defined to be LLVM_TARGET(target name 1) LLVM_TARGET(target name 2) ...
445 LDC_TARGETS 436 LDC_TARGETS
446 #undef LLVM_TARGET 437 #undef LLVM_TARGET
447 #endif
448 438
449 // Check whether the user has explicitly specified an architecture to compile for. 439 // Check whether the user has explicitly specified an architecture to compile for.
450 if (mArch == 0) 440 if (mArch == 0)
451 { 441 {
452 std::string Err; 442 std::string Err;
841 * module being linked to may not have generated them, so if 831 * module being linked to may not have generated them, so if
842 * we inline functions from those modules, the symbols for them will 832 * we inline functions from those modules, the symbols for them will
843 * not be found at link time. 833 * not be found at link time.
844 */ 834 */
845 if (!global.params.useArrayBounds && !global.params.useAssert) 835 if (!global.params.useArrayBounds && !global.params.useAssert)
846 #elif LLVM_REV >= 68940 836 #else
847 // This doesn't play nice with debug info at the moment 837 // This doesn't play nice with debug info at the moment
848 if (!global.params.symdebug && willInline()) 838 if (!global.params.symdebug && willInline())
849 { 839 {
850 global.params.useAvailableExternally = true; 840 global.params.useAvailableExternally = true;
851 Logger::println("Running some extra semantic3's for inlining purposes"); 841 Logger::println("Running some extra semantic3's for inlining purposes");
852 #else
853 // IN_LLVM, but available_externally not available yet.
854 if (false)
855 {
856 #endif 842 #endif
857 { 843 {
858 // Do pass 3 semantic analysis on all imported modules, 844 // Do pass 3 semantic analysis on all imported modules,
859 // since otherwise functions in them cannot be inlined 845 // since otherwise functions in them cannot be inlined
860 for (int i = 0; i < Module::amodules.dim; i++) 846 for (int i = 0; i < Module::amodules.dim; i++)
928 { 914 {
929 Module* m = (Module*)modules.data[0]; 915 Module* m = (Module*)modules.data[0];
930 char* name = m->toChars(); 916 char* name = m->toChars();
931 char* filename = m->objfile->name->str; 917 char* filename = m->objfile->name->str;
932 918
933 #if LLVM_REV >= 74640
934 llvm::Linker linker(name, name, llvm::getGlobalContext()); 919 llvm::Linker linker(name, name, llvm::getGlobalContext());
935 #else 920
936 llvm::Linker linker(name, name);
937 #endif
938 std::string errormsg; 921 std::string errormsg;
939 for (int i = 0; i < llvmModules.size(); i++) 922 for (int i = 0; i < llvmModules.size(); i++)
940 { 923 {
941 #ifdef USE_METADATA 924 #ifdef USE_METADATA
942 //FIXME: workaround for llvm metadata bug: 925 //FIXME: workaround for llvm metadata bug: