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