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'.

llvm-svn: 197523
This commit is contained in:
Nico Weber 2013-12-17 21:07:53 +00:00
parent 07eeb29386
commit 5f513f9b4a
3 changed files with 56 additions and 29 deletions

View File

@ -7,12 +7,12 @@
//
//===----------------------------------------------------------------------===//
#include "assembly.h"
.text
#if __i386__
.text
.globl __ZN9libunwind13Registers_x866jumptoEv
.private_extern __ZN9libunwind13Registers_x866jumptoEv
__ZN9libunwind13Registers_x866jumptoEv:
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_646jumptoEv:
#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

View File

@ -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

View File

@ -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 */