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