Skip to content

Commit 5283c3f

Browse files
committed
Create a backend specific copy of testsuite/tools
1 parent b4c0256 commit 5283c3f

15 files changed

+1934
-0
lines changed

testsuite/tools/asmgen_amd64.S

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
/**************************************************************************/
2+
/* */
3+
/* OCaml */
4+
/* */
5+
/* Xavier Leroy, projet Cristal, INRIA Rocquencourt */
6+
/* */
7+
/* Copyright 2000 Institut National de Recherche en Informatique et */
8+
/* en Automatique. */
9+
/* */
10+
/* All rights reserved. This file is distributed under the terms of */
11+
/* the GNU Lesser General Public License version 2.1, with the */
12+
/* special exception on linking described in the file LICENSE. */
13+
/* */
14+
/**************************************************************************/
15+
16+
#ifdef SYS_macosx
17+
#define ALIGN 4
18+
#else
19+
#define ALIGN 16
20+
#endif
21+
22+
#ifdef SYS_macosx
23+
#define CALL_GEN_CODE _call_gen_code
24+
#define CAML_C_CALL _caml_c_call
25+
#define CAML_NEGF_MASK _caml_negf_mask
26+
#define CAML_ABSF_MASK _caml_absf_mask
27+
#else
28+
#define CALL_GEN_CODE call_gen_code
29+
#define CAML_C_CALL caml_c_call
30+
#define CAML_NEGF_MASK caml_negf_mask
31+
#define CAML_ABSF_MASK caml_absf_mask
32+
#endif
33+
34+
.globl CALL_GEN_CODE
35+
.align ALIGN
36+
CALL_GEN_CODE:
37+
pushq %rbx
38+
pushq %rbp
39+
pushq %r12
40+
pushq %r13
41+
pushq %r14
42+
pushq %r15
43+
movq %rdi, %r10
44+
movq %rsi, %rax
45+
movq %rdx, %rbx
46+
movq %rcx, %rdi
47+
movq %r8, %rsi
48+
call *%r10
49+
popq %r15
50+
popq %r14
51+
popq %r13
52+
popq %r12
53+
popq %rbp
54+
popq %rbx
55+
ret
56+
57+
.globl CAML_C_CALL
58+
.align ALIGN
59+
CAML_C_CALL:
60+
jmp *%rax
61+
62+
#ifdef SYS_macosx
63+
.literal16
64+
#elif defined(SYS_mingw64) || defined(SYS_cygwin)
65+
.section .rodata.cst8
66+
#else
67+
.section .rodata.cst8,"aM",@progbits,8
68+
#endif
69+
.globl CAML_NEGF_MASK
70+
.align ALIGN
71+
CAML_NEGF_MASK:
72+
.quad 0x8000000000000000, 0
73+
.globl CAML_ABSF_MASK
74+
.align ALIGN
75+
CAML_ABSF_MASK:
76+
.quad 0x7FFFFFFFFFFFFFFF, 0
77+
78+
.comm young_limit, 8
79+
80+
#if defined(SYS_linux)
81+
/* Mark stack as non-executable */
82+
.section .note.GNU-stack,"",%progbits
83+
#endif

testsuite/tools/asmgen_arm.S

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/**************************************************************************/
2+
/* */
3+
/* OCaml */
4+
/* */
5+
/* Xavier Leroy, projet Cristal, INRIA Rocquencourt */
6+
/* */
7+
/* Copyright 1998 Institut National de Recherche en Informatique et */
8+
/* en Automatique. */
9+
/* */
10+
/* All rights reserved. This file is distributed under the terms of */
11+
/* the GNU Lesser General Public License version 2.1, with the */
12+
/* special exception on linking described in the file LICENSE. */
13+
/* */
14+
/**************************************************************************/
15+
16+
.text
17+
18+
.global call_gen_code
19+
.type call_gen_code, %function
20+
.align 0
21+
call_gen_code:
22+
mov ip, sp
23+
stmfd sp!, {r4, r5, r6, r7, r8, r9, fp, ip, lr, pc}
24+
sub fp, ip, #4
25+
@ r0 is function to call
26+
@ r1, r2, r3 are arguments 1, 2, 3
27+
mov r4, r0
28+
mov r0, r1
29+
mov r1, r2
30+
mov r2, r3
31+
blx r4
32+
ldmea fp, {r4, r5, r6, r7, r8, r9, fp, sp, pc}
33+
34+
.global caml_c_call
35+
.type caml_c_call, %function
36+
.align 0
37+
caml_c_call:
38+
@ function to call is in r10
39+
bx r10
40+
41+
/* Mark stack as non-executable */
42+
.section .note.GNU-stack,"",%progbits

testsuite/tools/asmgen_arm64.S

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/**************************************************************************/
2+
/* */
3+
/* OCaml */
4+
/* */
5+
/* Xavier Leroy, projet Gallium, INRIA Rocquencourt */
6+
/* */
7+
/* Copyright 2013 Institut National de Recherche en Informatique et */
8+
/* en Automatique. */
9+
/* */
10+
/* All rights reserved. This file is distributed under the terms of */
11+
/* the GNU Lesser General Public License version 2.1, with the */
12+
/* special exception on linking described in the file LICENSE. */
13+
/* */
14+
/**************************************************************************/
15+
16+
.globl call_gen_code
17+
.align 2
18+
call_gen_code:
19+
/* Set up stack frame and save callee-save registers */
20+
stp x29, x30, [sp, -160]!
21+
add x29, sp, #0
22+
stp x19, x20, [sp, 16]
23+
stp x21, x22, [sp, 32]
24+
stp x23, x24, [sp, 48]
25+
stp x25, x26, [sp, 64]
26+
stp x27, x28, [sp, 80]
27+
stp d8, d9, [sp, 96]
28+
stp d10, d11, [sp, 112]
29+
stp d12, d13, [sp, 128]
30+
stp d14, d15, [sp, 144]
31+
/* Shuffle arguments */
32+
mov x8, x0
33+
mov x0, x1
34+
mov x1, x2
35+
mov x2, x3
36+
mov x3, x4
37+
/* Call generated asm */
38+
blr x8
39+
/* Reload callee-save registers and return address */
40+
ldp x19, x20, [sp, 16]
41+
ldp x21, x22, [sp, 32]
42+
ldp x23, x24, [sp, 48]
43+
ldp x25, x26, [sp, 64]
44+
ldp x27, x28, [sp, 80]
45+
ldp d8, d9, [sp, 96]
46+
ldp d10, d11, [sp, 112]
47+
ldp d12, d13, [sp, 128]
48+
ldp d14, d15, [sp, 144]
49+
ldp x29, x30, [sp], 160
50+
ret
51+
52+
.globl caml_c_call
53+
.align 2
54+
caml_c_call:
55+
br x15
56+
57+
/* Mark stack as non-executable */
58+
.section .note.GNU-stack,"",%progbits

testsuite/tools/asmgen_i386.S

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
/**************************************************************************/
2+
/* */
3+
/* OCaml */
4+
/* */
5+
/* Xavier Leroy, projet Cristal, INRIA Rocquencourt */
6+
/* */
7+
/* Copyright 1996 Institut National de Recherche en Informatique et */
8+
/* en Automatique. */
9+
/* */
10+
/* All rights reserved. This file is distributed under the terms of */
11+
/* the GNU Lesser General Public License version 2.1, with the */
12+
/* special exception on linking described in the file LICENSE. */
13+
/* */
14+
/**************************************************************************/
15+
16+
/* Linux with ELF binaries does not prefix identifiers with _.
17+
Linux with a.out binaries, FreeBSD, and NextStep do. */
18+
19+
#if defined(SYS_linux_elf) || defined(SYS_bsd_elf) \
20+
|| defined(SYS_solaris) || defined(SYS_beos) || defined(SYS_gnu)
21+
#define G(x) x
22+
#define FUNCTION_ALIGN 16
23+
#else
24+
#define G(x) _##x
25+
#define FUNCTION_ALIGN 4
26+
#endif
27+
28+
.globl G(call_gen_code)
29+
.align FUNCTION_ALIGN
30+
G(call_gen_code):
31+
pushl %ebp
32+
movl %esp,%ebp
33+
pushl %ebx
34+
pushl %esi
35+
pushl %edi
36+
movl 12(%ebp),%eax
37+
movl 16(%ebp),%ebx
38+
movl 20(%ebp),%ecx
39+
movl 24(%ebp),%edx
40+
call *8(%ebp)
41+
popl %edi
42+
popl %esi
43+
popl %ebx
44+
popl %ebp
45+
ret
46+
47+
.globl G(caml_c_call)
48+
.align FUNCTION_ALIGN
49+
G(caml_c_call):
50+
jmp *%eax
51+
52+
.comm G(Caml_state), 4
53+
54+
/* Some tests are designed to cause registers to spill; on
55+
* x86 we require the caml_extra_params symbol from the RTS. */
56+
.data
57+
.globl G(caml_extra_params)
58+
G(caml_extra_params):
59+
#ifndef SYS_solaris
60+
.space 64
61+
#else
62+
.zero 64
63+
#endif
64+
65+
66+
67+
#if defined(SYS_linux_elf)
68+
/* Mark stack as non-executable */
69+
.section .note.GNU-stack,"",%progbits
70+
#endif

testsuite/tools/asmgen_i386nt.asm

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
;*********************************************************************;
2+
; ;
3+
; OCaml ;
4+
; ;
5+
; Xavier Leroy, projet Cristal, INRIA Rocquencourt ;
6+
; ;
7+
; Copyright 1996 Institut National de Recherche en Informatique et ;
8+
; en Automatique. All rights reserved. This file is distributed ;
9+
; under the terms of the Q Public License version 1.0. ;
10+
; ;
11+
;*********************************************************************;
12+
13+
.386
14+
.MODEL FLAT
15+
16+
.CODE
17+
PUBLIC _call_gen_code
18+
ALIGN 4
19+
_call_gen_code:
20+
push ebp
21+
mov ebp, esp
22+
push ebx
23+
push esi
24+
push edi
25+
mov eax, [ebp+12]
26+
mov ebx, [ebp+16]
27+
mov ecx, [ebp+20]
28+
mov edx, [ebp+24]
29+
call DWORD PTR [ebp+8]
30+
pop edi
31+
pop esi
32+
pop ebx
33+
pop ebp
34+
ret
35+
36+
PUBLIC _caml_c_call
37+
ALIGN 4
38+
_caml_c_call:
39+
ffree st(0)
40+
ffree st(1)
41+
ffree st(2)
42+
ffree st(3)
43+
jmp eax
44+
45+
PUBLIC _caml_call_gc
46+
PUBLIC _caml_alloc
47+
PUBLIC _caml_alloc1
48+
PUBLIC _caml_alloc2
49+
PUBLIC _caml_alloc3
50+
PUBLIC _caml_allocN
51+
PUBLIC _caml_extra_params
52+
PUBLIC _caml_raise_exn
53+
_caml_call_gc:
54+
_caml_alloc:
55+
_caml_alloc1:
56+
_caml_alloc2:
57+
_caml_alloc3:
58+
_caml_allocN:
59+
_caml_extra_params:
60+
_caml_raise_exn:
61+
int 3
62+
63+
.DATA
64+
PUBLIC _Caml_state
65+
_Caml_state dword 0
66+
67+
END

0 commit comments

Comments
 (0)