1384740dcSRalf Baechle /* 2384740dcSRalf Baechle * This file is subject to the terms and conditions of the GNU General Public 3384740dcSRalf Baechle * License. See the file "COPYING" in the main directory of this archive 4384740dcSRalf Baechle * for more details. 5384740dcSRalf Baechle * 6384740dcSRalf Baechle * Copyright (C) 2003 Ralf Baechle 7384740dcSRalf Baechle */ 8384740dcSRalf Baechle #ifndef _ASM_ASMMACRO_H 9384740dcSRalf Baechle #define _ASM_ASMMACRO_H 10384740dcSRalf Baechle 11384740dcSRalf Baechle #include <asm/hazards.h> 1271ca7588SJim Quinlan #include <asm/asm-offsets.h> 13f7a46fa7SPaul Burton #include <asm/msa.h> 14384740dcSRalf Baechle 15384740dcSRalf Baechle #ifdef CONFIG_32BIT 16384740dcSRalf Baechle #include <asm/asmmacro-32.h> 17384740dcSRalf Baechle #endif 18384740dcSRalf Baechle #ifdef CONFIG_64BIT 19384740dcSRalf Baechle #include <asm/asmmacro-64.h> 20384740dcSRalf Baechle #endif 21384740dcSRalf Baechle 22c7fd89a6SJames Hogan /* preprocessor replaces the fp in ".set fp=64" with $30 otherwise */ 23c7fd89a6SJames Hogan #undef fp 24c7fd89a6SJames Hogan 256e1b29c3SJames Hogan /* 266e1b29c3SJames Hogan * Helper macros for generating raw instruction encodings. 276e1b29c3SJames Hogan */ 286e1b29c3SJames Hogan #ifdef CONFIG_CPU_MICROMIPS 296e1b29c3SJames Hogan .macro insn32_if_mm enc 306e1b29c3SJames Hogan .insn 316e1b29c3SJames Hogan .hword ((\enc) >> 16) 326e1b29c3SJames Hogan .hword ((\enc) & 0xffff) 336e1b29c3SJames Hogan .endm 346e1b29c3SJames Hogan 356e1b29c3SJames Hogan .macro insn_if_mips enc 366e1b29c3SJames Hogan .endm 376e1b29c3SJames Hogan #else 386e1b29c3SJames Hogan .macro insn32_if_mm enc 396e1b29c3SJames Hogan .endm 406e1b29c3SJames Hogan 416e1b29c3SJames Hogan .macro insn_if_mips enc 426e1b29c3SJames Hogan .insn 436e1b29c3SJames Hogan .word (\enc) 446e1b29c3SJames Hogan .endm 456e1b29c3SJames Hogan #endif 466e1b29c3SJames Hogan 4705c4e272SHuang Pei #ifdef CONFIG_CPU_HAS_DIEI 48*275aca65SNathan Chancellor .macro local_irq_enable 49b6354db5SDavid Daney ei 50b6354db5SDavid Daney irq_enable_hazard 51b6354db5SDavid Daney .endm 52b6354db5SDavid Daney 53*275aca65SNathan Chancellor .macro local_irq_disable 54b6354db5SDavid Daney di 55b6354db5SDavid Daney irq_disable_hazard 56b6354db5SDavid Daney .endm 57ab7c01fdSSerge Semin #else /* !CONFIG_CPU_MIPSR2 && !CONFIG_CPU_MIPSR5 && !CONFIG_CPU_MIPSR6 */ 58384740dcSRalf Baechle .macro local_irq_enable reg=t0 59384740dcSRalf Baechle mfc0 \reg, CP0_STATUS 60384740dcSRalf Baechle ori \reg, \reg, 1 61384740dcSRalf Baechle mtc0 \reg, CP0_STATUS 62384740dcSRalf Baechle irq_enable_hazard 63384740dcSRalf Baechle .endm 64384740dcSRalf Baechle 65384740dcSRalf Baechle .macro local_irq_disable reg=t0 66098fa51bSThomas Gleixner #ifdef CONFIG_PREEMPTION 6771ca7588SJim Quinlan lw \reg, TI_PRE_COUNT($28) 6871ca7588SJim Quinlan addi \reg, \reg, 1 6971ca7588SJim Quinlan sw \reg, TI_PRE_COUNT($28) 7071ca7588SJim Quinlan #endif 71384740dcSRalf Baechle mfc0 \reg, CP0_STATUS 72384740dcSRalf Baechle ori \reg, \reg, 1 73384740dcSRalf Baechle xori \reg, \reg, 1 74384740dcSRalf Baechle mtc0 \reg, CP0_STATUS 75384740dcSRalf Baechle irq_disable_hazard 76098fa51bSThomas Gleixner #ifdef CONFIG_PREEMPTION 7771ca7588SJim Quinlan lw \reg, TI_PRE_COUNT($28) 7871ca7588SJim Quinlan addi \reg, \reg, -1 7971ca7588SJim Quinlan sw \reg, TI_PRE_COUNT($28) 8071ca7588SJim Quinlan #endif 81384740dcSRalf Baechle .endm 82ab7c01fdSSerge Semin #endif /* !CONFIG_CPU_MIPSR2 && !CONFIG_CPU_MIPSR5 && !CONFIG_CPU_MIPSR6 */ 83384740dcSRalf Baechle 84597ce172SPaul Burton .macro fpu_save_16even thread tmp=t0 85842dfc11SManuel Lauss .set push 8680a20d2fSNathan Chancellor .set hardfloat 87597ce172SPaul Burton cfc1 \tmp, fcr31 88466aec5fSJames Hogan sdc1 $f0, THREAD_FPR0(\thread) 89466aec5fSJames Hogan sdc1 $f2, THREAD_FPR2(\thread) 90466aec5fSJames Hogan sdc1 $f4, THREAD_FPR4(\thread) 91466aec5fSJames Hogan sdc1 $f6, THREAD_FPR6(\thread) 92466aec5fSJames Hogan sdc1 $f8, THREAD_FPR8(\thread) 93466aec5fSJames Hogan sdc1 $f10, THREAD_FPR10(\thread) 94466aec5fSJames Hogan sdc1 $f12, THREAD_FPR12(\thread) 95466aec5fSJames Hogan sdc1 $f14, THREAD_FPR14(\thread) 96466aec5fSJames Hogan sdc1 $f16, THREAD_FPR16(\thread) 97466aec5fSJames Hogan sdc1 $f18, THREAD_FPR18(\thread) 98466aec5fSJames Hogan sdc1 $f20, THREAD_FPR20(\thread) 99466aec5fSJames Hogan sdc1 $f22, THREAD_FPR22(\thread) 100466aec5fSJames Hogan sdc1 $f24, THREAD_FPR24(\thread) 101466aec5fSJames Hogan sdc1 $f26, THREAD_FPR26(\thread) 102466aec5fSJames Hogan sdc1 $f28, THREAD_FPR28(\thread) 103466aec5fSJames Hogan sdc1 $f30, THREAD_FPR30(\thread) 104597ce172SPaul Burton sw \tmp, THREAD_FCR31(\thread) 105842dfc11SManuel Lauss .set pop 106597ce172SPaul Burton .endm 107597ce172SPaul Burton 108597ce172SPaul Burton .macro fpu_save_16odd thread 109597ce172SPaul Burton .set push 110597ce172SPaul Burton .set mips64r2 111c7fd89a6SJames Hogan .set fp=64 11280a20d2fSNathan Chancellor .set hardfloat 113466aec5fSJames Hogan sdc1 $f1, THREAD_FPR1(\thread) 114466aec5fSJames Hogan sdc1 $f3, THREAD_FPR3(\thread) 115466aec5fSJames Hogan sdc1 $f5, THREAD_FPR5(\thread) 116466aec5fSJames Hogan sdc1 $f7, THREAD_FPR7(\thread) 117466aec5fSJames Hogan sdc1 $f9, THREAD_FPR9(\thread) 118466aec5fSJames Hogan sdc1 $f11, THREAD_FPR11(\thread) 119466aec5fSJames Hogan sdc1 $f13, THREAD_FPR13(\thread) 120466aec5fSJames Hogan sdc1 $f15, THREAD_FPR15(\thread) 121466aec5fSJames Hogan sdc1 $f17, THREAD_FPR17(\thread) 122466aec5fSJames Hogan sdc1 $f19, THREAD_FPR19(\thread) 123466aec5fSJames Hogan sdc1 $f21, THREAD_FPR21(\thread) 124466aec5fSJames Hogan sdc1 $f23, THREAD_FPR23(\thread) 125466aec5fSJames Hogan sdc1 $f25, THREAD_FPR25(\thread) 126466aec5fSJames Hogan sdc1 $f27, THREAD_FPR27(\thread) 127466aec5fSJames Hogan sdc1 $f29, THREAD_FPR29(\thread) 128466aec5fSJames Hogan sdc1 $f31, THREAD_FPR31(\thread) 129597ce172SPaul Burton .set pop 130597ce172SPaul Burton .endm 131597ce172SPaul Burton 132597ce172SPaul Burton .macro fpu_save_double thread status tmp 13322b8ba76SJames Hogan #if defined(CONFIG_64BIT) || defined(CONFIG_CPU_MIPSR2) || \ 134ab7c01fdSSerge Semin defined(CONFIG_CPU_MIPSR5) || defined(CONFIG_CPU_MIPSR6) 135597ce172SPaul Burton sll \tmp, \status, 5 136597ce172SPaul Burton bgez \tmp, 10f 137597ce172SPaul Burton fpu_save_16odd \thread 138597ce172SPaul Burton 10: 139597ce172SPaul Burton #endif 140597ce172SPaul Burton fpu_save_16even \thread \tmp 141597ce172SPaul Burton .endm 142597ce172SPaul Burton 143597ce172SPaul Burton .macro fpu_restore_16even thread tmp=t0 144842dfc11SManuel Lauss .set push 14580a20d2fSNathan Chancellor .set hardfloat 146597ce172SPaul Burton lw \tmp, THREAD_FCR31(\thread) 147466aec5fSJames Hogan ldc1 $f0, THREAD_FPR0(\thread) 148466aec5fSJames Hogan ldc1 $f2, THREAD_FPR2(\thread) 149466aec5fSJames Hogan ldc1 $f4, THREAD_FPR4(\thread) 150466aec5fSJames Hogan ldc1 $f6, THREAD_FPR6(\thread) 151466aec5fSJames Hogan ldc1 $f8, THREAD_FPR8(\thread) 152466aec5fSJames Hogan ldc1 $f10, THREAD_FPR10(\thread) 153466aec5fSJames Hogan ldc1 $f12, THREAD_FPR12(\thread) 154466aec5fSJames Hogan ldc1 $f14, THREAD_FPR14(\thread) 155466aec5fSJames Hogan ldc1 $f16, THREAD_FPR16(\thread) 156466aec5fSJames Hogan ldc1 $f18, THREAD_FPR18(\thread) 157466aec5fSJames Hogan ldc1 $f20, THREAD_FPR20(\thread) 158466aec5fSJames Hogan ldc1 $f22, THREAD_FPR22(\thread) 159466aec5fSJames Hogan ldc1 $f24, THREAD_FPR24(\thread) 160466aec5fSJames Hogan ldc1 $f26, THREAD_FPR26(\thread) 161466aec5fSJames Hogan ldc1 $f28, THREAD_FPR28(\thread) 162466aec5fSJames Hogan ldc1 $f30, THREAD_FPR30(\thread) 163597ce172SPaul Burton ctc1 \tmp, fcr31 1643cbc6fc9SHuacai Chen .set pop 165597ce172SPaul Burton .endm 166597ce172SPaul Burton 167597ce172SPaul Burton .macro fpu_restore_16odd thread 168597ce172SPaul Burton .set push 169597ce172SPaul Burton .set mips64r2 170c7fd89a6SJames Hogan .set fp=64 17180a20d2fSNathan Chancellor .set hardfloat 172466aec5fSJames Hogan ldc1 $f1, THREAD_FPR1(\thread) 173466aec5fSJames Hogan ldc1 $f3, THREAD_FPR3(\thread) 174466aec5fSJames Hogan ldc1 $f5, THREAD_FPR5(\thread) 175466aec5fSJames Hogan ldc1 $f7, THREAD_FPR7(\thread) 176466aec5fSJames Hogan ldc1 $f9, THREAD_FPR9(\thread) 177466aec5fSJames Hogan ldc1 $f11, THREAD_FPR11(\thread) 178466aec5fSJames Hogan ldc1 $f13, THREAD_FPR13(\thread) 179466aec5fSJames Hogan ldc1 $f15, THREAD_FPR15(\thread) 180466aec5fSJames Hogan ldc1 $f17, THREAD_FPR17(\thread) 181466aec5fSJames Hogan ldc1 $f19, THREAD_FPR19(\thread) 182466aec5fSJames Hogan ldc1 $f21, THREAD_FPR21(\thread) 183466aec5fSJames Hogan ldc1 $f23, THREAD_FPR23(\thread) 184466aec5fSJames Hogan ldc1 $f25, THREAD_FPR25(\thread) 185466aec5fSJames Hogan ldc1 $f27, THREAD_FPR27(\thread) 186466aec5fSJames Hogan ldc1 $f29, THREAD_FPR29(\thread) 187466aec5fSJames Hogan ldc1 $f31, THREAD_FPR31(\thread) 188597ce172SPaul Burton .set pop 189597ce172SPaul Burton .endm 190597ce172SPaul Burton 191597ce172SPaul Burton .macro fpu_restore_double thread status tmp 19222b8ba76SJames Hogan #if defined(CONFIG_64BIT) || defined(CONFIG_CPU_MIPSR2) || \ 193ab7c01fdSSerge Semin defined(CONFIG_CPU_MIPSR5) || defined(CONFIG_CPU_MIPSR6) 194597ce172SPaul Burton sll \tmp, \status, 5 195597ce172SPaul Burton bgez \tmp, 10f # 16 register mode? 196597ce172SPaul Burton 197597ce172SPaul Burton fpu_restore_16odd \thread 198597ce172SPaul Burton 10: 199597ce172SPaul Burton #endif 200597ce172SPaul Burton fpu_restore_16even \thread \tmp 201597ce172SPaul Burton .endm 202597ce172SPaul Burton 203ab7c01fdSSerge Semin #if defined(CONFIG_CPU_MIPSR2) || defined(CONFIG_CPU_MIPSR5) || \ 204ab7c01fdSSerge Semin defined(CONFIG_CPU_MIPSR6) 2051d688087SPaul Burton .macro _EXT rd, rs, p, s 2061d688087SPaul Burton ext \rd, \rs, \p, \s 2071d688087SPaul Burton .endm 208ab7c01fdSSerge Semin #else /* !CONFIG_CPU_MIPSR2 && !CONFIG_CPU_MIPSR5 && !CONFIG_CPU_MIPSR6 */ 2091d688087SPaul Burton .macro _EXT rd, rs, p, s 2101d688087SPaul Burton srl \rd, \rs, \p 2111d688087SPaul Burton andi \rd, \rd, (1 << \s) - 1 2121d688087SPaul Burton .endm 213ab7c01fdSSerge Semin #endif /* !CONFIG_CPU_MIPSR2 && !CONFIG_CPU_MIPSR5 && !CONFIG_CPU_MIPSR6 */ 2141d688087SPaul Burton 215384740dcSRalf Baechle /* 216384740dcSRalf Baechle * Temporary until all gas have MT ASE support 217384740dcSRalf Baechle */ 218384740dcSRalf Baechle .macro DMT reg=0 219384740dcSRalf Baechle .word 0x41600bc1 | (\reg << 16) 220384740dcSRalf Baechle .endm 221384740dcSRalf Baechle 222384740dcSRalf Baechle .macro EMT reg=0 223384740dcSRalf Baechle .word 0x41600be1 | (\reg << 16) 224384740dcSRalf Baechle .endm 225384740dcSRalf Baechle 226384740dcSRalf Baechle .macro DVPE reg=0 227384740dcSRalf Baechle .word 0x41600001 | (\reg << 16) 228384740dcSRalf Baechle .endm 229384740dcSRalf Baechle 230384740dcSRalf Baechle .macro EVPE reg=0 231384740dcSRalf Baechle .word 0x41600021 | (\reg << 16) 232384740dcSRalf Baechle .endm 233384740dcSRalf Baechle 234384740dcSRalf Baechle .macro MFTR rt=0, rd=0, u=0, sel=0 235384740dcSRalf Baechle .word 0x41000000 | (\rt << 16) | (\rd << 11) | (\u << 5) | (\sel) 236384740dcSRalf Baechle .endm 237384740dcSRalf Baechle 238384740dcSRalf Baechle .macro MTTR rt=0, rd=0, u=0, sel=0 239384740dcSRalf Baechle .word 0x41800000 | (\rt << 16) | (\rd << 11) | (\u << 5) | (\sel) 240384740dcSRalf Baechle .endm 241384740dcSRalf Baechle 2427f65afb9SPaul Burton #ifdef TOOLCHAIN_SUPPORTS_MSA 243e1bebbabSPaul Burton .macro _cfcmsa rd, cs 244e1bebbabSPaul Burton .set push 245e1bebbabSPaul Burton .set mips32r2 2462bd7bc25SMarkos Chandras .set fp=64 247e1bebbabSPaul Burton .set msa 248e1bebbabSPaul Burton cfcmsa \rd, $\cs 249e1bebbabSPaul Burton .set pop 250e1bebbabSPaul Burton .endm 251e1bebbabSPaul Burton 252e1bebbabSPaul Burton .macro _ctcmsa cd, rs 253e1bebbabSPaul Burton .set push 254e1bebbabSPaul Burton .set mips32r2 2552bd7bc25SMarkos Chandras .set fp=64 256e1bebbabSPaul Burton .set msa 257e1bebbabSPaul Burton ctcmsa $\cd, \rs 258e1bebbabSPaul Burton .set pop 259e1bebbabSPaul Burton .endm 260e1bebbabSPaul Burton 2616b35e114SPaul Burton .macro ld_b wd, off, base 2626b35e114SPaul Burton .set push 2636b35e114SPaul Burton .set mips32r2 26492e9953cSJames Hogan .set fp=64 2656b35e114SPaul Burton .set msa 2666b35e114SPaul Burton ld.b $w\wd, \off(\base) 2676b35e114SPaul Burton .set pop 2686b35e114SPaul Burton .endm 2696b35e114SPaul Burton 2706b35e114SPaul Burton .macro ld_h wd, off, base 2716b35e114SPaul Burton .set push 2726b35e114SPaul Burton .set mips32r2 27392e9953cSJames Hogan .set fp=64 2746b35e114SPaul Burton .set msa 2756b35e114SPaul Burton ld.h $w\wd, \off(\base) 2766b35e114SPaul Burton .set pop 2776b35e114SPaul Burton .endm 2786b35e114SPaul Burton 2796b35e114SPaul Burton .macro ld_w wd, off, base 2806b35e114SPaul Burton .set push 2816b35e114SPaul Burton .set mips32r2 28292e9953cSJames Hogan .set fp=64 2836b35e114SPaul Burton .set msa 2846b35e114SPaul Burton ld.w $w\wd, \off(\base) 2856b35e114SPaul Burton .set pop 2866b35e114SPaul Burton .endm 2876b35e114SPaul Burton 2887f65afb9SPaul Burton .macro ld_d wd, off, base 2897f65afb9SPaul Burton .set push 2907f65afb9SPaul Burton .set mips32r2 2912bd7bc25SMarkos Chandras .set fp=64 2927f65afb9SPaul Burton .set msa 2937f65afb9SPaul Burton ld.d $w\wd, \off(\base) 2947f65afb9SPaul Burton .set pop 2957f65afb9SPaul Burton .endm 2967f65afb9SPaul Burton 2976b35e114SPaul Burton .macro st_b wd, off, base 2986b35e114SPaul Burton .set push 2996b35e114SPaul Burton .set mips32r2 30092e9953cSJames Hogan .set fp=64 3016b35e114SPaul Burton .set msa 3026b35e114SPaul Burton st.b $w\wd, \off(\base) 3036b35e114SPaul Burton .set pop 3046b35e114SPaul Burton .endm 3056b35e114SPaul Burton 3066b35e114SPaul Burton .macro st_h wd, off, base 3076b35e114SPaul Burton .set push 3086b35e114SPaul Burton .set mips32r2 30992e9953cSJames Hogan .set fp=64 3106b35e114SPaul Burton .set msa 3116b35e114SPaul Burton st.h $w\wd, \off(\base) 3126b35e114SPaul Burton .set pop 3136b35e114SPaul Burton .endm 3146b35e114SPaul Burton 3156b35e114SPaul Burton .macro st_w wd, off, base 3166b35e114SPaul Burton .set push 3176b35e114SPaul Burton .set mips32r2 31892e9953cSJames Hogan .set fp=64 3196b35e114SPaul Burton .set msa 3206b35e114SPaul Burton st.w $w\wd, \off(\base) 3216b35e114SPaul Burton .set pop 3226b35e114SPaul Burton .endm 3236b35e114SPaul Burton 3247f65afb9SPaul Burton .macro st_d wd, off, base 3257f65afb9SPaul Burton .set push 3267f65afb9SPaul Burton .set mips32r2 3272bd7bc25SMarkos Chandras .set fp=64 3287f65afb9SPaul Burton .set msa 3297f65afb9SPaul Burton st.d $w\wd, \off(\base) 3307f65afb9SPaul Burton .set pop 3317f65afb9SPaul Burton .endm 3327f65afb9SPaul Burton 3338a3c8b48SPaul Burton .macro copy_s_w ws, n 3347f65afb9SPaul Burton .set push 3357f65afb9SPaul Burton .set mips32r2 3362bd7bc25SMarkos Chandras .set fp=64 3377f65afb9SPaul Burton .set msa 3388a3c8b48SPaul Burton copy_s.w $1, $w\ws[\n] 3397f65afb9SPaul Burton .set pop 3407f65afb9SPaul Burton .endm 3417f65afb9SPaul Burton 3428a3c8b48SPaul Burton .macro copy_s_d ws, n 3437f65afb9SPaul Burton .set push 3447f65afb9SPaul Burton .set mips64r2 3452bd7bc25SMarkos Chandras .set fp=64 3467f65afb9SPaul Burton .set msa 3478a3c8b48SPaul Burton copy_s.d $1, $w\ws[\n] 3487f65afb9SPaul Burton .set pop 3497f65afb9SPaul Burton .endm 3507f65afb9SPaul Burton 351f23ce388SPaul Burton .macro insert_w wd, n 3527f65afb9SPaul Burton .set push 3537f65afb9SPaul Burton .set mips32r2 3542bd7bc25SMarkos Chandras .set fp=64 3557f65afb9SPaul Burton .set msa 356f23ce388SPaul Burton insert.w $w\wd[\n], $1 3577f65afb9SPaul Burton .set pop 3587f65afb9SPaul Burton .endm 3597f65afb9SPaul Burton 360f23ce388SPaul Burton .macro insert_d wd, n 3617f65afb9SPaul Burton .set push 3627f65afb9SPaul Burton .set mips64r2 3632bd7bc25SMarkos Chandras .set fp=64 3647f65afb9SPaul Burton .set msa 365f23ce388SPaul Burton insert.d $w\wd[\n], $1 3667f65afb9SPaul Burton .set pop 3677f65afb9SPaul Burton .endm 3687f65afb9SPaul Burton #else 369d96cc3d1SSteven J. Hill 3707f65afb9SPaul Burton /* 3717f65afb9SPaul Burton * Temporary until all toolchains in use include MSA support. 3727f65afb9SPaul Burton */ 373e1bebbabSPaul Burton .macro _cfcmsa rd, cs 3747f65afb9SPaul Burton .set push 3757f65afb9SPaul Burton .set noat 37680a20d2fSNathan Chancellor .set hardfloat 3776e1b29c3SJames Hogan insn_if_mips 0x787e0059 | (\cs << 11) 3786e1b29c3SJames Hogan insn32_if_mm 0x587e0056 | (\cs << 11) 3797f65afb9SPaul Burton move \rd, $1 3807f65afb9SPaul Burton .set pop 3817f65afb9SPaul Burton .endm 3827f65afb9SPaul Burton 383e1bebbabSPaul Burton .macro _ctcmsa cd, rs 3847f65afb9SPaul Burton .set push 3857f65afb9SPaul Burton .set noat 38680a20d2fSNathan Chancellor .set hardfloat 3877f65afb9SPaul Burton move $1, \rs 3886e1b29c3SJames Hogan insn_if_mips 0x783e0819 | (\cd << 6) 3896e1b29c3SJames Hogan insn32_if_mm 0x583e0816 | (\cd << 6) 3907f65afb9SPaul Burton .set pop 3917f65afb9SPaul Burton .endm 3927f65afb9SPaul Burton 3936b35e114SPaul Burton .macro ld_b wd, off, base 3946b35e114SPaul Burton .set push 3956b35e114SPaul Burton .set noat 39680a20d2fSNathan Chancellor .set hardfloat 397ea168857SJames Hogan PTR_ADDU $1, \base, \off 3986e1b29c3SJames Hogan insn_if_mips 0x78000820 | (\wd << 6) 3996e1b29c3SJames Hogan insn32_if_mm 0x58000807 | (\wd << 6) 4006b35e114SPaul Burton .set pop 4016b35e114SPaul Burton .endm 4026b35e114SPaul Burton 4036b35e114SPaul Burton .macro ld_h wd, off, base 4046b35e114SPaul Burton .set push 4056b35e114SPaul Burton .set noat 40680a20d2fSNathan Chancellor .set hardfloat 407ea168857SJames Hogan PTR_ADDU $1, \base, \off 4086e1b29c3SJames Hogan insn_if_mips 0x78000821 | (\wd << 6) 4096e1b29c3SJames Hogan insn32_if_mm 0x58000817 | (\wd << 6) 4106b35e114SPaul Burton .set pop 4116b35e114SPaul Burton .endm 4126b35e114SPaul Burton 4136b35e114SPaul Burton .macro ld_w wd, off, base 4146b35e114SPaul Burton .set push 4156b35e114SPaul Burton .set noat 41680a20d2fSNathan Chancellor .set hardfloat 417ea168857SJames Hogan PTR_ADDU $1, \base, \off 4186e1b29c3SJames Hogan insn_if_mips 0x78000822 | (\wd << 6) 4196e1b29c3SJames Hogan insn32_if_mm 0x58000827 | (\wd << 6) 4206b35e114SPaul Burton .set pop 4216b35e114SPaul Burton .endm 4226b35e114SPaul Burton 4237f65afb9SPaul Burton .macro ld_d wd, off, base 4247f65afb9SPaul Burton .set push 4257f65afb9SPaul Burton .set noat 42680a20d2fSNathan Chancellor .set hardfloat 427ea168857SJames Hogan PTR_ADDU $1, \base, \off 4286e1b29c3SJames Hogan insn_if_mips 0x78000823 | (\wd << 6) 4296e1b29c3SJames Hogan insn32_if_mm 0x58000837 | (\wd << 6) 4307f65afb9SPaul Burton .set pop 4317f65afb9SPaul Burton .endm 4327f65afb9SPaul Burton 4336b35e114SPaul Burton .macro st_b wd, off, base 4346b35e114SPaul Burton .set push 4356b35e114SPaul Burton .set noat 43680a20d2fSNathan Chancellor .set hardfloat 437ea168857SJames Hogan PTR_ADDU $1, \base, \off 4386e1b29c3SJames Hogan insn_if_mips 0x78000824 | (\wd << 6) 4396e1b29c3SJames Hogan insn32_if_mm 0x5800080f | (\wd << 6) 4406b35e114SPaul Burton .set pop 4416b35e114SPaul Burton .endm 4426b35e114SPaul Burton 4436b35e114SPaul Burton .macro st_h wd, off, base 4446b35e114SPaul Burton .set push 4456b35e114SPaul Burton .set noat 44680a20d2fSNathan Chancellor .set hardfloat 447ea168857SJames Hogan PTR_ADDU $1, \base, \off 4486e1b29c3SJames Hogan insn_if_mips 0x78000825 | (\wd << 6) 4496e1b29c3SJames Hogan insn32_if_mm 0x5800081f | (\wd << 6) 4506b35e114SPaul Burton .set pop 4516b35e114SPaul Burton .endm 4526b35e114SPaul Burton 4536b35e114SPaul Burton .macro st_w wd, off, base 4546b35e114SPaul Burton .set push 4556b35e114SPaul Burton .set noat 45680a20d2fSNathan Chancellor .set hardfloat 457ea168857SJames Hogan PTR_ADDU $1, \base, \off 4586e1b29c3SJames Hogan insn_if_mips 0x78000826 | (\wd << 6) 4596e1b29c3SJames Hogan insn32_if_mm 0x5800082f | (\wd << 6) 4606b35e114SPaul Burton .set pop 4616b35e114SPaul Burton .endm 4626b35e114SPaul Burton 4637f65afb9SPaul Burton .macro st_d wd, off, base 4647f65afb9SPaul Burton .set push 4657f65afb9SPaul Burton .set noat 46680a20d2fSNathan Chancellor .set hardfloat 467ea168857SJames Hogan PTR_ADDU $1, \base, \off 4686e1b29c3SJames Hogan insn_if_mips 0x78000827 | (\wd << 6) 4696e1b29c3SJames Hogan insn32_if_mm 0x5800083f | (\wd << 6) 4707f65afb9SPaul Burton .set pop 4717f65afb9SPaul Burton .endm 4727f65afb9SPaul Burton 4738a3c8b48SPaul Burton .macro copy_s_w ws, n 4747f65afb9SPaul Burton .set push 4757f65afb9SPaul Burton .set noat 47680a20d2fSNathan Chancellor .set hardfloat 4776e1b29c3SJames Hogan insn_if_mips 0x78b00059 | (\n << 16) | (\ws << 11) 4786e1b29c3SJames Hogan insn32_if_mm 0x58b00056 | (\n << 16) | (\ws << 11) 4797f65afb9SPaul Burton .set pop 4807f65afb9SPaul Burton .endm 4817f65afb9SPaul Burton 4828a3c8b48SPaul Burton .macro copy_s_d ws, n 4837f65afb9SPaul Burton .set push 4847f65afb9SPaul Burton .set noat 48580a20d2fSNathan Chancellor .set hardfloat 4866e1b29c3SJames Hogan insn_if_mips 0x78b80059 | (\n << 16) | (\ws << 11) 4876e1b29c3SJames Hogan insn32_if_mm 0x58b80056 | (\n << 16) | (\ws << 11) 4887f65afb9SPaul Burton .set pop 4897f65afb9SPaul Burton .endm 4907f65afb9SPaul Burton 491f23ce388SPaul Burton .macro insert_w wd, n 4927f65afb9SPaul Burton .set push 4937f65afb9SPaul Burton .set noat 49480a20d2fSNathan Chancellor .set hardfloat 4956e1b29c3SJames Hogan insn_if_mips 0x79300819 | (\n << 16) | (\wd << 6) 4966e1b29c3SJames Hogan insn32_if_mm 0x59300816 | (\n << 16) | (\wd << 6) 4977f65afb9SPaul Burton .set pop 4987f65afb9SPaul Burton .endm 4997f65afb9SPaul Burton 500f23ce388SPaul Burton .macro insert_d wd, n 5017f65afb9SPaul Burton .set push 5027f65afb9SPaul Burton .set noat 50380a20d2fSNathan Chancellor .set hardfloat 5046e1b29c3SJames Hogan insn_if_mips 0x79380819 | (\n << 16) | (\wd << 6) 5056e1b29c3SJames Hogan insn32_if_mm 0x59380816 | (\n << 16) | (\wd << 6) 5067f65afb9SPaul Burton .set pop 5077f65afb9SPaul Burton .endm 5087f65afb9SPaul Burton #endif 5097f65afb9SPaul Burton 510143e93d7SJames Hogan #ifdef TOOLCHAIN_SUPPORTS_MSA 511143e93d7SJames Hogan #define FPR_BASE_OFFS THREAD_FPR0 512143e93d7SJames Hogan #define FPR_BASE $1 513143e93d7SJames Hogan #else 514143e93d7SJames Hogan #define FPR_BASE_OFFS 0 515143e93d7SJames Hogan #define FPR_BASE \thread 516143e93d7SJames Hogan #endif 517143e93d7SJames Hogan 5181db1af84SPaul Burton .macro msa_save_all thread 519f7a46fa7SPaul Burton .set push 520f7a46fa7SPaul Burton .set noat 521143e93d7SJames Hogan #ifdef TOOLCHAIN_SUPPORTS_MSA 522143e93d7SJames Hogan PTR_ADDU FPR_BASE, \thread, FPR_BASE_OFFS 523143e93d7SJames Hogan #endif 524143e93d7SJames Hogan st_d 0, THREAD_FPR0 - FPR_BASE_OFFS, FPR_BASE 525143e93d7SJames Hogan st_d 1, THREAD_FPR1 - FPR_BASE_OFFS, FPR_BASE 526143e93d7SJames Hogan st_d 2, THREAD_FPR2 - FPR_BASE_OFFS, FPR_BASE 527143e93d7SJames Hogan st_d 3, THREAD_FPR3 - FPR_BASE_OFFS, FPR_BASE 528143e93d7SJames Hogan st_d 4, THREAD_FPR4 - FPR_BASE_OFFS, FPR_BASE 529143e93d7SJames Hogan st_d 5, THREAD_FPR5 - FPR_BASE_OFFS, FPR_BASE 530143e93d7SJames Hogan st_d 6, THREAD_FPR6 - FPR_BASE_OFFS, FPR_BASE 531143e93d7SJames Hogan st_d 7, THREAD_FPR7 - FPR_BASE_OFFS, FPR_BASE 532143e93d7SJames Hogan st_d 8, THREAD_FPR8 - FPR_BASE_OFFS, FPR_BASE 533143e93d7SJames Hogan st_d 9, THREAD_FPR9 - FPR_BASE_OFFS, FPR_BASE 534143e93d7SJames Hogan st_d 10, THREAD_FPR10 - FPR_BASE_OFFS, FPR_BASE 535143e93d7SJames Hogan st_d 11, THREAD_FPR11 - FPR_BASE_OFFS, FPR_BASE 536143e93d7SJames Hogan st_d 12, THREAD_FPR12 - FPR_BASE_OFFS, FPR_BASE 537143e93d7SJames Hogan st_d 13, THREAD_FPR13 - FPR_BASE_OFFS, FPR_BASE 538143e93d7SJames Hogan st_d 14, THREAD_FPR14 - FPR_BASE_OFFS, FPR_BASE 539143e93d7SJames Hogan st_d 15, THREAD_FPR15 - FPR_BASE_OFFS, FPR_BASE 540143e93d7SJames Hogan st_d 16, THREAD_FPR16 - FPR_BASE_OFFS, FPR_BASE 541143e93d7SJames Hogan st_d 17, THREAD_FPR17 - FPR_BASE_OFFS, FPR_BASE 542143e93d7SJames Hogan st_d 18, THREAD_FPR18 - FPR_BASE_OFFS, FPR_BASE 543143e93d7SJames Hogan st_d 19, THREAD_FPR19 - FPR_BASE_OFFS, FPR_BASE 544143e93d7SJames Hogan st_d 20, THREAD_FPR20 - FPR_BASE_OFFS, FPR_BASE 545143e93d7SJames Hogan st_d 21, THREAD_FPR21 - FPR_BASE_OFFS, FPR_BASE 546143e93d7SJames Hogan st_d 22, THREAD_FPR22 - FPR_BASE_OFFS, FPR_BASE 547143e93d7SJames Hogan st_d 23, THREAD_FPR23 - FPR_BASE_OFFS, FPR_BASE 548143e93d7SJames Hogan st_d 24, THREAD_FPR24 - FPR_BASE_OFFS, FPR_BASE 549143e93d7SJames Hogan st_d 25, THREAD_FPR25 - FPR_BASE_OFFS, FPR_BASE 550143e93d7SJames Hogan st_d 26, THREAD_FPR26 - FPR_BASE_OFFS, FPR_BASE 551143e93d7SJames Hogan st_d 27, THREAD_FPR27 - FPR_BASE_OFFS, FPR_BASE 552143e93d7SJames Hogan st_d 28, THREAD_FPR28 - FPR_BASE_OFFS, FPR_BASE 553143e93d7SJames Hogan st_d 29, THREAD_FPR29 - FPR_BASE_OFFS, FPR_BASE 554143e93d7SJames Hogan st_d 30, THREAD_FPR30 - FPR_BASE_OFFS, FPR_BASE 555143e93d7SJames Hogan st_d 31, THREAD_FPR31 - FPR_BASE_OFFS, FPR_BASE 55680a20d2fSNathan Chancellor .set hardfloat 557e1bebbabSPaul Burton _cfcmsa $1, MSA_CSR 558f7a46fa7SPaul Burton sw $1, THREAD_MSA_CSR(\thread) 559f7a46fa7SPaul Burton .set pop 5601db1af84SPaul Burton .endm 5611db1af84SPaul Burton 5621db1af84SPaul Burton .macro msa_restore_all thread 563f7a46fa7SPaul Burton .set push 564f7a46fa7SPaul Burton .set noat 56580a20d2fSNathan Chancellor .set hardfloat 566f7a46fa7SPaul Burton lw $1, THREAD_MSA_CSR(\thread) 567e1bebbabSPaul Burton _ctcmsa MSA_CSR, $1 568143e93d7SJames Hogan #ifdef TOOLCHAIN_SUPPORTS_MSA 569143e93d7SJames Hogan PTR_ADDU FPR_BASE, \thread, FPR_BASE_OFFS 570143e93d7SJames Hogan #endif 571143e93d7SJames Hogan ld_d 0, THREAD_FPR0 - FPR_BASE_OFFS, FPR_BASE 572143e93d7SJames Hogan ld_d 1, THREAD_FPR1 - FPR_BASE_OFFS, FPR_BASE 573143e93d7SJames Hogan ld_d 2, THREAD_FPR2 - FPR_BASE_OFFS, FPR_BASE 574143e93d7SJames Hogan ld_d 3, THREAD_FPR3 - FPR_BASE_OFFS, FPR_BASE 575143e93d7SJames Hogan ld_d 4, THREAD_FPR4 - FPR_BASE_OFFS, FPR_BASE 576143e93d7SJames Hogan ld_d 5, THREAD_FPR5 - FPR_BASE_OFFS, FPR_BASE 577143e93d7SJames Hogan ld_d 6, THREAD_FPR6 - FPR_BASE_OFFS, FPR_BASE 578143e93d7SJames Hogan ld_d 7, THREAD_FPR7 - FPR_BASE_OFFS, FPR_BASE 579143e93d7SJames Hogan ld_d 8, THREAD_FPR8 - FPR_BASE_OFFS, FPR_BASE 580143e93d7SJames Hogan ld_d 9, THREAD_FPR9 - FPR_BASE_OFFS, FPR_BASE 581143e93d7SJames Hogan ld_d 10, THREAD_FPR10 - FPR_BASE_OFFS, FPR_BASE 582143e93d7SJames Hogan ld_d 11, THREAD_FPR11 - FPR_BASE_OFFS, FPR_BASE 583143e93d7SJames Hogan ld_d 12, THREAD_FPR12 - FPR_BASE_OFFS, FPR_BASE 584143e93d7SJames Hogan ld_d 13, THREAD_FPR13 - FPR_BASE_OFFS, FPR_BASE 585143e93d7SJames Hogan ld_d 14, THREAD_FPR14 - FPR_BASE_OFFS, FPR_BASE 586143e93d7SJames Hogan ld_d 15, THREAD_FPR15 - FPR_BASE_OFFS, FPR_BASE 587143e93d7SJames Hogan ld_d 16, THREAD_FPR16 - FPR_BASE_OFFS, FPR_BASE 588143e93d7SJames Hogan ld_d 17, THREAD_FPR17 - FPR_BASE_OFFS, FPR_BASE 589143e93d7SJames Hogan ld_d 18, THREAD_FPR18 - FPR_BASE_OFFS, FPR_BASE 590143e93d7SJames Hogan ld_d 19, THREAD_FPR19 - FPR_BASE_OFFS, FPR_BASE 591143e93d7SJames Hogan ld_d 20, THREAD_FPR20 - FPR_BASE_OFFS, FPR_BASE 592143e93d7SJames Hogan ld_d 21, THREAD_FPR21 - FPR_BASE_OFFS, FPR_BASE 593143e93d7SJames Hogan ld_d 22, THREAD_FPR22 - FPR_BASE_OFFS, FPR_BASE 594143e93d7SJames Hogan ld_d 23, THREAD_FPR23 - FPR_BASE_OFFS, FPR_BASE 595143e93d7SJames Hogan ld_d 24, THREAD_FPR24 - FPR_BASE_OFFS, FPR_BASE 596143e93d7SJames Hogan ld_d 25, THREAD_FPR25 - FPR_BASE_OFFS, FPR_BASE 597143e93d7SJames Hogan ld_d 26, THREAD_FPR26 - FPR_BASE_OFFS, FPR_BASE 598143e93d7SJames Hogan ld_d 27, THREAD_FPR27 - FPR_BASE_OFFS, FPR_BASE 599143e93d7SJames Hogan ld_d 28, THREAD_FPR28 - FPR_BASE_OFFS, FPR_BASE 600143e93d7SJames Hogan ld_d 29, THREAD_FPR29 - FPR_BASE_OFFS, FPR_BASE 601143e93d7SJames Hogan ld_d 30, THREAD_FPR30 - FPR_BASE_OFFS, FPR_BASE 602143e93d7SJames Hogan ld_d 31, THREAD_FPR31 - FPR_BASE_OFFS, FPR_BASE 603f7a46fa7SPaul Burton .set pop 6041db1af84SPaul Burton .endm 6051db1af84SPaul Burton 606143e93d7SJames Hogan #undef FPR_BASE_OFFS 607143e93d7SJames Hogan #undef FPR_BASE 608143e93d7SJames Hogan 609c9017757SPaul Burton .macro msa_init_upper wd 610c9017757SPaul Burton #ifdef CONFIG_64BIT 611c9017757SPaul Burton insert_d \wd, 1 612c9017757SPaul Burton #else 613c9017757SPaul Burton insert_w \wd, 2 614c9017757SPaul Burton insert_w \wd, 3 615c9017757SPaul Burton #endif 616c9017757SPaul Burton .endm 617c9017757SPaul Burton 618c9017757SPaul Burton .macro msa_init_all_upper 619c9017757SPaul Burton .set push 620c9017757SPaul Burton .set noat 62180a20d2fSNathan Chancellor .set hardfloat 622c9017757SPaul Burton not $1, zero 623c9017757SPaul Burton msa_init_upper 0 624a3a49810SPaul Burton msa_init_upper 1 625a3a49810SPaul Burton msa_init_upper 2 626a3a49810SPaul Burton msa_init_upper 3 627a3a49810SPaul Burton msa_init_upper 4 628a3a49810SPaul Burton msa_init_upper 5 629a3a49810SPaul Burton msa_init_upper 6 630a3a49810SPaul Burton msa_init_upper 7 631a3a49810SPaul Burton msa_init_upper 8 632a3a49810SPaul Burton msa_init_upper 9 633a3a49810SPaul Burton msa_init_upper 10 634a3a49810SPaul Burton msa_init_upper 11 635a3a49810SPaul Burton msa_init_upper 12 636a3a49810SPaul Burton msa_init_upper 13 637a3a49810SPaul Burton msa_init_upper 14 638a3a49810SPaul Burton msa_init_upper 15 639a3a49810SPaul Burton msa_init_upper 16 640a3a49810SPaul Burton msa_init_upper 17 641a3a49810SPaul Burton msa_init_upper 18 642a3a49810SPaul Burton msa_init_upper 19 643a3a49810SPaul Burton msa_init_upper 20 644a3a49810SPaul Burton msa_init_upper 21 645a3a49810SPaul Burton msa_init_upper 22 646a3a49810SPaul Burton msa_init_upper 23 647a3a49810SPaul Burton msa_init_upper 24 648a3a49810SPaul Burton msa_init_upper 25 649a3a49810SPaul Burton msa_init_upper 26 650a3a49810SPaul Burton msa_init_upper 27 651a3a49810SPaul Burton msa_init_upper 28 652a3a49810SPaul Burton msa_init_upper 29 653a3a49810SPaul Burton msa_init_upper 30 654a3a49810SPaul Burton msa_init_upper 31 655c9017757SPaul Burton .set pop 656c9017757SPaul Burton .endm 657c9017757SPaul Burton 658384740dcSRalf Baechle #endif /* _ASM_ASMMACRO_H */ 659