From cd65a15d81b32636c5097200446cc6d6afc7199b Mon Sep 17 00:00:00 2001 From: Yawning Angel Date: Fri, 15 Dec 2023 17:29:59 +0900 Subject: src: `enable_target_feature` should add features, not overwrite `llvm_features` being empty is the default state, and implies the presence of certain features. Previously if any target features were explicitly enabled by the `enable_target_feature` attribute, they were added comma separated to `llvm_features`. For example: `lzcnt,popcnt,...,sse4.2,sse` This was causing LLVM to try to target a CPU that *ONLY* has the explicitly enabled features. This now will prefix explicitly enabled features with a `+`, and preserve the existing `llvm_features` string by appending to it if it is set. --- src/build_settings.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/build_settings.cpp') diff --git a/src/build_settings.cpp b/src/build_settings.cpp index 18ad8ac0d..9d909fcae 100644 --- a/src/build_settings.cpp +++ b/src/build_settings.cpp @@ -1493,7 +1493,7 @@ gb_internal void enable_target_feature(TokenPos pos, String const &target_featur } -gb_internal char const *target_features_set_to_cstring(gbAllocator allocator, bool with_quotes) { +gb_internal char const *target_features_set_to_cstring(gbAllocator allocator, bool with_quotes, bool with_plus) { isize len = 0; isize i = 0; for (String const &feature : build_context.target_features_set) { @@ -1502,6 +1502,7 @@ gb_internal char const *target_features_set_to_cstring(gbAllocator allocator, bo } len += feature.len; if (with_quotes) len += 2; + if (with_plus) len += 1; i += 1; } char *features = gb_alloc_array(allocator, char, len+1); @@ -1513,6 +1514,7 @@ gb_internal char const *target_features_set_to_cstring(gbAllocator allocator, bo } if (with_quotes) features[len++] = '"'; + if (with_plus) features[len++] = '+'; gb_memmove(features + len, feature.text, feature.len); len += feature.len; if (with_quotes) features[len++] = '"'; -- cgit v1.2.3 From 76f52dd6c9d37683e8e1ef85755b77e7e9b71c7b Mon Sep 17 00:00:00 2001 From: codename-irvin Date: Mon, 15 Jan 2024 19:49:34 -0500 Subject: Add freestanding aarch64 target --- src/build_settings.cpp | 10 +++++++++- src/llvm_backend.cpp | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) (limited to 'src/build_settings.cpp') diff --git a/src/build_settings.cpp b/src/build_settings.cpp index 9d909fcae..db09eabcf 100644 --- a/src/build_settings.cpp +++ b/src/build_settings.cpp @@ -582,7 +582,14 @@ gb_global TargetMetrics target_freestanding_amd64_sysv = { TargetABI_SysV, }; - +gb_global TargetMetrics target_freestanding_arm64_sysv = { + TargetOs_freestanding, + TargetArch_arm64, + 8, 8, 8, 16, + str_lit("aarch64-none-elf"), + str_lit("e-m:o-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64"), + TargetABI_SysV, +}; struct NamedTargetMetrics { String name; @@ -617,6 +624,7 @@ gb_global NamedTargetMetrics named_targets[] = { { str_lit("wasi_wasm64p32"), &target_wasi_wasm64p32 }, { str_lit("freestanding_amd64_sysv"), &target_freestanding_amd64_sysv }, + { str_lit("freestanding_arm64_sysv"), &target_freestanding_arm64_sysv }, }; gb_global NamedTargetMetrics *selected_target_metrics; diff --git a/src/llvm_backend.cpp b/src/llvm_backend.cpp index 0175d039e..003424e0a 100644 --- a/src/llvm_backend.cpp +++ b/src/llvm_backend.cpp @@ -2503,7 +2503,7 @@ gb_internal bool lb_generate_code(lbGenerator *gen) { LLVMCodeModel code_mode = LLVMCodeModelDefault; if (is_arch_wasm()) { code_mode = LLVMCodeModelJITDefault; - } else if (build_context.metrics.os == TargetOs_freestanding) { + } else if (is_arch_x86() && build_context.metrics.os == TargetOs_freestanding) { code_mode = LLVMCodeModelKernel; } -- cgit v1.2.3 From 0fcd2f1d88b1b9d21fbc77adb45833fcbdc0d3d4 Mon Sep 17 00:00:00 2001 From: codename-irvin Date: Tue, 16 Jan 2024 10:47:25 -0500 Subject: Use default calling convention for arm target for now - not 100% sure this is correct --- src/build_settings.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src/build_settings.cpp') diff --git a/src/build_settings.cpp b/src/build_settings.cpp index db09eabcf..1f57b5625 100644 --- a/src/build_settings.cpp +++ b/src/build_settings.cpp @@ -582,13 +582,12 @@ gb_global TargetMetrics target_freestanding_amd64_sysv = { TargetABI_SysV, }; -gb_global TargetMetrics target_freestanding_arm64_sysv = { +gb_global TargetMetrics target_freestanding_arm64 = { TargetOs_freestanding, TargetArch_arm64, 8, 8, 8, 16, str_lit("aarch64-none-elf"), str_lit("e-m:o-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64"), - TargetABI_SysV, }; struct NamedTargetMetrics { @@ -624,7 +623,7 @@ gb_global NamedTargetMetrics named_targets[] = { { str_lit("wasi_wasm64p32"), &target_wasi_wasm64p32 }, { str_lit("freestanding_amd64_sysv"), &target_freestanding_amd64_sysv }, - { str_lit("freestanding_arm64_sysv"), &target_freestanding_arm64_sysv }, + { str_lit("freestanding_arm64"), &target_freestanding_arm64 }, }; gb_global NamedTargetMetrics *selected_target_metrics; -- cgit v1.2.3