1# RUN: llc -march=mips64 -target-abi n64 -start-before=expand-isel-pseudos \ 2# RUN: -stop-after=expand-isel-pseudos -relocation-model=pic -mxgot \ 3# RUN: -o /dev/null %s 4 5# A simple test to show that we can parse the target specific flags: gpoff-hi, 6# gpoff-lo, tlsgd, tlsldm, dtprel-hi, dtprel-lo, got-hi, got-lo, call-hi, 7# call-lo. 8 9--- | 10 @v = global i32 0, align 4 11 @k = thread_local global i32 0, align 4 12 @j = external thread_local global i32, align 4 13 @__tls_guard = internal thread_local global i1 false, align 1 14 declare extern_weak void @_ZTH1j() 15 16 declare i32 @_Z1gi(i32 signext) 17 18 define i32 @_Z2k1i(i32 signext %asd) { 19 entry: 20 %call = tail call i32 @_Z1gi(i32 signext %asd) 21 %add = add nsw i32 %call, %asd 22 %0 = load i32, i32* @v, align 4 23 %add1 = add nsw i32 %add, %0 24 %.b.i.i = load i1, i1* @__tls_guard, align 1 25 br i1 %.b.i.i, label %entry._ZTW1k.exit_crit_edge, label %init.i.i 26 27 entry._ZTW1k.exit_crit_edge: 28 %.pre = load i32, i32* @k, align 4 29 br label %_ZTW1k.exit 30 31 init.i.i: 32 store i1 true, i1* @__tls_guard, align 1 33 %call.i.i.i = tail call i32 @_Z1gi(i32 signext 3) 34 store i32 %call.i.i.i, i32* @k, align 4 35 br label %_ZTW1k.exit 36 37 _ZTW1k.exit: 38 %1 = phi i32 [ %.pre, %entry._ZTW1k.exit_crit_edge ], [ %call.i.i.i, %init.i.i ] 39 %add2 = add nsw i32 %add1, %1 40 br i1 icmp ne (void ()* @_ZTH1j, void ()* null), label %2, label %_ZTW1j.exit 41 42 ; <label>:2: 43 tail call void @_ZTH1j() 44 br label %_ZTW1j.exit 45 46 _ZTW1j.exit: 47 %3 = load i32, i32* @j, align 4 48 %add3 = add nsw i32 %add2, %3 49 ret i32 %add3 50 } 51... 52--- 53name: _Z2k1i 54alignment: 3 55exposesReturnsTwice: false 56legalized: false 57regBankSelected: false 58selected: false 59tracksRegLiveness: true 60registers: 61 - { id: 0, class: gpr32, preferred-register: '' } 62 - { id: 1, class: gpr32, preferred-register: '' } 63 - { id: 2, class: gpr32, preferred-register: '' } 64 - { id: 3, class: gpr32, preferred-register: '' } 65 - { id: 4, class: gpr32, preferred-register: '' } 66 - { id: 5, class: gpr64, preferred-register: '' } 67 - { id: 6, class: gpr64, preferred-register: '' } 68 - { id: 7, class: gpr64, preferred-register: '' } 69 - { id: 8, class: gpr64, preferred-register: '' } 70 - { id: 9, class: gpr64, preferred-register: '' } 71 - { id: 10, class: gpr32, preferred-register: '' } 72 - { id: 11, class: gpr32, preferred-register: '' } 73 - { id: 12, class: gpr32, preferred-register: '' } 74 - { id: 13, class: gpr64, preferred-register: '' } 75 - { id: 14, class: gpr64, preferred-register: '' } 76 - { id: 15, class: gpr64, preferred-register: '' } 77 - { id: 16, class: gpr32, preferred-register: '' } 78 - { id: 17, class: gpr64, preferred-register: '' } 79 - { id: 18, class: gpr64, preferred-register: '' } 80 - { id: 19, class: gpr64, preferred-register: '' } 81 - { id: 20, class: gpr64, preferred-register: '' } 82 - { id: 21, class: gpr64, preferred-register: '' } 83 - { id: 22, class: gpr64, preferred-register: '' } 84 - { id: 23, class: gpr32, preferred-register: '' } 85 - { id: 24, class: gpr64, preferred-register: '' } 86 - { id: 25, class: gpr64, preferred-register: '' } 87 - { id: 26, class: gpr64, preferred-register: '' } 88 - { id: 27, class: gpr64, preferred-register: '' } 89 - { id: 28, class: gpr64, preferred-register: '' } 90 - { id: 29, class: gpr64, preferred-register: '' } 91 - { id: 30, class: gpr32, preferred-register: '' } 92 - { id: 31, class: gpr64, preferred-register: '' } 93 - { id: 32, class: gpr64, preferred-register: '' } 94 - { id: 33, class: gpr64, preferred-register: '' } 95 - { id: 34, class: gpr64, preferred-register: '' } 96 - { id: 35, class: gpr32, preferred-register: '' } 97 - { id: 36, class: gpr64, preferred-register: '' } 98 - { id: 37, class: gpr64, preferred-register: '' } 99 - { id: 38, class: gpr64, preferred-register: '' } 100 - { id: 39, class: gpr64, preferred-register: '' } 101 - { id: 40, class: gpr64, preferred-register: '' } 102 - { id: 41, class: gpr64, preferred-register: '' } 103 - { id: 42, class: gpr64, preferred-register: '' } 104 - { id: 43, class: gpr64, preferred-register: '' } 105 - { id: 44, class: gpr64, preferred-register: '' } 106 - { id: 45, class: gpr64, preferred-register: '' } 107 - { id: 46, class: gpr64, preferred-register: '' } 108 - { id: 47, class: gpr64, preferred-register: '' } 109 - { id: 48, class: gpr64, preferred-register: '' } 110 - { id: 49, class: gpr64, preferred-register: '' } 111 - { id: 50, class: gpr64, preferred-register: '' } 112 - { id: 51, class: gpr64, preferred-register: '' } 113 - { id: 52, class: gpr64, preferred-register: '' } 114 - { id: 53, class: gpr64, preferred-register: '' } 115 - { id: 54, class: gpr64, preferred-register: '' } 116 - { id: 55, class: gpr32, preferred-register: '' } 117 - { id: 56, class: gpr32, preferred-register: '' } 118 - { id: 57, class: gpr64, preferred-register: '' } 119 - { id: 58, class: gpr64, preferred-register: '' } 120liveins: 121 - { reg: '$a0_64', virtual-reg: '%5' } 122 - { reg: '$t9_64', virtual-reg: '' } 123frameInfo: 124 isFrameAddressTaken: false 125 isReturnAddressTaken: false 126 hasStackMap: false 127 hasPatchPoint: false 128 stackSize: 0 129 offsetAdjustment: 0 130 maxAlignment: 1 131 adjustsStack: false 132 hasCalls: true 133 stackProtector: '' 134 maxCallFrameSize: 4294967295 135 hasOpaqueSPAdjustment: false 136 hasVAStart: false 137 hasMustTailInVarArgFunc: false 138 savePoint: '' 139 restorePoint: '' 140fixedStack: 141stack: 142constants: 143body: | 144 bb.0.entry: 145 successors: %bb.1.entry._ZTW1k.exit_crit_edge(0x7fe00000), %bb.2.init.i.i(0x00200000) 146 liveins: $a0_64, $t9_64 147 148 %57 = LUi64 target-flags(mips-gpoff-hi) @_Z2k1i 149 %58 = DADDu %57, $t9_64 150 %6 = DADDiu %58, target-flags(mips-gpoff-lo) @_Z2k1i 151 %5 = COPY $a0_64 152 ADJCALLSTACKDOWN 0, 0, implicit-def dead $sp, implicit $sp 153 %7 = LUi64 target-flags(mips-call-hi16) @_Z1gi 154 %8 = DADDu killed %7, %6 155 %9 = LD killed %8, target-flags(mips-call-lo16) @_Z1gi :: (load 8 from call-entry @_Z1gi) 156 $a0_64 = COPY %5 157 $gp_64 = COPY %6 158 JALR64Pseudo killed %9, csr_n64, implicit-def dead $ra, implicit $a0_64, implicit $gp_64, implicit-def $sp, implicit-def $v0 159 ADJCALLSTACKUP 0, 0, implicit-def dead $sp, implicit $sp 160 %10 = COPY $v0 161 %11 = COPY %5.sub_32 162 %12 = ADDu %10, killed %11 163 %13 = LUi64 target-flags(mips-got-hi16) @v 164 %14 = DADDu killed %13, %6 165 %15 = LD killed %14, target-flags(mips-got-lo16) @v :: (load 8 from got) 166 %16 = LW killed %15, 0 :: (dereferenceable load 4 from @v) 167 %0 = ADDu killed %12, killed %16 168 ADJCALLSTACKDOWN 0, 0, implicit-def dead $sp, implicit $sp 169 %17 = LUi64 target-flags(mips-call-hi16) &__tls_get_addr 170 %18 = DADDu killed %17, %6 171 %19 = LD killed %18, target-flags(mips-call-lo16) &__tls_get_addr :: (load 8 from call-entry &__tls_get_addr) 172 %20 = DADDiu %6, target-flags(mips-tlsldm) @__tls_guard 173 $a0_64 = COPY %20 174 $gp_64 = COPY %6 175 JALR64Pseudo killed %19, csr_n64, implicit-def dead $ra, implicit $a0_64, implicit $gp_64, implicit-def $sp, implicit-def $v0_64 176 ADJCALLSTACKUP 0, 0, implicit-def dead $sp, implicit $sp 177 %21 = COPY $v0_64 178 %22 = DADDiu %21, target-flags(mips-dtprel-hi) @__tls_guard 179 %23 = LBu killed %22, target-flags(mips-dtprel-lo) @__tls_guard :: (dereferenceable load 1 from @__tls_guard) 180 BEQ killed %23, $zero, %bb.2.init.i.i, implicit-def dead $at 181 B %bb.1.entry._ZTW1k.exit_crit_edge, implicit-def dead $at 182 183 bb.1.entry._ZTW1k.exit_crit_edge: 184 successors: %bb.3._ZTW1k.exit(0x80000000) 185 186 ADJCALLSTACKDOWN 0, 0, implicit-def dead $sp, implicit $sp 187 %39 = LUi64 target-flags(mips-call-hi16) &__tls_get_addr 188 %40 = DADDu killed %39, %6 189 %41 = LD killed %40, target-flags(mips-call-lo16) &__tls_get_addr :: (load 8 from call-entry &__tls_get_addr) 190 %42 = DADDiu %6, target-flags(mips-tlsgd) @k 191 $a0_64 = COPY %42 192 $gp_64 = COPY %6 193 JALR64Pseudo killed %41, csr_n64, implicit-def dead $ra, implicit $a0_64, implicit $gp_64, implicit-def $sp, implicit-def $v0_64 194 ADJCALLSTACKUP 0, 0, implicit-def dead $sp, implicit $sp 195 %43 = COPY $v0_64 196 %1 = LW %43, 0 :: (dereferenceable load 4 from @k) 197 B %bb.3._ZTW1k.exit, implicit-def dead $at 198 199 bb.2.init.i.i: 200 successors: %bb.3._ZTW1k.exit(0x80000000) 201 202 ADJCALLSTACKDOWN 0, 0, implicit-def dead $sp, implicit $sp 203 %24 = LUi64 target-flags(mips-call-hi16) &__tls_get_addr 204 %25 = DADDu killed %24, %6 205 %26 = LD %25, target-flags(mips-call-lo16) &__tls_get_addr :: (load 8 from call-entry &__tls_get_addr) 206 %27 = DADDiu %6, target-flags(mips-tlsldm) @__tls_guard 207 $a0_64 = COPY %27 208 $gp_64 = COPY %6 209 JALR64Pseudo killed %26, csr_n64, implicit-def dead $ra, implicit $a0_64, implicit $gp_64, implicit-def $sp, implicit-def $v0_64 210 ADJCALLSTACKUP 0, 0, implicit-def dead $sp, implicit $sp 211 %28 = COPY $v0_64 212 %29 = DADDiu %28, target-flags(mips-dtprel-hi) @__tls_guard 213 %30 = ADDiu $zero, 1 214 SB killed %30, killed %29, target-flags(mips-dtprel-lo) @__tls_guard :: (store 1 into @__tls_guard) 215 ADJCALLSTACKDOWN 0, 0, implicit-def dead $sp, implicit $sp 216 %31 = LUi64 target-flags(mips-call-hi16) @_Z1gi 217 %32 = DADDu killed %31, %6 218 %33 = DADDiu $zero_64, 3 219 %34 = LD killed %32, target-flags(mips-call-lo16) @_Z1gi :: (load 8 from call-entry @_Z1gi) 220 $a0_64 = COPY %33 221 $gp_64 = COPY %6 222 JALR64Pseudo killed %34, csr_n64, implicit-def dead $ra, implicit $a0_64, implicit $gp_64, implicit-def $sp, implicit-def $v0 223 ADJCALLSTACKUP 0, 0, implicit-def dead $sp, implicit $sp 224 %35 = COPY $v0 225 ADJCALLSTACKDOWN 0, 0, implicit-def dead $sp, implicit $sp 226 %36 = LD %25, target-flags(mips-call-lo16) &__tls_get_addr :: (load 8 from call-entry &__tls_get_addr) 227 %37 = DADDiu %6, target-flags(mips-tlsgd) @k 228 $a0_64 = COPY %37 229 $gp_64 = COPY %6 230 JALR64Pseudo killed %36, csr_n64, implicit-def dead $ra, implicit $a0_64, implicit $gp_64, implicit-def $sp, implicit-def $v0_64 231 ADJCALLSTACKUP 0, 0, implicit-def dead $sp, implicit $sp 232 %38 = COPY $v0_64 233 SW %35, %38, 0 :: (store 4 into @k) 234 %2 = COPY %35 235 236 bb.3._ZTW1k.exit: 237 successors: %bb.4(0x40000000), %bb.5._ZTW1j.exit(0x40000000) 238 239 %3 = PHI %2, %bb.2.init.i.i, %1, %bb.1.entry._ZTW1k.exit_crit_edge 240 %4 = ADDu %0, %3 241 %44 = LUi64 target-flags(mips-got-hi16) @_ZTH1j 242 %45 = DADDu killed %44, %6 243 %46 = LD killed %45, target-flags(mips-got-lo16) @_ZTH1j :: (load 8 from got) 244 BEQ64 killed %46, $zero_64, %bb.5._ZTW1j.exit, implicit-def dead $at 245 B %bb.4, implicit-def dead $at 246 247 bb.4 (%ir-block.2): 248 successors: %bb.5._ZTW1j.exit(0x80000000) 249 250 ADJCALLSTACKDOWN 0, 0, implicit-def dead $sp, implicit $sp 251 %47 = LUi64 target-flags(mips-call-hi16) @_ZTH1j 252 %48 = DADDu killed %47, %6 253 %49 = LD killed %48, target-flags(mips-call-lo16) @_ZTH1j :: (load 8 from call-entry @_ZTH1j) 254 $gp_64 = COPY %6 255 JALR64Pseudo killed %49, csr_n64, implicit-def dead $ra, implicit $gp_64, implicit-def $sp 256 ADJCALLSTACKUP 0, 0, implicit-def dead $sp, implicit $sp 257 258 bb.5._ZTW1j.exit: 259 ADJCALLSTACKDOWN 0, 0, implicit-def dead $sp, implicit $sp 260 %50 = LUi64 target-flags(mips-call-hi16) &__tls_get_addr 261 %51 = DADDu killed %50, %6 262 %52 = LD killed %51, target-flags(mips-call-lo16) &__tls_get_addr :: (load 8 from call-entry &__tls_get_addr) 263 %53 = DADDiu %6, target-flags(mips-tlsgd) @j 264 $a0_64 = COPY %53 265 $gp_64 = COPY %6 266 JALR64Pseudo killed %52, csr_n64, implicit-def dead $ra, implicit $a0_64, implicit $gp_64, implicit-def $sp, implicit-def $v0_64 267 ADJCALLSTACKUP 0, 0, implicit-def dead $sp, implicit $sp 268 %54 = COPY $v0_64 269 %55 = LW %54, 0 :: (dereferenceable load 4 from @j) 270 %56 = ADDu %4, killed %55 271 $v0 = COPY %56 272 RetRA implicit $v0 273 274... 275 276