[libcxxabi] r197523 - Add mangling macros for Unwind's inline assembly.

Nico Weber nicolasweber at gmx.de
Tue Dec 17 13:07:53 PST 2013


Author: nico
Date: Tue Dec 17 15:07:53 2013
New Revision: 197523

URL: http://llvm.org/viewvc/llvm-project?rev=197523&view=rev
Log:
Add mangling macros for Unwind's inline assembly.

This is in preparation for landing an implementation of unw_getcontext
on a system where it's mangled 'unw_getcontext', not '_unw_getcontext'.


Added:
    libcxxabi/trunk/src/Unwind/assembly.h
Modified:
    libcxxabi/trunk/src/Unwind/UnwindRegistersRestore.S
    libcxxabi/trunk/src/Unwind/UnwindRegistersSave.S

Modified: libcxxabi/trunk/src/Unwind/UnwindRegistersRestore.S
URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/Unwind/UnwindRegistersRestore.S?rev=197523&r1=197522&r2=197523&view=diff
==============================================================================
--- libcxxabi/trunk/src/Unwind/UnwindRegistersRestore.S (original)
+++ libcxxabi/trunk/src/Unwind/UnwindRegistersRestore.S Tue Dec 17 15:07:53 2013
@@ -7,12 +7,12 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "assembly.h"
 
-#if __i386__
   .text
-  .globl __ZN9libunwind13Registers_x866jumptoEv
-  .private_extern __ZN9libunwind13Registers_x866jumptoEv
-__ZN9libunwind13Registers_x866jumptoEv:
+
+#if __i386__
+DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind13Registers_x866jumptoEv)
 #
 # void libunwind::Registers_x86::jumpto()
 #
@@ -54,10 +54,7 @@ __ZN9libunwind13Registers_x866jumptoEv:
 
 #elif __x86_64__
 
-  .text
-  .globl __ZN9libunwind16Registers_x86_646jumptoEv
-  .private_extern __ZN9libunwind16Registers_x86_646jumptoEv
-__ZN9libunwind16Registers_x86_646jumptoEv:
+DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind16Registers_x86_646jumptoEv)
 #
 # void libunwind::Registers_x86_64::jumpto()
 #
@@ -98,10 +95,7 @@ __ZN9libunwind16Registers_x86_646jumptoE
 
 #elif __ppc__
 
-  .text
-  .globl __ZN9libunwind13Registers_ppc6jumptoEv
-  .private_extern __ZN9libunwind13Registers_ppc6jumptoEv
-__ZN9libunwind13Registers_ppc6jumptoEv:
+DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind13Registers_ppc6jumptoEv)
 ;
 ; void libunwind::Registers_ppc::jumpto()
 ;
@@ -266,16 +260,13 @@ Lnovec:
 
 #elif __arm64__
 
-  .text
-  .globl __ZN9libunwind15Registers_arm646jumptoEv
-  .private_extern __ZN9libunwind15Registers_arm646jumptoEv
-__ZN9libunwind15Registers_arm646jumptoEv:
 ;
 ; void libunwind::Registers_arm64::jumpto()
 ;
 ; On entry:
 ;  thread_state pointer is in x0
 ;
+DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind15Registers_arm646jumptoEv)
   ; skip restore of x0,x1 for now
   ldp    x2, x3,  [x0, #0x010]
   ldp    x4, x5,  [x0, #0x020]
@@ -316,8 +307,4 @@ __ZN9libunwind15Registers_arm646jumptoEv
   ldp    x0, x1,  [x0, #0x000]  ; restore x0,x1
   ret    lr            ; jump to pc
 
-
-
-
 #endif
-

Modified: libcxxabi/trunk/src/Unwind/UnwindRegistersSave.S
URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/Unwind/UnwindRegistersSave.S?rev=197523&r1=197522&r2=197523&view=diff
==============================================================================
--- libcxxabi/trunk/src/Unwind/UnwindRegistersSave.S (original)
+++ libcxxabi/trunk/src/Unwind/UnwindRegistersSave.S Tue Dec 17 15:07:53 2013
@@ -7,6 +7,7 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "assembly.h"
 
     .text
 
@@ -24,8 +25,7 @@
 #   +-----------------------+   <-- SP
 #   +                       +
 #
-  .globl _unw_getcontext
-_unw_getcontext:
+DEFINE_LIBUNWIND_FUNCTION(unw_getcontext)
   push  %eax
   movl  8(%esp), %eax
   movl  %ebx,  4(%eax)
@@ -60,8 +60,7 @@ _unw_getcontext:
 # On entry:
 #  thread_state pointer is in rdi
 #
-  .globl _unw_getcontext
-_unw_getcontext:
+DEFINE_LIBUNWIND_FUNCTION(unw_getcontext)
   movq  %rax,   (%rdi)
   movq  %rbx,  8(%rdi)
   movq  %rcx, 16(%rdi)
@@ -96,8 +95,7 @@ _unw_getcontext:
 ; On entry:
 ;  thread_state pointer is in r3
 ;
-  .globl _unw_getcontext
-_unw_getcontext:
+DEFINE_LIBUNWIND_FUNCTION(unw_getcontext)
   stw    r0,  8(r3)
   mflr  r0
   stw    r0,  0(r3)  ; store lr as ssr0
@@ -240,8 +238,7 @@ _unw_getcontext:
 ; On entry:
 ;  thread_state pointer is in x0
 ;
-  .globl _unw_getcontext
-_unw_getcontext:
+DEFINE_LIBUNWIND_FUNCTION(unw_getcontext)
   stp    x0, x1,  [x0, #0x000]
   stp    x2, x3,  [x0, #0x010]
   stp    x4, x5,  [x0, #0x020]
@@ -283,4 +280,3 @@ _unw_getcontext:
   ret
 
 #endif
-

Added: libcxxabi/trunk/src/Unwind/assembly.h
URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/Unwind/assembly.h?rev=197523&view=auto
==============================================================================
--- libcxxabi/trunk/src/Unwind/assembly.h (added)
+++ libcxxabi/trunk/src/Unwind/assembly.h Tue Dec 17 15:07:53 2013
@@ -0,0 +1,44 @@
+/* ===-- assembly.h - libUnwind assembler support macros -------------------===
+ *
+ *                     The LLVM Compiler Infrastructure
+ *
+ * This file is dual licensed under the MIT and the University of Illinois Open
+ * Source Licenses. See LICENSE.TXT for details.
+ *
+ * ===----------------------------------------------------------------------===
+ *
+ * This file defines macros for use in libUnwind assembler source.
+ * This file is not part of the interface of this library.
+ *
+ * ===----------------------------------------------------------------------===
+ */
+
+#ifndef UNWIND_ASSEMBLY_H
+#define UNWIND_ASSEMBLY_H
+
+#if defined(__POWERPC__) || defined(__powerpc__) || defined(__ppc__)
+#define SEPARATOR @
+#else
+#define SEPARATOR ;
+#endif
+
+#if defined(__APPLE__)
+#define HIDDEN_DIRECTIVE .private_extern
+#else
+#define HIDDEN_DIRECTIVE .hidden
+#endif
+
+#define GLUE2(a, b) a ## b
+#define GLUE(a, b) GLUE2(a, b)
+#define SYMBOL_NAME(name) GLUE(__USER_LABEL_PREFIX__, name)
+
+#define DEFINE_LIBUNWIND_FUNCTION(name)                   \
+  .globl SYMBOL_NAME(name) SEPARATOR                      \
+  SYMBOL_NAME(name):
+
+#define DEFINE_LIBUNWIND_PRIVATE_FUNCTION(name)           \
+  .globl SYMBOL_NAME(name) SEPARATOR                      \
+  HIDDEN_DIRECTIVE SYMBOL_NAME(name) SEPARATOR            \
+  SYMBOL_NAME(name):
+
+#endif /* UNWIND_ASSEMBLY_H */





More information about the cfe-commits mailing list