diff mbox

[ARM] attribute target (thumb,arm) [4/6]

Message ID 546CA025.1060007@st.com
State New
Headers show

Commit Message

Christian Bruel Nov. 19, 2014, 1:50 p.m. UTC
Implements and document the hooks to support target_attributes.

The emission of blx is handled directly for armv5 to overcome a bug with 
the current binutils that fails with calls to a static symbol in a 
different section. (e.g .text -> .text.startup) in different modes.
(ref https://sourceware.org/bugzilla/show_bug.cgi?id=17505)

Regtests included

Thanks

Christian
diff mbox

Patch

2014-09-23  Christian Bruel  <christian.bruel@st.com>

	* gcc.target/arm/attr_arm.c: New test.
	* gcc.target/arm/attr_thumb.c: New test.
	* gcc.target/arm/attr_thumb-static.c: New test.

diff '--exclude=ChangeLog*' '--exclude=.svn' '--exclude=*~' '--exclude=#*#' -rupN d/gcc/gcc/testsuite/gcc.target/arm/attr_arm.c e/gcc/gcc/testsuite/gcc.target/arm/attr_arm.c
--- d/gcc/gcc/testsuite/gcc.target/arm/attr_arm.c	1970-01-01 01:00:00.000000000 +0100
+++ e/gcc/gcc/testsuite/gcc.target/arm/attr_arm.c	2014-11-18 10:56:51.000000000 +0100
@@ -0,0 +1,13 @@ 
+/* Check that attribute target arm is recogniwed.  */
+/* { dg-do compile } */
+/* { dg-require-effective-target arm_arm_ok } */
+/* { dg-options "-O2" } */
+/* { dg-final { scan-assembler ".arm" } } */
+/* { dg-final { scan-assembler-not "ite" } } */
+
+int __attribute__((target("arm")))
+foo(int a)
+{
+  return a ? 1 : 5;
+}
+
diff '--exclude=ChangeLog*' '--exclude=.svn' '--exclude=*~' '--exclude=#*#' -rupN d/gcc/gcc/testsuite/gcc.target/arm/attr_arm-err.c e/gcc/gcc/testsuite/gcc.target/arm/attr_arm-err.c
--- d/gcc/gcc/testsuite/gcc.target/arm/attr_arm-err.c	1970-01-01 01:00:00.000000000 +0100
+++ e/gcc/gcc/testsuite/gcc.target/arm/attr_arm-err.c	2014-11-18 10:56:19.000000000 +0100
@@ -0,0 +1,12 @@ 
+/* Check that attribute target arm is rejected for M profile.  */
+/* { dg-do compile } */
+/* { dg-require-effective-target arm_arm_ok } */
+/* { dg-add-options arm_arch_v6m } */
+
+int __attribute__((target("arm")))
+foo(int a)
+{  /* { dg-error "does not support" } */
+  return a ? 1 : 5;
+}
+
+
diff '--exclude=ChangeLog*' '--exclude=.svn' '--exclude=*~' '--exclude=#*#' -rupN d/gcc/gcc/testsuite/gcc.target/arm/attr_thumb.c e/gcc/gcc/testsuite/gcc.target/arm/attr_thumb.c
--- d/gcc/gcc/testsuite/gcc.target/arm/attr_thumb.c	1970-01-01 01:00:00.000000000 +0100
+++ e/gcc/gcc/testsuite/gcc.target/arm/attr_thumb.c	2014-11-18 11:02:25.000000000 +0100
@@ -0,0 +1,13 @@ 
+/* Check that attribute target thumb is recogniwed. */
+/* { dg-do compile } */
+/* { dg-require-effective-target arm_thumb2_ok } */
+/* { dg-options "-O2" } */
+/* { dg-final { scan-assembler ".thumb" } } */
+/* { dg-final { scan-assembler "ite" } } */
+
+int __attribute__((target("thumb")))
+foo(int a)
+{
+  return a ? 1 : 5;
+}
+
diff '--exclude=ChangeLog*' '--exclude=.svn' '--exclude=*~' '--exclude=#*#' -rupN d/gcc/gcc/testsuite/gcc.target/arm/attr_thumb-static.c e/gcc/gcc/testsuite/gcc.target/arm/attr_thumb-static.c
--- d/gcc/gcc/testsuite/gcc.target/arm/attr_thumb-static.c	1970-01-01 01:00:00.000000000 +0100
+++ e/gcc/gcc/testsuite/gcc.target/arm/attr_thumb-static.c	2014-11-18 11:02:22.000000000 +0100
@@ -0,0 +1,24 @@ 
+/* Check that a change mode to a static function is correctly handled. */
+/* { dg-do run } */
+/* { dg-require-effective-target arm_thumb1_ok } */
+
+static void
+ __attribute__((__noinline__)) 
+foo (void)
+{
+  __asm__ ("");
+}
+
+static void
+__attribute__((__noinline__)) 
+__attribute__((target("thumb")))
+bar (void)
+{
+  __asm__ ("");
+}
+
+int main()
+{
+  foo();
+  bar();
+}