1 /* 2 * Copyright (c) 2023 Institute of Parallel And Distributed Systems (IPADS), Shanghai Jiao Tong University (SJTU) 3 * Licensed under the Mulan PSL v2. 4 * You can use this software according to the terms and conditions of the Mulan PSL v2. 5 * You may obtain a copy of Mulan PSL v2 at: 6 * http://license.coscl.org.cn/MulanPSL2 7 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR 8 * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR 9 * PURPOSE. 10 * See the Mulan PSL v2 for more details. 11 */ 12 #ifndef COMMON_ASM_H 13 #define COMMON_ASM_H 14 15 #define ASM_EXTABLE_32(insn, fixup) \ 16 .pushsection .extable, "a"; \ 17 .align 2; \ 18 .word ((insn)); \ 19 .word ((fixup)); \ 20 .popsection; 21 22 #define ASM_EXTABLE_64(insn, fixup) \ 23 .pushsection .extable, "a"; \ 24 .align 4; \ 25 .quad ((insn)); \ 26 .quad ((fixup)); \ 27 .popsection; 28 29 /* 30 * clang-format will change '%function' into '% function', 31 * which cannot be understood by the compiler 32 */ 33 // clang-format off 34 #define BEGIN_FUNC(_name) \ 35 .global _name; \ 36 .type _name, %function; \ 37 _name: 38 // clang-format on 39 40 #define END_FUNC(_name) .size _name, .- _name 41 42 #define EXPORT(symbol) \ 43 .globl symbol; \ 44 symbol: 45 46 #define LOCAL_DATA(x) \ 47 .type x, 1; \ 48 x: 49 50 #define DATA(x) \ 51 .global x; \ 52 .hidden x; \ 53 LOCAL_DATA(x) 54 55 #define END_DATA(x) .size x, .- x 56 57 #endif /* COMMON_ASM_H */