Skip to content

Commit 9a6aca3

Browse files
committed
arcv: apex: testsuite
Signed-off-by: Luis Silva <[email protected]>
1 parent fc88e88 commit 9a6aca3

36 files changed

+634
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Copyright (C) 2024-2025 Free Software Foundation, Inc.
2+
3+
# This program is free software; you can redistribute it and/or modify
4+
# it under the terms of the GNU General Public License as published by
5+
# the Free Software Foundation; either version 3 of the License, or
6+
# (at your option) any later version.
7+
#
8+
# This program is distributed in the hope that it will be useful,
9+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+
# GNU General Public License for more details.
12+
#
13+
# You should have received a copy of the GNU General Public License
14+
# along with GCC; see the file COPYING3. If not see
15+
# <http://www.gnu.org/licenses/>.
16+
17+
# GCC testsuite that uses the `dg.exp' driver.
18+
19+
# Exit immediately if this isn't a RISC-V target.
20+
if ![istarget riscv*-*-*] then {
21+
return
22+
}
23+
24+
# Load support procs.
25+
load_lib gcc-dg.exp
26+
27+
global DEFAULT_CFLAGS
28+
if ![info exists DEFAULT_CFLAGS] then {
29+
set DEFAULT_CFLAGS " -ansi -pedantic-errors"
30+
}
31+
32+
# Initialize `dg'.
33+
dg-init
34+
35+
# Main loop.
36+
dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cS\]]] \
37+
"" $DEFAULT_CFLAGS
38+
39+
# All done.
40+
dg-finish
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/* { dg-do compile } */
2+
/* { dg-options "-mabi=ilp32d -march=rv32gc -mtune=arc-v-rhx-100-series" }*/
3+
4+
5+
int foo(int,int);
6+
7+
#pragma intrinsic(foo,FOP,10,Key=>"bar") /* { dg-error "pragma intrinsic: APEX attribute 'Key' is not recognized" } */
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/* { dg-do compile } */
2+
/* { dg-options "-mabi=ilp32d -march=rv32gc -mtune=arc-v-rhx-100-series" }*/
3+
4+
int foo(int);
5+
int foou(int);
6+
7+
#pragma intrinsic(foo, FOP, 10, "XI")
8+
9+
extern int XX;
10+
int
11+
main (void)
12+
{
13+
int a;
14+
a = foo(-2049); /* { dg-error "argument value -2049 is outside the valid range \\\[-2048, 2047\\\]" } */
15+
a+= foo(2048); /* { dg-error "argument value 2048 is outside the valid range \\\[-2048, 2047\\\]" } */
16+
a+= foo(1000000); /* { dg-error "argument value 1000000 is outside the valid range \\\[-2048, 2047\\\]" } */
17+
return a;
18+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/* { dg-do compile } */
2+
/* { dg-options "-O0" } */
3+
/* { dg-options "-mabi=ilp32d -march=rv32gc -mtune=arc-v-rhx-100-series" }*/
4+
5+
int foo(int, int);
6+
7+
#pragma intrinsic(foo, FOP, 10, "XC")
8+
9+
int main() {
10+
int x = 12;
11+
int y = foo(x, 100000); /* { dg-error "argument value 100000 is outside the valid range \\\[-2048, 2047\\\]" } */
12+
return foo(y, x); /* { dg-error "argument to 'foo' must be a constant integer" } */
13+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/* { dg-do compile } */
2+
/* { dg-options "-O0" } */
3+
/* { dg-options "-mabi=ilp32d -march=rv32gc -mtune=arc-v-rhx-100-series" }*/
4+
5+
int foo(int, int);
6+
7+
#pragma intrinsic(foo, FOP, 10, "XS")
8+
9+
int main() {
10+
int x = 12;
11+
int y = foo(x, 100000); /* { dg-error "argument value 100000 is outside the valid range \\\[-128, 127\\\]" } */
12+
return foo(y, x); /* { dg-error "argument to 'foo' must be a constant integer" } */
13+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/* { dg-do compile } */
2+
/* { dg-options "-O0" } */
3+
/* { dg-options "-mabi=ilp32d -march=rv32gc -mtune=arc-v-rhx-100-series" }*/
4+
5+
void foo(int, int);
6+
int bar(int);
7+
8+
#pragma intrinsic(foo, FOP, 10, "XS")
9+
#pragma intrinsic(bar, BAR, 11, "XI")
10+
11+
int main() {
12+
foo(12, 100000); /* { dg-error "argument value 100000 is outside the valid range \\\[-128, 127\\\]" } */
13+
return bar(100000); /* { dg-error "argument value 100000 is outside the valid range \\\[-2048, 2047\\\]" } */
14+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/* { dg-do compile } */
2+
/* { dg-options "-mabi=ilp32d -march=rv32gc -mtune=arc-v-rhx-100-series" }*/
3+
4+
void foo(int, int);
5+
6+
#pragma intrinsic(foo, FOP, 10, "XC") /* { dg-error "pragma intrinsic: APEX function 'foo' must return the same type as the first parameter for the 'XC' format class" } */
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/* { dg-do compile } */
2+
/* { dg-options "-mabi=ilp32d -march=rv32gc -mtune=arc-v-rhx-100-series" }*/
3+
4+
int foo(int);
5+
int bar0();
6+
int bar3(int,int,int);
7+
8+
#pragma intrinsic(foo, FOP, 10, "XS") /* { dg-error "pragma intrinsic: APEX function 'foo' must have 2 scalar parameter\\(s\\) for the 'XS' format class" } */
9+
#pragma intrinsic(bar0, bar0, 11, "XS") /* { dg-error "pragma intrinsic: APEX function 'bar0' must have 2 scalar parameter\\(s\\) for the 'XS' format class" } */
10+
#pragma intrinsic(bar3, bar3, 12, "XS") /* { dg-warning "pragma intrinsic: Associated function can have no more than 2 parameters" } */
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/* { dg-do compile } */
2+
/* { dg-options "-mabi=lp64d -march=rv64gc -mtune=arc-v-rpx-100-series" }*/
3+
4+
struct S {int a,b,c,d; };
5+
long long foo(struct S *a, int b);
6+
7+
#pragma intrinsic(foo,"FOP",10, XD,XS)
8+
9+
int main(){
10+
struct S s = {1,2,3,4};
11+
return foo(&s, 100);
12+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/* { dg-do compile } */
2+
/* { dg-options "-mabi=ilp32d -march=rv32gc -mtune=arc-v-rhx-100-series" }*/
3+
4+
struct S {int a,b,c,d; };
5+
long long foo(struct S *a, int b);
6+
7+
#pragma intrinsic(foo,"FOP",10, XD,XS) /* { dg-error "pragma intrinsic: APEX function 'foo' must return void or a scalar type that does not exceed 4 bytes" } */
8+
9+
int
10+
main (void)
11+
{
12+
struct S s = {1,2,3,4};
13+
return foo(&s, 100);
14+
}

0 commit comments

Comments
 (0)