1#   Copyright (C) 2006-2021 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# Load support procs.
20load_lib gcc-dg.exp
21
22if ![check_effective_target_fgraphite] {
23  return
24}
25
26# Remove VALUE from LIST_VARIABLE.
27proc lremove {list_variable value} {
28    upvar 1 $list_variable var
29    set idx [lsearch -exact $var $value]
30    set var [lreplace $var $idx $idx]
31}
32
33# The default action for a test is 'compile'.  Save current default.
34global dg-do-what-default
35set save-dg-do-what-default ${dg-do-what-default}
36
37# Initialize `dg'.
38dg-init
39
40# Set up a list of effective targets to run vector tests for all supported
41# targets.
42global EFFECTIVE_TARGETS
43set EFFECTIVE_TARGETS ""
44
45set wait_to_run_files [lsort [glob -nocomplain $srcdir/$subdir/*.c ] ]
46set scop_files        [lsort [glob -nocomplain $srcdir/$subdir/scop-*.c ] ]
47set id_files          [lsort [glob -nocomplain $srcdir/$subdir/id-*.c ] ]
48set run_id_files      [lsort [glob -nocomplain $srcdir/$subdir/run-id-*.c ] ]
49set opt_files         [lsort [glob -nocomplain $srcdir/$subdir/interchange-*.c \
50					       $srcdir/$subdir/uns-interchange-*.c \
51					       $srcdir/$subdir/isl-ast-gen-*.c \
52					       $srcdir/$subdir/fuse-*.c \
53					       $srcdir/$subdir/block-*.c \
54					       $srcdir/$subdir/uns-block-*.c ] ]
55set vect_files        [lsort [glob -nocomplain $srcdir/$subdir/vect-*.c ] ]
56
57# Tests to be compiled.
58set dg-do-what-default compile
59dg-runtest $scop_files        "" "-O2 -fgraphite -fdump-tree-graphite-all -fno-finite-loops"
60dg-runtest $id_files          "" "-O2 -fgraphite-identity -ffast-math -fdump-tree-graphite-details"
61
62# Tests to be run.
63set dg-do-what-default run
64dg-runtest $run_id_files      "" "-O2 -fgraphite-identity -fdump-tree-graphite-details"
65dg-runtest $opt_files         "" "-O2 -ffast-math -floop-nest-optimize -fdump-tree-graphite-all"
66
67# Vectorizer tests, to be run or compiled, depending on target capabilities.
68global DEFAULT_VECTCFLAGS
69set DEFAULT_VECTCFLAGS "-O2 -fgraphite-identity -ftree-vectorize -fno-vect-cost-model -fdump-tree-vect-details -ffast-math"
70
71if [check_vect_support_and_set_flags] {
72    et-dg-runtest dg-runtest $vect_files        "" $DEFAULT_VECTCFLAGS
73}
74
75# The default action for the rest of the files is 'compile'.
76set dg-do-what-default compile
77foreach f $scop_files        {lremove wait_to_run_files $f}
78foreach f $id_files          {lremove wait_to_run_files $f}
79foreach f $run_id_files      {lremove wait_to_run_files $f}
80foreach f $opt_files         {lremove wait_to_run_files $f}
81foreach f $vect_files        {lremove wait_to_run_files $f}
82dg-runtest $wait_to_run_files "" "-ansi -pedantic-errors"
83
84# Clean up.
85set dg-do-what-default ${save-dg-do-what-default}
86
87# All done.
88dg-finish
89