1 /* 2 * Copyright (c) 2009 Loren Merritt 3 * 4 * This file is part of FFmpeg. 5 * 6 * FFmpeg is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU Lesser General Public 8 * License as published by the Free Software Foundation; either 9 * version 2.1 of the License, or (at your option) any later version. 10 * 11 * FFmpeg is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 * Lesser General Public License for more details. 15 * 16 * You should have received a copy of the GNU Lesser General Public 17 * License along with FFmpeg; if not, write to the Free Software 18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 */ 20 21 #include "config.h" 22 23 #define GLUE(a, b) a ## b 24 #define JOIN(a, b) GLUE(a, b) 25 #define X(s) JOIN(EXTERN_ASM, s) 26 27 #if __APPLE__ 28 #define R(n) r ## n 29 #else 30 #define R(n) n 31 #endif 32 33 #if ARCH_PPC64 34 35 #define PTR .quad 36 #define lp ld 37 #define lpx ldx 38 #define stp std 39 #define stpu stdu 40 #define PS 8 41 #define L(s) JOIN(., s) 42 43 .macro extfunc name 44 .global X(\name) 45 #if _CALL_ELF == 2 46 .text 47 X(\name): 48 addis %r2, %r12, .TOC.-X(\name)@ha 49 addi %r2, %r2, .TOC.-X(\name)@l 50 .localentry X(\name), .-X(\name) 51 #else 52 .section .opd, "aw" 53 X(\name): 54 .quad L(\name), .TOC.@tocbase, 0 55 .previous 56 .type X(\name), STT_FUNC 57 L(\name): 58 #endif 59 .endm 60 61 .macro movrel rd, sym, gp 62 ld \rd, \sym@got(R(2)) 63 .endm 64 65 .macro get_got rd 66 .endm 67 68 #else /* ARCH_PPC64 */ 69 70 #define PTR .int 71 #define lp lwz 72 #define lpx lwzx 73 #define stp stw 74 #define stpu stwu 75 #define PS 4 76 #define L(s) s 77 78 .macro extfunc name 79 .global X(\name) 80 .type X(\name), STT_FUNC 81 X(\name): 82 \name: 83 .endm 84 85 .macro movrel rd, sym, gp 86 #if CONFIG_PIC 87 lwz \rd, \sym@got(\gp) 88 #else 89 lis \rd, \sym@ha 90 la \rd, \sym@l(\rd) 91 #endif 92 .endm 93 94 .macro get_got rd 95 #if CONFIG_PIC 96 bcl 20, 31, .Lgot\@ 97 .Lgot\@: 98 mflr \rd 99 addis \rd, \rd, _GLOBAL_OFFSET_TABLE_ - .Lgot\@@ha 100 addi \rd, \rd, _GLOBAL_OFFSET_TABLE_ - .Lgot\@@l 101 #endif 102 .endm 103 104 #endif /* ARCH_PPC64 */ 105 106 #if HAVE_IBM_ASM 107 108 .macro DEFINE_REG n 109 .equiv r\n, \n 110 .equiv f\n, \n 111 .equiv v\n, \n 112 .endm 113 114 DEFINE_REG 0 115 DEFINE_REG 1 116 DEFINE_REG 2 117 DEFINE_REG 3 118 DEFINE_REG 4 119 DEFINE_REG 5 120 DEFINE_REG 6 121 DEFINE_REG 7 122 DEFINE_REG 8 123 DEFINE_REG 9 124 DEFINE_REG 10 125 DEFINE_REG 11 126 DEFINE_REG 12 127 DEFINE_REG 13 128 DEFINE_REG 14 129 DEFINE_REG 15 130 DEFINE_REG 16 131 DEFINE_REG 17 132 DEFINE_REG 18 133 DEFINE_REG 19 134 DEFINE_REG 20 135 DEFINE_REG 21 136 DEFINE_REG 22 137 DEFINE_REG 23 138 DEFINE_REG 24 139 DEFINE_REG 25 140 DEFINE_REG 26 141 DEFINE_REG 27 142 DEFINE_REG 28 143 DEFINE_REG 29 144 DEFINE_REG 30 145 DEFINE_REG 31 146 147 #endif /* HAVE_IBM_ASM */ 148