Skip to content

Commit 376fb2f

Browse files
committed
Improvements
1 parent 969a668 commit 376fb2f

File tree

3 files changed

+23
-9
lines changed

3 files changed

+23
-9
lines changed

gen_intrinsics/src/def_visitor.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ impl<'ast> Visit<'ast> for DefVisitor {
5454
return;
5555
}
5656

57+
if i.ident.to_string() == "JustOne" {
58+
return; // Multiple definitions across modules
59+
}
60+
5761
let mut ty = i.clone();
5862
ty.attrs = ty.attrs.into_iter().filter(|attr| attr.path().is_ident("repr")).collect();
5963

@@ -156,6 +160,11 @@ impl<'ast> Visit<'ast> for DefVisitor {
156160
| "llvm.aarch64.crypto.sm3tt2a"
157161
| "llvm.aarch64.crypto.sm3tt2b"
158162
| "llvm.aarch64.tcancel" => continue 'items,
163+
164+
"llvm.aarch64.addg" | "llvm.aarch64.gmi" | "llvm.aarch64.irg"
165+
| "llvm.aarch64.ldg" | "llvm.aarch64.stg" | "llvm.aarch64.subp" => {
166+
continue 'items;
167+
}
159168
_ => {}
160169
}
161170

gen_intrinsics/src/main.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,7 @@ fn main() {
113113
section.size(),
114114
);
115115

116-
let data = section.data().unwrap();
117-
let (code, ret) = data.split_at(data.len() - 4);
118-
assert_eq!(ret, [0xc0_u8, 0x03, 0x5f, 0xd6]); // arm64 ret instruction
116+
let code = section.data().unwrap();
119117

120118
let args = sig
121119
.inputs

src/intrinsics/llvm_aarch64.rs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,18 @@ fn call_asm<'tcx>(
1818
let name = format!("__rust_cranelift_{name}");
1919
let is_defined = fx.module.declarations().get_name(&name).is_none();
2020

21-
let sig = Signature { params: todo!(), returns: todo!(), call_conv: CallConv::SystemV };
21+
let sig = Signature {
22+
params: args
23+
.iter()
24+
.map(|arg| AbiParam::new(fx.clif_type(arg.layout().ty).unwrap()))
25+
.collect(),
26+
returns: vec![AbiParam::new(fx.clif_type(ret.layout().ty).unwrap())],
27+
call_conv: CallConv::SystemV,
28+
};
2229

2330
let func = fx.module.declare_function(&name, Linkage::Local, &sig).unwrap();
2431
if !is_defined {
25-
todo!("define");
32+
fx.module.define_function_bytes(func, &Function::new(), 4, &code, &[]).unwrap();
2633
}
2734

2835
let func_ref = fx.module.declare_func_in_func(func, &mut fx.bcx.func);
@@ -478,19 +485,19 @@ pub(crate) fn codegen_aarch64_llvm_intrinsic_call<'tcx>(
478485
// ==== begin autogenerated section ====
479486
"llvm.trunc.v1f64" => {
480487
intrinsic_args!(fx, args => (a); intrinsic);
481-
call_asm(fx, "llvm__trunc__v1f64", &[a], ret, &[0, 192, 101, 30]);
488+
call_asm(fx, "llvm__trunc__v1f64", &[a], ret, &[0, 192, 101, 30, 192, 3, 95, 214]);
482489
}
483490
"llvm.trunc.v2f32" => {
484491
intrinsic_args!(fx, args => (a); intrinsic);
485-
call_asm(fx, "llvm__trunc__v2f32", &[a], ret, &[0, 152, 161, 14]);
492+
call_asm(fx, "llvm__trunc__v2f32", &[a], ret, &[0, 152, 161, 14, 192, 3, 95, 214]);
486493
}
487494
"llvm.trunc.v2f64" => {
488495
intrinsic_args!(fx, args => (a); intrinsic);
489-
call_asm(fx, "llvm__trunc__v2f64", &[a], ret, &[0, 152, 225, 78]);
496+
call_asm(fx, "llvm__trunc__v2f64", &[a], ret, &[0, 152, 225, 78, 192, 3, 95, 214]);
490497
}
491498
"llvm.trunc.v4f32" => {
492499
intrinsic_args!(fx, args => (a); intrinsic);
493-
call_asm(fx, "llvm__trunc__v4f32", &[a], ret, &[0, 152, 161, 78]);
500+
call_asm(fx, "llvm__trunc__v4f32", &[a], ret, &[0, 152, 161, 78, 192, 3, 95, 214]);
494501
}
495502
// ==== end autogenerated section
496503

0 commit comments

Comments
 (0)