comparison dmd/mars.c @ 284:70c370e97944 trunk

[svn r305] Started support for custom class allocators/deallocators. Allocators with more than one argument still need to be fixed. Removed the LLVM stacktrace code from mars.c. Moved the LLVM based default target detection code from mars.c to llvmhelpers.cpp.
author lindquist
date Sat, 21 Jun 2008 02:48:53 +0200
parents a137ed004205
children 297690b5d4a5
comparison
equal deleted inserted replaced
283:9bb48fb57a7d 284:70c370e97944
5 // http://www.digitalmars.com 5 // http://www.digitalmars.com
6 // License for redistribution is by either the Artistic License 6 // License for redistribution is by either the Artistic License
7 // in artistic.txt, or the GNU General Public License in gnu.txt. 7 // in artistic.txt, or the GNU General Public License in gnu.txt.
8 // See the included readme.txt for details. 8 // See the included readme.txt for details.
9 9
10 #include "llvm/Target/TargetMachineRegistry.h"
11 #include "llvm/System/Signals.h"
12
13 #include <stdio.h> 10 #include <stdio.h>
14 #include <stdlib.h> 11 #include <stdlib.h>
15 #include <ctype.h> 12 #include <ctype.h>
16 #include <assert.h> 13 #include <assert.h>
17 #include <limits.h> 14 #include <limits.h>
39 36
40 #include "gen/logger.h" 37 #include "gen/logger.h"
41 #include "gen/linker.h" 38 #include "gen/linker.h"
42 39
43 void getenv_setargv(const char *envvar, int *pargc, char** *pargv); 40 void getenv_setargv(const char *envvar, int *pargc, char** *pargv);
41
42 // llvmdc
43 void findDefaultTarget();
44 44
45 Global global; 45 Global global;
46 46
47 Global::Global() 47 Global::Global()
48 { 48 {
223 ); 223 );
224 } 224 }
225 225
226 int main(int argc, char *argv[]) 226 int main(int argc, char *argv[])
227 { 227 {
228 llvm::sys::PrintStackTraceOnErrorSignal();
229
230 int i; 228 int i;
231 Array files; 229 Array files;
232 char *p; 230 char *p;
233 Module *m; 231 Module *m;
234 int status = EXIT_SUCCESS; 232 int status = EXIT_SUCCESS;
688 VersionCondition::addPredefinedGlobalIdent("D_Coverage"); 686 VersionCondition::addPredefinedGlobalIdent("D_Coverage");
689 687
690 bool allowForceEndianness = false; 688 bool allowForceEndianness = false;
691 689
692 if (global.params.llvmArch == 0) { 690 if (global.params.llvmArch == 0) {
693 std::string err_str; 691 findDefaultTarget();
694 const llvm::TargetMachineRegistry::entry* e = llvm::TargetMachineRegistry::getClosestTargetForJIT(err_str);
695 if (e == 0) {
696 error("Failed to find a default target machine: %s", err_str.c_str());
697 fatal();
698 }
699 else {
700 global.params.llvmArch = const_cast<char*>(e->Name);
701 if (global.params.verbose || very_verbose)
702 printf("Default target found: %s\n", global.params.llvmArch);
703 if (very_verbose) {
704 int X = sizeof(va_list);
705 printf("valist.sizeof = %d\n", X);
706 }
707 }
708 } 692 }
709 693
710 bool is_x86 = false; 694 bool is_x86 = false;
711 if (strcmp(global.params.llvmArch,"x86")==0) { 695 if (strcmp(global.params.llvmArch,"x86")==0) {
712 VersionCondition::addPredefinedGlobalIdent("X86"); 696 VersionCondition::addPredefinedGlobalIdent("X86");
715 global.params.is64bit = false; 699 global.params.is64bit = false;
716 global.params.cpu = ARCHx86; 700 global.params.cpu = ARCHx86;
717 tt_arch = "i686"; 701 tt_arch = "i686";
718 data_layout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-f80:32:32-v64:64:64-v128:128:128-a0:0:64"; 702 data_layout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-f80:32:32-v64:64:64-v128:128:128-a0:0:64";
719 is_x86 = true; 703 is_x86 = true;
720
721 } 704 }
722 else if (strcmp(global.params.llvmArch,"x86-64")==0) { 705 else if (strcmp(global.params.llvmArch,"x86-64")==0) {
723 VersionCondition::addPredefinedGlobalIdent("X86_64"); 706 VersionCondition::addPredefinedGlobalIdent("X86_64");
724 //VersionCondition::addPredefinedGlobalIdent("LLVM_InlineAsm_X86_64"); 707 //VersionCondition::addPredefinedGlobalIdent("LLVM_InlineAsm_X86_64");
725 global.params.isLE = true; 708 global.params.isLE = true;