1// 7zAsm.S -- ASM macros for arm64 2// 2021-04-25 : Igor Pavlov : Public domain 3 4#define r0 x0 5#define r1 x1 6#define r2 x2 7#define r3 x3 8#define r4 x4 9#define r5 x5 10#define r6 x6 11#define r7 x7 12#define r8 x8 13#define r9 x9 14#define r10 x10 15#define r11 x11 16#define r12 x12 17#define r13 x13 18#define r14 x14 19#define r15 x15 20#define r16 x16 21#define r17 x17 22#define r18 x18 23#define r19 x19 24#define r20 x20 25#define r21 x21 26#define r22 x22 27#define r23 x23 28#define r24 x24 29#define r25 x25 30#define r26 x26 31#define r27 x27 32#define r28 x28 33#define r29 x29 34#define r30 x30 35 36#define REG_ABI_PARAM_0 r0 37#define REG_ABI_PARAM_1 r1 38#define REG_ABI_PARAM_2 r2 39 40 41.macro p2_add reg:req, param:req 42 add \reg, \reg, \param 43.endm 44 45.macro p2_sub reg:req, param:req 46 sub \reg, \reg, \param 47.endm 48 49.macro p2_sub_s reg:req, param:req 50 subs \reg, \reg, \param 51.endm 52 53.macro p2_and reg:req, param:req 54 and \reg, \reg, \param 55.endm 56 57.macro xor reg:req, param:req 58 eor \reg, \reg, \param 59.endm 60 61.macro or reg:req, param:req 62 orr \reg, \reg, \param 63.endm 64 65.macro shl reg:req, param:req 66 lsl \reg, \reg, \param 67.endm 68 69.macro shr reg:req, param:req 70 lsr \reg, \reg, \param 71.endm 72 73.macro sar reg:req, param:req 74 asr \reg, \reg, \param 75.endm 76 77.macro p1_neg reg:req 78 neg \reg, \reg 79.endm 80 81.macro dec reg:req 82 sub \reg, \reg, 1 83.endm 84 85.macro dec_s reg:req 86 subs \reg, \reg, 1 87.endm 88 89.macro inc reg:req 90 add \reg, \reg, 1 91.endm 92 93.macro inc_s reg:req 94 adds \reg, \reg, 1 95.endm 96 97 98.macro imul reg:req, param:req 99 mul \reg, \reg, \param 100.endm 101 102/* 103arm64 and arm use reverted c flag after subs/cmp instructions: 104 arm64-arm : x86 105 b.lo / b.cc : jb / jc 106 b.hs / b.cs : jae / jnc 107*/ 108 109.macro jmp lab:req 110 b \lab 111.endm 112 113.macro je lab:req 114 b.eq \lab 115.endm 116 117.macro jz lab:req 118 b.eq \lab 119.endm 120 121.macro jnz lab:req 122 b.ne \lab 123.endm 124 125.macro jne lab:req 126 b.ne \lab 127.endm 128 129.macro jb lab:req 130 b.lo \lab 131.endm 132 133.macro jbe lab:req 134 b.ls \lab 135.endm 136 137.macro ja lab:req 138 b.hi \lab 139.endm 140 141.macro jae lab:req 142 b.hs \lab 143.endm 144 145 146.macro cmove dest:req, srcTrue:req 147 csel \dest, \srcTrue, \dest, eq 148.endm 149 150.macro cmovne dest:req, srcTrue:req 151 csel \dest, \srcTrue, \dest, ne 152.endm 153 154.macro cmovs dest:req, srcTrue:req 155 csel \dest, \srcTrue, \dest, mi 156.endm 157 158.macro cmovns dest:req, srcTrue:req 159 csel \dest, \srcTrue, \dest, pl 160.endm 161 162.macro cmovb dest:req, srcTrue:req 163 csel \dest, \srcTrue, \dest, lo 164.endm 165 166.macro cmovae dest:req, srcTrue:req 167 csel \dest, \srcTrue, \dest, hs 168.endm 169 170 171.macro MY_ALIGN_16 macro 172 .p2align 4,, (1 << 4) - 1 173.endm 174 175.macro MY_ALIGN_32 macro 176 .p2align 5,, (1 << 5) - 1 177.endm 178 179.macro MY_ALIGN_64 macro 180 .p2align 6,, (1 << 6) - 1 181.endm 182