comparison dmd/mars.c @ 237:a168a2c3ea48 trunk

[svn r253] Removed -inlineasm option. inline asm is now enabled by default unless the new -noasm option is passed. Tried adding a stack trace print when compiler crashes, not sure it's working though. Changed data layouts to match that of llvm-gcc. Fixed casting function pointers. Added support checks in AsmStatement.
author lindquist
date Sun, 08 Jun 2008 19:09:24 +0200
parents ccc2e6898a78
children fc9c1a0eabbd
comparison
equal deleted inserted replaced
236:df1abfe27be6 237:a168a2c3ea48
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" 10 #include "llvm/Target/TargetMachineRegistry.h"
11 #include "llvm/System/Signals.h"
11 12
12 #include <stdio.h> 13 #include <stdio.h>
13 #include <stdlib.h> 14 #include <stdlib.h>
14 #include <ctype.h> 15 #include <ctype.h>
15 #include <assert.h> 16 #include <assert.h>
178 -debug=level compile in debug code <= level\n\ 179 -debug=level compile in debug code <= level\n\
179 -debug=ident compile in debug code identified by ident\n\ 180 -debug=ident compile in debug code identified by ident\n\
180 -debuglib=name set symbolic debug library to name\n\ 181 -debuglib=name set symbolic debug library to name\n\
181 -defaultlib=name set default library to name\n\ 182 -defaultlib=name set default library to name\n\
182 -dis disassemble module after compiling\n\ 183 -dis disassemble module after compiling\n\
184 -fp80 enable 80bit reals on x86 32bit (EXPERIMENTAL)\n\
183 -g add symbolic debug info\n\ 185 -g add symbolic debug info\n\
184 -gc add symbolic debug info, pretend to be C\n\ 186 -gc add symbolic debug info, pretend to be C\n\
185 -H generate 'header' file\n\ 187 -H generate 'header' file\n\
186 -Hd<hdrdir> write 'header' file to <hdrdir> directory\n\ 188 -Hd<hdrdir> write 'header' file to <hdrdir> directory\n\
187 -Hf<filename> write 'header' file to <filename>\n\ 189 -Hf<filename> write 'header' file to <filename>\n\
191 -ignore ignore unsupported pragmas\n\ 193 -ignore ignore unsupported pragmas\n\
192 -inline do function inlining\n\ 194 -inline do function inlining\n\
193 -Llinkerflag pass linkerflag to link\n\ 195 -Llinkerflag pass linkerflag to link\n\
194 -m<arch> emit code specific to <arch>\n\ 196 -m<arch> emit code specific to <arch>\n\
195 x86 x86-64 ppc32 ppc64\n\ 197 x86 x86-64 ppc32 ppc64\n\
198 -noasm do not allow use of inline asm\n\
196 -nofloat do not emit reference to floating point\n\ 199 -nofloat do not emit reference to floating point\n\
197 -noruntime do not allow code that generates implicit runtime calls\n\ 200 -noruntime do not allow code that generates implicit runtime calls\n\
198 -noverify do not run the validation pass before writing bitcode\n\ 201 -noverify do not run the validation pass before writing bitcode\n\
199 -O optimize, same as -O2\n\ 202 -O optimize, same as -O2\n\
200 -O<n> optimize at level <n> (0-5)\n\ 203 -O<n> optimize at level <n> (0-5)\n\
213 -vv very verbose (does not include -v)\n\ 216 -vv very verbose (does not include -v)\n\
214 -v1 D language version 1\n\ 217 -v1 D language version 1\n\
215 -version=level compile in version code >= level\n\ 218 -version=level compile in version code >= level\n\
216 -version=ident compile in version code identified by ident\n\ 219 -version=ident compile in version code identified by ident\n\
217 -w enable warnings\n\ 220 -w enable warnings\n\
218 \n\
219 Experimental features:\n\
220 -inlineasm allow use of inline asm\n\
221 -fp80 enable 80bit reals on x86 32bit\n\
222 ", 221 ",
223 #if WIN32 222 #if WIN32
224 " @cmdfile read arguments from cmdfile\n" 223 " @cmdfile read arguments from cmdfile\n"
225 #else 224 #else
226 "" 225 ""
228 ); 227 );
229 } 228 }
230 229
231 int main(int argc, char *argv[]) 230 int main(int argc, char *argv[])
232 { 231 {
232 llvm::sys::PrintStackTraceOnErrorSignal();
233
233 int i; 234 int i;
234 Array files; 235 Array files;
235 char *p; 236 char *p;
236 Module *m; 237 Module *m;
237 int status = EXIT_SUCCESS; 238 int status = EXIT_SUCCESS;
298 global.params.forceBE = 0; 299 global.params.forceBE = 0;
299 global.params.noruntime = 0; 300 global.params.noruntime = 0;
300 global.params.novalidate = 0; 301 global.params.novalidate = 0;
301 global.params.optimizeLevel = -1; 302 global.params.optimizeLevel = -1;
302 global.params.runtimeImppath = 0; 303 global.params.runtimeImppath = 0;
304 global.params.useInlineAsm = 1;
303 305
304 global.params.defaultlibname = "phobos"; 306 global.params.defaultlibname = "phobos";
305 global.params.debuglibname = global.params.defaultlibname; 307 global.params.debuglibname = global.params.defaultlibname;
306 308
307 // Predefine version identifiers 309 // Predefine version identifiers
400 global.params.disassemble = 1; 402 global.params.disassemble = 1;
401 else if (strcmp(p + 1, "annotate") == 0) 403 else if (strcmp(p + 1, "annotate") == 0)
402 global.params.llvmAnnotate = 1; 404 global.params.llvmAnnotate = 1;
403 else if (strcmp(p + 1, "fp80") == 0) 405 else if (strcmp(p + 1, "fp80") == 0)
404 global.params.useFP80 = 1; 406 global.params.useFP80 = 1;
405 else if (strcmp(p + 1, "inlineasm") == 0) 407 else if (strcmp(p + 1, "noasm") == 0)
406 global.params.useInlineAsm = 1; 408 global.params.useInlineAsm = 0;
407 else if (p[1] == 'o') 409 else if (p[1] == 'o')
408 { 410 {
409 switch (p[2]) 411 switch (p[2])
410 { 412 {
411 case '-': 413 case '-':
708 if (strcmp(global.params.llvmArch,"x86")==0) { 710 if (strcmp(global.params.llvmArch,"x86")==0) {
709 VersionCondition::addPredefinedGlobalIdent("X86"); 711 VersionCondition::addPredefinedGlobalIdent("X86");
710 //VersionCondition::addPredefinedGlobalIdent("LLVM_InlineAsm_X86"); 712 //VersionCondition::addPredefinedGlobalIdent("LLVM_InlineAsm_X86");
711 global.params.isLE = true; 713 global.params.isLE = true;
712 global.params.is64bit = false; 714 global.params.is64bit = false;
715 global.params.cpu = ARCHx86;
713 tt_arch = "i686"; 716 tt_arch = "i686";
714 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-v64:64:64-v128:128:128-a0:0:8"; 717 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";
715 is_x86 = true; 718 is_x86 = true;
719
716 } 720 }
717 else if (strcmp(global.params.llvmArch,"x86-64")==0) { 721 else if (strcmp(global.params.llvmArch,"x86-64")==0) {
718 VersionCondition::addPredefinedGlobalIdent("X86_64"); 722 VersionCondition::addPredefinedGlobalIdent("X86_64");
719 //VersionCondition::addPredefinedGlobalIdent("LLVM_InlineAsm_X86_64"); 723 //VersionCondition::addPredefinedGlobalIdent("LLVM_InlineAsm_X86_64");
720 global.params.isLE = true; 724 global.params.isLE = true;
721 global.params.is64bit = true; 725 global.params.is64bit = true;
726 global.params.cpu = ARCHx86_64;
722 tt_arch = "x86_64"; 727 tt_arch = "x86_64";
723 data_layout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:8"; 728 data_layout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64";
724 } 729 }
725 else if (strcmp(global.params.llvmArch,"ppc32")==0) { 730 else if (strcmp(global.params.llvmArch,"ppc32")==0) {
726 VersionCondition::addPredefinedGlobalIdent("PPC"); 731 VersionCondition::addPredefinedGlobalIdent("PPC");
727 global.params.isLE = false; 732 global.params.isLE = false;
728 global.params.is64bit = false; 733 global.params.is64bit = false;
734 global.params.cpu = ARCHppc;
729 tt_arch = "powerpc"; 735 tt_arch = "powerpc";
730 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-v64:64:64-v128:128:128-a0:0:8"; 736 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-v64:64:64-v128:128:128-a0:0:64";
731 } 737 }
732 else if (strcmp(global.params.llvmArch,"ppc64")==0) { 738 else if (strcmp(global.params.llvmArch,"ppc64")==0) {
733 VersionCondition::addPredefinedGlobalIdent("PPC64"); 739 VersionCondition::addPredefinedGlobalIdent("PPC64");
734 global.params.isLE = false; 740 global.params.isLE = false;
735 global.params.is64bit = true; 741 global.params.is64bit = true;
742 global.params.cpu = ARCHppc_64;
736 tt_arch = "powerpc64"; 743 tt_arch = "powerpc64";
737 data_layout = "E-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:8"; 744 data_layout = "E-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64";
738 } 745 }
739 else { 746 else {
740 assert(0 && "Invalid arch"); 747 assert(0 && "Invalid arch");
741 } 748 }
742 749
753 760
754 if (global.params.is64bit) { 761 if (global.params.is64bit) {
755 VersionCondition::addPredefinedGlobalIdent("LLVM64"); 762 VersionCondition::addPredefinedGlobalIdent("LLVM64");
756 } 763 }
757 764
758 if (!is_x86 && (global.params.useFP80 || global.params.useInlineAsm)) {
759 error("the -fp80 option is only valid for the x86 32bit architecture");
760 fatal();
761 }
762
763 if (global.params.useFP80) { 765 if (global.params.useFP80) {
766 if (!is_x86) {
767 error("the -fp80 option is only valid for the x86 32bit architecture");
768 fatal();
769 }
764 VersionCondition::addPredefinedGlobalIdent("LLVM_X86_FP80"); 770 VersionCondition::addPredefinedGlobalIdent("LLVM_X86_FP80");
765 } 771 }
766 if (global.params.useInlineAsm) { 772 if (is_x86 && global.params.useInlineAsm) {
767 VersionCondition::addPredefinedGlobalIdent("D_InlineAsm"); 773 VersionCondition::addPredefinedGlobalIdent("D_InlineAsm");
768 VersionCondition::addPredefinedGlobalIdent("D_InlineAsm_X86"); 774 VersionCondition::addPredefinedGlobalIdent("D_InlineAsm_X86");
769 } 775 }
770 776
771 assert(tt_arch != 0); 777 assert(tt_arch != 0);