From: Rhys Weatherley Date: Mon, 14 Jun 2004 04:57:02 +0000 (+0000) Subject: Add some test cases for parameter passing; fix fastcall/stdcall X-Git-Tag: r.0.0.4~14 X-Git-Url: https://git.unchartedbackwaters.co.uk/w/?a=commitdiff_plain;h=311f4fc6b104574601126138d72cabec712d7dd8;p=francis%2Flibjit.git Add some test cases for parameter passing; fix fastcall/stdcall conventions for x86. --- diff --git a/ChangeLog b/ChangeLog index 68a3827..2676ede 100644 --- a/ChangeLog +++ b/ChangeLog @@ -10,6 +10,11 @@ jitplus/jit-plus-function.cpp: add the "outgoing_frame_posn" instruction, to support tail calls. + * dpas/dpas-internal.h, dpas/dpas-parser.y, dpas/dpas-scanner.l, + jit/jit-rules-x86.c, jit/jit-rules-x86.sel, tests/Makefile.am, + tests/param.pas, tools/gen-apply.c: add some test cases for + parameter passing; fix fastcall/stdcall conventions for x86. + 2004-06-11 Rhys Weatherley * doc/libjit.texi, jit/jit-insn.c, jit/jit-internal.h, diff --git a/dpas/dpas-internal.h b/dpas/dpas-internal.h index c50c035..6c6ed16 100644 --- a/dpas/dpas-internal.h +++ b/dpas/dpas-internal.h @@ -51,7 +51,7 @@ typedef struct char **names; jit_type_t *types; int len; - int has_vararg; + jit_abi_t abi; } dpas_params; diff --git a/dpas/dpas-parser.y b/dpas/dpas-parser.y index 0242db4..0584f8f 100644 --- a/dpas/dpas-parser.y +++ b/dpas/dpas-parser.y @@ -352,7 +352,7 @@ static void parameter_list_init(dpas_params *list) list->names = 0; list->types = 0; list->len = 0; - list->has_vararg = 0; + list->abi = jit_abi_cdecl; } /* @@ -781,6 +781,7 @@ static void push_if(jit_label_t end_label) int len; } expr_list; int direction; + jit_abi_t abi; } /* @@ -806,6 +807,7 @@ static void push_if(jit_label_t end_label) %token K_ELSE "`else'" %token K_END "`end'" %token K_EXIT "`exit'" +%token K_FASTCALL "`fastcall'" %token K_FINALLY "`finally'" %token K_FOR "`for'" %token K_FORWARD "`forward'" @@ -831,6 +833,7 @@ static void push_if(jit_label_t end_label) %token K_SHL "`shl'" %token K_SHR "`shr'" %token K_SIZEOF "`sizeof'" +%token K_STDCALL "`stdcall'" %token K_THEN "`then'" %token K_THROW "`throw'" %token K_TO "`to'" @@ -883,6 +886,8 @@ static void push_if(jit_label_t end_label) %type Direction +%type OptAbi + %expect 3 %start Program @@ -1315,8 +1320,8 @@ ProcedureHeading : K_PROCEDURE Identifier FormalParameterList { $$.name = $2; $$.type = jit_type_create_signature - (($3.has_vararg ? jit_abi_vararg : jit_abi_cdecl), - jit_type_void, $3.types, (unsigned int)($3.len), 1); + ($3.abi, jit_type_void, + $3.types, (unsigned int)($3.len), 1); if(!($$.type)) { dpas_out_of_memory(); @@ -1334,8 +1339,7 @@ FunctionHeading : K_FUNCTION Identifier FormalParameterList ':' TypeIdentifier { $$.name = $2; $$.type = jit_type_create_signature - (($3.has_vararg ? jit_abi_vararg : jit_abi_cdecl), - $5, $3.types, (unsigned int)($3.len), 1); + ($3.abi, $5, $3.types, (unsigned int)($3.len), 1); if(!($$.type)) { dpas_out_of_memory(); @@ -1352,13 +1356,22 @@ FunctionHeading FormalParameterList : /* empty */ { parameter_list_init(&($$)); } - | '(' FormalParameterSections ')' { $$ = $2; } + | '(' FormalParameterSections ')' OptAbi { + $$ = $2; + $$.abi = $4; + } | '(' FormalParameterSections ';' K_DOT_DOT ')' { $$ = $2; - $$.has_vararg = 1; + $$.abi = jit_abi_vararg; } ; +OptAbi + : /* empty */ { $$ = jit_abi_cdecl; } + | K_FASTCALL { $$ = jit_abi_fastcall; } + | K_STDCALL { $$ = jit_abi_stdcall; } + ; + FormalParameterSections : FormalParameterSection { $$ = $1; } | FormalParameterSections ';' FormalParameterSection { diff --git a/dpas/dpas-scanner.l b/dpas/dpas-scanner.l index 278abbb..23dccbd 100644 --- a/dpas/dpas-scanner.l +++ b/dpas/dpas-scanner.l @@ -182,6 +182,7 @@ WHITE [ \t\v\r\f] "else" { RETURNTOK(K_ELSE); } "end" { RETURNTOK(K_END); } "exit" { RETURNTOK(K_EXIT); } +"fastcall" { RETURNTOK(K_FASTCALL); } "finally" { RETURNTOK(K_FINALLY); } "for" { RETURNTOK(K_FOR); } "forward" { RETURNTOK(K_FORWARD); } @@ -207,6 +208,7 @@ WHITE [ \t\v\r\f] "shl" { RETURNTOK(K_SHL); } "shr" { RETURNTOK(K_SHR); } "sizeof" { RETURNTOK(K_SIZEOF); } +"stdcall" { RETURNTOK(K_STDCALL); } "then" { RETURNTOK(K_THEN); } "throw" { RETURNTOK(K_THROW); } "to" { RETURNTOK(K_TO); } diff --git a/jit/jit-rules-x86.c b/jit/jit-rules-x86.c index 7fbd2d7..d2b5b40 100644 --- a/jit/jit-rules-x86.c +++ b/jit/jit-rules-x86.c @@ -427,7 +427,7 @@ int _jit_create_call_setup_insns while(size > index) { size -= sizeof(void *); - value = jit_value_create(func, jit_type_void_ptr); + value = jit_insn_address_of(func, partial); if(!value) { return 0; @@ -443,10 +443,11 @@ int _jit_create_call_setup_insns return 0; } } + word_regs = 2; while(size > 0) { size -= sizeof(void *); - value = jit_value_create(func, jit_type_void_ptr); + value = jit_insn_address_of(func, partial); if(!value) { return 0; diff --git a/jit/jit-rules-x86.sel b/jit/jit-rules-x86.sel index 5a5792b..0b50bde 100644 --- a/jit/jit-rules-x86.sel +++ b/jit/jit-rules-x86.sel @@ -1894,10 +1894,47 @@ JIT_OP_COPY_LOAD_USHORT: unary JIT_OP_COPY_INT: unary [reg] -> {} -JIT_OP_COPY_LONG: spill_before +JIT_OP_COPY_LONG: manual [] -> { - /* TODO */ - TODO(); + unsigned char *inst; + int offset, offset2, reg, reg2; + _jit_regs_force_out(gen, insn->dest, 1); + _jit_gen_fix_value(insn->dest); + offset = insn->dest->frame_offset; + if(jit_value_is_constant(insn->value1)) + { + inst = gen->posn.ptr; + if(!jit_cache_check_for_n(&(gen->posn), 32)) + { + jit_cache_mark_full(&(gen->posn)); + return; + } + x86_mov_membase_imm(inst, X86_EBP, offset, + ((int *)(insn->value1->address))[0], 4); + x86_mov_membase_imm(inst, X86_EBP, offset + 4, + ((int *)(insn->value1->address))[1], 4); + gen->posn.ptr = inst; + } + else + { + _jit_regs_force_out(gen, insn->value1, 0); + _jit_gen_fix_value(insn->value1); + offset2 = insn->value1->frame_offset; + _jit_regs_get_reg_pair(gen, -1, -1, -1, ®, ®2); + reg = _jit_reg_info[reg].cpu_reg; + reg2 = _jit_reg_info[reg2].cpu_reg; + inst = gen->posn.ptr; + if(!jit_cache_check_for_n(&(gen->posn), 32)) + { + jit_cache_mark_full(&(gen->posn)); + return; + } + x86_mov_reg_membase(inst, reg, X86_EBP, offset2, 4); + x86_mov_reg_membase(inst, reg2, X86_EBP, offset2 + 4, 4); + x86_mov_membase_reg(inst, X86_EBP, offset, reg, 4); + x86_mov_membase_reg(inst, X86_EBP, offset + 4, reg2, 4); + gen->posn.ptr = inst; + } } JIT_OP_COPY_FLOAT32: unary, stack diff --git a/tests/Makefile.am b/tests/Makefile.am index 965b787..6804775 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,4 +1,5 @@ TESTS = coerce.pas \ - math.pas + math.pas \ + param.pas TESTS_ENVIRONMENT = $(top_builddir)/dpas/dpas --dont-fold diff --git a/tests/param.pas b/tests/param.pas new file mode 100644 index 0000000..5258ff8 --- /dev/null +++ b/tests/param.pas @@ -0,0 +1,411 @@ +(* + * param.pas - Test parameter passing. + * + * Copyright (C) 2004 Southern Storm Software, Pty Ltd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + *) + +program local; + +var + failed: Boolean; + +procedure run(msg: String; value: Boolean); +begin + Write(msg); + Write(" ... "); + if value then begin + WriteLn("ok"); + end else begin + WriteLn("failed"); + failed := True; + end; +end; + +{ Test large numbers of 32-bit int parameters, which should stress + both register and stack parameter passing } +procedure param_int + (p1, p2, p3, p4, p5, p6, p7, p8, + p9, p10, p11, p12, p13, p14, p15, p16, + p17, p18, p19, p20, p21, p22, p23, p24, + p25, p26, p27, p28, p29, p30, p31, p32: integer); +begin + run("param_int", + (p1 = 1) and (p2 = 2) and (p3 = 3) and (p4 = 4) and + (p5 = 5) and (p6 = 6) and (p7 = 7) and (p8 = 8) and + (p9 = 9) and (p10 = 10) and (p11 = 11) and (p12 = 12) and + (p13 = 13) and (p14 = 14) and (p15 = 15) and (p16 = 16) and + (p17 = 17) and (p18 = 18) and (p19 = 19) and (p20 = 20) and + (p21 = 21) and (p22 = 22) and (p23 = 23) and (p24 = 24) and + (p25 = 25) and (p26 = 26) and (p27 = 27) and (p28 = 28) and + (p29 = 29) and (p30 = 30) and (p31 = 31) and (p32 = 32)); +end; +procedure param_int_fastcall + (p1, p2, p3, p4, p5, p6, p7, p8, + p9, p10, p11, p12, p13, p14, p15, p16, + p17, p18, p19, p20, p21, p22, p23, p24, + p25, p26, p27, p28, p29, p30, p31, p32: integer) fastcall; +begin + run("param_int_fastcall", + (p1 = 1) and (p2 = 2) and (p3 = 3) and (p4 = 4) and + (p5 = 5) and (p6 = 6) and (p7 = 7) and (p8 = 8) and + (p9 = 9) and (p10 = 10) and (p11 = 11) and (p12 = 12) and + (p13 = 13) and (p14 = 14) and (p15 = 15) and (p16 = 16) and + (p17 = 17) and (p18 = 18) and (p19 = 19) and (p20 = 20) and + (p21 = 21) and (p22 = 22) and (p23 = 23) and (p24 = 24) and + (p25 = 25) and (p26 = 26) and (p27 = 27) and (p28 = 28) and + (p29 = 29) and (p30 = 30) and (p31 = 31) and (p32 = 32)); +end; +procedure param_int_stdcall + (p1, p2, p3, p4, p5, p6, p7, p8, + p9, p10, p11, p12, p13, p14, p15, p16, + p17, p18, p19, p20, p21, p22, p23, p24, + p25, p26, p27, p28, p29, p30, p31, p32: integer) stdcall; +begin + run("param_int_stdcall", + (p1 = 1) and (p2 = 2) and (p3 = 3) and (p4 = 4) and + (p5 = 5) and (p6 = 6) and (p7 = 7) and (p8 = 8) and + (p9 = 9) and (p10 = 10) and (p11 = 11) and (p12 = 12) and + (p13 = 13) and (p14 = 14) and (p15 = 15) and (p16 = 16) and + (p17 = 17) and (p18 = 18) and (p19 = 19) and (p20 = 20) and + (p21 = 21) and (p22 = 22) and (p23 = 23) and (p24 = 24) and + (p25 = 25) and (p26 = 26) and (p27 = 27) and (p28 = 28) and + (p29 = 29) and (p30 = 30) and (p31 = 31) and (p32 = 32)); +end; + +{ Test large numbers of 64-bit int parameters, which should stress + both register and stack parameter passing. On a 32-bit system, + parameters will be passed in pairs. If the test platform has an + odd number of word registers, then this will also test long + splitting on 32-bit systems } +procedure param_long + (p1, p2, p3, p4, p5, p6, p7, p8, + p9, p10, p11, p12, p13, p14, p15, p16, + p17, p18, p19, p20, p21, p22, p23, p24, + p25, p26, p27, p28, p29, p30, p31, p32: longint); +begin + run("param_long", + (p1 = 1) and (p2 = 2) and (p3 = 3) and (p4 = 4) and + (p5 = 5) and (p6 = 6) and (p7 = 7) and (p8 = 8) and + (p9 = 9) and (p10 = 10) and (p11 = 11) and (p12 = 12) and + (p13 = 13) and (p14 = 14) and (p15 = 15) and (p16 = 16) and + (p17 = 17) and (p18 = 18) and (p19 = 19) and (p20 = 20) and + (p21 = 21) and (p22 = 22) and (p23 = 23) and (p24 = 24) and + (p25 = 25) and (p26 = 26) and (p27 = 27) and (p28 = 28) and + (p29 = 29) and (p30 = 30) and (p31 = 31) and (p32 = 32)); +end; +procedure param_long_fastcall + (p1, p2, p3, p4, p5, p6, p7, p8, + p9, p10, p11, p12, p13, p14, p15, p16, + p17, p18, p19, p20, p21, p22, p23, p24, + p25, p26, p27, p28, p29, p30, p31, p32: longint) fastcall; +begin + run("param_long_fastcall", + (p1 = 1) and (p2 = 2) and (p3 = 3) and (p4 = 4) and + (p5 = 5) and (p6 = 6) and (p7 = 7) and (p8 = 8) and + (p9 = 9) and (p10 = 10) and (p11 = 11) and (p12 = 12) and + (p13 = 13) and (p14 = 14) and (p15 = 15) and (p16 = 16) and + (p17 = 17) and (p18 = 18) and (p19 = 19) and (p20 = 20) and + (p21 = 21) and (p22 = 22) and (p23 = 23) and (p24 = 24) and + (p25 = 25) and (p26 = 26) and (p27 = 27) and (p28 = 28) and + (p29 = 29) and (p30 = 30) and (p31 = 31) and (p32 = 32)); +end; +procedure param_long_stdcall + (p1, p2, p3, p4, p5, p6, p7, p8, + p9, p10, p11, p12, p13, p14, p15, p16, + p17, p18, p19, p20, p21, p22, p23, p24, + p25, p26, p27, p28, p29, p30, p31, p32: longint) stdcall; +begin + run("param_long_stdcall", + (p1 = 1) and (p2 = 2) and (p3 = 3) and (p4 = 4) and + (p5 = 5) and (p6 = 6) and (p7 = 7) and (p8 = 8) and + (p9 = 9) and (p10 = 10) and (p11 = 11) and (p12 = 12) and + (p13 = 13) and (p14 = 14) and (p15 = 15) and (p16 = 16) and + (p17 = 17) and (p18 = 18) and (p19 = 19) and (p20 = 20) and + (p21 = 21) and (p22 = 22) and (p23 = 23) and (p24 = 24) and + (p25 = 25) and (p26 = 26) and (p27 = 27) and (p28 = 28) and + (p29 = 29) and (p30 = 30) and (p31 = 31) and (p32 = 32)); +end; + +{ Test long splitting on 32-bit systems that have an even + number of word registers } +procedure param_int_long + (p1: integer; p2, p3, p4, p5, p6, p7, p8, + p9, p10, p11, p12, p13, p14, p15, p16, + p17, p18, p19, p20, p21, p22, p23, p24, + p25, p26, p27, p28, p29, p30, p31, p32: longint); +begin + run("param_int_long", + (p1 = 1) and (p2 = 2) and (p3 = 3) and (p4 = 4) and + (p5 = 5) and (p6 = 6) and (p7 = 7) and (p8 = 8) and + (p9 = 9) and (p10 = 10) and (p11 = 11) and (p12 = 12) and + (p13 = 13) and (p14 = 14) and (p15 = 15) and (p16 = 16) and + (p17 = 17) and (p18 = 18) and (p19 = 19) and (p20 = 20) and + (p21 = 21) and (p22 = 22) and (p23 = 23) and (p24 = 24) and + (p25 = 25) and (p26 = 26) and (p27 = 27) and (p28 = 28) and + (p29 = 29) and (p30 = 30) and (p31 = 31) and (p32 = 32)); +end; +procedure param_int_long_fastcall + (p1: integer; p2, p3, p4, p5, p6, p7, p8, + p9, p10, p11, p12, p13, p14, p15, p16, + p17, p18, p19, p20, p21, p22, p23, p24, + p25, p26, p27, p28, p29, p30, p31, p32: longint) fastcall; +begin + run("param_int_long_fastcall", + (p1 = 1) and (p2 = 2) and (p3 = 3) and (p4 = 4) and + (p5 = 5) and (p6 = 6) and (p7 = 7) and (p8 = 8) and + (p9 = 9) and (p10 = 10) and (p11 = 11) and (p12 = 12) and + (p13 = 13) and (p14 = 14) and (p15 = 15) and (p16 = 16) and + (p17 = 17) and (p18 = 18) and (p19 = 19) and (p20 = 20) and + (p21 = 21) and (p22 = 22) and (p23 = 23) and (p24 = 24) and + (p25 = 25) and (p26 = 26) and (p27 = 27) and (p28 = 28) and + (p29 = 29) and (p30 = 30) and (p31 = 31) and (p32 = 32)); +end; +procedure param_int_long_stdcall + (p1: integer; p2, p3, p4, p5, p6, p7, p8, + p9, p10, p11, p12, p13, p14, p15, p16, + p17, p18, p19, p20, p21, p22, p23, p24, + p25, p26, p27, p28, p29, p30, p31, p32: longint) stdcall; +begin + run("param_int_long_stdcall", + (p1 = 1) and (p2 = 2) and (p3 = 3) and (p4 = 4) and + (p5 = 5) and (p6 = 6) and (p7 = 7) and (p8 = 8) and + (p9 = 9) and (p10 = 10) and (p11 = 11) and (p12 = 12) and + (p13 = 13) and (p14 = 14) and (p15 = 15) and (p16 = 16) and + (p17 = 17) and (p18 = 18) and (p19 = 19) and (p20 = 20) and + (p21 = 21) and (p22 = 22) and (p23 = 23) and (p24 = 24) and + (p25 = 25) and (p26 = 26) and (p27 = 27) and (p28 = 28) and + (p29 = 29) and (p30 = 30) and (p31 = 31) and (p32 = 32)); +end; + +{ Test passing 32-bit float values in registers and on the stack } +procedure param_float32 + (p1, p2, p3, p4, p5, p6, p7, p8, + p9, p10, p11, p12, p13, p14, p15, p16, + p17, p18, p19, p20, p21, p22, p23, p24, + p25, p26, p27, p28, p29, p30, p31, p32: shortreal); +begin + run("param_float32", + (p1 = 1) and (p2 = 2) and (p3 = 3) and (p4 = 4) and + (p5 = 5) and (p6 = 6) and (p7 = 7) and (p8 = 8) and + (p9 = 9) and (p10 = 10) and (p11 = 11) and (p12 = 12) and + (p13 = 13) and (p14 = 14) and (p15 = 15) and (p16 = 16) and + (p17 = 17) and (p18 = 18) and (p19 = 19) and (p20 = 20) and + (p21 = 21) and (p22 = 22) and (p23 = 23) and (p24 = 24) and + (p25 = 25) and (p26 = 26) and (p27 = 27) and (p28 = 28) and + (p29 = 29) and (p30 = 30) and (p31 = 31) and (p32 = 32)); +end; + +{ Test passing 64-bit float values in registers and on the stack } +procedure param_float64 + (p1, p2, p3, p4, p5, p6, p7, p8, + p9, p10, p11, p12, p13, p14, p15, p16, + p17, p18, p19, p20, p21, p22, p23, p24, + p25, p26, p27, p28, p29, p30, p31, p32: real); +begin + run("param_float64", + (p1 = 1) and (p2 = 2) and (p3 = 3) and (p4 = 4) and + (p5 = 5) and (p6 = 6) and (p7 = 7) and (p8 = 8) and + (p9 = 9) and (p10 = 10) and (p11 = 11) and (p12 = 12) and + (p13 = 13) and (p14 = 14) and (p15 = 15) and (p16 = 16) and + (p17 = 17) and (p18 = 18) and (p19 = 19) and (p20 = 20) and + (p21 = 21) and (p22 = 22) and (p23 = 23) and (p24 = 24) and + (p25 = 25) and (p26 = 26) and (p27 = 27) and (p28 = 28) and + (p29 = 29) and (p30 = 30) and (p31 = 31) and (p32 = 32)); +end; + +{ Test passing native float values in registers and on the stack } +procedure param_nfloat + (p1, p2, p3, p4, p5, p6, p7, p8, + p9, p10, p11, p12, p13, p14, p15, p16, + p17, p18, p19, p20, p21, p22, p23, p24, + p25, p26, p27, p28, p29, p30, p31, p32: longreal); +begin + run("param_nfloat", + (p1 = 1) and (p2 = 2) and (p3 = 3) and (p4 = 4) and + (p5 = 5) and (p6 = 6) and (p7 = 7) and (p8 = 8) and + (p9 = 9) and (p10 = 10) and (p11 = 11) and (p12 = 12) and + (p13 = 13) and (p14 = 14) and (p15 = 15) and (p16 = 16) and + (p17 = 17) and (p18 = 18) and (p19 = 19) and (p20 = 20) and + (p21 = 21) and (p22 = 22) and (p23 = 23) and (p24 = 24) and + (p25 = 25) and (p26 = 26) and (p27 = 27) and (p28 = 28) and + (p29 = 29) and (p30 = 30) and (p31 = 31) and (p32 = 32)); +end; + +{ Test passing both int and float64 parameters } +procedure param_int_float64 + (p1, p2, p3, p4, p5, p6, p7, p8, + p9, p10, p11, p12, p13, p14, p15, p16, + p17, p18, p19, p20, p21, p22, p23, p24, + p25, p26, p27, p28, p29, p30, p31, p32: integer; + q1, q2, q3, q4, q5, q6, q7, q8, + q9, q10, q11, q12, q13, q14, q15, q16, + q17, q18, q19, q20, q21, q22, q23, q24, + q25, q26, q27, q28, q29, q30, q31, q32: real); +begin + run("param_int_float64", + (p1 = 1) and (p2 = 2) and (p3 = 3) and (p4 = 4) and + (p5 = 5) and (p6 = 6) and (p7 = 7) and (p8 = 8) and + (p9 = 9) and (p10 = 10) and (p11 = 11) and (p12 = 12) and + (p13 = 13) and (p14 = 14) and (p15 = 15) and (p16 = 16) and + (p17 = 17) and (p18 = 18) and (p19 = 19) and (p20 = 20) and + (p21 = 21) and (p22 = 22) and (p23 = 23) and (p24 = 24) and + (p25 = 25) and (p26 = 26) and (p27 = 27) and (p28 = 28) and + (p29 = 29) and (p30 = 30) and (p31 = 31) and (p32 = 32) and + (q1 = 1) and (q2 = 2) and (q3 = 3) and (q4 = 4) and + (q5 = 5) and (q6 = 6) and (q7 = 7) and (q8 = 8) and + (q9 = 9) and (q10 = 10) and (q11 = 11) and (q12 = 12) and + (q13 = 13) and (q14 = 14) and (q15 = 15) and (q16 = 16) and + (q17 = 17) and (q18 = 18) and (q19 = 19) and (q20 = 20) and + (q21 = 21) and (q22 = 22) and (q23 = 23) and (q24 = 24) and + (q25 = 25) and (q26 = 26) and (q27 = 27) and (q28 = 28) and + (q29 = 29) and (q30 = 30) and (q31 = 31) and (q32 = 32)); +end; + +{ Test passing both int and float64 parameters, reversed from above } +procedure param_float64_int + (p1, p2, p3, p4, p5, p6, p7, p8, + p9, p10, p11, p12, p13, p14, p15, p16, + p17, p18, p19, p20, p21, p22, p23, p24, + p25, p26, p27, p28, p29, p30, p31, p32: real; + q1, q2, q3, q4, q5, q6, q7, q8, + q9, q10, q11, q12, q13, q14, q15, q16, + q17, q18, q19, q20, q21, q22, q23, q24, + q25, q26, q27, q28, q29, q30, q31, q32: integer); +begin + run("param_float64_int", + (p1 = 1) and (p2 = 2) and (p3 = 3) and (p4 = 4) and + (p5 = 5) and (p6 = 6) and (p7 = 7) and (p8 = 8) and + (p9 = 9) and (p10 = 10) and (p11 = 11) and (p12 = 12) and + (p13 = 13) and (p14 = 14) and (p15 = 15) and (p16 = 16) and + (p17 = 17) and (p18 = 18) and (p19 = 19) and (p20 = 20) and + (p21 = 21) and (p22 = 22) and (p23 = 23) and (p24 = 24) and + (p25 = 25) and (p26 = 26) and (p27 = 27) and (p28 = 28) and + (p29 = 29) and (p30 = 30) and (p31 = 31) and (p32 = 32) and + (q1 = 1) and (q2 = 2) and (q3 = 3) and (q4 = 4) and + (q5 = 5) and (q6 = 6) and (q7 = 7) and (q8 = 8) and + (q9 = 9) and (q10 = 10) and (q11 = 11) and (q12 = 12) and + (q13 = 13) and (q14 = 14) and (q15 = 15) and (q16 = 16) and + (q17 = 17) and (q18 = 18) and (q19 = 19) and (q20 = 20) and + (q21 = 21) and (q22 = 22) and (q23 = 23) and (q24 = 24) and + (q25 = 25) and (q26 = 26) and (q27 = 27) and (q28 = 28) and + (q29 = 29) and (q30 = 30) and (q31 = 31) and (q32 = 32)); +end; + +{ Test passing both int and float 64 parameters, alternatively mixed } +procedure param_int_float64_mixed + ( p1: integer; q1: real; p2: integer; q2: real; + p3: integer; q3: real; p4: integer; q4: real; + p5: integer; q5: real; p6: integer; q6: real; + p7: integer; q7: real; p8: integer; q8: real; + p9: integer; q9: real; p10: integer; q10: real; + p11: integer; q11: real; p12: integer; q12: real; + p13: integer; q13: real; p14: integer; q14: real; + p15: integer; q15: real; p16: integer; q16: real; + p17: integer; q17: real; p18: integer; q18: real; + p19: integer; q19: real; p20: integer; q20: real; + p21: integer; q21: real; p22: integer; q22: real; + p23: integer; q23: real; p24: integer; q24: real; + p25: integer; q25: real; p26: integer; q26: real; + p27: integer; q27: real; p28: integer; q28: real; + p29: integer; q29: real; p30: integer; q30: real; + p31: integer; q31: real; p32: integer; q32: real); +begin + run("param_int_float64_mixed", + (p1 = 1) and (q1 = 2) and (p2 = 3) and (q2 = 4) and + (p3 = 5) and (q3 = 6) and (p4 = 7) and (q4 = 8) and + (p5 = 9) and (q5 = 10) and (p6 = 11) and (q6 = 12) and + (p7 = 13) and (q7 = 14) and (p8 = 15) and (q8 = 16) and + (p9 = 17) and (q9 = 18) and (p10 = 19) and (q10 = 20) and + (p11 = 21) and (q11 = 22) and (p12 = 23) and (q12 = 24) and + (p13 = 25) and (q13 = 26) and (p14 = 27) and (q14 = 28) and + (p15 = 29) and (q15 = 30) and (p16 = 31) and (q16 = 32) and + (p17 = 1) and (q17 = 2) and (p18 = 3) and (q18 = 4) and + (p19 = 5) and (q19 = 6) and (p20 = 7) and (q20 = 8) and + (p21 = 9) and (q21 = 10) and (p22 = 11) and (q22 = 12) and + (p23 = 13) and (q23 = 14) and (p24 = 15) and (q24 = 16) and + (p25 = 17) and (q25 = 18) and (p26 = 19) and (q26 = 20) and + (p27 = 21) and (q27 = 22) and (p28 = 23) and (q28 = 24) and + (p29 = 25) and (q29 = 26) and (p30 = 27) and (q30 = 28) and + (p31 = 29) and (q31 = 30) and (p32 = 31) and (q32 = 32)); +end; + +procedure run_tests; +begin + param_int + (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, + 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32); + param_int_fastcall + (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, + 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32); + param_int_stdcall + (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, + 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32); + + param_long + (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, + 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32); + param_long_fastcall + (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, + 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32); + param_long_stdcall + (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, + 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32); + + param_int_long + (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, + 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32); + param_int_long_fastcall + (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, + 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32); + param_int_long_stdcall + (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, + 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32); + + param_float32 + (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, + 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32); + param_float64 + (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, + 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32); + param_nfloat + (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, + 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32); + + param_int_float64 + (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, + 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, + 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, + 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32); + param_float64_int + (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, + 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, + 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, + 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32); + param_int_float64_mixed + (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, + 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, + 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, + 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32); +end; + +begin + failed := False; + run_tests; + if failed then begin + Terminate(1); + end; +end. diff --git a/tools/gen-apply.c b/tools/gen-apply.c index d6e39c2..8bf30f4 100644 --- a/tools/gen-apply.c +++ b/tools/gen-apply.c @@ -2311,8 +2311,8 @@ int main(int argc, char *argv[]) /* Detect the calling conventions for structures */ detect_struct_conventions(); - /* Detect support for x86 FASTCALL handling code (Win32 only) */ -#if defined(PLATFORM_IS_WIN32) + /* Detect support for x86 FASTCALL handling code */ +#if defined(PLATFORM_IS_X86) x86_fastcall = 1; #endif