diff mbox

[testsuite,avr] : Support dg-require-effective-target avr_3byte_pc (and use it with PR71151 tests).

Message ID d2f80c3d-dc0d-7b8d-249b-1f1672dfcb8e@gjlay.de
State New
Headers show

Commit Message

Georg-Johann Lay June 22, 2016, 2:21 p.m. UTC
Some tests for PR71151 assume that the target MCU has a 3-byte PC.  The tests 
are failing because the simulator (avrtest) rejects to load the respective 
executables if .text exceeds 128KiB, e.g. for -mmcu=atmega128 which has only 
flash of 128KiB and only a 2-byte PC.

Hence the tests have to be skipped if the target MCU has no 3-byte PC, hence a 
new dg-require-effective-target proc supporting "avr_3byte_pc".

I added the new proc right after the last check_effective_target_arm_*** so 
that the test is in ASCII collating order.

Ok for trunk and v6?

Johann


gcc/testsuite/
	PR target/71151
	* lib/target-supports.exp (check_effective_target_avr_3byte_pc):
	New proc.
	* gcc.target/avr/pr71151-5.c: Remove code for __AVR_2_BYTE_PC__.
	Use dg-require-effective-target	avr_3byte_pc.
	* gcc.target/avr/pr71151-6.c: Same.
	* gcc.target/avr/pr71151-7.c: Same.
	* gcc.target/avr/pr71151-8.c: Same.

Comments

Jeff Law June 22, 2016, 4:55 p.m. UTC | #1
On 06/22/2016 08:21 AM, Georg-Johann Lay wrote:
> Some tests for PR71151 assume that the target MCU has a 3-byte PC.  The
> tests are failing because the simulator (avrtest) rejects to load the
> respective executables if .text exceeds 128KiB, e.g. for -mmcu=atmega128
> which has only flash of 128KiB and only a 2-byte PC.
>
> Hence the tests have to be skipped if the target MCU has no 3-byte PC,
> hence a new dg-require-effective-target proc supporting "avr_3byte_pc".
>
> I added the new proc right after the last check_effective_target_arm_***
> so that the test is in ASCII collating order.
>
> Ok for trunk and v6?
Would it make more sense to have a generic test around the size of the 
PC and or the size of pointers rather than something AVR specific?

Jeff
Mike Stump June 22, 2016, 5:06 p.m. UTC | #2
On Jun 22, 2016, at 7:21 AM, Georg-Johann Lay <avr@gjlay.de> wrote:
> 
> Some tests for PR71151 assume that the target MCU has a 3-byte PC.  The tests are failing because the simulator (avrtest) rejects to load the respective executables if .text exceeds 128KiB, e.g. for -mmcu=atmega128 which has only flash of 128KiB and only a 2-byte PC.
> 
> Hence the tests have to be skipped if the target MCU has no 3-byte PC, hence a new dg-require-effective-target proc supporting "avr_3byte_pc".
> 
> I added the new proc right after the last check_effective_target_arm_*** so that the test is in ASCII collating order.
> 
> Ok for trunk and v6?

No.  Please see target-utils.exp and ensure that the tools generate a stylized message and then add support for that to target-utils.exp.  If you are using binutils, the text should go into a memory segment that will fill when it is too large.  When it does, then binutils will generate one of the messages already handled, then you're done.
Mike Stump June 22, 2016, 5:13 p.m. UTC | #3
On Jun 22, 2016, at 10:06 AM, Mike Stump <mikestump@comcast.net> wrote:
> Please see target-utils.exp and ensure that the tools generate a stylized message and then add support for that to target-utils.exp.

Also, see return "::unsupported::memory full" in gcc-dg.exp, there is a copy there as well.
Georg-Johann Lay June 22, 2016, 5:44 p.m. UTC | #4
Jeff Law schrieb:
> On 06/22/2016 08:21 AM, Georg-Johann Lay wrote:
>> Some tests for PR71151 assume that the target MCU has a 3-byte PC.  The
>> tests are failing because the simulator (avrtest) rejects to load the
>> respective executables if .text exceeds 128KiB, e.g. for -mmcu=atmega128
>> which has only flash of 128KiB and only a 2-byte PC.
>>
>> Hence the tests have to be skipped if the target MCU has no 3-byte PC,
>> hence a new dg-require-effective-target proc supporting "avr_3byte_pc".
>>
>> I added the new proc right after the last check_effective_target_arm_***
>> so that the test is in ASCII collating order.
>>
>> Ok for trunk and v6?
> Would it make more sense to have a generic test around the size of the 
> PC and or the size of pointers rather than something AVR specific?
> 
> Jeff

At least a test for pointer-size won't work for avr because pointers for 
avr are 2-byte, yet there are AVR devices with 3-byte PC.

Dunno if other targets need to distinguish between PC sizes like the avr 
target...  For the vast majority of targets stuff like ptr32plus et al. 
are likely to be the right kinds of filters, but that's not the case for 
avr -- ptr*plus won't do it.

Actually it's a test for whether avrtest simulator is run for 
-mmcu=avr51 cores or -mmcu=avr6 cores, so this is quite target specific. 
  It's just the case that 3-byte-pc is more descriptive for avr people 
and more related to gcc because that feature is tested in many places in 
the avr BE and even shipped to user land as a built-in macro.

If it helps other targets I could rename it to, say, pc17plus for 
"Program Counter is at least 17 bits wide".

Johann
Jeff Law June 22, 2016, 5:54 p.m. UTC | #5
On 06/22/2016 11:44 AM, Georg-Johann Lay wrote:
> Jeff Law schrieb:
>> On 06/22/2016 08:21 AM, Georg-Johann Lay wrote:
>>> Some tests for PR71151 assume that the target MCU has a 3-byte PC.  The
>>> tests are failing because the simulator (avrtest) rejects to load the
>>> respective executables if .text exceeds 128KiB, e.g. for -mmcu=atmega128
>>> which has only flash of 128KiB and only a 2-byte PC.
>>>
>>> Hence the tests have to be skipped if the target MCU has no 3-byte PC,
>>> hence a new dg-require-effective-target proc supporting "avr_3byte_pc".
>>>
>>> I added the new proc right after the last check_effective_target_arm_***
>>> so that the test is in ASCII collating order.
>>>
>>> Ok for trunk and v6?
>> Would it make more sense to have a generic test around the size of the
>> PC and or the size of pointers rather than something AVR specific?
>>
>> Jeff
>
> At least a test for pointer-size won't work for avr because pointers for
> avr are 2-byte, yet there are AVR devices with 3-byte PC.
One of the H8 series might have had similar properties.  H8 stuff is 
getting rather fuzzy for me these days.

I vaguely recall code somewhere that detected when the resulting program 
wouldn't fit into the address space and gracefully exited with an error. 
  I think it was the linker that compiled and something in dejagnu knew 
to look for that error.  IT's probably worth digging around a bit to 
find that code and see if it can be re-used.

jeff
diff mbox

Patch

Index: testsuite/lib/target-supports.exp
===================================================================
--- testsuite/lib/target-supports.exp	(revision 237587)
+++ testsuite/lib/target-supports.exp	(working copy)
@@ -3588,6 +3588,16 @@  proc check_effective_target_arm_prefer_l
     }  "-O2 -mthumb" ]
 }
 
+# Return 1 if this is an AVR target with a 3-byte PC.
+
+proc check_effective_target_avr_3byte_pc { } {
+    return [ check_no_compiler_messages avr_3byte_pc assembly {
+    #if !defined(__AVR_3_BYTE_PC__)
+    #error !__AVR_3_BYTE_PC__
+    #endif
+    }]
+}
+
 # Return 1 if this is a PowerPC target supporting -meabi.
 
 proc check_effective_target_powerpc_eabi_ok { } {
Index: testsuite/gcc.target/avr/pr71151-5.c
===================================================================
--- testsuite/gcc.target/avr/pr71151-5.c	(revision 237587)
+++ testsuite/gcc.target/avr/pr71151-5.c	(working copy)
@@ -1,5 +1,6 @@ 
 /* { dg-do run } */
 /* { dg-options "-Os -fno-tree-switch-conversion -ffunction-sections -fdata-sections -mno-relax -Wl,--section-start=.foo=0x20000" } */
+/* { dg-require-effective-target avr_3byte_pc } */
 
 /* Make sure jumptables work properly if placed above 128 KB, i.e. 3 byte
    flash address for loading jump table entry and a jump table entry
@@ -11,10 +12,6 @@ 
 
 int main()
 {
-	/* Not meant for devices with flash <= 128K */
-#if defined (__AVR_2_BYTE_PC__)
-	exit(0);
-#else
 	foo(5);
 	if (y != 37)
 		abort();
@@ -26,5 +23,4 @@  int main()
 	foo(7);
 	if (y != 98)
 		abort();
-#endif
 }
Index: testsuite/gcc.target/avr/pr71151-6.c
===================================================================
--- testsuite/gcc.target/avr/pr71151-6.c	(revision 237587)
+++ testsuite/gcc.target/avr/pr71151-6.c	(working copy)
@@ -1,5 +1,6 @@ 
 /* { dg-do run } */
 /* { dg-options "-Os -fno-tree-switch-conversion -ffunction-sections -fdata-sections -mrelax -Wl,--section-start=.foo=0x20000" } */
+/* { dg-require-effective-target avr_3byte_pc } */
 
 /* Make sure jumptables work properly if placed above 128 KB, i.e. 3 byte
    flash address for loading jump table entry and a jump table entry
@@ -11,10 +12,6 @@ 
 
 int main()
 {
-	/* Not meant for devices with flash <= 128K */
-#if defined (__AVR_2_BYTE_PC__)
-	exit(0);
-#else
 	foo(5);
 	if (y != 37)
 		abort();
@@ -26,5 +23,4 @@  int main()
 	foo(7);
 	if (y != 98)
 		abort();
-#endif
 }
Index: testsuite/gcc.target/avr/pr71151-7.c
===================================================================
--- testsuite/gcc.target/avr/pr71151-7.c	(revision 237587)
+++ testsuite/gcc.target/avr/pr71151-7.c	(working copy)
@@ -1,5 +1,6 @@ 
 /* { dg-do run } */
 /* { dg-options "-Os -fno-tree-switch-conversion -ffunction-sections -fdata-sections -mno-relax -Wl,--section-start=.foo=0x1fffa" } */
+/* { dg-require-effective-target avr_3byte_pc } */
 
 /* Make sure jumptables work properly if placed straddling 128 KB i.e
    some entries below 128 KB and some above it, with relaxation disabled. */
@@ -9,10 +10,6 @@ 
 
 int main()
 {
-	/* Not meant for devices with flash <= 128K */
-#if defined (__AVR_2_BYTE_PC__)
-	exit(0);
-#else
 	foo(5);
 	if (y != 37)
 		abort();
@@ -24,5 +21,4 @@  int main()
 	foo(7);
 	if (y != 98)
 		abort();
-#endif
 }
Index: testsuite/gcc.target/avr/pr71151-8.c
===================================================================
--- testsuite/gcc.target/avr/pr71151-8.c	(revision 237587)
+++ testsuite/gcc.target/avr/pr71151-8.c	(working copy)
@@ -1,5 +1,6 @@ 
 /* { dg-do run } */
 /* { dg-options "-Os -fno-tree-switch-conversion -ffunction-sections -fdata-sections -mrelax -Wl,--section-start=.foo=0x1fffa" } */
+/* { dg-require-effective-target avr_3byte_pc } */
 
 /* Make sure jumptables work properly if placed straddling 128 KB i.e
    some entries below 128 KB and some above it, with relaxation disabled. */
@@ -9,10 +10,6 @@ 
 
 int main()
 {
-	/* Not meant for devices with flash <= 128K */
-#if defined (__AVR_2_BYTE_PC__)
-	exit(0);
-#else
 	foo(5);
 	if (y != 37)
 		abort();
@@ -24,5 +21,4 @@  int main()
 	foo(7);
 	if (y != 98)
 		abort();
-#endif
 }