Commit 2b8b9f74 by Ben Elliston Committed by Ulrich Weigand

ea.exp: New file.

2009-10-26  Ben Elliston  <bje@au.ibm.com>
	    Michael Meissner  <meissner@linux.vnet.ibm.com>
	    Ulrich Weigand  <uweigand@de.ibm.com>

	* gcc.target/spu/ea/ea.exp: New file.
	* gcc.target/spu/ea/cache1.c: Likewise.
	* gcc.target/spu/ea/cast1.c: Likewise.
	* gcc.target/spu/ea/cast2.c: Likewise.
	* gcc.target/spu/ea/compile1.c: Likewise.
	* gcc.target/spu/ea/compile2.c: Likewise.
	* gcc.target/spu/ea/cppdefine.c: Likewise.
	* gcc.target/spu/ea/errors1.c: Likewise.
	* gcc.target/spu/ea/errors2.c: Likewise.
	* gcc.target/spu/ea/execute1.c: Likewise.
	* gcc.target/spu/ea/execute2.c: Likewise.
	* gcc.target/spu/ea/execute3.c: Likewise.
	* gcc.target/spu/ea/ops1.c: Likewise.
	* gcc.target/spu/ea/ops2.c: Likewise.
	* gcc.target/spu/ea/options1.c: Likewise.
	* gcc.target/spu/ea/test-sizes.c: Likewise.

Co-Authored-By: Michael Meissner <meissner@linux.vnet.ibm.com>
Co-Authored-By: Ulrich Weigand <uweigand@de.ibm.com>

From-SVN: r153576
parent 299456f3
2009-10-26 Ben Elliston <bje@au.ibm.com>
Michael Meissner <meissner@linux.vnet.ibm.com>
Ulrich Weigand <uweigand@de.ibm.com>
* gcc.target/spu/ea/ea.exp: New file.
* gcc.target/spu/ea/cache1.c: Likewise.
* gcc.target/spu/ea/cast1.c: Likewise.
* gcc.target/spu/ea/cast2.c: Likewise.
* gcc.target/spu/ea/compile1.c: Likewise.
* gcc.target/spu/ea/compile2.c: Likewise.
* gcc.target/spu/ea/cppdefine.c: Likewise.
* gcc.target/spu/ea/errors1.c: Likewise.
* gcc.target/spu/ea/errors2.c: Likewise.
* gcc.target/spu/ea/execute1.c: Likewise.
* gcc.target/spu/ea/execute2.c: Likewise.
* gcc.target/spu/ea/execute3.c: Likewise.
* gcc.target/spu/ea/ops1.c: Likewise.
* gcc.target/spu/ea/ops2.c: Likewise.
* gcc.target/spu/ea/options1.c: Likewise.
* gcc.target/spu/ea/test-sizes.c: Likewise.
2009-10-26 Jakub Jelinek <jakub@redhat.com>
PR bootstrap/41345
......
/* Copyright (C) 2009 Free Software Foundation, Inc.
This file 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 3 of the License, or (at your option)
any later version.
This file 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 file; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */
/* { dg-do run } */
/* { dg-require-effective-target "ealib" } */
#include <stdlib.h>
#include <string.h>
#include <ea.h>
#include <spu_cache.h>
#ifdef __EA64__
#define addr unsigned long long
#else
#define addr unsigned long
#endif
static __ea void *bigblock;
static __ea void *block;
static int *ls_block;
extern char __cache_tag_array_size[];
#define CACHE_SIZE (4 * (int) &__cache_tag_array_size[0])
#define LINE_SIZE ((addr)128)
void
init_mem (void)
{
bigblock = malloc_ea (CACHE_SIZE + 2 * LINE_SIZE);
block = malloc_ea (2 * LINE_SIZE);
ls_block = malloc (LINE_SIZE);
memset_ea (bigblock, 0, CACHE_SIZE + 2 * LINE_SIZE);
memset_ea (block, -1, 2 * LINE_SIZE);
memset (ls_block, -1, LINE_SIZE);
cache_flush ();
}
/* Test 1: Simple cache fetching. */
void
test1 (void)
{
addr aligned = ((((addr) block) + LINE_SIZE - 1) & -LINE_SIZE);
int *p1 = NULL;
int *p2 = NULL;
int i = 0;
/* First, check if the same addr give the same cache ptr. */
p1 = cache_fetch ((__ea void *) aligned);
p2 = cache_fetch ((__ea void *) aligned);
if (p1 != p2)
abort ();
/* Check that the data actually is in the cache. */
for (i = 0; i < LINE_SIZE / sizeof (int); i++)
{
if (p1[i] != -1)
abort ();
}
/* Check returning within the cache line. */
p2 = cache_fetch ((__ea void *) (aligned + sizeof (int)));
if (p2 - p1 != 1)
abort ();
/* Finally, check that fetching an LS pointer returns that pointer. */
p1 = cache_fetch ((__ea char *) ls_block);
if (p1 != ls_block)
abort ();
}
/* Test 2: Eviction testing. */
void
test2 (void)
{
addr aligned = ((((addr) block) + LINE_SIZE - 1) & -LINE_SIZE);
int *p = NULL;
int i = 0;
/* First check that clean evictions don't write back. */
p = cache_fetch ((__ea void *) aligned);
for (i = 0; i < LINE_SIZE / sizeof (int); i++)
p[i] = 0;
cache_evict ((__ea void *) aligned);
memcpy_ea ((__ea char *) ls_block, (__ea void *) aligned, LINE_SIZE);
for (i = 0; i < LINE_SIZE / sizeof (int); i++)
{
if (ls_block[i] == 0)
abort ();
}
/* Now check that dirty evictions do write back. */
p = cache_fetch_dirty ((__ea void *) aligned, LINE_SIZE);
for (i = 0; i < LINE_SIZE / sizeof (int); i++)
p[i] = 0;
cache_evict ((__ea void *) aligned);
memcpy_ea ((__ea char *) ls_block, (__ea void *) aligned, LINE_SIZE);
for (i = 0; i < LINE_SIZE / sizeof (int); i++)
{
if (ls_block[i] != 0)
abort ();
}
/* Finally, check that non-atomic writeback only writes dirty bytes. */
for (i = 0; i < LINE_SIZE / sizeof (int); i++)
{
p = cache_fetch_dirty ((__ea void *) (aligned + i * sizeof (int)),
(i % 2) * sizeof (int));
p[0] = -1;
}
cache_evict ((__ea void *) aligned);
memcpy_ea ((__ea char *) ls_block, (__ea void *) aligned, LINE_SIZE);
for (i = 0; i < LINE_SIZE / sizeof (int); i++)
{
if ((ls_block[i] == -1) && (i % 2 == 0))
abort ();
if ((ls_block[i] == 0) && (i % 2 == 1))
abort ();
}
}
/* Test LS forced-eviction. */
void
test3 (void)
{
addr aligned = ((((addr) bigblock) + LINE_SIZE - 1) & -LINE_SIZE);
char *test = NULL;
char *ls = NULL;
int i = 0;
/* Init memory, fill the cache to capacity. */
ls = cache_fetch_dirty ((__ea void *) aligned, LINE_SIZE);
for (i = 1; i < (CACHE_SIZE / LINE_SIZE); i++)
cache_fetch_dirty ((__ea void *) (aligned + i * LINE_SIZE), LINE_SIZE);
memset (ls, -1, LINE_SIZE);
test = cache_fetch ((__ea void *) (aligned + CACHE_SIZE));
/* test == ls indicates cache collision. */
if (test != ls)
abort ();
/* Make sure it actually wrote the cache line. */
for (i = 0; i < LINE_SIZE; i++)
{
if (ls[i] != 0)
abort ();
}
ls = cache_fetch ((__ea void *) aligned);
/* test != ls indicates another entry was evicted. */
if (test == ls)
abort ();
/* Make sure that the previous eviction actually wrote back. */
for (i = 0; i < LINE_SIZE; i++)
{
if (ls[i] != 0xFF)
abort ();
}
}
int
main (int argc, char **argv)
{
init_mem ();
test1 ();
test2 ();
test3 ();
return 0;
}
/* Copyright (C) 2009 Free Software Foundation, Inc.
This file 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 3 of the License, or (at your option)
any later version.
This file 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 file; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */
/* { dg-do run } */
extern void abort (void);
extern unsigned long long __ea_local_store;
__ea int *ppu;
int x, *spu = &x, *spu2;
int
main (int argc, char **argv)
{
ppu = (__ea int *) spu;
spu2 = (int *) ppu;
#ifdef __EA32__
if ((int) ppu != (int) __ea_local_store + (int) spu)
#else
if ((unsigned long long) ppu != __ea_local_store + (unsigned long long)(int) spu)
#endif
abort ();
if (spu != spu2)
abort ();
return 0;
}
/* Copyright (C) 2009 Free Software Foundation, Inc.
This file 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 3 of the License, or (at your option)
any later version.
This file 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 file; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */
/* { dg-do run } */
extern void abort (void);
int array[128];
__ea int *ea;
int *lm;
void verify_ea (void) __attribute__ ((noinline));
void
verify_ea (void)
{
if (ea != (__ea int *)lm)
abort ();
}
void verify_lm (void) __attribute__ ((noinline));
void
verify_lm (void)
{
if ((int *)ea != lm)
abort ();
}
void verify_diff (int x) __attribute__ ((noinline));
void
verify_diff (int x)
{
if (ea - lm != x)
abort ();
}
int
main (int argc, char **argv)
{
ea = 0;
lm = 0;
verify_ea ();
verify_lm ();
verify_diff (0);
ea = &array[64];
lm = &array[64];
verify_ea ();
verify_lm ();
verify_diff (0);
ea = &array[0];
lm = &array[64];
verify_diff (-64);
ea = &array[64];
lm = &array[0];
verify_diff (64);
return 0;
}
/* Copyright (C) 2009 Free Software Foundation, Inc.
This file 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 3 of the License, or (at your option)
any later version.
This file 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 file; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */
/* Valid __ea declarations. */
/* { dg-do compile } */
/* Typedefs. */
typedef __ea int ea_int_t;
typedef __ea int *ea_int_star_t;
typedef int outer_t;
/* Externs. */
__ea extern int i1;
extern __ea int i2;
extern int __ea i3;
extern __ea ea_int_t i4; /* __ea qualifier permitted via typedef. */
extern int __ea __ea __ea dupe; /* __ea duplicate permitted directly. */
extern int __ea *ppu;
/* Pointers. */
__ea int *i4p;
/* Structs. */
struct st {
__ea int *p;
};
/* Variable definitions. */
__ea int ii0;
int *__ea ii1;
static int __ea ii2;
void
f1 ()
{
int *spu;
ppu = (ea_int_t *) spu;
ppu = (ea_int_star_t) spu;
}
void
f2 ()
{
int *spu;
spu = (int *) ppu;
ppu = (__ea int *) spu;
}
void
f3 ()
{
int i = sizeof (__ea int);
}
__ea int *f4 (void)
{
return 0;
}
int f5 (__ea int *parm)
{
static __ea int local4;
int tmp = local4;
local4 = *parm;
return tmp;
}
static inline __ea void *f6 (__ea void *start)
{
return 0;
}
void f7 (void)
{
__ea void *s1;
auto __ea void *s2;
}
__ea int *f8 (__ea int *x)
{
register __ea int *y = x;
__ea int *z = y;
return z;
}
long long f9 (__ea long long x[2])
{
return x[0] + x[1];
}
void f10 ()
{
static __ea outer_t o;
}
/* Copyright (C) 2009 Free Software Foundation, Inc.
This file 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 3 of the License, or (at your option)
any later version.
This file 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 file; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */
/* Make sure __ea structure references work. */
/* { dg-do compile } */
typedef unsigned long int uintptr_t;
struct tostruct
{
uintptr_t selfpc;
long count;
unsigned short link;
};
/* froms are indexing tos */
static __ea unsigned short *froms;
static __ea struct tostruct *tos = 0;
void
foo (uintptr_t frompc, uintptr_t selfpc)
{
__ea unsigned short *frompcindex;
frompcindex = &froms[(frompc) / (4 * sizeof (*froms))];
*frompcindex = tos[0].link;
return;
}
/* Copyright (C) 2009 Free Software Foundation, Inc.
This file 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 3 of the License, or (at your option)
any later version.
This file 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 file; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */
/* Test default __EA32__/__EA64__ define. */
/* { dg-do compile } */
#if !defined (__EA32__) && !defined (__EA64__)
#error both __EA32__ and __EA64__ undefined
#endif
#if defined (__EA32__) && defined (__EA64__)
#error both __EA32__ and __EA64__ defined
#endif
#ifdef __EA32__
int x [ sizeof (__ea char *) == 4 ? 1 : -1 ];
#endif
#ifdef __EA64__
int x [ sizeof (__ea char *) == 8 ? 1 : -1 ];
#endif
# Copyright (C) 2008, 2009 Free Software Foundation, Inc.
# 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 3 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 GCC; see the file COPYING3. If not see
# <http://www.gnu.org/licenses/>.
# GCC testsuite that uses the `dg.exp' driver.
# Exit immediately if this isn't a SPU target.
if { ![istarget spu-*-*] } then {
return
}
# Load support procs.
load_lib gcc-dg.exp
# Return 1 if target __ea library functions are available
proc check_effective_target_ealib { } {
return [check_no_compiler_messages ealib executable {
#include <ea.h>
int main (void)
{
__ea void *ptr = malloc_ea (1024);
return 0;
}
}]
}
# If a testcase doesn't have special options, use these.
# We do not use the global DEFAULT_CFLAGS as all test cases
# in this directory use the __ea address space qualifier
# extension and thus will not compile with -ansi.
set DEFAULT_EA_CFLAGS "-std=gnu99 -pedantic-errors -O2"
# Initialize `dg'.
dg-init
# Run all tests in both -mea32 and -mea64 mode.
set tests [lsort [glob -nocomplain $srcdir/$subdir/*.\[cS\]]]
dg-runtest $tests "-mea32" $DEFAULT_EA_CFLAGS
dg-runtest $tests "-mea64" $DEFAULT_EA_CFLAGS
# All done.
dg-finish
/* Copyright (C) 2009 Free Software Foundation, Inc.
This file 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 3 of the License, or (at your option)
any later version.
This file 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 file; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */
/* Invalid __ea declarations. */
/* { dg-do compile } */
typedef __ea int eaint;
void func ()
{
register __ea int local1; /* { dg-error "'__ea' combined with 'register' qualifier for 'local1'" } */
auto __ea int local2; /* { dg-error "'__ea' combined with 'auto' qualifier for 'local2'" } */
__ea int local3; /* { dg-error "'__ea' specified for auto variable 'local3'" } */
register int *__ea p1; /* { dg-error "'__ea' combined with 'register' qualifier for 'p1'" } */
auto char *__ea p2; /* { dg-error "'__ea' combined with 'auto' qualifier for 'p2'" } */
void *__ea p3; /* { dg-error "'__ea' specified for auto variable 'p3'" } */
register __ea int a1[2]; /* { dg-error "'__ea' combined with 'register' qualifier for 'a1'" } */
auto __ea char a2[1]; /* { dg-error "'__ea' combined with 'auto' qualifier for 'a2'" } */
__ea char a3[5]; /* { dg-error "'__ea' specified for auto variable 'a3'" } */
register eaint td1; /* { dg-error "'__ea' combined with 'register' qualifier for 'td1'" } */
auto eaint td2; /* { dg-error "'__ea' combined with 'auto' qualifier for 'td2'" } */
eaint td3; /* { dg-error "'__ea' specified for auto variable 'td3'" } */
}
void func2 (__ea int x) /* { dg-error "'__ea' specified for parameter 'x'" } */
{ }
void func2td (eaint x) /* { dg-error "'__ea' specified for parameter 'x'" } */
{ }
struct st {
__ea int x; /* { dg-error "'__ea' specified for structure field 'x'" } */
eaint td; /* { dg-error "'__ea' specified for structure field 'td'" } */
int *__ea q; /* { dg-error "'__ea' specified for structure field 'q'" } */
int __ea b : 7; /* { dg-error "'__ea' specified for structure field 'b'" } */
int __ea : 1; /* { dg-error "'__ea' specified for structure field" } */
} s;
struct A { int a; };
int func3 (int *__ea); /* { dg-error "'__ea' specified for unnamed parameter" } */
int func3 (int *__ea x) /* { dg-error "'__ea' specified for parameter 'x'" } */
{
struct A i = (__ea struct A) { 1 }; /* { dg-error "compound literal qualified by address-space qualifier" } */
return i.a;
}
extern __ea int ea_var; /* { dg-message "note: previous declaration of 'ea_var' was here" } */
int ea_var; /* { dg-error "conflicting named address spaces \\(generic vs __ea\\) for 'ea_var'" } */
extern eaint ea_var_td; /* { dg-message "note: previous declaration of 'ea_var_td' was here" } */
int ea_var_td; /* { dg-error "conflicting named address spaces \\(generic vs __ea\\) for 'ea_var_td'" } */
/* Copyright (C) 2009 Free Software Foundation, Inc.
This file 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 3 of the License, or (at your option)
any later version.
This file 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 file; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */
/* Invalid __ea declarations. */
/* { dg-do compile } */
__ea char ea_str[] = "abc";
char lm_str[] = "abc";
__ea char *lm_ea_ptr1 = "abc"; /* { dg-error "initializer element is not computable at load time" } */
__ea char *lm_ea_ptr2 = (__ea char *)"abc"; /* { dg-error "initializer element is not constant" } */
__ea char *lm_ea_ptr3 = ea_str;
__ea char *lm_ea_ptr4 = (__ea char *)ea_str;
__ea char *lm_ea_ptr5 = lm_str; /* { dg-error "initializer element is not computable at load time" } */
__ea char *lm_ea_ptr6 = (__ea char *)lm_str; /* { dg-error "initializer element is not constant" } */
__ea char * __ea ea_ea_ptr1 = ea_str;
__ea char * __ea ea_ea_ptr2 = (__ea char *)ea_str;
char * __ea ea_lm_ptr1 = lm_str;
char * __ea ea_lm_ptr2 = (char *)lm_str;
struct foo {
int first;
__ea char *ptr;
int last;
};
__ea struct foo ea_struct1 = {
10,
(__ea char *)0,
11,
};
__ea struct foo ea_struct2 = {
20,
0,
21,
};
struct foo ea_struct3 = {
30,
ea_str,
31,
};
struct foo ea_struct4 = {
40,
(__ea char *)lm_str, /* { dg-error "(initializer element is not constant)|(near initialization)" "" } */
41,
};
struct bar {
int first;
char *ptr;
int last;
};
__ea struct bar ea_struct5 = {
50,
0,
51,
};
__ea struct bar ea_struct6 = {
60,
(char *)0,
61,
};
__ea struct bar ea_struct7 = {
70,
lm_str,
71,
};
struct bar lm_struct8 = {
80,
0,
81,
};
struct bar lm_struct9 = {
90,
(char *)0,
91,
};
struct bar lm_struct10 = {
100,
lm_str,
101,
};
/* Copyright (C) 2009 Free Software Foundation, Inc.
This file 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 3 of the License, or (at your option)
any later version.
This file 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 file; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */
/* { dg-do compile } */
#include <stdlib.h>
__ea char str[] = "abc";
int
main (void)
{
__ea char *p = str;
if (*p++ != 'a')
abort ();
if (*p++ != 'b')
abort ();
if (*p++ != 'c')
abort ();
if (*p++ != '\0')
abort ();
return 0;
}
/* Copyright (C) 2009 Free Software Foundation, Inc.
This file 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 3 of the License, or (at your option)
any later version.
This file 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 file; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */
/* { dg-do run } */
#include <stdlib.h>
char str[] = "abc";
int
main (void)
{
__ea char *p = (__ea char *)str;
if (*p++ != 'a')
abort ();
if (*p++ != 'b')
abort ();
if (*p++ != 'c')
abort ();
if (*p++ != '\0')
abort ();
return 0;
}
/* Copyright (C) 2009 Free Software Foundation, Inc.
This file 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 3 of the License, or (at your option)
any later version.
This file 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 file; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */
/* { dg-do run } */
#include <stdlib.h>
int
main (void)
{
__ea char *p = (__ea char *)"abc";
if (*p++ != 'a')
abort ();
if (*p++ != 'b')
abort ();
if (*p++ != 'c')
abort ();
if (*p++ != '\0')
abort ();
return 0;
}
/* Copyright (C) 2009 Free Software Foundation, Inc.
This file 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 3 of the License, or (at your option)
any later version.
This file 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 file; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */
/* This is the same as ops2.c except for the compile option.
If you modify this code, please modify ops2.c as well. */
/* { dg-do compile } */
/* { dg-options "-O2 -std=gnu99 -pedantic-errors -maddress-space-conversion" } */
#define __lm
__ea int ea_var = 1;
__lm int lm_var = 2;
typedef __ea int *ea_ptr_t;
typedef __lm int *lm_ptr_t;
typedef __ea void *ea_vptr_t;
typedef __lm void *lm_vptr_t;
ea_ptr_t ea, ea2;
lm_ptr_t lm, lm2;
ea_vptr_t eav;
lm_vptr_t lmv;
extern void call_ea (ea_ptr_t);
extern void call_lm (lm_ptr_t);
/* Assignment, initialization, argument passing, and return. */
void to_ea (void) { ea = lm; }
void to_lm (void) { lm = ea; } /* { dg-error "assignment from pointer to non-enclosed address space" } */
void init_ea (void) { ea_ptr_t l_ea = lm; }
void init_lm (void) { lm_ptr_t l_lm = ea; } /* { dg-error "initialization from pointer to non-enclosed address space" } */
ea_ptr_t ret_ea (void) { return lm; }
lm_ptr_t ret_lm (void) { return ea; } /* { dg-error "return from pointer to non-enclosed address space" } */
void call_ea2 (void) { call_ea (lm); }
void call_lm2 (void) { call_lm (ea); } /* { dg-error "passing argument 1 of 'call_lm' from pointer to non-enclosed address space" } */
/* Explicit casts. */
void to_ea_with_cast (void) { ea = (ea_ptr_t)lm; }
void to_lm_with_cast (void) { lm = (lm_ptr_t)ea; }
void init_ea_with_cast (void) { ea_ptr_t l_ea = (ea_ptr_t)lm; }
void init_lm_with_cast (void) { lm_ptr_t l_lm = (lm_ptr_t)ea; }
ea_ptr_t ret_ea_with_cast (void) { return (ea_ptr_t)lm; }
lm_ptr_t ret_lm_with_cast (void) { return (lm_ptr_t)ea; }
void call_ea2_with_cast (void) { call_ea ((ea_ptr_t)lm); }
void call_lm2_with_cast (void) { call_lm ((lm_ptr_t)ea); }
/* Arithmetic operators. */
int sub_eaea (void) { return ea - ea2; }
int sub_ealm (void) { return ea - lm2; }
int sub_lmea (void) { return lm - ea2; }
int sub_lmlm (void) { return lm - lm2; }
ea_ptr_t if_eaea1 (int test) { return test? ea : ea2; }
lm_ptr_t if_eaea2 (int test) { return test? ea : ea2; } /* { dg-error "return from pointer to non-enclosed address space" } */
ea_ptr_t if_ealm1 (int test) { return test? ea : lm2; }
lm_ptr_t if_ealm2 (int test) { return test? ea : lm2; } /* { dg-error "return from pointer to non-enclosed address space" } */
ea_ptr_t if_lmea1 (int test) { return test? lm : ea2; }
lm_ptr_t if_lmea2 (int test) { return test? lm : ea2; } /* { dg-error "return from pointer to non-enclosed address space" } */
ea_ptr_t if_lmlm1 (int test) { return test? lm : lm2; }
lm_ptr_t if_lmlm2 (int test) { return test? lm : lm2; }
/* Relational operators. */
int eq_eaea (void) { return ea == ea2; }
int eq_ealm (void) { return ea == lm2; }
int eq_lmea (void) { return lm == ea2; }
int eq_lmlm (void) { return lm == lm2; }
int lt_eaea (void) { return ea < ea2; }
int lt_ealm (void) { return ea < lm2; }
int lt_lmea (void) { return lm < ea2; }
int lt_lmlm (void) { return lm < lm2; }
/* Null pointer. */
void null_ea1 (void) { ea = 0; }
void null_ea2 (void) { ea = (void *)0; }
void null_ea3 (void) { ea = (__ea void *)0; }
void null_lm1 (void) { lm = 0; }
void null_lm2 (void) { lm = (void *)0; }
void null_lm3 (void) { lm = (__ea void *)0; } /* { dg-error "assignment from pointer to non-enclosed address space" } */
/* Copyright (C) 2009 Free Software Foundation, Inc.
This file 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 3 of the License, or (at your option)
any later version.
This file 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 file; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */
/* This is the same as ops1.c except for the compile option.
If you modify this code, please modify ops1.c as well. */
/* { dg-do compile } */
/* { dg-options "-O2 -std=gnu99 -pedantic-errors -mno-address-space-conversion" } */
#define __lm
__ea int ea_var = 1;
__lm int lm_var = 2;
typedef __ea int *ea_ptr_t;
typedef __lm int *lm_ptr_t;
typedef __ea void *ea_vptr_t;
typedef __lm void *lm_vptr_t;
ea_ptr_t ea, ea2;
lm_ptr_t lm, lm2;
ea_vptr_t eav;
lm_vptr_t lmv;
extern void call_ea (ea_ptr_t);
extern void call_lm (lm_ptr_t);
/* Assignment, initialization, argument passing, and return. */
void to_ea (void) { ea = lm; } /* { dg-error "assignment from pointer to non-enclosed address space" } */
void to_lm (void) { lm = ea; } /* { dg-error "assignment from pointer to non-enclosed address space" } */
void init_ea (void) { ea_ptr_t l_ea = lm; } /* { dg-error "initialization from pointer to non-enclosed address space" } */
void init_lm (void) { lm_ptr_t l_lm = ea; } /* { dg-error "initialization from pointer to non-enclosed address space" } */
ea_ptr_t ret_ea (void) { return lm; } /* { dg-error "return from pointer to non-enclosed address space" } */
lm_ptr_t ret_lm (void) { return ea; } /* { dg-error "return from pointer to non-enclosed address space" } */
void call_ea2 (void) { call_ea (lm); } /* { dg-error "passing argument 1 of 'call_ea' from pointer to non-enclosed address space" } */
void call_lm2 (void) { call_lm (ea); } /* { dg-error "passing argument 1 of 'call_lm' from pointer to non-enclosed address space" } */
/* Explicit casts. */
void to_ea_with_cast (void) { ea = (ea_ptr_t)lm; } /* { dg-warning "cast to __ea address space pointer" } */
void to_lm_with_cast (void) { lm = (lm_ptr_t)ea; } /* { dg-warning "cast to generic address space pointer" } */
void init_ea_with_cast (void) { ea_ptr_t l_ea = (ea_ptr_t)lm; } /* { dg-warning "cast to __ea address space pointer" } */
void init_lm_with_cast (void) { lm_ptr_t l_lm = (lm_ptr_t)ea; } /* { dg-warning "cast to generic address space pointer" } */
ea_ptr_t ret_ea_with_cast (void) { return (ea_ptr_t)lm; } /* { dg-warning "cast to __ea address space pointer" } */
lm_ptr_t ret_lm_with_cast (void) { return (lm_ptr_t)ea; } /* { dg-warning "cast to generic address space pointer" } */
void call_ea2_with_cast (void) { call_ea ((ea_ptr_t)lm); } /* { dg-warning "cast to __ea address space pointer" } */
void call_lm2_with_cast (void) { call_lm ((lm_ptr_t)ea); } /* { dg-warning "cast to generic address space pointer" } */
/* Arithmetic operators. */
int sub_eaea (void) { return ea - ea2; }
int sub_ealm (void) { return ea - lm2; } /* { dg-error "invalid operands to binary -" } */
int sub_lmea (void) { return lm - ea2; } /* { dg-error "invalid operands to binary -" } */
int sub_lmlm (void) { return lm - lm2; }
ea_ptr_t if_eaea1 (int test) { return test? ea : ea2; }
lm_ptr_t if_eaea2 (int test) { return test? ea : ea2; } /* { dg-error "return from pointer to non-enclosed address space" } */
ea_ptr_t if_ealm1 (int test) { return test? ea : lm2; } /* { dg-error "pointers to disjoint address spaces used in conditional expression" } */
lm_ptr_t if_ealm2 (int test) { return test? ea : lm2; } /* { dg-error "pointers to disjoint address spaces used in conditional expression" } */
ea_ptr_t if_lmea1 (int test) { return test? lm : ea2; } /* { dg-error "pointers to disjoint address spaces used in conditional expression" } */
lm_ptr_t if_lmea2 (int test) { return test? lm : ea2; } /* { dg-error "pointers to disjoint address spaces used in conditional expression" } */
ea_ptr_t if_lmlm1 (int test) { return test? lm : lm2; } /* { dg-error "return from pointer to non-enclosed address space" } */
lm_ptr_t if_lmlm2 (int test) { return test? lm : lm2; }
/* Relational operators. */
int eq_eaea (void) { return ea == ea2; }
int eq_ealm (void) { return ea == lm2; } /* { dg-error "comparison of pointers to disjoint address spaces" } */
int eq_lmea (void) { return lm == ea2; } /* { dg-error "comparison of pointers to disjoint address spaces" } */
int eq_lmlm (void) { return lm == lm2; }
int lt_eaea (void) { return ea < ea2; }
int lt_ealm (void) { return ea < lm2; } /* { dg-error "comparison of pointers to disjoint address spaces" } */
int lt_lmea (void) { return lm < ea2; } /* { dg-error "comparison of pointers to disjoint address spaces" } */
int lt_lmlm (void) { return lm < lm2; }
/* Null pointer. */
void null_ea1 (void) { ea = 0; }
void null_ea2 (void) { ea = (void *)0; }
void null_ea3 (void) { ea = (__ea void *)0; }
void null_lm1 (void) { lm = 0; }
void null_lm2 (void) { lm = (void *)0; }
void null_lm3 (void) { lm = (__ea void *)0; } /* { dg-error "assignment from pointer to non-enclosed address space" } */
/* Copyright (C) 2009 Free Software Foundation, Inc.
This file 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 3 of the License, or (at your option)
any later version.
This file 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 file; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */
/* Test -mcache-size. */
/* { dg-do compile } */
/* { dg-options "-mcache-size=128" } */
int x;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment