(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.target/
arm/
cmse/
cmse.exp
#   Copyright (C) 1997-2023 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 for ARMv8-M Security Extensions using the `dg.exp' driver.

# Load support procs.
load_lib gcc-dg.exp

# Exit immediately if the target does not support -mcmse.
if ![check_effective_target_arm_cmse_ok] then {
    return
}

# If a testcase doesn't have special options, use these.
global DEFAULT_CFLAGS
if ![info exists DEFAULT_CFLAGS] then {
    set DEFAULT_CFLAGS " -ansi -pedantic-errors"
}

# Initialize `dg'.
dg-init

set saved-dg-do-what-default ${dg-do-what-default}

if {[is-effective-target arm_cmse_hw]} then {
    set dg-do-what-default run
} else {
    set dg-do-what-default assemble
}

set saved-lto_torture_options ${LTO_TORTURE_OPTIONS}
set LTO_TORTURE_OPTIONS ""

# Return the start address of the .gnu.sgstubs section.
proc cmse_sgstubs {} {
    # Allow to override the location of .gnu.sgstubs section.
    set tboard [target_info name]
    if {[board_info $tboard exists cmse_sgstubs]} {
	return [board_info $tboard cmse_sgstubs]
    }

    return "0x00400000"
}

# These are for both baseline and mainline.
gcc-dg-runtest [lsort [glob $srcdir/$subdir/*.c]] \
	"" $DEFAULT_CFLAGS

if {[check_effective_target_arm_arch_v8m_base_ok]} then {
    # Baseline only
    set BASELINE_FLAGS [add_options_for_arm_arch_v8m_base ""]
    gcc-dg-runtest [lsort [glob $srcdir/$subdir/baseline/*.c]] \
	    "$BASELINE_FLAGS" $DEFAULT_CFLAGS
}

if {[check_effective_target_arm_arch_v8m_main_ok]} then {
    set MAINLINE_8M_FLAGS [add_options_for_arm_arch_v8m_main ""]
    gcc-dg-runtest [lsort [glob $srcdir/$subdir/mainline/8m/*.c]] \
	    "$MAINLINE_8M_FLAGS" $DEFAULT_CFLAGS
    # Mainline -mfloat-abi=soft
    gcc-dg-runtest [lsort [glob $srcdir/$subdir/mainline/8m/soft/*.c]] \
	    "$MAINLINE_8M_FLAGS -mfloat-abi=soft" $DEFAULT_CFLAGS
    gcc-dg-runtest [lsort [glob $srcdir/$subdir/mainline/8m/softfp/*.c]] \
	    "$MAINLINE_8M_FLAGS" $DEFAULT_CFLAGS
    gcc-dg-runtest [lsort [glob $srcdir/$subdir/mainline/8m/softfp-sp/*.c]] \
	    "$MAINLINE_8M_FLAGS" $DEFAULT_CFLAGS
    gcc-dg-runtest [lsort [glob $srcdir/$subdir/mainline/8m/hard/*.c]] \
	    "$MAINLINE_8M_FLAGS" $DEFAULT_CFLAGS
    gcc-dg-runtest [lsort [glob $srcdir/$subdir/mainline/8m/hard-sp/*.c]] \
	    "$MAINLINE_8M_FLAGS" $DEFAULT_CFLAGS
}

if {[check_effective_target_arm_arch_v8_1m_main_ok]} then {
    set MAINLINE_8_1M_FLAGS [add_options_for_arm_arch_v8_1m_main ""]
    gcc-dg-runtest [lsort [glob $srcdir/$subdir/mainline/8_1m/*.c]] \
	    "$MAINLINE_8_1M_FLAGS" $DEFAULT_CFLAGS
    # Mainline -mfloat-abi=soft
    gcc-dg-runtest [lsort [glob $srcdir/$subdir/mainline/8_1m/soft/*.c]] \
	    "$MAINLINE_8_1M_FLAGS -mfloat-abi=soft" $DEFAULT_CFLAGS
    gcc-dg-runtest [lsort [glob $srcdir/$subdir/mainline/8_1m/softfp/*.c]] \
	    "$MAINLINE_8_1M_FLAGS" $DEFAULT_CFLAGS
    gcc-dg-runtest [lsort [glob $srcdir/$subdir/mainline/8_1m/softfp-sp/*.c]] \
	    "$MAINLINE_8_1M_FLAGS" $DEFAULT_CFLAGS
    gcc-dg-runtest [lsort [glob $srcdir/$subdir/mainline/8_1m/hard/*.c]] \
	    "$MAINLINE_8_1M_FLAGS" $DEFAULT_CFLAGS
    gcc-dg-runtest [lsort [glob $srcdir/$subdir/mainline/8_1m/hard-sp/*.c]] \
	    "$MAINLINE_8_1M_FLAGS" $DEFAULT_CFLAGS
}

set LTO_TORTURE_OPTIONS ${saved-lto_torture_options}
set dg-do-what-default ${saved-dg-do-what-default}

# All done.
dg-finish