2016-04-11 23:24:23 +08:00
|
|
|
; RUN: llc -march=mipsel -relocation-model=pic < %s | FileCheck %s
|
|
|
|
; RUN: llc -march=mipsel -force-mips-long-branch -O3 -relocation-model=pic < %s \
|
2014-04-30 23:06:25 +08:00
|
|
|
; RUN: | FileCheck %s -check-prefix=O32
|
2016-06-18 23:39:43 +08:00
|
|
|
; RUN: llc -march=mipsel -mcpu=mips32r6 -force-mips-long-branch -O3 \
|
|
|
|
; RUN: -relocation-model=pic -asm-show-inst < %s | FileCheck %s -check-prefix=O32-R6
|
2016-04-11 23:24:23 +08:00
|
|
|
; RUN: llc -march=mips64el -mcpu=mips4 -target-abi=n64 -force-mips-long-branch -O3 -relocation-model=pic \
|
2014-04-30 23:06:25 +08:00
|
|
|
; RUN: < %s | FileCheck %s -check-prefix=N64
|
2016-04-11 23:24:23 +08:00
|
|
|
; RUN: llc -march=mips64el -mcpu=mips64 -target-abi=n64 -force-mips-long-branch -O3 -relocation-model=pic \
|
2014-04-30 23:06:25 +08:00
|
|
|
; RUN: < %s | FileCheck %s -check-prefix=N64
|
2016-06-18 23:39:43 +08:00
|
|
|
; RUN: llc -march=mips64el -mcpu=mips64r6 -target-abi=n64 -force-mips-long-branch -O3 \
|
|
|
|
; RUN: -relocation-model=pic -asm-show-inst < %s | FileCheck %s -check-prefix=N64-R6
|
2014-04-30 23:06:25 +08:00
|
|
|
; RUN: llc -march=mipsel -mcpu=mips32r2 -mattr=micromips \
|
2016-04-11 23:24:23 +08:00
|
|
|
; RUN: -force-mips-long-branch -O3 -relocation-model=pic < %s | FileCheck %s -check-prefix=MICROMIPS
|
|
|
|
; RUN: llc -mtriple=mipsel-none-nacl -force-mips-long-branch -O3 -relocation-model=pic < %s \
|
2014-06-05 21:52:08 +08:00
|
|
|
; RUN: | FileCheck %s -check-prefix=NACL
|
2012-06-14 10:12:21 +08:00
|
|
|
|
|
|
|
|
2014-04-30 23:06:25 +08:00
|
|
|
@x = external global i32
|
|
|
|
|
2014-11-08 00:54:21 +08:00
|
|
|
define void @test1(i32 signext %s) {
|
2012-06-14 10:12:21 +08:00
|
|
|
entry:
|
2014-04-30 23:06:25 +08:00
|
|
|
%cmp = icmp eq i32 %s, 0
|
|
|
|
br i1 %cmp, label %end, label %then
|
|
|
|
|
|
|
|
then:
|
|
|
|
store i32 1, i32* @x, align 4
|
|
|
|
br label %end
|
|
|
|
|
|
|
|
end:
|
2012-06-14 10:12:21 +08:00
|
|
|
ret void
|
|
|
|
|
2014-04-30 23:06:25 +08:00
|
|
|
|
|
|
|
; First check the normal version (without long branch). beqz jumps to return,
|
|
|
|
; and fallthrough block stores 1 to global variable.
|
|
|
|
|
|
|
|
; CHECK: lui $[[R0:[0-9]+]], %hi(_gp_disp)
|
|
|
|
; CHECK: addiu $[[R0]], $[[R0]], %lo(_gp_disp)
|
2015-05-20 22:18:59 +08:00
|
|
|
; CHECK: beqz $4, $[[BB0:BB[0-9_]+]]
|
2014-04-30 23:06:25 +08:00
|
|
|
; CHECK: addu $[[GP:[0-9]+]], $[[R0]], $25
|
|
|
|
; CHECK: lw $[[R1:[0-9]+]], %got(x)($[[GP]])
|
|
|
|
; CHECK: addiu $[[R2:[0-9]+]], $zero, 1
|
|
|
|
; CHECK: sw $[[R2]], 0($[[R1]])
|
2015-05-20 22:18:59 +08:00
|
|
|
; CHECK: $[[BB0]]:
|
2014-04-30 23:06:25 +08:00
|
|
|
; CHECK: jr $ra
|
|
|
|
; CHECK: nop
|
|
|
|
|
|
|
|
|
|
|
|
; Check the MIPS32 version. Check that branch logic is inverted, so that the
|
|
|
|
; target of the new branch (bnez) is the fallthrough block of the original
|
|
|
|
; branch. Check that fallthrough block of the new branch contains long branch
|
|
|
|
; expansion which at the end indirectly jumps to the target of the original
|
|
|
|
; branch.
|
|
|
|
|
|
|
|
; O32: lui $[[R0:[0-9]+]], %hi(_gp_disp)
|
|
|
|
; O32: addiu $[[R0]], $[[R0]], %lo(_gp_disp)
|
2015-05-20 22:18:59 +08:00
|
|
|
; O32: bnez $4, $[[BB0:BB[0-9_]+]]
|
2014-04-30 23:06:25 +08:00
|
|
|
; O32: addu $[[GP:[0-9]+]], $[[R0]], $25
|
|
|
|
|
|
|
|
; Check for long branch expansion:
|
|
|
|
; O32: addiu $sp, $sp, -8
|
|
|
|
; O32-NEXT: sw $ra, 0($sp)
|
2015-05-20 22:18:59 +08:00
|
|
|
; O32-NEXT: lui $1, %hi(($[[BB2:BB[0-9_]+]])-($[[BB1:BB[0-9_]+]]))
|
|
|
|
; O32-NEXT: bal $[[BB1]]
|
|
|
|
; O32-NEXT: addiu $1, $1, %lo(($[[BB2]])-($[[BB1]]))
|
|
|
|
; O32-NEXT: $[[BB1]]:
|
2014-04-30 23:06:25 +08:00
|
|
|
; O32-NEXT: addu $1, $ra, $1
|
|
|
|
; O32-NEXT: lw $ra, 0($sp)
|
|
|
|
; O32-NEXT: jr $1
|
|
|
|
; O32-NEXT: addiu $sp, $sp, 8
|
|
|
|
|
2015-05-20 22:18:59 +08:00
|
|
|
; O32: $[[BB0]]:
|
2014-04-30 23:06:25 +08:00
|
|
|
; O32: lw $[[R1:[0-9]+]], %got(x)($[[GP]])
|
|
|
|
; O32: addiu $[[R2:[0-9]+]], $zero, 1
|
|
|
|
; O32: sw $[[R2]], 0($[[R1]])
|
2015-05-20 22:18:59 +08:00
|
|
|
; O32: $[[BB2]]:
|
2014-04-30 23:06:25 +08:00
|
|
|
; O32: jr $ra
|
|
|
|
; O32: nop
|
|
|
|
|
2016-06-18 23:39:43 +08:00
|
|
|
; In MIPS32R6 JR is an alias to JALR with $rd=0. As everything else remains the
|
|
|
|
; same with the O32 prefix, we use -asm-show-inst in order to make sure that
|
|
|
|
; the opcode of the MachineInst is a JALR.
|
|
|
|
; O32-R6: JALR
|
2014-04-30 23:06:25 +08:00
|
|
|
|
|
|
|
; Check the MIPS64 version.
|
|
|
|
|
|
|
|
; N64: lui $[[R0:[0-9]+]], %hi(%neg(%gp_rel(test1)))
|
2016-07-19 18:49:03 +08:00
|
|
|
; N64: bnez $4, [[BB0:\.LBB[0-9_]+]]
|
2014-04-30 23:06:25 +08:00
|
|
|
; N64: daddu $[[R1:[0-9]+]], $[[R0]], $25
|
|
|
|
|
|
|
|
; Check for long branch expansion:
|
|
|
|
; N64: daddiu $sp, $sp, -16
|
|
|
|
; N64-NEXT: sd $ra, 0($sp)
|
2016-07-19 18:49:03 +08:00
|
|
|
; N64-NEXT: daddiu $1, $zero, %hi([[BB2:\.LBB[0-9_]+]]-[[BB1:\.LBB[0-9_]+]])
|
2014-04-30 23:06:25 +08:00
|
|
|
; N64-NEXT: dsll $1, $1, 16
|
2016-07-19 18:49:03 +08:00
|
|
|
; N64-NEXT: bal [[BB1]]
|
|
|
|
; N64-NEXT: daddiu $1, $1, %lo([[BB2]]-[[BB1]])
|
|
|
|
; N64-NEXT: [[BB1]]:
|
2014-04-30 23:06:25 +08:00
|
|
|
; N64-NEXT: daddu $1, $ra, $1
|
|
|
|
; N64-NEXT: ld $ra, 0($sp)
|
|
|
|
; N64-NEXT: jr $1
|
|
|
|
; N64-NEXT: daddiu $sp, $sp, 16
|
|
|
|
|
2016-07-19 18:49:03 +08:00
|
|
|
; N64: [[BB0]]:
|
2014-04-30 23:06:25 +08:00
|
|
|
; N64: daddiu $[[GP:[0-9]+]], $[[R1]], %lo(%neg(%gp_rel(test1)))
|
|
|
|
; N64: addiu $[[R3:[0-9]+]], $zero, 1
|
2016-09-01 22:53:53 +08:00
|
|
|
; N64: ld $[[R2:[0-9]+]], %got_disp(x)($[[GP]])
|
2014-04-30 23:06:25 +08:00
|
|
|
; N64: sw $[[R3]], 0($[[R2]])
|
2016-07-19 18:49:03 +08:00
|
|
|
; N64: [[BB2]]:
|
2014-04-30 23:06:25 +08:00
|
|
|
; N64: jr $ra
|
|
|
|
; N64: nop
|
|
|
|
|
2016-06-18 23:39:43 +08:00
|
|
|
; In MIPS64R6 JR is an alias to JALR with $rd=0. As everything else remains the
|
|
|
|
; same with the N64 prefix, we use -asm-show-inst in order to make sure that
|
|
|
|
; the opcode of the MachineInst is a JALR.
|
|
|
|
; N64-R6: JALR64
|
|
|
|
|
2014-04-30 23:06:25 +08:00
|
|
|
|
|
|
|
; Check the microMIPS version.
|
|
|
|
|
|
|
|
; MICROMIPS: lui $[[R0:[0-9]+]], %hi(_gp_disp)
|
|
|
|
; MICROMIPS: addiu $[[R0]], $[[R0]], %lo(_gp_disp)
|
2015-05-20 22:18:59 +08:00
|
|
|
; MICROMIPS: bnez $4, $[[BB0:BB[0-9_]+]]
|
2014-04-30 23:06:25 +08:00
|
|
|
; MICROMIPS: addu $[[GP:[0-9]+]], $[[R0]], $25
|
|
|
|
|
|
|
|
; Check for long branch expansion:
|
|
|
|
; MICROMIPS: addiu $sp, $sp, -8
|
|
|
|
; MICROMIPS-NEXT: sw $ra, 0($sp)
|
2015-05-20 22:18:59 +08:00
|
|
|
; MICROMIPS-NEXT: lui $1, %hi(($[[BB2:BB[0-9_]+]])-($[[BB1:BB[0-9_]+]]))
|
|
|
|
; MICROMIPS-NEXT: bal $[[BB1]]
|
|
|
|
; MICROMIPS-NEXT: addiu $1, $1, %lo(($[[BB2]])-($[[BB1]]))
|
|
|
|
; MICROMIPS-NEXT: $[[BB1]]:
|
2014-04-30 23:06:25 +08:00
|
|
|
; MICROMIPS-NEXT: addu $1, $ra, $1
|
|
|
|
; MICROMIPS-NEXT: lw $ra, 0($sp)
|
|
|
|
; MICROMIPS-NEXT: jr $1
|
|
|
|
; MICROMIPS-NEXT: addiu $sp, $sp, 8
|
|
|
|
|
2015-05-20 22:18:59 +08:00
|
|
|
; MICROMIPS: $[[BB0]]:
|
2014-04-30 23:06:25 +08:00
|
|
|
; MICROMIPS: lw $[[R1:[0-9]+]], %got(x)($[[GP]])
|
2014-12-11 21:56:23 +08:00
|
|
|
; MICROMIPS: li16 $[[R2:[0-9]+]], 1
|
2015-02-04 23:43:17 +08:00
|
|
|
; MICROMIPS: sw16 $[[R2]], 0($[[R1]])
|
2015-05-20 22:18:59 +08:00
|
|
|
; MICROMIPS: $[[BB2]]:
|
2015-02-14 01:51:27 +08:00
|
|
|
; MICROMIPS: jrc $ra
|
2014-06-05 21:52:08 +08:00
|
|
|
|
|
|
|
|
|
|
|
; Check the NaCl version. Check that sp change is not in the branch delay slot
|
|
|
|
; of "jr $1" instruction. Check that target of indirect branch "jr $1" is
|
|
|
|
; bundle aligned.
|
|
|
|
|
|
|
|
; NACL: lui $[[R0:[0-9]+]], %hi(_gp_disp)
|
|
|
|
; NACL: addiu $[[R0]], $[[R0]], %lo(_gp_disp)
|
2015-05-20 22:18:59 +08:00
|
|
|
; NACL: bnez $4, $[[BB0:BB[0-9_]+]]
|
2014-06-05 21:52:08 +08:00
|
|
|
; NACL: addu $[[GP:[0-9]+]], $[[R0]], $25
|
|
|
|
|
|
|
|
; Check for long branch expansion:
|
|
|
|
; NACL: addiu $sp, $sp, -8
|
|
|
|
; NACL-NEXT: sw $ra, 0($sp)
|
2015-05-20 22:18:59 +08:00
|
|
|
; NACL-NEXT: lui $1, %hi(($[[BB2:BB[0-9_]+]])-($[[BB1:BB[0-9_]+]]))
|
|
|
|
; NACL-NEXT: bal $[[BB1]]
|
|
|
|
; NACL-NEXT: addiu $1, $1, %lo(($[[BB2]])-($[[BB1]]))
|
|
|
|
; NACL-NEXT: $[[BB1]]:
|
2014-06-05 21:52:08 +08:00
|
|
|
; NACL-NEXT: addu $1, $ra, $1
|
|
|
|
; NACL-NEXT: lw $ra, 0($sp)
|
|
|
|
; NACL-NEXT: addiu $sp, $sp, 8
|
|
|
|
; NACL-NEXT: jr $1
|
|
|
|
; NACL-NEXT: nop
|
|
|
|
|
2015-05-20 22:18:59 +08:00
|
|
|
; NACL: $[[BB0]]:
|
2014-06-05 21:52:08 +08:00
|
|
|
; NACL: lw $[[R1:[0-9]+]], %got(x)($[[GP]])
|
|
|
|
; NACL: addiu $[[R2:[0-9]+]], $zero, 1
|
|
|
|
; NACL: sw $[[R2]], 0($[[R1]])
|
2016-01-26 08:03:25 +08:00
|
|
|
; NACL: .p2align 4
|
2015-05-20 22:18:59 +08:00
|
|
|
; NACL-NEXT: $[[BB2]]:
|
2014-06-05 21:52:08 +08:00
|
|
|
; NACL: jr $ra
|
|
|
|
; NACL: nop
|
2014-04-30 23:06:25 +08:00
|
|
|
}
|