aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.target/msp430/msp430.exp
blob: bcc56861abc4f0bfb580af22a3f37b2a972c9591 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
# Copyright (C) 2015-2019 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 this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  

# GCC testsuite that uses the `dg.exp' driver.

# Exit immediately if this isn't the right target.
if { ![istarget msp430-*-*] } then {
    return
}

# Below are msp430-specific effective target keywords, required for checking
# device related warnings/errors
proc check_effective_target_msp430_430_selected { } {
    return [check-flags [list "" { *-*-* } { "-mcpu=msp430" } { "" } ]]
}

proc check_effective_target_msp430_430x_selected { } {
    return [check-flags [list "" { *-*-* } \
    { "-mcpu=msp430x" "-mcpu=msp430xv2" } { "" } ]]
}

proc check_effective_target_msp430_mlarge_selected { } {
    return [check-flags [list "" { *-*-* } { "-mlarge" } { "" } ]]
}

proc check_effective_target_msp430_region_not_lower { } {
    return [check-flags [list "" { *-*-* } { "-mdata-region=none" "-mdata-region=upper" "-mdata-region=either" } { "" } ]]
}

proc check_effective_target_msp430_region_lower { } {
    return [check-flags [list "" { *-*-* } { "*" } { "-mdata-region=none" "-mdata-region=upper" "-mdata-region=either" } ]]
}

proc check_effective_target_msp430_hwmul_not_none { } {
    return [check-flags [list "" { *-*-* } \
    { "-mhwmult=16bit" "-mhwmult=32bit" "-mhwmult=f5series" } { "" } ]]
}

proc check_effective_target_msp430_hwmul_not_16bit { } {
    return [check-flags [list "" { *-*-* } \
    { "-mhwmult=f5series" "-mhwmult=32bit" } { "" } ]]
}

proc check_effective_target_msp430_hwmul_not_32bit { } {
    return [check-flags [list "" { *-*-* } \
    { "-mhwmult=16bit" "-mhwmult=f5series" } { "" } ]]
}

proc check_effective_target_msp430_hwmul_not_f5 { } {
    return [check-flags [list "" { *-*-* } \
    { "-mhwmult=16bit" "-mhwmult=32bit" } { "" } ]]
}

# Return a list of msp430-specific options we can run the test with.
# The mcu name is extracted from the file name, not from the -mmcu option
# specified in the test file.
proc msp430_get_opts { test_file } {
    global board_info
    # If the mcu name is not recognized, run the test as normal without
    # additional options.
    if { ![regexp {[a-z0-9]+430[a-z0-9_]+(?=\.c)} $test_file mcu_name] } {
	return { "" }
    }
    # If the testsuite has been invoked with specific MSP430 options, don't run
    # in this torture style.
    set multi_flags [board_info [target_info name] multilib_flags]
    if { [string match "*mlarge*" $multi_flags]
	|| [string match "*msmall*" $multi_flags]
	|| [string match "*mcpu*" $multi_flags]
	|| [string match "*mmcu*" $multi_flags]
	|| [string match "*mhwmult*" $multi_flags] } {
	return { "" }
    }
    # Test all device related options. The compiler will warn about
    # incompatibilities, so ensure dg-warning or dg-error directives are set up
    # in the test sources.
    return {"" -mhwmult=none -mhwmult=16bit -mhwmult=32bit -mhwmult=f5series \
        -mcpu=msp430 -mcpu=msp430x -mcpu=msp430xv2 -mlarge}
}

# Run each test file in 'tests' with every possible value for -mcpu and
# -mhwmult, and with -mlarge.
proc msp430_device_permutations_runtest { tests } {
    # The specific tests being run
    global runtests
    global MSP430_DEFAULT_CFLAGS
    foreach { test_file } $tests {
	if { ![runtest_file_p $runtests $test_file] } {
	    continue
	}
	foreach { mcu_flags } [msp430_get_opts $test_file] {
	    if { [string match "csv-*" [file tail $test_file]] } {
		# Specify the path to devices.csv for devices/csv-* tests with -I.
		# Note that the csv-* tests do not have dg-options directives,
		# they only have dg-additional-options to pass -mmcu.  This is
		# so we can set the path to devices.csv as a "default" flag
		# with -I, and the path won't show up in the test results
		# summary.  If there were dg-options directives, then these
		# default flags passed as the 3rd argument to dg-runtest would
		# not be used.
		dg-runtest $test_file "$mcu_flags" "-I[file dirname $test_file] $MSP430_DEFAULT_CFLAGS"
	    } elseif { [string match "bad-devices*" [file tail $test_file]] } {
		dg-runtest $test_file "$mcu_flags" "-mdevices-csv-loc=[file dirname $test_file]/[file tail $test_file]sv $MSP430_DEFAULT_CFLAGS"
	    } else {
		dg-runtest $test_file "$mcu_flags" "$MSP430_DEFAULT_CFLAGS"
	    }
	}
    }
}

# Load support procs.
load_lib gcc-dg.exp

# The '-pedantic-errors' option in the global variable DEFAULT_CFLAGS that is
# set by other drivers causes an error when the __int20 type is used, so remove
# this option from DEFAULT_CFLAGS for the msp430 tests.
global DEFAULT_CFLAGS
if [info exists DEFAULT_CFLAGS] then {
    set MSP430_DEFAULT_CFLAGS \
      [ string map { "-pedantic-errors" "" } $DEFAULT_CFLAGS ]
} else {
   set MSP430_DEFAULT_CFLAGS ""
}

# Initialize `dg'.
dg-init

# Main loop.
dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cCS\]]] \
	"" $MSP430_DEFAULT_CFLAGS

msp430_device_permutations_runtest [lsort [glob -nocomplain $srcdir/$subdir/devices/*.\[cCS\]]]

# All done.
dg-finish