1# RUN: llvm-mc -triple mips64-unknown-unknown -target-abi o32 -filetype=obj -o - %s | \ 2# RUN: llvm-objdump -d -r -arch=mips64 - | \ 3# RUN: FileCheck -check-prefix=ALL -check-prefix=O32 %s 4 5# RUN: llvm-mc -triple mips64-unknown-unknown -target-abi o32 %s | \ 6# RUN: FileCheck -check-prefix=ALL -check-prefix=ASM %s 7 8# RUN: llvm-mc -triple mips64-unknown-unknown -target-abi n32 -filetype=obj -o - %s | \ 9# RUN: llvm-objdump -d -r -t -arch=mips64 - | \ 10# RUN: FileCheck -check-prefix=ALL -check-prefix=NXX -check-prefix=N32 %s 11 12# RUN: llvm-mc -triple mips64-unknown-unknown -target-abi n32 %s | \ 13# RUN: FileCheck -check-prefix=ALL -check-prefix=ASM %s 14 15# RUN: llvm-mc -triple mips64-unknown-unknown %s -filetype=obj -o - | \ 16# RUN: llvm-objdump -d -r -t -arch=mips64 - | \ 17# RUN: FileCheck -check-prefix=ALL -check-prefix=NXX -check-prefix=N64 %s 18 19# RUN: llvm-mc -triple mips64-unknown-unknown %s | \ 20# RUN: FileCheck -check-prefix=ALL -check-prefix=ASM %s 21 22 .text 23 .option pic2 24t1: 25 .cpsetup $25, 8, __cerror 26 nop 27 .cpreturn 28 nop 29 30# ALL-LABEL: t1: 31 32# O32-NOT: __cerror 33 34# FIXME: Direct object emission for N32 is still under development. 35# N32 doesn't allow 3 operations to be specified in the same relocation 36# record like N64 does. 37 38# NXX-NEXT: sd $gp, 8($sp) 39# NXX-NEXT: lui $gp, 0 40# NXX-NEXT: R_MIPS_GPREL16/R_MIPS_SUB/R_MIPS_HI16 __cerror 41# NXX-NEXT: addiu $gp, $gp, 0 42# NXX-NEXT: R_MIPS_GPREL16/R_MIPS_SUB/R_MIPS_LO16 __cerror 43# N32-NEXT: addu $gp, $gp, $25 44# N64-NEXT: daddu $gp, $gp, $25 45 46# ASM-NEXT: .cpsetup $25, 8, __cerror 47 48# ALL-NEXT: nop 49 50# ASM-NEXT: .cpreturn 51# NXX-NEXT: ld $gp, 8($sp) 52 53# ALL-NEXT: nop 54 55t2: 56 .cpsetup $25, $2, __cerror 57 nop 58 .cpreturn 59 nop 60 61# ALL-LABEL: t2: 62 63# O32-NOT: __cerror 64 65# FIXME: Direct object emission for N32 is still under development. 66# N32 doesn't allow 3 operations to be specified in the same relocation 67# record like N64 does. 68 69# NXX-NEXT: move $2, $gp 70# NXX-NEXT: lui $gp, 0 71# NXX-NEXT: R_MIPS_GPREL16/R_MIPS_SUB/R_MIPS_HI16 __cerror 72# NXX-NEXT: addiu $gp, $gp, 0 73# NXX-NEXT: R_MIPS_GPREL16/R_MIPS_SUB/R_MIPS_LO16 __cerror 74# N32-NEXT: addu $gp, $gp, $25 75# N64-NEXT: daddu $gp, $gp, $25 76 77# ASM-NEXT: .cpsetup $25, $2, __cerror 78 79# ALL-NEXT: nop 80 81# ASM-NEXT: .cpreturn 82# NXX-NEXT: move $gp, $2 83 84# ALL-NEXT: nop 85 86# .cpsetup with local labels (PR22518): 87 88# The '1:' label isn't emitted in all cases but we still want a label to match 89# so we force one here. 90 91t3: 92 nop 931: 94 .cpsetup $25, $2, 1b 95 nop 96 sub $3, $3, $2 97 98# ALL-LABEL: t3: 99# ALL-NEXT: nop 100 101# O32-NEXT: nop 102# O32-NEXT: sub $3, $3, $2 103 104# FIXME: Direct object emission for N32 is still under development. 105# N32 doesn't allow 3 operations to be specified in the same relocation 106# record like N64 does. 107 108# NXX: $tmp0: 109# NXX-NEXT: move $2, $gp 110# NXX-NEXT: lui $gp, 0 111# NXX-NEXT: R_MIPS_GPREL16/R_MIPS_SUB/R_MIPS_HI16 $tmp0 112# NXX-NEXT: addiu $gp, $gp, 0 113# NXX-NEXT: R_MIPS_GPREL16/R_MIPS_SUB/R_MIPS_LO16 $tmp0 114# N32-NEXT: addu $gp, $gp, $25 115# N64-NEXT: daddu $gp, $gp, $25 116# NXX-NEXT: nop 117# NXX-NEXT: sub $3, $3, $2 118 119# ASM: $tmp0: 120# ASM-NEXT: .cpsetup $25, $2, $tmp0 121 122# Ensure we have at least one instruction between labels so that the labels 123# we're matching aren't removed. 124 nop 125# ALL-NEXT: nop 126 127 .option pic0 128t4: 129 nop 130 .cpsetup $25, 8, __cerror 131 nop 132 .cpreturn 133 nop 134 135# Testing that .cpsetup expands to nothing in this case 136# by checking that the next instruction after the first 137# nop is also a 'nop'. 138 139# ALL-LABEL: t4: 140 141# NXX-NEXT: nop 142# NXX-NEXT: nop 143# NXX-NEXT: nop 144 145# ASM-NEXT: nop 146# ASM-NEXT: .cpsetup $25, 8, __cerror 147# ASM-NEXT: nop 148# ASM-NEXT: .cpreturn 149# ASM-NEXT: nop 150 151# Test that we accept constant expressions. 152 .option pic2 153t5: 154 .cpsetup $25, ((8*4) - (3*8)), __cerror 155 nop 156 157# ALL-LABEL: t5: 158 159# O32-NOT: __cerror 160 161# FIXME: Direct object emission for N32 is still under development. 162# N32 doesn't allow 3 operations to be specified in the same relocation 163# record like N64 does. 164 165# NXX-NEXT: sd $gp, 8($sp) 166# NXX-NEXT: lui $gp, 0 167# NXX-NEXT: R_MIPS_GPREL16/R_MIPS_SUB/R_MIPS_HI16 __cerror 168# NXX-NEXT: addiu $gp, $gp, 0 169# NXX-NEXT: R_MIPS_GPREL16/R_MIPS_SUB/R_MIPS_LO16 __cerror 170# N32-NEXT: addu $gp, $gp, $25 171# N64-NEXT: daddu $gp, $gp, $25 172 173# ASM-NEXT: .cpsetup $25, 8, __cerror 174 175# ALL-NEXT: nop 176 177# NXX-LABEL: SYMBOL TABLE: 178 179# For .cpsetup with local labels, we need to check if $tmp0 is in the symbol 180# table: 181# NXX: .text 00000000 $tmp0 182