Commit e37e2bb1 by Jozef Lawrynowicz Committed by Jozef Lawrynowicz

MSP430: Consolidate handling of hard-coded MCU data

gcc/ChangeLog:

2019-08-13  Jozef Lawrynowicz  <jozef.l@mittosystems.com>

	* gcc/config.gcc (msp430*-*-*): Add msp430-devices.o to extra_objs and
	extra_gcc_objs.
	* gcc/config/msp430/driver-msp430.c: Remove msp430_mcu_data.
	(msp430_select_cpu): New spec function.
	(msp430_select_hwmult_lib): Use msp430_extract_mcu_data to extract
	MCU data.
	* gcc/config/msp430/msp430-devices.c: New file.
	* gcc/config/msp430/msp430-devices.h: New file.
	* gcc/config/msp430/msp430.c: Remove msp430_mcu_data.
	(msp430_option_override): Use msp430_extract_mcu_data to extract
	MCU data.
	(msp430_use_f5_series_hwmult): Likewise.
	(use_32bit_hwmult): Likewise.
	(msp430_no_hwmult): Likewise.
	* gcc/config/msp430/msp430.h (ASM_SPEC): Don't pass -mmcu to the
	assembler.
	(DRIVER_SELF_SPECS): Call msp430_select_cpu if -mmcu is used without
	and -mcpu option.
	(EXTRA_SPEC_FUNCTIONS): Add msp430_select_cpu.
	* gcc/config/msp430/t-msp430: Add rule to build msp430-devices.o.
	Remove hard-coded MCU multilib data.

gcc/testsuite/ChangeLog:

2019-08-13  Jozef Lawrynowicz  <jozef.l@mittosystems.com>

	* gcc.target/msp430/msp430.exp
	(check_effective_target_msp430_430_selected): New.
	(check_effective_target_msp430_430x_selected): New.
	(check_effective_target_msp430_mlarge_selected): New.
	(check_effective_target_msp430_hwmul_not_none): New.
	(check_effective_target_msp430_hwmul_not_16bit): New.
	(check_effective_target_msp430_hwmul_not_32bit): New.
	(check_effective_target_msp430_hwmul_not_f5): New.
	(msp430_get_opts): New.
	(msp430_device_permutations_runtest): New.
	* gcc.target/msp430/devices/README: New file.
	* gcc.target/msp430/devices-main.c: New test.
	* gcc.target/msp430/devices/hard-cc430f5123.c: Likewise.
	* gcc.target/msp430/devices/hard-foo.c: Likewise.
	* gcc.target/msp430/devices/hard-msp430afe253.c: Likewise.
	* gcc.target/msp430/devices/hard-msp430cg4616.c: Likewise.
	* gcc.target/msp430/devices/hard-msp430f4783.c: Likewise.
	* gcc.target/msp430/devices/hard-rf430frl154h_rom.c: Likewise.

From-SVN: r274370
parent 806f69cd
2019-08-13 Jozef Lawrynowicz <jozef.l@mittosystems.com>
* gcc/config.gcc (msp430*-*-*): Add msp430-devices.o to extra_objs and
extra_gcc_objs.
* gcc/config/msp430/driver-msp430.c: Remove msp430_mcu_data.
(msp430_select_cpu): New spec function.
(msp430_select_hwmult_lib): Use msp430_extract_mcu_data to extract
MCU data.
* gcc/config/msp430/msp430-devices.c: New file.
* gcc/config/msp430/msp430-devices.h: New file.
* gcc/config/msp430/msp430.c: Remove msp430_mcu_data.
(msp430_option_override): Use msp430_extract_mcu_data to extract
MCU data.
(msp430_use_f5_series_hwmult): Likewise.
(use_32bit_hwmult): Likewise.
(msp430_no_hwmult): Likewise.
* gcc/config/msp430/msp430.h (ASM_SPEC): Don't pass -mmcu to the
assembler.
(DRIVER_SELF_SPECS): Call msp430_select_cpu if -mmcu is used without
and -mcpu option.
(EXTRA_SPEC_FUNCTIONS): Add msp430_select_cpu.
* gcc/config/msp430/t-msp430: Add rule to build msp430-devices.o.
Remove hard-coded MCU multilib data.
2019-08-13 Richard Sandiford <richard.sandiford@arm.com>
* config/aarch64/aarch64.c (aarch64_classify_vector_mode): Switch
......
......@@ -2519,7 +2519,8 @@ msp430*-*-*)
c_target_objs="msp430-c.o"
cxx_target_objs="msp430-c.o"
tmake_file="${tmake_file} msp430/t-msp430"
extra_gcc_objs="driver-msp430.o"
extra_objs="${extra_objs} msp430-devices.o"
extra_gcc_objs="driver-msp430.o msp430-devices.o"
# Enable .init_array unless it has been explicitly disabled.
# The MSP430 EABI mandates the use of .init_array, and the Newlib CRT
# code since mid-2019 expects it.
......
/* Definitions of subroutines used for reading MCU data on TI MSP430 processors.
Copyright (C) 2019 Free Software Foundation, Inc.
Contributed by Jozef Lawrynowicz <jozef.l@mittosystems.com>.
This file is part of GCC.
GCC 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, or (at your option)
any later version.
GCC 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/>. */
struct t_msp430_mcu_data
{
const char * name;
unsigned int revision; /* 0=> MSP430, 1=>MSP430X, 2=> MSP430Xv2. */
unsigned int hwmpy; /* 0=>none, 1=>16-bit, 2=>16-bit w/sign extend. */
/* 4=>32-bit, 8=> 32-bit (5xx). */
};
extern struct t_msp430_mcu_data extracted_mcu_data;
void msp430_extract_mcu_data (const char * mcu_name);
......@@ -53,7 +53,7 @@ extern bool msp430x;
"%{minrt:%:if-exists(crtn-minrt.o%s)}%{!minrt:%:if-exists(crtn.o%s)} -lgcc"
#define ASM_SPEC "-mP " /* Enable polymorphic instructions. */ \
"%{mcpu=*:-mcpu=%*}%{!mcpu=*:%{mmcu=*:-mmcu=%*}} " /* Pass the CPU type on to the assembler. */ \
"%{mcpu=*:-mcpu=%*} " /* Pass the CPU type on to the assembler. */ \
"%{mrelax=-mQ} " /* Pass the relax option on to the assembler. */ \
"%{mlarge:-ml} " /* Tell the assembler if we are building for the LARGE pointer model. */ \
"%{!msim:-md} %{msim:%{mlarge:-md}} " /* Copy data from ROM to RAM if necessary. */ \
......@@ -74,11 +74,15 @@ extern bool msp430x;
" %{!mlarge:%{mcode-region=*:" \
"%e-mcode-region requires the large memory model (-mlarge)}}" \
" %{!mlarge:%{mdata-region=*:" \
"%e-mdata-region requires the large memory model (-mlarge)}}"
"%e-mdata-region requires the large memory model (-mlarge)}}" \
" %{!mcpu=*:%{mmcu=*:%:msp430_select_cpu(%{mmcu=*:%*})}}"
extern const char * msp430_select_hwmult_lib (int, const char **);
extern const char * msp430_select_cpu (int, const char **);
# define EXTRA_SPEC_FUNCTIONS \
{ "msp430_hwmult_lib", msp430_select_hwmult_lib },
{ "msp430_hwmult_lib", msp430_select_hwmult_lib }, \
{ "msp430_select_cpu", msp430_select_cpu },
/* Specify the libraries to include on the linker command line.
......
2019-08-13 Jozef Lawrynowicz <jozef.l@mittosystems.com>
* gcc.target/msp430/msp430.exp
(check_effective_target_msp430_430_selected): New.
(check_effective_target_msp430_430x_selected): New.
(check_effective_target_msp430_mlarge_selected): New.
(check_effective_target_msp430_hwmul_not_none): New.
(check_effective_target_msp430_hwmul_not_16bit): New.
(check_effective_target_msp430_hwmul_not_32bit): New.
(check_effective_target_msp430_hwmul_not_f5): New.
(msp430_get_opts): New.
(msp430_device_permutations_runtest): New.
* gcc.target/msp430/devices/README: New file.
* gcc.target/msp430/devices-main.c: New test.
* gcc.target/msp430/devices/hard-cc430f5123.c: Likewise.
* gcc.target/msp430/devices/hard-foo.c: Likewise.
* gcc.target/msp430/devices/hard-msp430afe253.c: Likewise.
* gcc.target/msp430/devices/hard-msp430cg4616.c: Likewise.
* gcc.target/msp430/devices/hard-msp430f4783.c: Likewise.
* gcc.target/msp430/devices/hard-rf430frl154h_rom.c: Likewise.
2019-08-13 Richard Sandiford <richard.sandiford@arm.com>
* gcc.target/aarch64/asm-x-constraint-1.c: New test.
......
int
main (void)
{
while (1);
return 0;
}
Some tests in this directory are run in a msp430-specific "torture" style,
where all target specific options (that change code generation) are each used
on each test source file in turn.
The criteria for this torture style of testing is:
- The source file has a .c suffix
- The source file is in this "devices" subdirectory of the msp430 tests
- Somewhere in the test file name matches the regex:
[a-z0-9]+430[a-z0-9_]+(?=\.c).
Some of the options used to run the tests will produce warnings/errors for the
mcus, so ensure the test has dg-warning and dg-error directives as appropriate.
/* { dg-do compile } */
/* { dg-options "-mmcu=cc430f5123" } */
/* { dg-warning "supports 430X ISA but '-mcpu' option is set to 430" "" { target msp430_430_selected } 0 } */
/* { dg-warning "supports 32-bit .5xx. hardware multiply" "" { target msp430_hwmul_not_f5 } 0 } */
/* revision=2, hwmpy=8 */
#include "../devices-main.c"
/* { dg-do compile } */
/* { dg-options "-mmcu=msp430foo" } */
/* { dg-warning "Unrecognized MCU name 'msp430foo'.*\n.*Use the" "" { target *-*-* } 0 } */
#include "../devices-main.c"
/* { dg-do compile } */
/* { dg-options "-mmcu=msp430afe253" } */
/* { dg-warning "supports 16-bit hardware multiply" "" { target msp430_hwmul_not_16bit } 0 } */
/* { dg-warning "supports 430 ISA but" "" { target msp430_430x_selected } 0 } */
/* { dg-error "'-mlarge' requires a 430X-compatible '-mmcu='" "" { target msp430_mlarge_selected } 0 } */
/* revision=0, hwmpy=2 */
#include "../devices-main.c"
/* { dg-do compile } */
/* { dg-options "-mmcu=msp430cg4616" } */
/* { dg-warning "supports 430X ISA but '-mcpu' option is set to 430" "" { target msp430_430_selected } 0 } */
/* { dg-warning "supports 16-bit hardware multiply" "" { target msp430_hwmul_not_16bit } 0 } */
/* revision=1, hwmpy=1 */
#include "../devices-main.c"
/* { dg-do compile } */
/* { dg-options "-mmcu=msp430f4783" } */
/* { dg-warning "supports 32-bit hardware multiply" "" { target msp430_hwmul_not_32bit } 0 } */
/* { dg-warning "supports 430 ISA but" "" { target msp430_430x_selected } 0 } */
/* { dg-error "'-mlarge' requires a 430X-compatible '-mmcu='" "" { target msp430_mlarge_selected } 0 } */
/* revision=0, hwmpy=4 */
#include "../devices-main.c"
/* { dg-do compile } */
/* { dg-options "-mmcu=rf430frl154h_rom" } */
/* { dg-warning "does not have hardware multiply" "" { target msp430_hwmul_not_none } 0 } */
/* { dg-warning "supports 430 ISA but" "" { target msp430_430x_selected } 0 } */
/* { dg-error "'-mlarge' requires a 430X-compatible '-mmcu='" "" { target msp430_mlarge_selected } 0 } */
/* revision=0, hwmpy=0 */
#include "../devices-main.c"
......@@ -18,7 +18,85 @@
# Exit immediately if this isn't the right target.
if { ![istarget msp430-*-*] } then {
return
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_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] {
dg-runtest $test_file "$mcu_flags" "$MSP430_DEFAULT_CFLAGS"
}
}
}
# Load support procs.
......@@ -42,5 +120,7 @@ dg-init
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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment