Skip to content

Commit 0c6fa8d

Browse files
committed
Add tests for all regparm values
1 parent 7b1f417 commit 0c6fa8d

File tree

1 file changed

+33
-12
lines changed

1 file changed

+33
-12
lines changed
Lines changed: 33 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
//@ add-core-stubs
22
//@ assembly-output: emit-asm
3-
//@ compile-flags: -O -Zregparm=3 --target=i686-unknown-linux-gnu -C relocation-model=static
3+
//@ compile-flags: -O --target=i686-unknown-linux-gnu -Crelocation-model=static
4+
//@ revisions: REGPARM1 REGPARM2 REGPARM3
5+
//@[REGPARM1] compile-flags: -Zregparm=1
6+
//@[REGPARM2] compile-flags: -Zregparm=2
7+
//@[REGPARM3] compile-flags: -Zregparm=3
48
//@ needs-llvm-components: x86
5-
69
#![feature(no_core)]
710
#![no_std]
811
#![no_core]
@@ -18,20 +21,38 @@ unsafe extern "C" {
1821

1922
#[unsafe(no_mangle)]
2023
pub unsafe extern "C" fn entrypoint(len: usize, ptr: *mut c_void, val: i32) -> *mut c_void {
21-
// CHECK-LABEL: entrypoint
22-
// CHECK: mov{{.*}}eax
23-
// CHECK: mov{{.*}}ecx
24-
// CHECK: mov{{.*}}esi
25-
// CHECK: jmp{{.*}}memset
24+
// REGPARM1-LABEL: entrypoint
25+
// REGPARM1: movl %eax, %ecx
26+
// REGPARM1: calll memset
27+
28+
// REGPARM2-LABEL: entrypoint
29+
// REGPARM2: movl %e{{.*}}, (%esp)
30+
// REGPARM2: movl %e{{.*}}, %eax
31+
// REGPARM2: calll memset
32+
33+
// REGPARM3-LABEL: entrypoint
34+
// REGPARM3: movl %e{{.*}}, %esi
35+
// REGPARM3: movl %e{{.*}}, %eax
36+
// REGPARM3: movl %e{{.*}}, %ecx
37+
// REGPARM3: jmp memset
2638
unsafe { memset(ptr, val, len) }
2739
}
2840

2941
#[unsafe(no_mangle)]
3042
pub unsafe extern "C" fn non_builtin_entrypoint(len: usize, ptr: *mut c_void, val: i32) -> *mut c_void {
31-
// CHECK-LABEL: my_entrypoint
32-
// CHECK: mov{{.*}}eax
33-
// CHECK: mov{{.*}}ecx
34-
// CHECK: mov{{.*}}esi
35-
// CHECK: jmp{{.*}}memset
43+
// REGPARM1-LABEL: non_builtin_entrypoint
44+
// REGPARM1: movl %eax, %ecx
45+
// REGPARM1: calll non_builtin_memset
46+
47+
// REGPARM2-LABEL: non_builtin_entrypoint
48+
// REGPARM2: movl %e{{.*}}, (%esp)
49+
// REGPARM2: movl %e{{.*}}, %eax
50+
// REGPARM2: calll non_builtin_memset
51+
52+
// REGPARM3-LABEL: non_builtin_entrypoint
53+
// REGPARM3: movl %e{{.*}}, %esi
54+
// REGPARM3: movl %e{{.*}}, %eax
55+
// REGPARM3: movl %e{{.*}}, %ecx
56+
// REGPARM3: jmp non_builtin_memset
3657
unsafe { non_builtin_memset(ptr, val, len) }
3758
}

0 commit comments

Comments
 (0)