summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXavier Leroy <xavier.leroy@inria.fr>2017-10-03 15:43:17 +0200
committerXavier Leroy <xavier.leroy@inria.fr>2017-10-03 15:43:17 +0200
commitf7010e83987f5b6c3ea241256ae0645be8ed9d19 (patch)
tree42cdc13ad480ad6bf87d9457c5f02ee6887fa78d
parent715fbc49c6ccc19baac8b04e1c45941963798449 (diff)
downloadocaml-f7010e83987f5b6c3ea241256ae0645be8ed9d19.tar.gz
Split C-- tests off tests/asmcomp and into tests/asmgen
tests/asmgen contains the custom C-- code generator and the tests written in C-- tests/asmcomp contains the tests written in OCaml The purpose of this split is to make it easier to skip or remove entirely the asmgen tests in the future, and to adapt the other tests to the new test infrastructure. Also: modernize the asm stubs in asmgen and remove the stubs for no-longer-supported architectures.
-rw-r--r--.gitignore12
-rw-r--r--testsuite/tests/asmcomp/Makefile84
-rw-r--r--testsuite/tests/asmcomp/alpha.S63
-rw-r--r--testsuite/tests/asmcomp/hppa.S161
-rw-r--r--testsuite/tests/asmcomp/ia64.S119
-rw-r--r--testsuite/tests/asmcomp/m68k.S57
-rw-r--r--testsuite/tests/asmcomp/mips.s72
-rw-r--r--testsuite/tests/asmcomp/sparc.S42
-rw-r--r--testsuite/tests/asmgen/Makefile122
-rw-r--r--testsuite/tests/asmgen/amd64.S (renamed from testsuite/tests/asmcomp/amd64.S)5
-rw-r--r--testsuite/tests/asmgen/arith.cmm (renamed from testsuite/tests/asmcomp/arith.cmm)0
-rw-r--r--testsuite/tests/asmgen/arm.S (renamed from testsuite/tests/asmcomp/arm.S)8
-rw-r--r--testsuite/tests/asmgen/arm64.S (renamed from testsuite/tests/asmcomp/arm64.S)3
-rw-r--r--testsuite/tests/asmgen/catch-rec.cmm (renamed from testsuite/tests/asmcomp/catch-rec.cmm)0
-rw-r--r--testsuite/tests/asmgen/catch-try.cmm (renamed from testsuite/tests/asmcomp/catch-try.cmm)0
-rw-r--r--testsuite/tests/asmgen/checkbound.cmm (renamed from testsuite/tests/asmcomp/checkbound.cmm)0
-rw-r--r--testsuite/tests/asmgen/even-odd-spill.cmm (renamed from testsuite/tests/asmcomp/even-odd-spill.cmm)0
-rw-r--r--testsuite/tests/asmgen/even-odd.cmm (renamed from testsuite/tests/asmcomp/even-odd.cmm)0
-rw-r--r--testsuite/tests/asmgen/fib.cmm (renamed from testsuite/tests/asmcomp/fib.cmm)0
-rw-r--r--testsuite/tests/asmgen/i386.S (renamed from testsuite/tests/asmcomp/i386.S)9
-rw-r--r--testsuite/tests/asmgen/i386nt.asm (renamed from testsuite/tests/asmcomp/i386nt.asm)0
-rw-r--r--testsuite/tests/asmgen/integr.cmm (renamed from testsuite/tests/asmcomp/integr.cmm)0
-rw-r--r--testsuite/tests/asmgen/lexcmm.mli (renamed from testsuite/tests/asmcomp/lexcmm.mli)0
-rw-r--r--testsuite/tests/asmgen/lexcmm.mll (renamed from testsuite/tests/asmcomp/lexcmm.mll)0
-rw-r--r--testsuite/tests/asmgen/main.c (renamed from testsuite/tests/asmcomp/main.c)0
-rw-r--r--testsuite/tests/asmgen/main.ml (renamed from testsuite/tests/asmcomp/main.ml)0
-rw-r--r--testsuite/tests/asmgen/mainarith.c (renamed from testsuite/tests/asmcomp/mainarith.c)0
-rw-r--r--testsuite/tests/asmgen/parsecmm.mly (renamed from testsuite/tests/asmcomp/parsecmm.mly)0
-rw-r--r--testsuite/tests/asmgen/parsecmmaux.ml (renamed from testsuite/tests/asmcomp/parsecmmaux.ml)0
-rw-r--r--testsuite/tests/asmgen/parsecmmaux.mli (renamed from testsuite/tests/asmcomp/parsecmmaux.mli)0
-rw-r--r--testsuite/tests/asmgen/pgcd.cmm (renamed from testsuite/tests/asmcomp/pgcd.cmm)0
-rw-r--r--testsuite/tests/asmgen/power.S (renamed from testsuite/tests/asmcomp/power.S)3
-rw-r--r--testsuite/tests/asmgen/quicksort.cmm (renamed from testsuite/tests/asmcomp/quicksort.cmm)0
-rw-r--r--testsuite/tests/asmgen/quicksort2.cmm (renamed from testsuite/tests/asmcomp/quicksort2.cmm)0
-rw-r--r--testsuite/tests/asmgen/s390x.S (renamed from testsuite/tests/asmcomp/s390x.S)3
-rw-r--r--testsuite/tests/asmgen/soli.cmm (renamed from testsuite/tests/asmcomp/soli.cmm)0
-rw-r--r--testsuite/tests/asmgen/tagged-fib.cmm (renamed from testsuite/tests/asmcomp/tagged-fib.cmm)0
-rw-r--r--testsuite/tests/asmgen/tagged-integr.cmm (renamed from testsuite/tests/asmcomp/tagged-integr.cmm)0
-rw-r--r--testsuite/tests/asmgen/tagged-quicksort.cmm (renamed from testsuite/tests/asmcomp/tagged-quicksort.cmm)0
-rw-r--r--testsuite/tests/asmgen/tagged-tak.cmm (renamed from testsuite/tests/asmcomp/tagged-tak.cmm)0
-rw-r--r--testsuite/tests/asmgen/tak.cmm (renamed from testsuite/tests/asmcomp/tak.cmm)0
41 files changed, 156 insertions, 607 deletions
diff --git a/.gitignore b/.gitignore
index 348178dd66..dd41a29eb2 100644
--- a/.gitignore
+++ b/.gitignore
@@ -244,12 +244,12 @@ _ocamltest
/testsuite/_retries
-/testsuite/tests/asmcomp/codegen
-/testsuite/tests/asmcomp/parsecmm.ml
-/testsuite/tests/asmcomp/parsecmm.mli
-/testsuite/tests/asmcomp/lexcmm.ml
-/testsuite/tests/asmcomp/*.s
-/testsuite/tests/asmcomp/*.out.manifest
+/testsuite/tests/asmgen/codegen
+/testsuite/tests/asmgen/parsecmm.ml
+/testsuite/tests/asmgen/parsecmm.mli
+/testsuite/tests/asmgen/lexcmm.ml
+/testsuite/tests/asmgen/*.s
+/testsuite/tests/asmgen/*.out.manifest
/testsuite/tests/basic/*.safe-string
/testsuite/tests/basic/pr6322.ml
diff --git a/testsuite/tests/asmcomp/Makefile b/testsuite/tests/asmcomp/Makefile
index 08921d12f0..eeadfa16c6 100644
--- a/testsuite/tests/asmcomp/Makefile
+++ b/testsuite/tests/asmcomp/Makefile
@@ -17,42 +17,14 @@ BASEDIR=../..
include $(BASEDIR)/../config/Makefile
-INCLUDES=\
- -I $(OTOPDIR)/parsing \
- -I $(OTOPDIR)/utils \
- -I $(OTOPDIR)/typing \
- -I $(OTOPDIR)/middle_end \
- -I $(OTOPDIR)/bytecomp \
- -I $(OTOPDIR)/asmcomp
-
-OTHEROBJS=\
- $(OTOPDIR)/compilerlibs/ocamlcommon.cma \
- $(OTOPDIR)/compilerlibs/ocamloptcomp.cma
-
-OBJS=parsecmmaux.cmo parsecmm.cmo lexcmm.cmo
-
-ADD_COMPFLAGS=$(INCLUDES) -w -40 -g
-
default:
@if $(BYTECODE_ONLY) || $(SKIP) ; then $(MAKE) skips ; else \
$(MAKE) all; \
fi
all:
- @$(MAKE) arch codegen
@$(MAKE) tests
-main.cmo: parsecmm.cmo
-
-codegen: parsecmm.ml lexcmm.ml $(OBJS:.cmo=.cmi) $(OBJS) main.cmo
- @$(OCAMLC) $(LINKFLAGS) -o codegen $(OTHEROBJS) $(OBJS) main.cmo
-
-parsecmm.mli parsecmm.ml: parsecmm.mly
- @$(OCAMLYACC) -q parsecmm.mly
-
-lexcmm.ml: lexcmm.mll
- @$(OCAMLLEX) -q lexcmm.mll
-
MLCASES=optargs staticalloc bind_tuples is_static register_typing \
register_typing_switch
ARGS_optargs=-g
@@ -66,32 +38,10 @@ ARGS_static_float_array_flambda=\
-I $(OTOPDIR)/byterun is_in_static_data.c simple_float_const.ml
ARGS_static_float_array_flambda_opaque=\
-I $(OTOPDIR)/byterun is_in_static_data.c -opaque simple_float_const_opaque.ml
-
-CASES=fib tak quicksort quicksort2 soli \
- arith checkbound tagged-fib tagged-integr tagged-quicksort tagged-tak \
- catch-try catch-rec even-odd even-odd-spill pgcd
-ARGS_fib=-DINT_INT -DFUN=fib main.c
-ARGS_tak=-DUNIT_INT -DFUN=takmain main.c
-ARGS_quicksort=-DSORT -DFUN=quicksort main.c
-ARGS_quicksort2=-DSORT -DFUN=quicksort main.c
-ARGS_soli=-DUNIT_INT -DFUN=solitaire main.c
-ARGS_integr=-DINT_FLOAT -DFUN=test main.c
-ARGS_arith=mainarith.c
-ARGS_checkbound=-DCHECKBOUND main.c
-ARGS_tagged-fib=-DINT_INT -DFUN=fib main.c
-ARGS_tagged-integr=-DINT_FLOAT -DFUN=test main.c
-ARGS_tagged-quicksort=-DSORT -DFUN=quicksort main.c
-ARGS_tagged-tak=-DUNIT_INT -DFUN=takmain main.c
ARGS_staticalloc=-I $(OTOPDIR)/utils config.cmx
-ARGS_catch-try=-DINT_INT -DFUN=catch_exit main.c
-ARGS_catch-rec=-DINT_INT -DFUN=catch_fact main.c
-ARGS_even-odd=-DINT_INT -DFUN=is_even main.c
-ARGS_even-odd-spill=-DINT_INT -DFUN=is_even main.c
-ARGS_pgcd=-DINT_INT -DFUN=pgcd_30030 main.c
skips:
- @for c in $(CASES) $(MLCASES) $(MLCASES_FLAMBDA) \
- $(MLCASES_FLAMBDA_FLOAT); do \
+ @for c in $(MLCASES) $(MLCASES_FLAMBDA) $(MLCASES_FLAMBDA_FLOAT); do \
echo " ... testing '$$c': => skipped"; \
done
@@ -107,39 +57,18 @@ one_ml_cond:
echo " => skipped"; \
fi
-one:
- @$(call CCOMP,$(NAME).out $(ARGS_$(NAME)) $(NAME).$(O) $(ARCH).$(O)) \
- && echo " => passed" || echo " => failed"
-
clean: defaultclean
- @rm -f ./codegen *.out *.out.manifest *.$(O) *.exe
- @rm -f parsecmm.ml parsecmm.mli lexcmm.ml
- @rm -f $(CASES:=.s)
include $(BASEDIR)/makefiles/Makefile.common
-ifeq "$(CCOMPTYPE)-$(ARCH)" "msvc-amd64"
-# these tests are not ported to MSVC64 yet
-SKIP=true
-else
-SKIP=false
-endif
-
ifeq "$(WITH_SPACETIME)" "true"
# These tests have not been ported for Spacetime
SKIP=true
-endif
-
-ifeq ($(CCOMPTYPE),msvc)
-CCOMP=set -o pipefail ; $(CC) $(CFLAGS) /Fe$(1) | tail -n +2
else
-CCOMP=$(CC) $(CFLAGS) -o $(1)
+SKIP=false
endif
-tests: $(CASES:=.$(O))
- @for c in $(CASES); do \
- printf " ... testing '$$c':"; \
- $(MAKE) one NAME=$$c; \
- done
+
+tests:
@for c in $(MLCASES); do \
printf " ... testing '$$c':"; \
$(MAKE) one_ml NAME=$$c; \
@@ -156,8 +85,3 @@ tests: $(CASES:=.$(O))
promote:
-arch: $(ARCH).$(O)
-
-i386.obj: i386nt.asm
- @set -o pipefail ; \
- $(ASM) $@ $^ | tail -n +2
diff --git a/testsuite/tests/asmcomp/alpha.S b/testsuite/tests/asmcomp/alpha.S
deleted file mode 100644
index 4452876996..0000000000
--- a/testsuite/tests/asmcomp/alpha.S
+++ /dev/null
@@ -1,63 +0,0 @@
-/**************************************************************************/
-/* */
-/* OCaml */
-/* */
-/* Xavier Leroy, projet Cristal, INRIA Rocquencourt */
-/* */
-/* Copyright 1996 Institut National de Recherche en Informatique et */
-/* en Automatique. */
-/* */
-/* All rights reserved. This file is distributed under the terms of */
-/* the GNU Lesser General Public License version 2.1, with the */
-/* special exception on linking described in the file LICENSE. */
-/* */
-/**************************************************************************/
-
- .globl call_gen_code
- .ent call_gen_code
-
-call_gen_code:
- lda $sp, -80($sp)
- stq $26, 0($sp)
- stq $9, 8($sp)
- stq $10, 16($sp)
- stq $11, 24($sp)
- stq $12, 32($sp)
- stt $f2, 40($sp)
- stt $f3, 48($sp)
- stt $f4, 56($sp)
- stt $f5, 64($sp)
- mov $16, $27
- mov $17, $16
- mov $18, $17
- mov $19, $18
- mov $20, $19
- jsr ($27)
- ldq $26, 0($sp)
- ldq $9, 8($sp)
- ldq $10, 16($sp)
- ldq $11, 24($sp)
- ldq $12, 32($sp)
- ldt $f2, 40($sp)
- ldt $f3, 48($sp)
- ldt $f4, 56($sp)
- ldt $f5, 64($sp)
- lda $sp, 80($sp)
- ret ($26)
-
- .end call_gen_code
-
- .globl caml_c_call
- .ent caml_c_call
-caml_c_call:
- lda $sp, -16($sp)
- stq $26, 0($sp)
- stq $gp, 8($sp)
- mov $25, $27
- jsr ($25)
- ldq $26, 0($sp)
- ldq $gp, 8($sp)
- lda $sp, 16($sp)
- ret ($26)
-
- .end caml_c_call
diff --git a/testsuite/tests/asmcomp/hppa.S b/testsuite/tests/asmcomp/hppa.S
deleted file mode 100644
index 5f7455b7cb..0000000000
--- a/testsuite/tests/asmcomp/hppa.S
+++ /dev/null
@@ -1,161 +0,0 @@
-;*********************************************************************
-;* *
-;* OCaml *
-;* *
-;* Xavier Leroy, projet Cristal, INRIA Rocquencourt *
-;* *
-;* Copyright 1996 Institut National de Recherche en Informatique et *
-;* en Automatique. All rights reserved. This file is distributed *
-;* under the terms of the Q Public License version 1.0. *
-;* *
-;*********************************************************************
-
-; Must be preprocessed by cpp
-
-#ifdef SYS_hpux
-#define G(x) x
-#define CODESPACE .code
-#define CODE_ALIGN 4
-#define EXPORT_CODE(x) .export x, entry, priv_lev=3
-#define STARTPROC .proc ! .callinfo frame=0, no_calls ! .entry
-#define ENDPROC .exit ! .procend
-#endif
-
-#ifdef SYS_nextstep
-#define G(x) _##x
-#define CODESPACE .text
-#define CODE_ALIGN 2
-#define EXPORT_CODE(x) .globl x
-#define STARTPROC
-#define ENDPROC
-#endif
-
-#ifdef SYS_hpux
- .space $PRIVATE$
- .subspa $DATA$,quad=1,align=8,access=31
- .subspa $BSS$,quad=1,align=8,access=31,zero,sort=82
- .space $TEXT$
- .subspa $LIT$,quad=0,align=8,access=44
- .subspa $CODE$,quad=0,align=8,access=44,code_only
- .import $global$, data
- .import $$dyncall, millicode
-#endif
-
- CODESPACE
- .align CODE_ALIGN
- EXPORT_CODE(G(call_gen_code))
-G(call_gen_code):
- STARTPROC
- stw %r2,-20(%r30)
- ldo 256(%r30), %r30
-; Save the callee-save registers
- ldo -32(%r30), %r1
- stws,ma %r3, -4(%r1)
- stws,ma %r4, -4(%r1)
- stws,ma %r5, -4(%r1)
- stws,ma %r6, -4(%r1)
- stws,ma %r7, -4(%r1)
- stws,ma %r8, -4(%r1)
- stws,ma %r9, -4(%r1)
- stws,ma %r10, -4(%r1)
- stws,ma %r11, -4(%r1)
- stws,ma %r12, -4(%r1)
- stws,ma %r13, -4(%r1)
- stws,ma %r14, -4(%r1)
- stws,ma %r15, -4(%r1)
- stws,ma %r16, -4(%r1)
- stws,ma %r17, -4(%r1)
- stws,ma %r18, -4(%r1)
- fstds,ma %fr12, -8(%r1)
- fstds,ma %fr13, -8(%r1)
- fstds,ma %fr14, -8(%r1)
- fstds,ma %fr15, -8(%r1)
- fstds,ma %fr16, -8(%r1)
- fstds,ma %fr17, -8(%r1)
- fstds,ma %fr18, -8(%r1)
- fstds,ma %fr19, -8(%r1)
- fstds,ma %fr20, -8(%r1)
- fstds,ma %fr21, -8(%r1)
- fstds,ma %fr22, -8(%r1)
- fstds,ma %fr23, -8(%r1)
- fstds,ma %fr24, -8(%r1)
- fstds,ma %fr25, -8(%r1)
- fstds,ma %fr26, -8(%r1)
- fstds,ma %fr27, -8(%r1)
- fstds,ma %fr28, -8(%r1)
- fstds,ma %fr29, -8(%r1)
- fstds,ma %fr30, -8(%r1)
- fstds,ma %fr31, -8(%r1)
-
-; Shuffle the arguments and call
- copy %r26, %r22
- copy %r25, %r26
- copy %r24, %r25
- copy %r23, %r24
- fcpy,dbl %fr5, %fr4
-#ifdef SYS_hpux
- bl $$dyncall, %r2
- nop
-#else
- ble 0(4, %r22)
- copy %r31, %r2
-#endif
-; Shuffle the results
- copy %r26, %r28
-; Restore the callee-save registers
- ldo -32(%r30), %r1
- ldws,ma -4(%r1), %r3
- ldws,ma -4(%r1), %r4
- ldws,ma -4(%r1), %r5
- ldws,ma -4(%r1), %r6
- ldws,ma -4(%r1), %r7
- ldws,ma -4(%r1), %r8
- ldws,ma -4(%r1), %r9
- ldws,ma -4(%r1), %r10
- ldws,ma -4(%r1), %r11
- ldws,ma -4(%r1), %r12
- ldws,ma -4(%r1), %r13
- ldws,ma -4(%r1), %r14
- ldws,ma -4(%r1), %r15
- ldws,ma -4(%r1), %r16
- ldws,ma -4(%r1), %r17
- ldws,ma -4(%r1), %r18
- fldds,ma -8(%r1), %fr12
- fldds,ma -8(%r1), %fr13
- fldds,ma -8(%r1), %fr14
- fldds,ma -8(%r1), %fr15
- fldds,ma -8(%r1), %fr16
- fldds,ma -8(%r1), %fr17
- fldds,ma -8(%r1), %fr18
- fldds,ma -8(%r1), %fr19
- fldds,ma -8(%r1), %fr20
- fldds,ma -8(%r1), %fr21
- fldds,ma -8(%r1), %fr22
- fldds,ma -8(%r1), %fr23
- fldds,ma -8(%r1), %fr24
- fldds,ma -8(%r1), %fr25
- fldds,ma -8(%r1), %fr26
- fldds,ma -8(%r1), %fr27
- fldds,ma -8(%r1), %fr28
- fldds,ma -8(%r1), %fr29
- fldds,ma -8(%r1), %fr30
- fldds,ma -8(%r1), %fr31
-
- ldo -256(%r30), %r30
- ldw -20(%r30), %r2
- bv 0(%r2)
- nop
- ENDPROC
-
- .align CODE_ALIGN
- EXPORT_CODE(caml_c_call)
-G(caml_c_call):
- STARTPROC
-#ifdef SYS_hpux
- bl $$dyncall, %r0
- nop
-#else
- bv 0(%r22)
- nop
-#endif
- ENDPROC
diff --git a/testsuite/tests/asmcomp/ia64.S b/testsuite/tests/asmcomp/ia64.S
deleted file mode 100644
index 5c3259428d..0000000000
--- a/testsuite/tests/asmcomp/ia64.S
+++ /dev/null
@@ -1,119 +0,0 @@
-/**************************************************************************/
-/* */
-/* OCaml */
-/* */
-/* Xavier Leroy, projet Cristal, INRIA Rocquencourt */
-/* */
-/* Copyright 1996 Institut National de Recherche en Informatique et */
-/* en Automatique. */
-/* */
-/* All rights reserved. This file is distributed under the terms of */
-/* the GNU Lesser General Public License version 2.1, with the */
-/* special exception on linking described in the file LICENSE. */
-/* */
-/**************************************************************************/
-
-#define ST8OFF(a,b,d) st8 [a] = b, d
-#define LD8OFF(a,b,d) ld8 a = [b], d
-#define STFDOFF(a,b,d) stfd [a] = b, d
-#define LDFDOFF(a,b,d) ldfd a = [b], d
-#define STFSPILLOFF(a,b,d) stf.spill [a] = b, d
-#define LDFFILLOFF(a,b,d) ldf.fill a = [b], d
-
- .text
- .align 16
-
- .global call_gen_code#
- .proc call_gen_code#
-
-call_gen_code:
- /* Allocate 64 "out" registers (for the OCaml code) and no locals */
- alloc r3 = ar.pfs, 0, 0, 64, 0
-
- /* Save PFS, return address and GP on stack */
- add sp = -368, sp ;;
- add r2 = 16, sp ;;
- ST8OFF(r2,r3,8) ;;
- mov r3 = b0 ;;
- ST8OFF(r2,r3,8) ;;
- ST8OFF(r2,gp,8) ;;
-
- /* Save predicates on stack */
- mov r3 = pr ;;
- st8 [r2] = r3
-
- /* Save callee-save floating-point registers on stack */
- add r2 = 48, sp
- add r3 = 64, sp ;;
- STFSPILLOFF(r2,f2,16) ;;
- STFSPILLOFF(r3,f3,16) ;;
- STFSPILLOFF(r2,f4,16) ;;
- STFSPILLOFF(r3,f5,16) ;;
- STFSPILLOFF(r2,f16,16) ;;
- STFSPILLOFF(r3,f17,16) ;;
- STFSPILLOFF(r2,f18,16) ;;
- STFSPILLOFF(r3,f19,16) ;;
- STFSPILLOFF(r2,f20,16) ;;
- STFSPILLOFF(r3,f21,16) ;;
- STFSPILLOFF(r2,f22,16) ;;
- STFSPILLOFF(r3,f23,16) ;;
- STFSPILLOFF(r2,f24,16) ;;
- STFSPILLOFF(r3,f25,16) ;;
- STFSPILLOFF(r2,f26,16) ;;
- STFSPILLOFF(r3,f27,16) ;;
- STFSPILLOFF(r2,f28,16) ;;
- STFSPILLOFF(r3,f29,16) ;;
- STFSPILLOFF(r2,f30,16) ;;
- STFSPILLOFF(r3,f31,16) ;;
-
- /* Recover entry point and gp from the function pointer in in0 */
- LD8OFF(r2,r32,8) ;;
- ld8 r3 = [r32] ;;
- mov b6 = r2
- mov gp = r3 ;;
-
- /* Shift arguments r33 ... r35 to r32 ... r34 */
- mov r32 = r33
- mov r33 = r34
- mov r34 = r35
-
- /* Do the call */
- br.call.sptk b0 = b6 ;;
-
- /* Restore the saved floating-point registers */
- add r2 = 48, sp
- add r3 = 64, sp ;;
- LDFFILLOFF(f2,r2,16) ;;
- LDFFILLOFF(f3,r3,16) ;;
- LDFFILLOFF(f4,r2,16) ;;
- LDFFILLOFF(f5,r3,16) ;;
- LDFFILLOFF(f16,r2,16) ;;
- LDFFILLOFF(f17,r3,16) ;;
- LDFFILLOFF(f18,r2,16) ;;
- LDFFILLOFF(f19,r3,16) ;;
- LDFFILLOFF(f20,r2,16) ;;
- LDFFILLOFF(f21,r3,16) ;;
- LDFFILLOFF(f22,r2,16) ;;
- LDFFILLOFF(f23,r3,16) ;;
- LDFFILLOFF(f24,r2,16) ;;
- LDFFILLOFF(f25,r3,16) ;;
- LDFFILLOFF(f26,r2,16) ;;
- LDFFILLOFF(f27,r3,16) ;;
- LDFFILLOFF(f28,r2,16) ;;
- LDFFILLOFF(f29,r3,16) ;;
- LDFFILLOFF(f30,r2,16) ;;
- LDFFILLOFF(f31,r3,16) ;;
-
- /* Restore gp, predicates and return */
- add r2 = 16, sp ;;
- LD8OFF(r3,r2,8) ;;
- mov ar.pfs = r3
- LD8OFF(r3,r2,8) ;;
- mov b0 = r3
- LD8OFF(gp,r2,8) ;;
- LD8OFF(r3,r2,8) ;;
- mov pr = r3, -1
-
- br.ret.sptk.many b0 ;;
-
- .endp call_gen_code#
diff --git a/testsuite/tests/asmcomp/m68k.S b/testsuite/tests/asmcomp/m68k.S
deleted file mode 100644
index 4d0f6a3a81..0000000000
--- a/testsuite/tests/asmcomp/m68k.S
+++ /dev/null
@@ -1,57 +0,0 @@
-|***********************************************************************
-|* *
-|* OCaml *
-|* *
-|* Xavier Leroy, projet Cristal, INRIA Rocquencourt *
-|* *
-|* Copyright 1996 Institut National de Recherche en Informatique et *
-|* en Automatique. All rights reserved. This file is distributed *
-|* under the terms of the Q Public License version 1.0. *
-|* *
-|***********************************************************************
-
-| call_gen_code is used with the following types:
-| unit -> int
-| int -> int
-| int -> double
-| int * int * address -> void
-| int * int -> void
-| unit -> unit
-| Hence arg1 -> d0, arg2 -> d1, arg3 -> a0,
-| and we need a special case for int -> double
-
- .text
- .globl _call_gen_code
-_call_gen_code:
- link a6, #0
- movem d2-d7/a2-a6, a7@-
- fmovem fp2-fp7, a7@-
- movel a6@(8), a1
- movel a6@(12), d0
- movel a6@(16), d1
- movel a6@(20), a0
- jsr a1@
- fmovem a7@+, fp2-fp7
- movem a7@+, d2-d7/a2-a6
- unlk a6
- rts
-
- .globl _call_gen_code_float
-_call_gen_code_float:
- link a6, #0
- moveml d2-d7/a2-a6, a7@-
- fmovem fp2-fp7, a7@-
- movel a6@(8), a1
- movel a6@(12), d0
- jsr a1@
- fmoved fp0, a7@-
- movel a7@+, d0
- movel a7@+, d1
- fmovem a7@+, fp2-fp7
- moveml a7@+, d2-d7/a2-a6
- unlk a6
- rts
-
- .globl _caml_c_call
-_caml_c_call:
- jmp a0@
diff --git a/testsuite/tests/asmcomp/mips.s b/testsuite/tests/asmcomp/mips.s
deleted file mode 100644
index 1549dc0ae1..0000000000
--- a/testsuite/tests/asmcomp/mips.s
+++ /dev/null
@@ -1,72 +0,0 @@
-/**************************************************************************/
-/* */
-/* OCaml */
-/* */
-/* Xavier Leroy, projet Cristal, INRIA Rocquencourt */
-/* */
-/* Copyright 1996 Institut National de Recherche en Informatique et */
-/* en Automatique. */
-/* */
-/* All rights reserved. This file is distributed under the terms of */
-/* the GNU Lesser General Public License version 2.1, with the */
-/* special exception on linking described in the file LICENSE. */
-/* */
-/**************************************************************************/
-
- .globl call_gen_code
- .ent call_gen_code
-call_gen_code:
- subu $sp, $sp, 0x90
- sd $31, 0x88($sp)
- /* Save all callee-save registers */
- sd $16, 0x0($sp)
- sd $17, 0x8($sp)
- sd $18, 0x10($sp)
- sd $19, 0x18($sp)
- sd $20, 0x20($sp)
- sd $21, 0x28($sp)
- sd $22, 0x30($sp)
- sd $23, 0x38($sp)
- sd $30, 0x40($sp)
- s.d $f20, 0x48($sp)
- s.d $f22, 0x50($sp)
- s.d $f24, 0x58($sp)
- s.d $f26, 0x60($sp)
- s.d $f28, 0x68($sp)
- s.d $f30, 0x70($sp)
- /* Shuffle arguments */
- move $8, $5
- move $9, $6
- move $10, $7
- move $25, $4
- jal $4
- /* Restore registers */
- ld $31, 0x88($sp)
- ld $16, 0x0($sp)
- ld $17, 0x8($sp)
- ld $18, 0x10($sp)
- ld $19, 0x18($sp)
- ld $20, 0x20($sp)
- ld $21, 0x28($sp)
- ld $22, 0x30($sp)
- ld $23, 0x38($sp)
- ld $30, 0x40($sp)
- l.d $f20, 0x48($sp)
- l.d $f22, 0x50($sp)
- l.d $f24, 0x58($sp)
- l.d $f26, 0x60($sp)
- l.d $f28, 0x68($sp)
- l.d $f30, 0x70($sp)
- addu $sp, $sp, 0x90
- j $31
-
- .end call_gen_code
-
-/* Call a C function */
-
- .globl caml_c_call
- .ent caml_c_call
-caml_c_call:
- move $25, $24
- j $24
- .end caml_c_call
diff --git a/testsuite/tests/asmcomp/sparc.S b/testsuite/tests/asmcomp/sparc.S
deleted file mode 100644
index 5fd797b36f..0000000000
--- a/testsuite/tests/asmcomp/sparc.S
+++ /dev/null
@@ -1,42 +0,0 @@
-/**************************************************************************/
-/* */
-/* OCaml */
-/* */
-/* Xavier Leroy, projet Cristal, INRIA Rocquencourt */
-/* */
-/* Copyright 1996 Institut National de Recherche en Informatique et */
-/* en Automatique. */
-/* */
-/* All rights reserved. This file is distributed under the terms of */
-/* the GNU Lesser General Public License version 2.1, with the */
-/* special exception on linking described in the file LICENSE. */
-/* */
-/**************************************************************************/
-
-#if defined(SYS_solaris) || defined(SYS_linux)
-#define Call_gen_code call_gen_code
-#define Caml_c_call caml_c_call
-#else
-#define Call_gen_code _call_gen_code
-#define Caml_c_call _caml_c_call
-#endif
-
- .global Call_gen_code
-Call_gen_code:
- save %sp, -96, %sp
- mov %i0, %l0
- mov %i1, %i0
- mov %i2, %i1
- mov %i3, %i2
- mov %i4, %i3
- mov %i5, %i4
- call %l0
- nop
- mov %o0, %i0
- ret
- restore
-
- .global Caml_c_call
-Caml_c_call:
- jmp %g4
- nop
diff --git a/testsuite/tests/asmgen/Makefile b/testsuite/tests/asmgen/Makefile
new file mode 100644
index 0000000000..f6d0c238ff
--- /dev/null
+++ b/testsuite/tests/asmgen/Makefile
@@ -0,0 +1,122 @@
+#**************************************************************************
+#* *
+#* OCaml *
+#* *
+#* Xavier Clerc, SED, INRIA Rocquencourt *
+#* *
+#* Copyright 2010 Institut National de Recherche en Informatique et *
+#* en Automatique. *
+#* *
+#* All rights reserved. This file is distributed under the terms of *
+#* the GNU Lesser General Public License version 2.1, with the *
+#* special exception on linking described in the file LICENSE. *
+#* *
+#**************************************************************************
+
+BASEDIR=../..
+
+include $(BASEDIR)/../config/Makefile
+
+INCLUDES=\
+ -I $(OTOPDIR)/parsing \
+ -I $(OTOPDIR)/utils \
+ -I $(OTOPDIR)/typing \
+ -I $(OTOPDIR)/middle_end \
+ -I $(OTOPDIR)/bytecomp \
+ -I $(OTOPDIR)/asmcomp
+
+OTHEROBJS=\
+ $(OTOPDIR)/compilerlibs/ocamlcommon.cma \
+ $(OTOPDIR)/compilerlibs/ocamloptcomp.cma
+
+OBJS=parsecmmaux.cmo parsecmm.cmo lexcmm.cmo
+
+ADD_COMPFLAGS=$(INCLUDES) -w -40 -g
+
+default:
+ @if $(BYTECODE_ONLY) || $(SKIP) ; then $(MAKE) skips ; else \
+ $(MAKE) all; \
+ fi
+
+all:
+ @$(MAKE) arch codegen
+ @$(MAKE) tests
+
+main.cmo: parsecmm.cmo
+
+codegen: parsecmm.ml lexcmm.ml $(OBJS:.cmo=.cmi) $(OBJS) main.cmo
+ @$(OCAMLC) $(LINKFLAGS) -o codegen $(OTHEROBJS) $(OBJS) main.cmo
+
+parsecmm.mli parsecmm.ml: parsecmm.mly
+ @$(OCAMLYACC) -q parsecmm.mly
+
+lexcmm.ml: lexcmm.mll
+ @$(OCAMLLEX) -q lexcmm.mll
+
+CASES=fib tak quicksort quicksort2 soli \
+ arith checkbound tagged-fib tagged-integr tagged-quicksort tagged-tak \
+ catch-try catch-rec even-odd even-odd-spill pgcd
+ARGS_fib=-DINT_INT -DFUN=fib main.c
+ARGS_tak=-DUNIT_INT -DFUN=takmain main.c
+ARGS_quicksort=-DSORT -DFUN=quicksort main.c
+ARGS_quicksort2=-DSORT -DFUN=quicksort main.c
+ARGS_soli=-DUNIT_INT -DFUN=solitaire main.c
+ARGS_integr=-DINT_FLOAT -DFUN=test main.c
+ARGS_arith=mainarith.c
+ARGS_checkbound=-DCHECKBOUND main.c
+ARGS_tagged-fib=-DINT_INT -DFUN=fib main.c
+ARGS_tagged-integr=-DINT_FLOAT -DFUN=test main.c
+ARGS_tagged-quicksort=-DSORT -DFUN=quicksort main.c
+ARGS_tagged-tak=-DUNIT_INT -DFUN=takmain main.c
+ARGS_catch-try=-DINT_INT -DFUN=catch_exit main.c
+ARGS_catch-rec=-DINT_INT -DFUN=catch_fact main.c
+ARGS_even-odd=-DINT_INT -DFUN=is_even main.c
+ARGS_even-odd-spill=-DINT_INT -DFUN=is_even main.c
+ARGS_pgcd=-DINT_INT -DFUN=pgcd_30030 main.c
+
+skips:
+ @for c in $(CASES); do \
+ echo " ... testing '$$c': => skipped"; \
+ done
+
+one:
+ @$(call CCOMP,$(NAME).out $(ARGS_$(NAME)) $(NAME).$(O) $(ARCH).$(O)) \
+ && echo " => passed" || echo " => failed"
+
+clean: defaultclean
+ @rm -f ./codegen *.out *.out.manifest *.$(O) *.exe
+ @rm -f parsecmm.ml parsecmm.mli lexcmm.ml
+ @rm -f $(CASES:=.s)
+
+include $(BASEDIR)/makefiles/Makefile.common
+
+ifeq "$(CCOMPTYPE)-$(ARCH)" "msvc-amd64"
+# these tests are not ported to MSVC64 yet
+SKIP=true
+else
+SKIP=false
+endif
+
+ifeq "$(WITH_SPACETIME)" "true"
+# These tests have not been ported for Spacetime
+SKIP=true
+endif
+
+ifeq ($(CCOMPTYPE),msvc)
+CCOMP=set -o pipefail ; $(CC) $(CFLAGS) /Fe$(1) | tail -n +2
+else
+CCOMP=$(CC) $(CFLAGS) -o $(1)
+endif
+tests: $(CASES:=.$(O))
+ @for c in $(CASES); do \
+ printf " ... testing '$$c':"; \
+ $(MAKE) one NAME=$$c; \
+ done
+
+promote:
+
+arch: $(ARCH).$(O)
+
+i386.obj: i386nt.asm
+ @set -o pipefail ; \
+ $(ASM) $@ $^ | tail -n +2
diff --git a/testsuite/tests/asmcomp/amd64.S b/testsuite/tests/asmgen/amd64.S
index bb4f9b5c0b..fb87307df0 100644
--- a/testsuite/tests/asmcomp/amd64.S
+++ b/testsuite/tests/asmgen/amd64.S
@@ -76,3 +76,8 @@ CAML_ABSF_MASK:
.quad 0x7FFFFFFFFFFFFFFF, 0
.comm young_limit, 8
+
+#if defined(SYS_linux)
+ /* Mark stack as non-executable */
+ .section .note.GNU-stack,"",%progbits
+#endif
diff --git a/testsuite/tests/asmcomp/arith.cmm b/testsuite/tests/asmgen/arith.cmm
index 09156568a9..09156568a9 100644
--- a/testsuite/tests/asmcomp/arith.cmm
+++ b/testsuite/tests/asmgen/arith.cmm
diff --git a/testsuite/tests/asmcomp/arm.S b/testsuite/tests/asmgen/arm.S
index fbbe276359..da6d9ee74f 100644
--- a/testsuite/tests/asmcomp/arm.S
+++ b/testsuite/tests/asmgen/arm.S
@@ -28,8 +28,7 @@ call_gen_code:
mov r0, r1
mov r1, r2
mov r2, r3
- mov lr, pc
- mov pc, r4
+ blx r4
ldmea fp, {r4, r5, r6, r7, r8, r9, fp, sp, pc}
.global caml_c_call
@@ -37,4 +36,7 @@ call_gen_code:
.align 0
caml_c_call:
@ function to call is in r10
- mov pc, r10
+ bx r10
+
+/* Mark stack as non-executable */
+ .section .note.GNU-stack,"",%progbits
diff --git a/testsuite/tests/asmcomp/arm64.S b/testsuite/tests/asmgen/arm64.S
index fa49f1aee1..4b803d20b1 100644
--- a/testsuite/tests/asmcomp/arm64.S
+++ b/testsuite/tests/asmgen/arm64.S
@@ -53,3 +53,6 @@ call_gen_code:
.align 2
caml_c_call:
br x15
+
+/* Mark stack as non-executable */
+ .section .note.GNU-stack,"",%progbits
diff --git a/testsuite/tests/asmcomp/catch-rec.cmm b/testsuite/tests/asmgen/catch-rec.cmm
index 69208f5f4a..69208f5f4a 100644
--- a/testsuite/tests/asmcomp/catch-rec.cmm
+++ b/testsuite/tests/asmgen/catch-rec.cmm
diff --git a/testsuite/tests/asmcomp/catch-try.cmm b/testsuite/tests/asmgen/catch-try.cmm
index bbbdc387b1..bbbdc387b1 100644
--- a/testsuite/tests/asmcomp/catch-try.cmm
+++ b/testsuite/tests/asmgen/catch-try.cmm
diff --git a/testsuite/tests/asmcomp/checkbound.cmm b/testsuite/tests/asmgen/checkbound.cmm
index 35206f25bb..35206f25bb 100644
--- a/testsuite/tests/asmcomp/checkbound.cmm
+++ b/testsuite/tests/asmgen/checkbound.cmm
diff --git a/testsuite/tests/asmcomp/even-odd-spill.cmm b/testsuite/tests/asmgen/even-odd-spill.cmm
index 0c5f05589c..0c5f05589c 100644
--- a/testsuite/tests/asmcomp/even-odd-spill.cmm
+++ b/testsuite/tests/asmgen/even-odd-spill.cmm
diff --git a/testsuite/tests/asmcomp/even-odd.cmm b/testsuite/tests/asmgen/even-odd.cmm
index db79f1cab8..db79f1cab8 100644
--- a/testsuite/tests/asmcomp/even-odd.cmm
+++ b/testsuite/tests/asmgen/even-odd.cmm
diff --git a/testsuite/tests/asmcomp/fib.cmm b/testsuite/tests/asmgen/fib.cmm
index 49de4ba12e..49de4ba12e 100644
--- a/testsuite/tests/asmcomp/fib.cmm
+++ b/testsuite/tests/asmgen/fib.cmm
diff --git a/testsuite/tests/asmcomp/i386.S b/testsuite/tests/asmgen/i386.S
index 6da92f2a3c..26dc83fcac 100644
--- a/testsuite/tests/asmcomp/i386.S
+++ b/testsuite/tests/asmgen/i386.S
@@ -47,12 +47,13 @@ G(call_gen_code):
.globl G(caml_c_call)
.align FUNCTION_ALIGN
G(caml_c_call):
- ffree %st(0)
- ffree %st(1)
- ffree %st(2)
- ffree %st(3)
jmp *%eax
.comm G(caml_exception_pointer), 4
.comm G(young_ptr), 4
.comm G(young_start), 4
+
+#if defined(SYS_linux_elf)
+ /* Mark stack as non-executable */
+ .section .note.GNU-stack,"",%progbits
+#endif
diff --git a/testsuite/tests/asmcomp/i386nt.asm b/testsuite/tests/asmgen/i386nt.asm
index 618d41c949..618d41c949 100644
--- a/testsuite/tests/asmcomp/i386nt.asm
+++ b/testsuite/tests/asmgen/i386nt.asm
diff --git a/testsuite/tests/asmcomp/integr.cmm b/testsuite/tests/asmgen/integr.cmm
index c82d60b247..c82d60b247 100644
--- a/testsuite/tests/asmcomp/integr.cmm
+++ b/testsuite/tests/asmgen/integr.cmm
diff --git a/testsuite/tests/asmcomp/lexcmm.mli b/testsuite/tests/asmgen/lexcmm.mli
index f9fe6afadf..f9fe6afadf 100644
--- a/testsuite/tests/asmcomp/lexcmm.mli
+++ b/testsuite/tests/asmgen/lexcmm.mli
diff --git a/testsuite/tests/asmcomp/lexcmm.mll b/testsuite/tests/asmgen/lexcmm.mll
index a946f6aa62..a946f6aa62 100644
--- a/testsuite/tests/asmcomp/lexcmm.mll
+++ b/testsuite/tests/asmgen/lexcmm.mll
diff --git a/testsuite/tests/asmcomp/main.c b/testsuite/tests/asmgen/main.c
index 5f305731f0..5f305731f0 100644
--- a/testsuite/tests/asmcomp/main.c
+++ b/testsuite/tests/asmgen/main.c
diff --git a/testsuite/tests/asmcomp/main.ml b/testsuite/tests/asmgen/main.ml
index 6970f99a93..6970f99a93 100644
--- a/testsuite/tests/asmcomp/main.ml
+++ b/testsuite/tests/asmgen/main.ml
diff --git a/testsuite/tests/asmcomp/mainarith.c b/testsuite/tests/asmgen/mainarith.c
index de876bfead..de876bfead 100644
--- a/testsuite/tests/asmcomp/mainarith.c
+++ b/testsuite/tests/asmgen/mainarith.c
diff --git a/testsuite/tests/asmcomp/parsecmm.mly b/testsuite/tests/asmgen/parsecmm.mly
index 52a6dfad1d..52a6dfad1d 100644
--- a/testsuite/tests/asmcomp/parsecmm.mly
+++ b/testsuite/tests/asmgen/parsecmm.mly
diff --git a/testsuite/tests/asmcomp/parsecmmaux.ml b/testsuite/tests/asmgen/parsecmmaux.ml
index db55527354..db55527354 100644
--- a/testsuite/tests/asmcomp/parsecmmaux.ml
+++ b/testsuite/tests/asmgen/parsecmmaux.ml
diff --git a/testsuite/tests/asmcomp/parsecmmaux.mli b/testsuite/tests/asmgen/parsecmmaux.mli
index f5478579ee..f5478579ee 100644
--- a/testsuite/tests/asmcomp/parsecmmaux.mli
+++ b/testsuite/tests/asmgen/parsecmmaux.mli
diff --git a/testsuite/tests/asmcomp/pgcd.cmm b/testsuite/tests/asmgen/pgcd.cmm
index e75a149ac0..e75a149ac0 100644
--- a/testsuite/tests/asmcomp/pgcd.cmm
+++ b/testsuite/tests/asmgen/pgcd.cmm
diff --git a/testsuite/tests/asmcomp/power.S b/testsuite/tests/asmgen/power.S
index d13035a46e..71c692f97b 100644
--- a/testsuite/tests/asmcomp/power.S
+++ b/testsuite/tests/asmgen/power.S
@@ -195,3 +195,6 @@ FUNCTION(caml_c_call)
#error "wrong MODEL"
#endif
bctr
+
+/* Mark stack as non-executable */
+ .section .note.GNU-stack,"",%progbits
diff --git a/testsuite/tests/asmcomp/quicksort.cmm b/testsuite/tests/asmgen/quicksort.cmm
index b08594154b..b08594154b 100644
--- a/testsuite/tests/asmcomp/quicksort.cmm
+++ b/testsuite/tests/asmgen/quicksort.cmm
diff --git a/testsuite/tests/asmcomp/quicksort2.cmm b/testsuite/tests/asmgen/quicksort2.cmm
index 96c1fc12e7..96c1fc12e7 100644
--- a/testsuite/tests/asmcomp/quicksort2.cmm
+++ b/testsuite/tests/asmgen/quicksort2.cmm
diff --git a/testsuite/tests/asmcomp/s390x.S b/testsuite/tests/asmgen/s390x.S
index d0b4b3c8df..99eeca2704 100644
--- a/testsuite/tests/asmcomp/s390x.S
+++ b/testsuite/tests/asmgen/s390x.S
@@ -62,3 +62,6 @@ CAML_ABSF_MASK:
.quad 0x7FFFFFFFFFFFFFFF, 0
.comm young_limit, 8
+
+/* Mark stack as non-executable */
+ .section .note.GNU-stack,"",%progbits
diff --git a/testsuite/tests/asmcomp/soli.cmm b/testsuite/tests/asmgen/soli.cmm
index c8ffc5d684..c8ffc5d684 100644
--- a/testsuite/tests/asmcomp/soli.cmm
+++ b/testsuite/tests/asmgen/soli.cmm
diff --git a/testsuite/tests/asmcomp/tagged-fib.cmm b/testsuite/tests/asmgen/tagged-fib.cmm
index d83afaa487..d83afaa487 100644
--- a/testsuite/tests/asmcomp/tagged-fib.cmm
+++ b/testsuite/tests/asmgen/tagged-fib.cmm
diff --git a/testsuite/tests/asmcomp/tagged-integr.cmm b/testsuite/tests/asmgen/tagged-integr.cmm
index b89bd50863..b89bd50863 100644
--- a/testsuite/tests/asmcomp/tagged-integr.cmm
+++ b/testsuite/tests/asmgen/tagged-integr.cmm
diff --git a/testsuite/tests/asmcomp/tagged-quicksort.cmm b/testsuite/tests/asmgen/tagged-quicksort.cmm
index 59293aa2ed..59293aa2ed 100644
--- a/testsuite/tests/asmcomp/tagged-quicksort.cmm
+++ b/testsuite/tests/asmgen/tagged-quicksort.cmm
diff --git a/testsuite/tests/asmcomp/tagged-tak.cmm b/testsuite/tests/asmgen/tagged-tak.cmm
index 30c98a00bf..30c98a00bf 100644
--- a/testsuite/tests/asmcomp/tagged-tak.cmm
+++ b/testsuite/tests/asmgen/tagged-tak.cmm
diff --git a/testsuite/tests/asmcomp/tak.cmm b/testsuite/tests/asmgen/tak.cmm
index 2750fff334..2750fff334 100644
--- a/testsuite/tests/asmcomp/tak.cmm
+++ b/testsuite/tests/asmgen/tak.cmm