asm.S (3633B)
1 /* 2 * Copyright © 2018, VideoLAN and dav1d authors 3 * Copyright © 2023, Nathan Egge 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions are met: 8 * 9 * 1. Redistributions of source code must retain the above copyright notice, this 10 * list of conditions and the following disclaimer. 11 * 12 * 2. Redistributions in binary form must reproduce the above copyright notice, 13 * this list of conditions and the following disclaimer in the documentation 14 * and/or other materials provided with the distribution. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 */ 27 28 #ifndef DAV1D_SRC_RISCV_ASM_S 29 #define DAV1D_SRC_RISCV_ASM_S 30 31 #include "config.h" 32 33 #if !defined(PIC) 34 #if defined(__PIC__) 35 #define PIC __PIC__ 36 #elif defined(__pic__) 37 #define PIC __pic__ 38 #endif 39 #endif 40 41 #ifndef PRIVATE_PREFIX 42 #define PRIVATE_PREFIX dav1d_ 43 #endif 44 45 #define PASTE(a,b) a ## b 46 #define CONCAT(a,b) PASTE(a,b) 47 48 #ifdef PREFIX 49 #define EXTERN CONCAT(_,PRIVATE_PREFIX) 50 #else 51 #define EXTERN PRIVATE_PREFIX 52 #endif 53 54 .macro arch ext:req, more:vararg 55 .option arch, +\ext 56 .ifnb \more 57 arch \more 58 .endif 59 .endm 60 61 .macro function name, export=0, ext= 62 .macro endfunc 63 #ifdef __ELF__ 64 .size \name, . - \name 65 #endif 66 .option pop 67 .purgem endfunc 68 .endm 69 .text 70 .option push 71 .ifnb \ext 72 arch \ext 73 .endif 74 .if \export 75 .global EXTERN\name 76 #ifdef __ELF__ 77 .type EXTERN\name, %function 78 .hidden EXTERN\name 79 #elif defined(__MACH__) 80 .private_extern EXTERN\name 81 #endif 82 EXTERN\name: 83 .else 84 #ifdef __ELF__ 85 .type \name, %function 86 #endif 87 .endif 88 \name: 89 .endm 90 91 .macro const name, export=0, align=2 92 .macro endconst 93 #ifdef __ELF__ 94 .size \name, . - \name 95 #endif 96 .purgem endconst 97 .endm 98 #if defined(_WIN32) 99 .section .rdata 100 #elif !defined(__MACH__) 101 .section .rodata 102 #else 103 .const_data 104 #endif 105 .align \align 106 .if \export 107 .global EXTERN\name 108 #ifdef __ELF__ 109 .hidden EXTERN\name 110 #elif defined(__MACH__) 111 .private_extern EXTERN\name 112 #endif 113 EXTERN\name: 114 .endif 115 \name: 116 .endm 117 118 .macro thread_local name, align=3, quads=1 119 .macro end_thread_local 120 .size \name, . - \name 121 .purgem end_thread_local 122 .endm 123 .section .tbss, "waT" 124 .align \align 125 .hidden \name 126 \name: 127 .rept \quads 128 .quad 0 129 .endr 130 end_thread_local 131 .endm 132 133 #define L(x) .L ## x 134 135 #define MA (1 << 7) 136 #define TA (1 << 6) 137 #define E8 (0 << 3) 138 #define E16 (1 << 3) 139 #define E32 (2 << 3) 140 #define E64 (3 << 3) 141 #define M1 0 142 #define M2 1 143 #define M4 2 144 #define M8 3 145 #define MF2 7 146 #define MF4 6 147 #define MF8 5 148 149 #endif /* DAV1D_SRC_RISCV_ASM_S */