| author | |
| committer | |
| log | 1ff2edf67ef7a5d434697bb494247b76f34f6c84 |
| tree | f395713208e536e8b3cb6aee6ff1fb1574898f85 |
| parent | b988017547581ea39163913e400c962f74fc9b32 |
9 files changed, 435 insertions(+), 9 deletions(-)
CMakeLists.txt+1| ... | @@ -27,6 +27,7 @@ include_directories( | ... | @@ -27,6 +27,7 @@ include_directories( |
| 27 | ) | 27 | ) |
| 28 | 28 | ||
| 29 | set(ZIG_SOURCES | 29 | set(ZIG_SOURCES |
| 30 | "${CMAKE_SOURCE_DIR}/src/target.cpp" | ||
| 30 | "${CMAKE_SOURCE_DIR}/src/ast_render.cpp" | 31 | "${CMAKE_SOURCE_DIR}/src/ast_render.cpp" |
| 31 | "${CMAKE_SOURCE_DIR}/src/bignum.cpp" | 32 | "${CMAKE_SOURCE_DIR}/src/bignum.cpp" |
| 32 | "${CMAKE_SOURCE_DIR}/src/tokenizer.cpp" | 33 | "${CMAKE_SOURCE_DIR}/src/tokenizer.cpp" |
doc/langref.md+3-3| ... | @@ -350,9 +350,9 @@ The functions take an integer (TODO float?) type, two variables of the specified | ... | @@ -350,9 +350,9 @@ The functions take an integer (TODO float?) type, two variables of the specified |
| 350 | 350 | ||
| 351 | ``` | 351 | ``` |
| 352 | Function Operation | 352 | Function Operation |
| 353 | bool add_with_overflow(type, a: type, b: type, x: &type) *x = a + b | 353 | bool add_with_overflow(T: type, a: T, b: T, x: &T) *x = a + b |
| 354 | bool sub_with_overflow(type, a: type, b: type, x: &type) *x = a - b | 354 | bool sub_with_overflow(T: type, a: T, b: T, x: &T) *x = a - b |
| 355 | bool mul_with_overflow(type, a: type, b: type, x: &type) *x = a * b | 355 | bool mul_with_overflow(T: type, a: T, b: T, x: &T) *x = a * b |
| 356 | ``` | 356 | ``` |
| 357 | 357 | ||
| 358 | ### Memory Operations | 358 | ### Memory Operations |
src/all_types.hpp-1| ... | @@ -1124,7 +1124,6 @@ struct CodeGen { | ... | @@ -1124,7 +1124,6 @@ struct CodeGen { |
| 1124 | bool is_test_build; | 1124 | bool is_test_build; |
| 1125 | LLVMTargetMachineRef target_machine; | 1125 | LLVMTargetMachineRef target_machine; |
| 1126 | LLVMZigDIFile *dummy_di_file; | 1126 | LLVMZigDIFile *dummy_di_file; |
| 1127 | bool is_native_target; | ||
| 1128 | Buf *root_source_dir; | 1127 | Buf *root_source_dir; |
| 1129 | Buf *root_out_name; | 1128 | Buf *root_out_name; |
| 1130 | 1129 |
src/codegen.cpp-3| ... | @@ -3498,8 +3498,6 @@ static void define_builtin_fns(CodeGen *g) { | ... | @@ -3498,8 +3498,6 @@ static void define_builtin_fns(CodeGen *g) { |
| 3498 | create_builtin_fn_with_arg_count(g, BuiltinFnIdConstEval, "const_eval", 1); | 3498 | create_builtin_fn_with_arg_count(g, BuiltinFnIdConstEval, "const_eval", 1); |
| 3499 | } | 3499 | } |
| 3500 | 3500 | ||
| 3501 | |||
| 3502 | |||
| 3503 | static void init(CodeGen *g, Buf *source_path) { | 3501 | static void init(CodeGen *g, Buf *source_path) { |
| 3504 | g->lib_search_paths.append(g->root_source_dir); | 3502 | g->lib_search_paths.append(g->root_source_dir); |
| 3505 | g->lib_search_paths.append(buf_create_from_str(ZIG_STD_DIR)); | 3503 | g->lib_search_paths.append(buf_create_from_str(ZIG_STD_DIR)); |
| ... | @@ -3510,7 +3508,6 @@ static void init(CodeGen *g, Buf *source_path) { | ... | @@ -3510,7 +3508,6 @@ static void init(CodeGen *g, Buf *source_path) { |
| 3510 | LLVMInitializeAllAsmParsers(); | 3508 | LLVMInitializeAllAsmParsers(); |
| 3511 | LLVMInitializeNativeTarget(); | 3509 | LLVMInitializeNativeTarget(); |
| 3512 | 3510 | ||
| 3513 | g->is_native_target = true; | ||
| 3514 | char *native_triple = LLVMGetDefaultTargetTriple(); | 3511 | char *native_triple = LLVMGetDefaultTargetTriple(); |
| 3515 | 3512 | ||
| 3516 | g->module = LLVMModuleCreateWithName(buf_ptr(source_path)); | 3513 | g->module = LLVMModuleCreateWithName(buf_ptr(source_path)); |
src/main.cpp+40| ... | @@ -10,6 +10,7 @@ | ... | @@ -10,6 +10,7 @@ |
| 10 | #include "codegen.hpp" | 10 | #include "codegen.hpp" |
| 11 | #include "os.hpp" | 11 | #include "os.hpp" |
| 12 | #include "error.hpp" | 12 | #include "error.hpp" |
| 13 | #include "target.hpp" | ||
| 13 | 14 | ||
| 14 | #include <stdio.h> | 15 | #include <stdio.h> |
| 15 | 16 | ||
| ... | @@ -20,6 +21,7 @@ static int usage(const char *arg0) { | ... | @@ -20,6 +21,7 @@ static int usage(const char *arg0) { |
| 20 | " test create and run a test build\n" | 21 | " test create and run a test build\n" |
| 21 | " version print version number and exit\n" | 22 | " version print version number and exit\n" |
| 22 | " parseh convert a c header file to zig extern declarations\n" | 23 | " parseh convert a c header file to zig extern declarations\n" |
| 24 | " targets list available compilation targets\n" | ||
| 23 | "Options:\n" | 25 | "Options:\n" |
| 24 | " --release build with optimizations on and debug protection off\n" | 26 | " --release build with optimizations on and debug protection off\n" |
| 25 | " --static output will be statically linked\n" | 27 | " --static output will be statically linked\n" |
| ... | @@ -40,12 +42,45 @@ static int usage(const char *arg0) { | ... | @@ -40,12 +42,45 @@ static int usage(const char *arg0) { |
| 40 | return EXIT_FAILURE; | 42 | return EXIT_FAILURE; |
| 41 | } | 43 | } |
| 42 | 44 | ||
| 45 | static int print_target_list(FILE *f) { | ||
| 46 | fprintf(f, "Architectures:\n"); | ||
| 47 | int arch_count = target_arch_count(); | ||
| 48 | int sub_arch_count = target_sub_arch_count(); | ||
| 49 | for (int arch_i = 0; arch_i < arch_count; arch_i += 1) { | ||
| 50 | const ArchType *arch = get_target_arch(arch_i); | ||
| 51 | fprintf(f, " %s\n", ZigLLVMGetArchTypeName(arch->llvm_arch)); | ||
| 52 | for (int sub_arch_i = 0; sub_arch_i < sub_arch_count; sub_arch_i += 1) { | ||
| 53 | const SubArchType *sub_arch = get_target_sub_arch(sub_arch_i); | ||
| 54 | if (sub_arch->arch == arch->llvm_arch) { | ||
| 55 | fprintf(f, " %s\n", sub_arch->name); | ||
| 56 | } | ||
| 57 | } | ||
| 58 | } | ||
| 59 | |||
| 60 | fprintf(f, "\nOperating Systems:\n"); | ||
| 61 | int os_count = target_os_count(); | ||
| 62 | for (int i = 0; i < os_count; i += 1) { | ||
| 63 | const OsType *os_type = get_target_os(i); | ||
| 64 | fprintf(f, " %s\n", get_target_os_name(os_type)); | ||
| 65 | } | ||
| 66 | |||
| 67 | fprintf(f, "\nABIs:\n"); | ||
| 68 | int environ_count = target_environ_count(); | ||
| 69 | for (int i = 0; i < environ_count; i += 1) { | ||
| 70 | const EnvironmentType *environ_type = get_target_environ(i); | ||
| 71 | fprintf(f, " %s\n", ZigLLVMGetEnvironmentTypeName(environ_type->llvm_environment)); | ||
| 72 | } | ||
| 73 | |||
| 74 | return EXIT_SUCCESS; | ||
| 75 | } | ||
| 76 | |||
| 43 | enum Cmd { | 77 | enum Cmd { |
| 44 | CmdInvalid, | 78 | CmdInvalid, |
| 45 | CmdBuild, | 79 | CmdBuild, |
| 46 | CmdTest, | 80 | CmdTest, |
| 47 | CmdVersion, | 81 | CmdVersion, |
| 48 | CmdParseH, | 82 | CmdParseH, |
| 83 | CmdTargets, | ||
| 49 | }; | 84 | }; |
| 50 | 85 | ||
| 51 | int main(int argc, char **argv) { | 86 | int main(int argc, char **argv) { |
| ... | @@ -139,6 +174,8 @@ int main(int argc, char **argv) { | ... | @@ -139,6 +174,8 @@ int main(int argc, char **argv) { |
| 139 | cmd = CmdParseH; | 174 | cmd = CmdParseH; |
| 140 | } else if (strcmp(arg, "test") == 0) { | 175 | } else if (strcmp(arg, "test") == 0) { |
| 141 | cmd = CmdTest; | 176 | cmd = CmdTest; |
| 177 | } else if (strcmp(arg, "targets") == 0) { | ||
| 178 | cmd = CmdTargets; | ||
| 142 | } else { | 179 | } else { |
| 143 | fprintf(stderr, "Unrecognized command: %s\n", arg); | 180 | fprintf(stderr, "Unrecognized command: %s\n", arg); |
| 144 | return usage(arg0); | 181 | return usage(arg0); |
| ... | @@ -155,6 +192,7 @@ int main(int argc, char **argv) { | ... | @@ -155,6 +192,7 @@ int main(int argc, char **argv) { |
| 155 | } | 192 | } |
| 156 | break; | 193 | break; |
| 157 | case CmdVersion: | 194 | case CmdVersion: |
| 195 | case CmdTargets: | ||
| 158 | return usage(arg0); | 196 | return usage(arg0); |
| 159 | case CmdInvalid: | 197 | case CmdInvalid: |
| 160 | zig_unreachable(); | 198 | zig_unreachable(); |
| ... | @@ -249,6 +287,8 @@ int main(int argc, char **argv) { | ... | @@ -249,6 +287,8 @@ int main(int argc, char **argv) { |
| 249 | case CmdVersion: | 287 | case CmdVersion: |
| 250 | printf("%s\n", ZIG_VERSION_STRING); | 288 | printf("%s\n", ZIG_VERSION_STRING); |
| 251 | return EXIT_SUCCESS; | 289 | return EXIT_SUCCESS; |
| 290 | case CmdTargets: | ||
| 291 | return print_target_list(stdout); | ||
| 252 | case CmdInvalid: | 292 | case CmdInvalid: |
| 253 | return usage(arg0); | 293 | return usage(arg0); |
| 254 | } | 294 | } |
src/target.cpp created+169| ... | @@ -0,0 +1,169 @@ | ||
| 1 | /* | ||
| 2 | * Copyright (c) 2016 Andrew Kelley | ||
| 3 | * | ||
| 4 | * This file is part of zig, which is MIT licensed. | ||
| 5 | * See http://opensource.org/licenses/MIT | ||
| 6 | */ | ||
| 7 | |||
| 8 | #include "target.hpp" | ||
| 9 | #include "util.hpp" | ||
| 10 | |||
| 11 | static const ArchType arch_list[] = { | ||
| 12 | {ZigLLVM_arm}, | ||
| 13 | {ZigLLVM_armeb}, | ||
| 14 | {ZigLLVM_aarch64}, | ||
| 15 | {ZigLLVM_aarch64_be}, | ||
| 16 | {ZigLLVM_bpfel}, | ||
| 17 | {ZigLLVM_bpfeb}, | ||
| 18 | {ZigLLVM_hexagon}, | ||
| 19 | {ZigLLVM_mips}, | ||
| 20 | {ZigLLVM_mipsel}, | ||
| 21 | {ZigLLVM_mips64}, | ||
| 22 | {ZigLLVM_mips64el}, | ||
| 23 | {ZigLLVM_msp430}, | ||
| 24 | {ZigLLVM_ppc}, | ||
| 25 | {ZigLLVM_ppc64}, | ||
| 26 | {ZigLLVM_ppc64le}, | ||
| 27 | {ZigLLVM_r600}, | ||
| 28 | {ZigLLVM_amdgcn}, | ||
| 29 | {ZigLLVM_sparc}, | ||
| 30 | {ZigLLVM_sparcv9}, | ||
| 31 | {ZigLLVM_sparcel}, | ||
| 32 | {ZigLLVM_systemz}, | ||
| 33 | {ZigLLVM_tce}, | ||
| 34 | {ZigLLVM_thumb}, | ||
| 35 | {ZigLLVM_thumbeb}, | ||
| 36 | {ZigLLVM_x86}, | ||
| 37 | {ZigLLVM_x86_64}, | ||
| 38 | {ZigLLVM_xcore}, | ||
| 39 | {ZigLLVM_nvptx}, | ||
| 40 | {ZigLLVM_nvptx64}, | ||
| 41 | {ZigLLVM_le32}, | ||
| 42 | {ZigLLVM_le64}, | ||
| 43 | {ZigLLVM_amdil}, | ||
| 44 | {ZigLLVM_amdil64}, | ||
| 45 | {ZigLLVM_hsail}, | ||
| 46 | {ZigLLVM_hsail64}, | ||
| 47 | {ZigLLVM_spir}, | ||
| 48 | {ZigLLVM_spir64}, | ||
| 49 | {ZigLLVM_kalimba}, | ||
| 50 | {ZigLLVM_shave}, | ||
| 51 | {ZigLLVM_wasm32}, | ||
| 52 | {ZigLLVM_wasm64}, | ||
| 53 | }; | ||
| 54 | |||
| 55 | static const SubArchType sub_arch_list[] = { | ||
| 56 | {ZigLLVM_arm, ZigLLVM_ARMSubArch_v8_1a, "v8_1a"}, | ||
| 57 | {ZigLLVM_arm, ZigLLVM_ARMSubArch_v8, "v8"}, | ||
| 58 | {ZigLLVM_arm, ZigLLVM_ARMSubArch_v7, "v7"}, | ||
| 59 | {ZigLLVM_arm, ZigLLVM_ARMSubArch_v7em, "v7em"}, | ||
| 60 | {ZigLLVM_arm, ZigLLVM_ARMSubArch_v7m, "v7m"}, | ||
| 61 | {ZigLLVM_arm, ZigLLVM_ARMSubArch_v7s, "v7s"}, | ||
| 62 | {ZigLLVM_arm, ZigLLVM_ARMSubArch_v6, "v6"}, | ||
| 63 | {ZigLLVM_arm, ZigLLVM_ARMSubArch_v6m, "v6m"}, | ||
| 64 | {ZigLLVM_arm, ZigLLVM_ARMSubArch_v6k, "v6k"}, | ||
| 65 | {ZigLLVM_arm, ZigLLVM_ARMSubArch_v6t2, "v6t2"}, | ||
| 66 | {ZigLLVM_arm, ZigLLVM_ARMSubArch_v5, "v5"}, | ||
| 67 | {ZigLLVM_arm, ZigLLVM_ARMSubArch_v5te, "v5te"}, | ||
| 68 | {ZigLLVM_arm, ZigLLVM_ARMSubArch_v4t, "v4t"}, | ||
| 69 | |||
| 70 | {ZigLLVM_kalimba, ZigLLVM_KalimbaSubArch_v3, "v3"}, | ||
| 71 | {ZigLLVM_kalimba, ZigLLVM_KalimbaSubArch_v4, "v4"}, | ||
| 72 | {ZigLLVM_kalimba, ZigLLVM_KalimbaSubArch_v5, "v5"}, | ||
| 73 | }; | ||
| 74 | |||
| 75 | static const VendorType vendor_list[] = { | ||
| 76 | {ZigLLVM_Apple}, | ||
| 77 | {ZigLLVM_PC}, | ||
| 78 | {ZigLLVM_SCEI}, | ||
| 79 | {ZigLLVM_BGP}, | ||
| 80 | {ZigLLVM_BGQ}, | ||
| 81 | {ZigLLVM_Freescale}, | ||
| 82 | {ZigLLVM_IBM}, | ||
| 83 | {ZigLLVM_ImaginationTechnologies}, | ||
| 84 | {ZigLLVM_MipsTechnologies}, | ||
| 85 | {ZigLLVM_NVIDIA}, | ||
| 86 | {ZigLLVM_CSR}, | ||
| 87 | }; | ||
| 88 | |||
| 89 | static const OsType os_list[] = { | ||
| 90 | {ZigLLVM_UnknownOS}, | ||
| 91 | {ZigLLVM_CloudABI}, | ||
| 92 | {ZigLLVM_Darwin}, | ||
| 93 | {ZigLLVM_DragonFly}, | ||
| 94 | {ZigLLVM_FreeBSD}, | ||
| 95 | {ZigLLVM_IOS}, | ||
| 96 | {ZigLLVM_KFreeBSD}, | ||
| 97 | {ZigLLVM_Linux}, | ||
| 98 | {ZigLLVM_Lv2}, | ||
| 99 | {ZigLLVM_MacOSX}, | ||
| 100 | {ZigLLVM_NetBSD}, | ||
| 101 | {ZigLLVM_OpenBSD}, | ||
| 102 | {ZigLLVM_Solaris}, | ||
| 103 | {ZigLLVM_Win32}, | ||
| 104 | {ZigLLVM_Haiku}, | ||
| 105 | {ZigLLVM_Minix}, | ||
| 106 | {ZigLLVM_RTEMS}, | ||
| 107 | {ZigLLVM_NaCl}, | ||
| 108 | {ZigLLVM_CNK}, | ||
| 109 | {ZigLLVM_Bitrig}, | ||
| 110 | {ZigLLVM_AIX}, | ||
| 111 | {ZigLLVM_CUDA}, | ||
| 112 | {ZigLLVM_NVCL}, | ||
| 113 | {ZigLLVM_AMDHSA}, | ||
| 114 | {ZigLLVM_PS4}, | ||
| 115 | }; | ||
| 116 | |||
| 117 | static const EnvironmentType environ_list[] = { | ||
| 118 | {ZigLLVM_GNU}, | ||
| 119 | {ZigLLVM_GNUEABI}, | ||
| 120 | {ZigLLVM_GNUEABIHF}, | ||
| 121 | {ZigLLVM_GNUX32}, | ||
| 122 | {ZigLLVM_CODE16}, | ||
| 123 | {ZigLLVM_EABI}, | ||
| 124 | {ZigLLVM_EABIHF}, | ||
| 125 | {ZigLLVM_Android}, | ||
| 126 | {ZigLLVM_MSVC}, | ||
| 127 | {ZigLLVM_Itanium}, | ||
| 128 | {ZigLLVM_Cygnus}, | ||
| 129 | }; | ||
| 130 | |||
| 131 | int target_arch_count(void) { | ||
| 132 | return array_length(arch_list); | ||
| 133 | } | ||
| 134 | |||
| 135 | const ArchType *get_target_arch(int index) { | ||
| 136 | return &arch_list[index]; | ||
| 137 | } | ||
| 138 | |||
| 139 | int target_sub_arch_count(void) { | ||
| 140 | return array_length(sub_arch_list); | ||
| 141 | } | ||
| 142 | const SubArchType *get_target_sub_arch(int index) { | ||
| 143 | return &sub_arch_list[index]; | ||
| 144 | } | ||
| 145 | |||
| 146 | int target_vendor_count(void) { | ||
| 147 | return array_length(vendor_list); | ||
| 148 | } | ||
| 149 | |||
| 150 | const VendorType *get_target_vendor(int index) { | ||
| 151 | return &vendor_list[index]; | ||
| 152 | } | ||
| 153 | |||
| 154 | int target_os_count(void) { | ||
| 155 | return array_length(os_list); | ||
| 156 | } | ||
| 157 | const OsType *get_target_os(int index) { | ||
| 158 | return &os_list[index]; | ||
| 159 | } | ||
| 160 | const char *get_target_os_name(const OsType *os_type) { | ||
| 161 | return (os_type->llvm_os == ZigLLVM_UnknownOS) ? "freestanding" : ZigLLVMGetOSTypeName(os_type->llvm_os); | ||
| 162 | } | ||
| 163 | |||
| 164 | int target_environ_count(void) { | ||
| 165 | return array_length(environ_list); | ||
| 166 | } | ||
| 167 | const EnvironmentType *get_target_environ(int index) { | ||
| 168 | return &environ_list[index]; | ||
| 169 | } | ||
src/target.hpp created+51| ... | @@ -0,0 +1,51 @@ | ||
| 1 | /* | ||
| 2 | * Copyright (c) 2016 Andrew Kelley | ||
| 3 | * | ||
| 4 | * This file is part of zig, which is MIT licensed. | ||
| 5 | * See http://opensource.org/licenses/MIT | ||
| 6 | */ | ||
| 7 | |||
| 8 | #ifndef ZIG_TARGET_HPP | ||
| 9 | #define ZIG_TARGET_HPP | ||
| 10 | |||
| 11 | #include <zig_llvm.hpp> | ||
| 12 | |||
| 13 | struct ArchType { | ||
| 14 | ZigLLVM_ArchType llvm_arch; | ||
| 15 | }; | ||
| 16 | |||
| 17 | struct SubArchType { | ||
| 18 | ZigLLVM_ArchType arch; // which arch it applies to | ||
| 19 | ZigLLVM_SubArchType sub_arch; | ||
| 20 | const char *name; | ||
| 21 | }; | ||
| 22 | |||
| 23 | struct VendorType { | ||
| 24 | ZigLLVM_VendorType llvm_vendor; | ||
| 25 | }; | ||
| 26 | |||
| 27 | struct OsType { | ||
| 28 | ZigLLVM_OSType llvm_os; | ||
| 29 | }; | ||
| 30 | |||
| 31 | struct EnvironmentType { | ||
| 32 | ZigLLVM_EnvironmentType llvm_environment; | ||
| 33 | }; | ||
| 34 | |||
| 35 | int target_arch_count(void); | ||
| 36 | const ArchType *get_target_arch(int index); | ||
| 37 | |||
| 38 | int target_sub_arch_count(void); | ||
| 39 | const SubArchType *get_target_sub_arch(int index); | ||
| 40 | |||
| 41 | int target_vendor_count(void); | ||
| 42 | const VendorType *get_target_vendor(int index); | ||
| 43 | |||
| 44 | int target_os_count(void); | ||
| 45 | const OsType *get_target_os(int index); | ||
| 46 | const char *get_target_os_name(const OsType *os_type); | ||
| 47 | |||
| 48 | int target_environ_count(void); | ||
| 49 | const EnvironmentType *get_target_environ(int index); | ||
| 50 | |||
| 51 | #endif | ||
src/zig_llvm.cpp+24| ... | @@ -514,8 +514,32 @@ void LLVMZigSetFastMath(LLVMBuilderRef builder_wrapped, bool on_state) { | ... | @@ -514,8 +514,32 @@ void LLVMZigSetFastMath(LLVMBuilderRef builder_wrapped, bool on_state) { |
| 514 | } | 514 | } |
| 515 | } | 515 | } |
| 516 | 516 | ||
| 517 | |||
| 518 | static_assert((Triple::ArchType)ZigLLVM_LastArchType == Triple::LastArchType, ""); | ||
| 519 | static_assert((Triple::VendorType)ZigLLVM_LastVendorType == Triple::LastVendorType, ""); | ||
| 520 | static_assert((Triple::OSType)ZigLLVM_LastOSType == Triple::LastOSType, ""); | ||
| 521 | static_assert((Triple::EnvironmentType)ZigLLVM_LastEnvironmentType == Triple::LastEnvironmentType, ""); | ||
| 522 | |||
| 523 | const char *ZigLLVMGetArchTypeName(ZigLLVM_ArchType arch) { | ||
| 524 | return Triple::getArchTypeName((Triple::ArchType)arch); | ||
| 525 | } | ||
| 526 | |||
| 527 | const char *ZigLLVMGetVendorTypeName(ZigLLVM_VendorType vendor) { | ||
| 528 | return Triple::getVendorTypeName((Triple::VendorType)vendor); | ||
| 529 | } | ||
| 530 | |||
| 531 | const char *ZigLLVMGetOSTypeName(ZigLLVM_OSType os) { | ||
| 532 | return Triple::getOSTypeName((Triple::OSType)os); | ||
| 533 | } | ||
| 534 | |||
| 535 | const char *ZigLLVMGetEnvironmentTypeName(ZigLLVM_EnvironmentType environ) { | ||
| 536 | return Triple::getEnvironmentTypeName((Triple::EnvironmentType)environ); | ||
| 537 | } | ||
| 538 | |||
| 517 | //------------------------------------ | 539 | //------------------------------------ |
| 518 | 540 | ||
| 541 | #include "buffer.hpp" | ||
| 542 | |||
| 519 | enum FloatAbi { | 543 | enum FloatAbi { |
| 520 | FloatAbiHard, | 544 | FloatAbiHard, |
| 521 | FloatAbiSoft, | 545 | FloatAbiSoft, |
src/zig_llvm.hpp+147-2| ... | @@ -143,11 +143,156 @@ LLVMZigDILocation *LLVMZigGetDebugLoc(unsigned line, unsigned col, LLVMZigDIScop | ... | @@ -143,11 +143,156 @@ LLVMZigDILocation *LLVMZigGetDebugLoc(unsigned line, unsigned col, LLVMZigDIScop |
| 143 | void LLVMZigSetFastMath(LLVMBuilderRef builder_wrapped, bool on_state); | 143 | void LLVMZigSetFastMath(LLVMBuilderRef builder_wrapped, bool on_state); |
| 144 | 144 | ||
| 145 | 145 | ||
| 146 | // copied from include/llvm/ADT/Triple.h | ||
| 147 | |||
| 148 | enum ZigLLVM_ArchType { | ||
| 149 | ZigLLVM_UnknownArch, | ||
| 150 | |||
| 151 | ZigLLVM_arm, // ARM (little endian): arm, armv.*, xscale | ||
| 152 | ZigLLVM_armeb, // ARM (big endian): armeb | ||
| 153 | ZigLLVM_aarch64, // AArch64 (little endian): aarch64 | ||
| 154 | ZigLLVM_aarch64_be, // AArch64 (big endian): aarch64_be | ||
| 155 | ZigLLVM_bpfel, // eBPF or extended BPF or 64-bit BPF (little endian) | ||
| 156 | ZigLLVM_bpfeb, // eBPF or extended BPF or 64-bit BPF (big endian) | ||
| 157 | ZigLLVM_hexagon, // Hexagon: hexagon | ||
| 158 | ZigLLVM_mips, // MIPS: mips, mipsallegrex | ||
| 159 | ZigLLVM_mipsel, // MIPSEL: mipsel, mipsallegrexel | ||
| 160 | ZigLLVM_mips64, // MIPS64: mips64 | ||
| 161 | ZigLLVM_mips64el, // MIPS64EL: mips64el | ||
| 162 | ZigLLVM_msp430, // MSP430: msp430 | ||
| 163 | ZigLLVM_ppc, // PPC: powerpc | ||
| 164 | ZigLLVM_ppc64, // PPC64: powerpc64, ppu | ||
| 165 | ZigLLVM_ppc64le, // PPC64LE: powerpc64le | ||
| 166 | ZigLLVM_r600, // R600: AMD GPUs HD2XXX - HD6XXX | ||
| 167 | ZigLLVM_amdgcn, // AMDGCN: AMD GCN GPUs | ||
| 168 | ZigLLVM_sparc, // Sparc: sparc | ||
| 169 | ZigLLVM_sparcv9, // Sparcv9: Sparcv9 | ||
| 170 | ZigLLVM_sparcel, // Sparc: (endianness = little). NB: 'Sparcle' is a CPU variant | ||
| 171 | ZigLLVM_systemz, // SystemZ: s390x | ||
| 172 | ZigLLVM_tce, // TCE (http://tce.cs.tut.fi/): tce | ||
| 173 | ZigLLVM_thumb, // Thumb (little endian): thumb, thumbv.* | ||
| 174 | ZigLLVM_thumbeb, // Thumb (big endian): thumbeb | ||
| 175 | ZigLLVM_x86, // X86: i[3-9]86 | ||
| 176 | ZigLLVM_x86_64, // X86-64: amd64, x86_64 | ||
| 177 | ZigLLVM_xcore, // XCore: xcore | ||
| 178 | ZigLLVM_nvptx, // NVPTX: 32-bit | ||
| 179 | ZigLLVM_nvptx64, // NVPTX: 64-bit | ||
| 180 | ZigLLVM_le32, // le32: generic little-endian 32-bit CPU (PNaCl / Emscripten) | ||
| 181 | ZigLLVM_le64, // le64: generic little-endian 64-bit CPU (PNaCl / Emscripten) | ||
| 182 | ZigLLVM_amdil, // AMDIL | ||
| 183 | ZigLLVM_amdil64, // AMDIL with 64-bit pointers | ||
| 184 | ZigLLVM_hsail, // AMD HSAIL | ||
| 185 | ZigLLVM_hsail64, // AMD HSAIL with 64-bit pointers | ||
| 186 | ZigLLVM_spir, // SPIR: standard portable IR for OpenCL 32-bit version | ||
| 187 | ZigLLVM_spir64, // SPIR: standard portable IR for OpenCL 64-bit version | ||
| 188 | ZigLLVM_kalimba, // Kalimba: generic kalimba | ||
| 189 | ZigLLVM_shave, // SHAVE: Movidius vector VLIW processors | ||
| 190 | ZigLLVM_wasm32, // WebAssembly with 32-bit pointers | ||
| 191 | ZigLLVM_wasm64, // WebAssembly with 64-bit pointers | ||
| 192 | ZigLLVM_LastArchType = ZigLLVM_wasm64 | ||
| 193 | }; | ||
| 194 | |||
| 195 | enum ZigLLVM_SubArchType { | ||
| 196 | ZigLLVM_NoSubArch, | ||
| 197 | |||
| 198 | ZigLLVM_ARMSubArch_v8_1a, | ||
| 199 | ZigLLVM_ARMSubArch_v8, | ||
| 200 | ZigLLVM_ARMSubArch_v7, | ||
| 201 | ZigLLVM_ARMSubArch_v7em, | ||
| 202 | ZigLLVM_ARMSubArch_v7m, | ||
| 203 | ZigLLVM_ARMSubArch_v7s, | ||
| 204 | ZigLLVM_ARMSubArch_v6, | ||
| 205 | ZigLLVM_ARMSubArch_v6m, | ||
| 206 | ZigLLVM_ARMSubArch_v6k, | ||
| 207 | ZigLLVM_ARMSubArch_v6t2, | ||
| 208 | ZigLLVM_ARMSubArch_v5, | ||
| 209 | ZigLLVM_ARMSubArch_v5te, | ||
| 210 | ZigLLVM_ARMSubArch_v4t, | ||
| 211 | |||
| 212 | ZigLLVM_KalimbaSubArch_v3, | ||
| 213 | ZigLLVM_KalimbaSubArch_v4, | ||
| 214 | ZigLLVM_KalimbaSubArch_v5 | ||
| 215 | }; | ||
| 216 | enum ZigLLVM_VendorType { | ||
| 217 | ZigLLVM_UnknownVendor, | ||
| 218 | |||
| 219 | ZigLLVM_Apple, | ||
| 220 | ZigLLVM_PC, | ||
| 221 | ZigLLVM_SCEI, | ||
| 222 | ZigLLVM_BGP, | ||
| 223 | ZigLLVM_BGQ, | ||
| 224 | ZigLLVM_Freescale, | ||
| 225 | ZigLLVM_IBM, | ||
| 226 | ZigLLVM_ImaginationTechnologies, | ||
| 227 | ZigLLVM_MipsTechnologies, | ||
| 228 | ZigLLVM_NVIDIA, | ||
| 229 | ZigLLVM_CSR, | ||
| 230 | ZigLLVM_LastVendorType = ZigLLVM_CSR | ||
| 231 | }; | ||
| 232 | enum ZigLLVM_OSType { | ||
| 233 | ZigLLVM_UnknownOS, | ||
| 234 | |||
| 235 | ZigLLVM_CloudABI, | ||
| 236 | ZigLLVM_Darwin, | ||
| 237 | ZigLLVM_DragonFly, | ||
| 238 | ZigLLVM_FreeBSD, | ||
| 239 | ZigLLVM_IOS, | ||
| 240 | ZigLLVM_KFreeBSD, | ||
| 241 | ZigLLVM_Linux, | ||
| 242 | ZigLLVM_Lv2, // PS3 | ||
| 243 | ZigLLVM_MacOSX, | ||
| 244 | ZigLLVM_NetBSD, | ||
| 245 | ZigLLVM_OpenBSD, | ||
| 246 | ZigLLVM_Solaris, | ||
| 247 | ZigLLVM_Win32, | ||
| 248 | ZigLLVM_Haiku, | ||
| 249 | ZigLLVM_Minix, | ||
| 250 | ZigLLVM_RTEMS, | ||
| 251 | ZigLLVM_NaCl, // Native Client | ||
| 252 | ZigLLVM_CNK, // BG/P Compute-Node Kernel | ||
| 253 | ZigLLVM_Bitrig, | ||
| 254 | ZigLLVM_AIX, | ||
| 255 | ZigLLVM_CUDA, // NVIDIA CUDA | ||
| 256 | ZigLLVM_NVCL, // NVIDIA OpenCL | ||
| 257 | ZigLLVM_AMDHSA, // AMD HSA Runtime | ||
| 258 | ZigLLVM_PS4, | ||
| 259 | ZigLLVM_LastOSType = ZigLLVM_PS4 | ||
| 260 | }; | ||
| 261 | enum ZigLLVM_EnvironmentType { | ||
| 262 | ZigLLVM_UnknownEnvironment, | ||
| 263 | |||
| 264 | ZigLLVM_GNU, | ||
| 265 | ZigLLVM_GNUEABI, | ||
| 266 | ZigLLVM_GNUEABIHF, | ||
| 267 | ZigLLVM_GNUX32, | ||
| 268 | ZigLLVM_CODE16, | ||
| 269 | ZigLLVM_EABI, | ||
| 270 | ZigLLVM_EABIHF, | ||
| 271 | ZigLLVM_Android, | ||
| 272 | |||
| 273 | ZigLLVM_MSVC, | ||
| 274 | ZigLLVM_Itanium, | ||
| 275 | ZigLLVM_Cygnus, | ||
| 276 | ZigLLVM_LastEnvironmentType = ZigLLVM_Cygnus | ||
| 277 | }; | ||
| 278 | enum ZigLLVM_ObjectFormatType { | ||
| 279 | ZigLLVM_UnknownObjectFormat, | ||
| 280 | |||
| 281 | ZigLLVM_COFF, | ||
| 282 | ZigLLVM_ELF, | ||
| 283 | ZigLLVM_MachO, | ||
| 284 | }; | ||
| 285 | |||
| 286 | const char *ZigLLVMGetArchTypeName(ZigLLVM_ArchType arch); | ||
| 287 | const char *ZigLLVMGetVendorTypeName(ZigLLVM_VendorType vendor); | ||
| 288 | const char *ZigLLVMGetOSTypeName(ZigLLVM_OSType os); | ||
| 289 | const char *ZigLLVMGetEnvironmentTypeName(ZigLLVM_EnvironmentType environ); | ||
| 290 | |||
| 291 | |||
| 146 | /* | 292 | /* |
| 147 | * This stuff is not LLVM API but it depends on the LLVM C++ API so we put it here. | 293 | * This stuff is not LLVM API but it depends on the LLVM C++ API so we put it here. |
| 148 | */ | 294 | */ |
| 149 | #include "buffer.hpp" | 295 | struct Buf; |
| 150 | |||
| 151 | Buf *get_dynamic_linker(LLVMTargetMachineRef target_machine); | 296 | Buf *get_dynamic_linker(LLVMTargetMachineRef target_machine); |
| 152 | 297 | ||
| 153 | #endif | 298 | #endif |