Skip to content

Commit d408f23

Browse files
authored
Merge pull request #504 from rust-lang/fix/aarch64
Some fixes for aarch64
2 parents 01b0fb7 + 65e8717 commit d408f23

File tree

3 files changed

+23
-9
lines changed

3 files changed

+23
-9
lines changed

src/attributes.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,12 @@ pub fn from_fn_attrs<'gcc, 'tcx>(
128128
.join(",");
129129
if !target_features.is_empty() {
130130
#[cfg(feature = "master")]
131-
func.add_attribute(FnAttribute::Target(&target_features));
131+
match cx.sess().target.arch.as_ref() {
132+
"x86" | "x86_64" | "powerpc" => {
133+
func.add_attribute(FnAttribute::Target(&target_features))
134+
}
135+
// The target attribute is not supported on other targets in GCC.
136+
_ => (),
137+
}
132138
}
133139
}

src/builder.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1129,7 +1129,7 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
11291129
// the following cast is required to avoid this error:
11301130
// gcc_jit_context_new_call: mismatching types for argument 2 of function "__atomic_store_4": assignment to param arg1 (type: int) from loadedValue3577 (type: unsigned int __attribute__((aligned(4))))
11311131
let int_type = atomic_store.get_param(1).to_rvalue().get_type();
1132-
let value = self.context.new_cast(self.location, value, int_type);
1132+
let value = self.context.new_bitcast(self.location, value, int_type);
11331133
self.llbb().add_eval(
11341134
self.location,
11351135
self.context.new_call(self.location, atomic_store, &[ptr, value, ordering]),

src/intrinsic/llvm.rs

+15-7
Original file line numberDiff line numberDiff line change
@@ -629,14 +629,22 @@ pub fn intrinsic<'gcc, 'tcx>(name: &str, cx: &CodegenCx<'gcc, 'tcx>) -> Function
629629

630630
#[cfg(feature = "master")]
631631
pub fn intrinsic<'gcc, 'tcx>(name: &str, cx: &CodegenCx<'gcc, 'tcx>) -> Function<'gcc> {
632-
if name == "llvm.prefetch" {
633-
let gcc_name = "__builtin_prefetch";
634-
let func = cx.context.get_builtin_function(gcc_name);
635-
cx.functions.borrow_mut().insert(gcc_name.to_string(), func);
636-
return func;
637-
}
638-
639632
let gcc_name = match name {
633+
"llvm.prefetch" => {
634+
let gcc_name = "__builtin_prefetch";
635+
let func = cx.context.get_builtin_function(gcc_name);
636+
cx.functions.borrow_mut().insert(gcc_name.to_string(), func);
637+
return func;
638+
}
639+
640+
"llvm.aarch64.isb" => {
641+
// FIXME: GCC doesn't support __builtin_arm_isb yet, check if this builtin is OK.
642+
let gcc_name = "__atomic_thread_fence";
643+
let func = cx.context.get_builtin_function(gcc_name);
644+
cx.functions.borrow_mut().insert(gcc_name.to_string(), func);
645+
return func;
646+
}
647+
640648
"llvm.x86.xgetbv" => "__builtin_ia32_xgetbv",
641649
// NOTE: this doc specifies the equivalent GCC builtins: http://huonw.github.io/llvmint/llvmint/x86/index.html
642650
"llvm.sqrt.v2f64" => "__builtin_ia32_sqrtpd",

0 commit comments

Comments
 (0)