asm.S 2.44 KB
Newer Older
1 2 3
/*
 * Copyright (c) 2009 Loren Merritt
 *
4
 * This file is part of Libav.
5
 *
6
 * Libav is free software; you can redistribute it and/or
7 8 9 10
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
11
 * Libav is distributed in the hope that it will be useful,
12 13 14 15 16
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
17
 * License along with Libav; if not, write to the Free Software
18 19 20 21 22
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 */

#include "config.h"

23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
#define GLUE(a, b) a ## b
#define JOIN(a, b) GLUE(a, b)
#define X(s) JOIN(EXTERN_ASM, s)

#if ARCH_PPC64

#define PTR  .quad
#define lp   ld
#define lpx  ldx
#define stp  std
#define stpu stdu
#define PS   8
#define L(s) JOIN(., s)

.macro extfunc name
    .global X(\name)
    .section .opd, "aw"
X(\name):
    .quad L(\name), .TOC.@tocbase, 0
    .previous
    .type X(\name), STT_FUNC
L(\name):
.endm

47
.macro movrel rd, sym, gp
48 49 50
    ld      \rd, \sym@got(r2)
.endm

51 52 53
.macro get_got rd
.endm

54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
#else /* ARCH_PPC64 */

#define PTR  .int
#define lp   lwz
#define lpx  lwzx
#define stp  stw
#define stpu stwu
#define PS   4
#define L(s) s

.macro extfunc name
    .global X(\name)
    .type   X(\name), STT_FUNC
X(\name):
\name:
.endm

71
.macro movrel rd, sym, gp
72
#if CONFIG_PIC
73
    lwz     \rd, \sym@got(\gp)
74 75 76 77 78 79
#else
    lis     \rd, \sym@ha
    la      \rd, \sym@l(\rd)
#endif
.endm

80 81 82 83 84 85 86 87 88 89
.macro get_got rd
#if CONFIG_PIC
    bcl     20, 31, .Lgot\@
.Lgot\@:
    mflr    \rd
    addis   \rd, \rd, _GLOBAL_OFFSET_TABLE_ - .Lgot\@@ha
    addi    \rd, \rd, _GLOBAL_OFFSET_TABLE_ - .Lgot\@@l
#endif
.endm

90 91
#endif /* ARCH_PPC64 */

92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133
#if HAVE_IBM_ASM

.macro DEFINE_REG n
    .equiv r\n, \n
    .equiv f\n, \n
    .equiv v\n, \n
.endm

DEFINE_REG 0
DEFINE_REG 1
DEFINE_REG 2
DEFINE_REG 3
DEFINE_REG 4
DEFINE_REG 5
DEFINE_REG 6
DEFINE_REG 7
DEFINE_REG 8
DEFINE_REG 9
DEFINE_REG 10
DEFINE_REG 11
DEFINE_REG 12
DEFINE_REG 13
DEFINE_REG 14
DEFINE_REG 15
DEFINE_REG 16
DEFINE_REG 17
DEFINE_REG 18
DEFINE_REG 19
DEFINE_REG 20
DEFINE_REG 21
DEFINE_REG 22
DEFINE_REG 23
DEFINE_REG 24
DEFINE_REG 25
DEFINE_REG 26
DEFINE_REG 27
DEFINE_REG 28
DEFINE_REG 29
DEFINE_REG 30
DEFINE_REG 31

#endif /* HAVE_IBM_ASM */