From: Saurabh Jha <[email protected]>

For mingw targets, there is no way to identify the end of function using
assembly directives right now.

This patch adds such directive as a comment. This is not a real
directive because some other things, like Structured Exception Handling
(SEH), needs to be supported before we can emit a real directive.

However, emitting an end of function marker now will let us modify
check-function-bodies in scanasm.exp, which in turn enables us to write
dg-compile tests for mingw target.

gcc/ChangeLog:

        * config/aarch64/aarch64-abi-ms.h
        (ASM_COMMENT_START): Specify start of comment.
        (ASM_OUTPUT_TYPE_DIRECTIVE): Moved from aarch64-coff.h.
        (ASM_DECLARE_FUNCTION_SIZE): Specify end of function as comment.
        * config/aarch64/aarch64-coff.h
        (ASM_OUTPUT_TYPE_DIRECTIVE): Moved to aarch64-abi-ms.h.
        (ASM_DECLARE_FUNCTION_SIZE): Moved to aarch64-abi-ms.h.

gcc/testsuite/ChangeLog:

        * lib/scanasm.exp: Add support for mingw targets.
---
 gcc/config/aarch64/aarch64-abi-ms.h | 12 ++++++++++++
 gcc/config/aarch64/aarch64-coff.h   |  5 -----
 gcc/testsuite/lib/scanasm.exp       | 12 +++++++-----
 3 files changed, 19 insertions(+), 10 deletions(-)

diff --git a/gcc/config/aarch64/aarch64-abi-ms.h b/gcc/config/aarch64/aarch64-abi-ms.h
index bc9ada01772a..6eefe2188b62 100644
--- a/gcc/config/aarch64/aarch64-abi-ms.h
+++ b/gcc/config/aarch64/aarch64-abi-ms.h
@@ -31,4 +31,16 @@ along with GCC; see the file COPYING3.  If not see
 #undef  STATIC_CHAIN_REGNUM
 #define STATIC_CHAIN_REGNUM R17_REGNUM
 
+#define ASM_COMMENT_START "//"
+
+/* ASM_OUTPUT_TYPE_DIRECTIVE is not yet supported by binutils for the
+   aarch64-w64-mingw32 target.  */
+#define ASM_OUTPUT_TYPE_DIRECTIVE(STREAM, NAME, TYPE)
+
+/* Structured Exception Handling (SEH) is not yet supported by binutils
+   so adding seh_endproc as an assembly comment to mark the end of a
+   function.  */
+#define ASM_DECLARE_FUNCTION_SIZE(FILE, FNAME, DECL) \
+  fprintf (FILE, "\t" ASM_COMMENT_START "  seh_endproc\n")
+
 #endif /* GCC_AARCH64_ABI_MS_H.  */
diff --git a/gcc/config/aarch64/aarch64-coff.h b/gcc/config/aarch64/aarch64-coff.h
index 72607262e1ba..42ae022720ce 100644
--- a/gcc/config/aarch64/aarch64-coff.h
+++ b/gcc/config/aarch64/aarch64-coff.h
@@ -61,11 +61,6 @@
 #define ASM_OUTPUT_SKIP(STREAM, NBYTES) 	\
   fprintf (STREAM, "\t.space\t%d  // skip\n", (int) (NBYTES))
 
-/* Definitions that are not yet supported by binutils for the
-   aarch64-w64-mingw32 target.  */
-#define ASM_OUTPUT_TYPE_DIRECTIVE(STREAM, NAME, TYPE)
-#define ASM_DECLARE_FUNCTION_SIZE(FILE, FNAME, DECL)
-
 #define TEXT_SECTION_ASM_OP	"\t.text"
 #define DATA_SECTION_ASM_OP	"\t.data"
 #define BSS_SECTION_ASM_OP	"\t.bss"
diff --git a/gcc/testsuite/lib/scanasm.exp b/gcc/testsuite/lib/scanasm.exp
index 51952a6a7f45..9582eea70ae0 100644
--- a/gcc/testsuite/lib/scanasm.exp
+++ b/gcc/testsuite/lib/scanasm.exp
@@ -4,12 +4,12 @@
 # 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/>.
@@ -138,7 +138,7 @@ proc scan-assembler-not { args } {
 
 set_required_options_for scan-assembler-not
 
-# Return the scan for the assembly for hidden visibility. 
+# Return the scan for the assembly for hidden visibility.
 
 proc hidden-scan-for { symbol } {
 
@@ -516,7 +516,7 @@ proc scan-assembler-times { args } {
 
 set_required_options_for scan-assembler-times
 
-# Call pass if pattern is present within a lower or upper bound, 
+# Call pass if pattern is present within a lower or upper bound,
 # otherwise fail.
 # ex /* { dg-final { scan-assembler-bound {RE} > 3 } }
 proc scan-assembler-bound { args } {
@@ -563,7 +563,7 @@ proc scan-assembler-bound { args } {
         error "scan-assembler-bound: illegal argument: $bound"
         return
     }
-    
+
     set fd [open $output_file r]
     set text [read $fd]
     close $fd
@@ -885,6 +885,8 @@ proc configure_check-function-bodies { config } {
 	set up_config(end) {^\}$}
     } elseif { [istarget *-*-darwin*] } {
 	set up_config(end) {^LFE[0-9]+}
+    } elseif { [istarget aarch64*-*-mingw32] } {
+	set up_config(end) {seh_endproc}
     } else {
 	set up_config(end) {^\s*\.size}
     }

Reply via email to