From 6ef4a6242a8f32f393901396e4636e8dc99eb250 Mon Sep 17 00:00:00 2001 From: hubicka Date: Tue, 6 Jan 2004 10:49:58 +0000 Subject: [PATCH] * gcc.dg/i386-sse-5.c: New test * g++.dg/eh/simd-1.c: Add -w argument for i386. * i386.c (init_cumulative_args): Add handling of MMX_REGPARM. (function_arg_advance): Do not pass aggregates in SSE; deal handling of MMX_REGPARM. (function_arg): Add new warnings about ABI changes; fix SSE_REGPARM; add MMX_REGPARM. * i386.h (ix86_args): Add mmx_words/mmx_regs/mmx_regno fields. (SSE_REGPARM_MAX): Default to 3 on i386 -msse ABI. (MMX_REGPARM_MAX): Similarly for -mmmx. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@75467 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 11 ++++++++ gcc/config/i386/i386.c | 56 +++++++++++++++++++++++++++++++++++---- gcc/config/i386/i386.h | 7 ++++- gcc/testsuite/ChangeLog | 5 ++++ gcc/testsuite/g++.dg/eh/simd-1.C | 1 + gcc/testsuite/gcc.dg/i386-sse-5.c | 8 ++++++ 6 files changed, 82 insertions(+), 6 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/i386-sse-5.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index d2733425427..109b0d68fb0 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,14 @@ +2004-01-06 Jan Hubicka + + * i386.c (init_cumulative_args): Add handling of MMX_REGPARM. + (function_arg_advance): Do not pass aggregates in SSE; deal handling + of MMX_REGPARM. + (function_arg): Add new warnings about ABI changes; fix SSE_REGPARM; + add MMX_REGPARM. + * i386.h (ix86_args): Add mmx_words/mmx_regs/mmx_regno fields. + (SSE_REGPARM_MAX): Default to 3 on i386 -msse ABI. + (MMX_REGPARM_MAX): Similarly for -mmmx. + 2004-01-05 Kazu Hirata * config/sh/linux.h: Fix comment formatting. diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index 842a29cd7bf..be4e542b9de 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -1832,6 +1832,7 @@ init_cumulative_args (CUMULATIVE_ARGS *cum, /* Argument info to initialize */ else cum->nregs = ix86_regparm; cum->sse_nregs = SSE_REGPARM_MAX; + cum->mmx_nregs = MMX_REGPARM_MAX; cum->maybe_vaarg = false; /* Use ecx and edx registers if function has fastcall attribute */ @@ -2430,8 +2431,8 @@ function_arg_advance (CUMULATIVE_ARGS *cum, /* current arg information */ if (TARGET_DEBUG_ARG) fprintf (stderr, - "function_adv (sz=%d, wds=%2d, nregs=%d, mode=%s, named=%d)\n\n", - words, cum->words, cum->nregs, GET_MODE_NAME (mode), named); + "function_adv (sz=%d, wds=%2d, nregs=%d, ssenregs=%d, mode=%s, named=%d)\n\n", + words, cum->words, cum->nregs, cum->sse_nregs, GET_MODE_NAME (mode), named); if (TARGET_64BIT) { int int_nregs, sse_nregs; @@ -2449,7 +2450,8 @@ function_arg_advance (CUMULATIVE_ARGS *cum, /* current arg information */ } else { - if (TARGET_SSE && mode == TImode) + if (TARGET_SSE && SSE_REG_MODE_P (mode) + && (!type || !AGGREGATE_TYPE_P (type))) { cum->sse_words += words; cum->sse_nregs -= 1; @@ -2460,6 +2462,18 @@ function_arg_advance (CUMULATIVE_ARGS *cum, /* current arg information */ cum->sse_regno = 0; } } + else if (TARGET_MMX && MMX_REG_MODE_P (mode) + && (!type || !AGGREGATE_TYPE_P (type))) + { + cum->mmx_words += words; + cum->mmx_nregs -= 1; + cum->mmx_regno += 1; + if (cum->mmx_nregs <= 0) + { + cum->mmx_nregs = 0; + cum->mmx_regno = 0; + } + } else { cum->words += words; @@ -2499,6 +2513,7 @@ function_arg (CUMULATIVE_ARGS *cum, /* current arg information */ int bytes = (mode == BLKmode) ? int_size_in_bytes (type) : (int) GET_MODE_SIZE (mode); int words = (bytes + UNITS_PER_WORD - 1) / UNITS_PER_WORD; + static bool warnedsse, warnedmmx; /* Handle a hidden AL argument containing number of registers for varargs x86-64 functions. For i386 ABI just return constm1_rtx to avoid @@ -2552,8 +2567,39 @@ function_arg (CUMULATIVE_ARGS *cum, /* current arg information */ } break; case TImode: - if (cum->sse_nregs) - ret = gen_rtx_REG (mode, cum->sse_regno); + case V16QImode: + case V8HImode: + case V4SImode: + case V2DImode: + case V4SFmode: + case V2DFmode: + if (!type || !AGGREGATE_TYPE_P (type)) + { + if (!TARGET_SSE && !warnedmmx) + { + warnedsse = true; + warning ("SSE vector argument without SSE enabled " + "changes the ABI"); + } + if (cum->sse_nregs) + ret = gen_rtx_REG (mode, cum->sse_regno + FIRST_SSE_REG); + } + break; + case V8QImode: + case V4HImode: + case V2SImode: + case V2SFmode: + if (!type || !AGGREGATE_TYPE_P (type)) + { + if (!TARGET_MMX && !warnedmmx) + { + warnedmmx = true; + warning ("MMX vector argument without MMX enabled " + "changes the ABI"); + } + if (cum->mmx_nregs) + ret = gen_rtx_REG (mode, cum->mmx_regno + FIRST_MMX_REG); + } break; } diff --git a/gcc/config/i386/i386.h b/gcc/config/i386/i386.h index 148726adb96..791c5ce56fd 100644 --- a/gcc/config/i386/i386.h +++ b/gcc/config/i386/i386.h @@ -1744,6 +1744,9 @@ typedef struct ix86_args { int sse_words; /* # sse words passed so far */ int sse_nregs; /* # sse registers available for passing */ int sse_regno; /* next available sse register number */ + int mmx_words; /* # mmx words passed so far */ + int mmx_nregs; /* # mmx registers available for passing */ + int mmx_regno; /* next available mmx register number */ int maybe_vaarg; /* true for calls to possibly vardic fncts. */ } CUMULATIVE_ARGS; @@ -2531,7 +2534,9 @@ enum ix86_builtins #define REGPARM_MAX (TARGET_64BIT ? 6 : 3) -#define SSE_REGPARM_MAX (TARGET_64BIT ? 8 : 0) +#define SSE_REGPARM_MAX (TARGET_64BIT ? 8 : (TARGET_SSE ? 3 : 0)) + +#define MMX_REGPARM_MAX (TARGET_64BIT ? 0 : (TARGET_MMX ? 3 : 0)) /* Specify the machine mode that this machine uses diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index d9c510868de..ca55ce96ce0 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2004-01-06 Jan Hubicka + + * gcc.dg/i386-sse-5.c: New test + * g++.dg/eh/simd-1.c: Add -w argument for i386. + 2004-01-05 Mark Mitchell PR c++/12815 diff --git a/gcc/testsuite/g++.dg/eh/simd-1.C b/gcc/testsuite/g++.dg/eh/simd-1.C index 9cad5ad9d10..2be5e63cba4 100644 --- a/gcc/testsuite/g++.dg/eh/simd-1.C +++ b/gcc/testsuite/g++.dg/eh/simd-1.C @@ -1,6 +1,7 @@ // Test EH when V2SI SIMD registers are involved. // Contributed by Aldy Hernandez (aldy@quesejoda.com). // { dg-options "-O" } +// { dg-options "-O -w" { target i?86-*-* } } // { dg-do run } // { dg-error "" "PR target/12916" { target sparc*-*-* } 10 } diff --git a/gcc/testsuite/gcc.dg/i386-sse-5.c b/gcc/testsuite/gcc.dg/i386-sse-5.c new file mode 100644 index 00000000000..edb4fb4519e --- /dev/null +++ b/gcc/testsuite/gcc.dg/i386-sse-5.c @@ -0,0 +1,8 @@ +/* { dg-do compile { target i?86-*-* } } */ +/* { dg-options "-Winline -O2 -march=i386" } */ +typedef int v2df __attribute__ ((mode(V2DF))); +v2df p; +q(v2df t) +{ /* { dg-warning "SSE" "" } */ + p=t; +} -- 2.11.4.GIT