aboutsummaryrefslogtreecommitdiff
path: root/src/codegen.cpp
diff options
context:
space:
mode:
authorLayne Gustafson <lgustaf1@binghamton.edu>2020-01-08 20:27:36 -0500
committerAndrew Kelley <andrew@ziglang.org>2020-01-19 20:53:19 -0500
commitc61856ebcf54a55f1c17a5fd6a3b3300115b2c65 (patch)
tree16c00869a16f4c80f697be2822bbfa80c1b04cef /src/codegen.cpp
parent79a2747de490ca2bb1603fd1ce55637fb5278671 (diff)
downloadzig-c61856ebcf54a55f1c17a5fd6a3b3300115b2c65.tar.gz
zig-c61856ebcf54a55f1c17a5fd6a3b3300115b2c65.zip
Add TargetDetails abstraction
Diffstat (limited to 'src/codegen.cpp')
-rw-r--r--src/codegen.cpp23
1 files changed, 12 insertions, 11 deletions
diff --git a/src/codegen.cpp b/src/codegen.cpp
index 798f406c8e..760284a2e2 100644
--- a/src/codegen.cpp
+++ b/src/codegen.cpp
@@ -8655,8 +8655,10 @@ static Error define_builtin_compile_vars(CodeGen *g) {
cache_bool(&cache_hash, g->valgrind_support);
cache_bool(&cache_hash, g->link_eh_frame_hdr);
cache_int(&cache_hash, detect_subsystem(g));
- if (g->llvm_cpu) cache_str(&cache_hash, g->llvm_cpu);
- if (g->llvm_features) cache_str(&cache_hash, g->llvm_features);
+
+ if (g->target_details) {
+ cache_str(&cache_hash, stage2_target_details_get_cache_str(g->target_details));
+ }
Buf digest = BUF_INIT;
buf_resize(&digest, 0);
@@ -8802,15 +8804,12 @@ static void init(CodeGen *g) {
target_specific_features = "";
}
- // Override CPU and features if non-null.
- if (g->llvm_cpu != nullptr) {
- target_specific_cpu_args = g->llvm_cpu;
+ // Override CPU and features if defined by user.
+ if (g->target_details) {
+ target_specific_cpu_args = stage2_target_details_get_llvm_cpu(g->target_details);
+ target_specific_features = stage2_target_details_get_llvm_features(g->target_details);
}
- if (g->llvm_features != nullptr) {
- target_specific_features = g->llvm_features;
- }
-
g->target_machine = ZigLLVMCreateTargetMachine(target_ref, buf_ptr(&g->llvm_triple_str),
target_specific_cpu_args, target_specific_features, opt_level, reloc_mode,
LLVMCodeModelDefault, g->function_sections);
@@ -10390,8 +10389,10 @@ static Error check_cache(CodeGen *g, Buf *manifest_dir, Buf *digest) {
}
cache_buf_opt(ch, g->dynamic_linker_path);
cache_buf_opt(ch, g->version_script_path);
- if (g->llvm_cpu) cache_str(ch, g->llvm_cpu);
- if (g->llvm_features) cache_str(ch, g->llvm_features);
+
+ if (g->target_details) {
+ cache_str(ch, stage2_target_details_get_cache_str(g->target_details));
+ }
// gen_c_objects appends objects to g->link_objects which we want to include in the hash
gen_c_objects(g);