Skip to content

Commit 6e6851b

Browse files
committed
arcv: apex: Add ARC-V APEX Compiler testsuite.
This testsuite tests the compiler to generate the correct APEX instruction formats and their respective variants. Also validates error handling. Signed-off-by: Luis Silva <[email protected]>
1 parent 40fea09 commit 6e6851b

36 files changed

+597
-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: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/* { dg-do compile } */
2+
3+
int foo (int,int);
4+
#pragma intrinsic (foo,FOP,10,Key=>"bar") /* { dg-error "pragma intrinsic: APEX attribute 'Key' is not recognized" } */
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/* { dg-do compile } */
2+
3+
int foo (int);
4+
#pragma intrinsic (foo, FOP, 10, "XI")
5+
6+
int
7+
main (void)
8+
{
9+
int a;
10+
a = foo (-2049); /* { dg-error "argument value -2049 is outside the valid range \\\[-2048, 2047\\\]" } */
11+
a += foo (2048); /* { dg-error "argument value 2048 is outside the valid range \\\[-2048, 2047\\\]" } */
12+
a += foo (1000000); /* { dg-error "argument value 1000000 is outside the valid range \\\[-2048, 2047\\\]" } */
13+
return a;
14+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/* { dg-do compile } */
2+
/* { dg-options "-O0" } */
3+
4+
int foo (int, int);
5+
#pragma intrinsic (foo, FOP, 10, "XC")
6+
7+
int main() {
8+
int x = 12;
9+
int y = foo (x, 100000); /* { dg-error "argument value 100000 is outside the valid range \\\[-2048, 2047\\\]" } */
10+
return foo (y, x); /* { dg-error "argument to 'foo' must be a constant integer" } */
11+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/* { dg-do compile } */
2+
/* { dg-options "-O0" } */
3+
4+
int foo (int, int);
5+
#pragma intrinsic (foo, FOP, 10, "XS")
6+
7+
int main() {
8+
int x = 12;
9+
int y = foo (x, 100000); /* { dg-error "argument value 100000 is outside the valid range \\\[-128, 127\\\]" } */
10+
return foo (y, x); /* { dg-error "argument to 'foo' must be a constant integer" } */
11+
}
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+
4+
void foo (int, int);
5+
int bar (int);
6+
7+
#pragma intrinsic (foo, FOP, 10, "XS")
8+
#pragma intrinsic (bar, BAR, 11, "XI")
9+
10+
int main() {
11+
foo (12, 100000); /* { dg-error "argument value 100000 is outside the valid range \\\[-128, 127\\\]" } */
12+
return bar (100000); /* { dg-error "argument value 100000 is outside the valid range \\\[-2048, 2047\\\]" } */
13+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/* { dg-do compile } */
2+
3+
void foo (int, int);
4+
#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: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/* { dg-do compile } */
2+
3+
int foo (int);
4+
int bar0 ();
5+
int bar3 (int,int,int);
6+
7+
#pragma intrinsic (foo, FOP, 10, "XS") /* { dg-error "pragma intrinsic: APEX function 'foo' must have 2 scalar parameter\\(s\\) for the 'XS' format class" } */
8+
#pragma intrinsic (bar0, bar0, 11, "XS") /* { dg-error "pragma intrinsic: APEX function 'bar0' must have 2 scalar parameter\\(s\\) for the 'XS' format class" } */
9+
#pragma intrinsic (bar3, bar3, 12, "XS") /* { dg-warning "pragma intrinsic: Associated function can have no more than 2 parameters" } */
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=lp64d -march=rv64gc" }*/
3+
4+
struct S {int a,b,c,d; };
5+
6+
long long foo (struct S *a, int b);
7+
#pragma intrinsic (foo,"FOP",10, XD,XS)
8+
9+
int
10+
main (void)
11+
{
12+
struct S s = {1,2,3,4};
13+
return foo (&s, 100);
14+
}
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" }*/
3+
4+
struct S {int a,b,c,d; };
5+
6+
long long foo (struct S *a, int b);
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)