Mercurial > projects > ldc
comparison dmd/mars.c @ 735:eee9efe5b51f
Attempt at getting LLVM to provide a proper target data layout. Should assert now if things are borked.
Added untested support for Thumb target.
author | Tomas Lindquist Olsen <tomas.l.olsen@gmail.com> |
---|---|
date | Mon, 27 Oct 2008 17:37:34 +0100 |
parents | 6dcab994ddc3 |
children | 4ac97ec7c18e |
comparison
equal
deleted
inserted
replaced
734:6dcab994ddc3 | 735:eee9efe5b51f |
---|---|
184 -Dd<docdir> write documentation file to <docdir> directory\n\ | 184 -Dd<docdir> write documentation file to <docdir> directory\n\ |
185 -Df<filename> write documentation file to <filename>\n\ | 185 -Df<filename> write documentation file to <filename>\n\ |
186 \n\ | 186 \n\ |
187 Codegen control:\n\ | 187 Codegen control:\n\ |
188 -m<arch> emit code specific to <arch> being one of:\n\ | 188 -m<arch> emit code specific to <arch> being one of:\n\ |
189 x86 x86-64 ppc32 ppc64\n\ | 189 x86 x86-64 ppc32 ppc64 arm thumb\n\ |
190 -t<os> emit code specific to <os> being one of:\n\ | 190 -t<os> emit code specific to <os> being one of:\n\ |
191 Linux, Windows, MacOSX, FreeBSD\n\ | 191 Linux, Windows, MacOSX, FreeBSD\n\ |
192 \n\ | 192 \n\ |
193 -g, -gc add symbolic debug info\n\ | 193 -g, -gc add symbolic debug info\n\ |
194 \n\ | 194 \n\ |
828 global.params.llvmArch = "ppc64"; | 828 global.params.llvmArch = "ppc64"; |
829 else | 829 else |
830 global.params.llvmArch = "ppc32"; | 830 global.params.llvmArch = "ppc32"; |
831 #elif defined(__arm__) | 831 #elif defined(__arm__) |
832 global.params.llvmArch = "arm"; | 832 global.params.llvmArch = "arm"; |
833 #elif defined(__thumb__) | |
834 global.params.llvmArch = "thumb"; | |
833 #else | 835 #else |
834 #error | 836 #error |
835 #endif | 837 #endif |
836 } | 838 } |
837 | 839 |
838 if (strcmp(global.params.llvmArch,"x86")==0) { | 840 if (strcmp(global.params.llvmArch,"x86")==0) { |
839 VersionCondition::addPredefinedGlobalIdent("X86"); | 841 VersionCondition::addPredefinedGlobalIdent("X86"); |
840 global.params.isLE = true; | 842 global.params.isLE = true; |
841 global.params.is64bit = false; | 843 global.params.is64bit = false; |
842 global.params.cpu = ARCHx86; | 844 global.params.cpu = ARCHx86; |
843 //global.params.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"; | |
844 if (global.params.useInlineAsm) { | 845 if (global.params.useInlineAsm) { |
845 VersionCondition::addPredefinedGlobalIdent("LLVM_InlineAsm_X86"); | 846 VersionCondition::addPredefinedGlobalIdent("LLVM_InlineAsm_X86"); |
846 } | 847 } |
847 } | 848 } |
848 else if (strcmp(global.params.llvmArch,"x86-64")==0) { | 849 else if (strcmp(global.params.llvmArch,"x86-64")==0) { |
849 VersionCondition::addPredefinedGlobalIdent("X86_64"); | 850 VersionCondition::addPredefinedGlobalIdent("X86_64"); |
850 global.params.isLE = true; | 851 global.params.isLE = true; |
851 global.params.is64bit = true; | 852 global.params.is64bit = true; |
852 global.params.cpu = ARCHx86_64; | 853 global.params.cpu = ARCHx86_64; |
853 //global.params.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"; | |
854 } | 854 } |
855 else if (strcmp(global.params.llvmArch,"ppc32")==0) { | 855 else if (strcmp(global.params.llvmArch,"ppc32")==0) { |
856 VersionCondition::addPredefinedGlobalIdent("PPC"); | 856 VersionCondition::addPredefinedGlobalIdent("PPC"); |
857 global.params.isLE = false; | 857 global.params.isLE = false; |
858 global.params.is64bit = false; | 858 global.params.is64bit = false; |
859 global.params.cpu = ARCHppc; | 859 global.params.cpu = ARCHppc; |
860 //global.params.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"; | |
861 } | 860 } |
862 else if (strcmp(global.params.llvmArch,"ppc64")==0) { | 861 else if (strcmp(global.params.llvmArch,"ppc64")==0) { |
863 VersionCondition::addPredefinedGlobalIdent("PPC64"); | 862 VersionCondition::addPredefinedGlobalIdent("PPC64"); |
864 global.params.isLE = false; | 863 global.params.isLE = false; |
865 global.params.is64bit = true; | 864 global.params.is64bit = true; |
866 global.params.cpu = ARCHppc_64; | 865 global.params.cpu = ARCHppc_64; |
867 //global.params.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"; | |
868 } | 866 } |
869 else if (strcmp(global.params.llvmArch,"arm")==0) { | 867 else if (strcmp(global.params.llvmArch,"arm")==0) { |
870 VersionCondition::addPredefinedGlobalIdent("ARM"); | 868 VersionCondition::addPredefinedGlobalIdent("ARM"); |
871 global.params.isLE = true; | 869 global.params.isLE = true; |
872 global.params.is64bit = false; | 870 global.params.is64bit = false; |
873 global.params.cpu = ARCHarm; | 871 global.params.cpu = ARCHarm; |
874 } | 872 } |
873 else if (strcmp(global.params.llvmArch,"thumb")==0) { | |
874 VersionCondition::addPredefinedGlobalIdent("Thumb"); | |
875 global.params.isLE = true; | |
876 global.params.is64bit = false; | |
877 global.params.cpu = ARCHthumb; | |
878 } | |
875 else { | 879 else { |
876 assert(0 && "Invalid arch"); | 880 assert(0 && "Invalid arch"); |
877 } | 881 } |
878 | 882 |
879 assert(global.params.cpu != ARCHinvalid); | 883 assert(global.params.cpu != ARCHinvalid); |
924 | 928 |
925 if (!global.params.targetTriple) | 929 if (!global.params.targetTriple) |
926 global.params.targetTriple = DEFAULT_TARGET_TRIPLE; | 930 global.params.targetTriple = DEFAULT_TARGET_TRIPLE; |
927 | 931 |
928 Logger::println("Target triple: %s", global.params.targetTriple); | 932 Logger::println("Target triple: %s", global.params.targetTriple); |
933 | |
934 // build a minimal data layout so llvm can find the target | |
935 global.params.dataLayout = global.params.isLE | |
936 ? (char*)(global.params.is64bit ? "e-p:64:64" : "e-p:32:32") | |
937 : (char*)(global.params.is64bit ? "E-p:64:64" : "E-p:32:32"); | |
938 Logger::println("Layout: %s", global.params.dataLayout); | |
929 | 939 |
930 // Initialization | 940 // Initialization |
931 Type::init(); | 941 Type::init(); |
932 Id::initialize(); | 942 Id::initialize(); |
933 Module::init(); | 943 Module::init(); |