[mips] Never select JAL for calls to an absolute immediate address.

Summary:
It actually takes an offset into the current PC-region.

This fixes the 'expr' command in lldb.

Reviewers: vkalintiris, jaydeep, bhushan

Subscribers: dsanders, llvm-commits

Differential Revision: http://reviews.llvm.org/D16054


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@257339 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Daniel Sanders 2016-01-11 15:57:46 +00:00
parent 274cad5260
commit 58a84d9b9c
20 changed files with 34 additions and 3 deletions

View File

@ -1003,7 +1003,7 @@ class IndirectBranch<string opstr, RegisterOperand RO> : JumpFR<opstr, RO> {
let isCall=1, hasDelaySlot=1, Defs = [RA] in { let isCall=1, hasDelaySlot=1, Defs = [RA] in {
class JumpLink<string opstr, DAGOperand opnd> : class JumpLink<string opstr, DAGOperand opnd> :
InstSE<(outs), (ins opnd:$target), !strconcat(opstr, "\t$target"), InstSE<(outs), (ins opnd:$target), !strconcat(opstr, "\t$target"),
[(MipsJmpLink imm:$target)], II_JAL, FrmJ, opstr> { [(MipsJmpLink tglobaladdr:$target)], II_JAL, FrmJ, opstr> {
let DecoderMethod = "DecodeJumpTarget"; let DecoderMethod = "DecodeJumpTarget";
} }
@ -2075,8 +2075,6 @@ def : MipsPat<(MipsSync (i32 immz)),
(SYNC 0)>, ISA_MIPS2; (SYNC 0)>, ISA_MIPS2;
// Call // Call
def : MipsPat<(MipsJmpLink (i32 tglobaladdr:$dst)),
(JAL tglobaladdr:$dst)>;
def : MipsPat<(MipsJmpLink (i32 texternalsym:$dst)), def : MipsPat<(MipsJmpLink (i32 texternalsym:$dst)),
(JAL texternalsym:$dst)>; (JAL texternalsym:$dst)>;
//def : MipsPat<(MipsJmpLink GPR32:$dst), //def : MipsPat<(MipsJmpLink GPR32:$dst),

View File

@ -182,3 +182,18 @@ define hidden void @thunk_undef_double(i32 %this, double %volume) unnamed_addr a
tail call void @undef_double(i32 undef, double undef) #8 tail call void @undef_double(i32 undef, double undef) #8
ret void ret void
} }
; Check that immediate addresses do not use jal.
define i32 @jal_only_allows_symbols() {
; ALL-LABEL: jal_only_allows_symbols:
; ALL-NOT: {{jal }}
; ALL: addiu $[[TGT:[0-9]+]], $zero, 1234
; ALL-NOT: {{jal }}
; ALL: jalr $[[TGT]]
; ALL-NOT: {{jal }}
call void () inttoptr (i32 1234 to void ()*)()
ret i32 0
}

View File

@ -83,6 +83,7 @@
0x08 0x00 0x00 0x01 # CHECK: j 4 0x08 0x00 0x00 0x01 # CHECK: j 4
0x09 0x33 0x00 0x2a # CHECK: j 80478376 0x09 0x33 0x00 0x2a # CHECK: j 80478376
0x0b 0x2a 0xd1 0x44 # CHECK: j 212550928 0x0b 0x2a 0xd1 0x44 # CHECK: j 212550928
0x0c 0x00 0x01 0x4c # CHECK: jal 1328
0x21 0x08 0xff 0xfe # CHECK: addi $8, $8, -2 0x21 0x08 0xff 0xfe # CHECK: addi $8, $8, -2
0x21 0x2d 0x66 0xd2 # CHECK: addi $13, $9, 26322 0x21 0x2d 0x66 0xd2 # CHECK: addi $13, $9, 26322
0x21 0xad 0xe6 0x90 # CHECK: addi $13, $13, -6512 0x21 0xad 0xe6 0x90 # CHECK: addi $13, $13, -6512

View File

@ -114,6 +114,7 @@
0x08 0x00 0x00 0x01 # CHECK: j 4 0x08 0x00 0x00 0x01 # CHECK: j 4
0x09 0x33 0x00 0x2a # CHECK: j 80478376 0x09 0x33 0x00 0x2a # CHECK: j 80478376
0x0b 0x2a 0xd1 0x44 # CHECK: j 212550928 0x0b 0x2a 0xd1 0x44 # CHECK: j 212550928
0x0c 0x00 0x01 0x4c # CHECK: jal 1328
0x21 0x08 0xff 0xfe # CHECK: addi $8, $8, -2 0x21 0x08 0xff 0xfe # CHECK: addi $8, $8, -2
0x21 0x2d 0x66 0xd2 # CHECK: addi $13, $9, 26322 0x21 0x2d 0x66 0xd2 # CHECK: addi $13, $9, 26322
0x21 0xad 0xe6 0x90 # CHECK: addi $13, $13, -6512 0x21 0xad 0xe6 0x90 # CHECK: addi $13, $13, -6512

View File

@ -118,6 +118,7 @@
0x08 0x00 0x00 0x01 # CHECK: j 4 0x08 0x00 0x00 0x01 # CHECK: j 4
0x09 0x33 0x00 0x2a # CHECK: j 80478376 0x09 0x33 0x00 0x2a # CHECK: j 80478376
0x0b 0x2a 0xd1 0x44 # CHECK: j 212550928 0x0b 0x2a 0xd1 0x44 # CHECK: j 212550928
0x0c 0x00 0x01 0x4c # CHECK: jal 1328
0x21 0x08 0xff 0xfe # CHECK: addi $8, $8, -2 0x21 0x08 0xff 0xfe # CHECK: addi $8, $8, -2
0x21 0x2d 0x66 0xd2 # CHECK: addi $13, $9, 26322 0x21 0x2d 0x66 0xd2 # CHECK: addi $13, $9, 26322
0x21 0xad 0xe6 0x90 # CHECK: addi $13, $13, -6512 0x21 0xad 0xe6 0x90 # CHECK: addi $13, $13, -6512

View File

@ -46,6 +46,7 @@ a:
j a # CHECK: j a # encoding: [0b000010AA,A,A,A] j a # CHECK: j a # encoding: [0b000010AA,A,A,A]
# CHECK: # fixup A - offset: 0, value: a, kind: fixup_Mips_26 # CHECK: # fixup A - offset: 0, value: a, kind: fixup_Mips_26
j 1328 # CHECK: j 1328 # encoding: [0x08,0x00,0x01,0x4c] j 1328 # CHECK: j 1328 # encoding: [0x08,0x00,0x01,0x4c]
jal 21100 # CHECK: jal 21100 # encoding: [0x0c,0x00,0x14,0x9b]
lb $24,-14515($10) lb $24,-14515($10)
lbu $8,30195($v1) lbu $8,30195($v1)
lh $11,-8556($s5) lh $11,-8556($s5)

View File

@ -62,6 +62,7 @@ a:
j a # CHECK: j a # encoding: [0b000010AA,A,A,A] j a # CHECK: j a # encoding: [0b000010AA,A,A,A]
# CHECK: # fixup A - offset: 0, value: a, kind: fixup_Mips_26 # CHECK: # fixup A - offset: 0, value: a, kind: fixup_Mips_26
j 1328 # CHECK: j 1328 # encoding: [0x08,0x00,0x01,0x4c] j 1328 # CHECK: j 1328 # encoding: [0x08,0x00,0x01,0x4c]
jal 21100 # CHECK: jal 21100 # encoding: [0x0c,0x00,0x14,0x9b]
lb $24,-14515($10) lb $24,-14515($10)
lbu $8,30195($v1) lbu $8,30195($v1)
ldc1 $f11,16391($s0) ldc1 $f11,16391($s0)

View File

@ -117,6 +117,7 @@ a:
j a # CHECK: j a # encoding: [0b000010AA,A,A,A] j a # CHECK: j a # encoding: [0b000010AA,A,A,A]
# CHECK: # fixup A - offset: 0, value: a, kind: fixup_Mips_26 # CHECK: # fixup A - offset: 0, value: a, kind: fixup_Mips_26
j 1328 # CHECK: j 1328 # encoding: [0x08,0x00,0x01,0x4c] j 1328 # CHECK: j 1328 # encoding: [0x08,0x00,0x01,0x4c]
jal 21100 # CHECK: jal 21100 # encoding: [0x0c,0x00,0x14,0x9b]
lb $24,-14515($10) lb $24,-14515($10)
lbu $8,30195($v1) lbu $8,30195($v1)
ld $sp,-28645($s1) ld $sp,-28645($s1)

View File

@ -71,6 +71,7 @@ a:
j a # CHECK: j a # encoding: [0b000010AA,A,A,A] j a # CHECK: j a # encoding: [0b000010AA,A,A,A]
# CHECK: # fixup A - offset: 0, value: a, kind: fixup_Mips_26 # CHECK: # fixup A - offset: 0, value: a, kind: fixup_Mips_26
j 1328 # CHECK: j 1328 # encoding: [0x08,0x00,0x01,0x4c] j 1328 # CHECK: j 1328 # encoding: [0x08,0x00,0x01,0x4c]
jal 21100 # CHECK: jal 21100 # encoding: [0x0c,0x00,0x14,0x9b]
lb $24,-14515($10) lb $24,-14515($10)
lbu $8,30195($v1) lbu $8,30195($v1)
ldc1 $f11,16391($s0) ldc1 $f11,16391($s0)

View File

@ -77,6 +77,7 @@ a:
j a # CHECK: j a # encoding: [0b000010AA,A,A,A] j a # CHECK: j a # encoding: [0b000010AA,A,A,A]
# CHECK: # fixup A - offset: 0, value: a, kind: fixup_Mips_26 # CHECK: # fixup A - offset: 0, value: a, kind: fixup_Mips_26
j 1328 # CHECK: j 1328 # encoding: [0x08,0x00,0x01,0x4c] j 1328 # CHECK: j 1328 # encoding: [0x08,0x00,0x01,0x4c]
jal 21100 # CHECK: jal 21100 # encoding: [0x0c,0x00,0x14,0x9b]
jr.hb $4 # CHECK: jr.hb $4 # encoding: [0x00,0x80,0x04,0x08] jr.hb $4 # CHECK: jr.hb $4 # encoding: [0x00,0x80,0x04,0x08]
jalr.hb $4 # CHECK: jalr.hb $4 # encoding: [0x00,0x80,0xfc,0x09] jalr.hb $4 # CHECK: jalr.hb $4 # encoding: [0x00,0x80,0xfc,0x09]
jalr.hb $4, $5 # CHECK: jalr.hb $4, $5 # encoding: [0x00,0xa0,0x24,0x09] jalr.hb $4, $5 # CHECK: jalr.hb $4, $5 # encoding: [0x00,0xa0,0x24,0x09]

View File

@ -77,6 +77,7 @@ a:
j a # CHECK: j a # encoding: [0b000010AA,A,A,A] j a # CHECK: j a # encoding: [0b000010AA,A,A,A]
# CHECK: # fixup A - offset: 0, value: a, kind: fixup_Mips_26 # CHECK: # fixup A - offset: 0, value: a, kind: fixup_Mips_26
j 1328 # CHECK: j 1328 # encoding: [0x08,0x00,0x01,0x4c] j 1328 # CHECK: j 1328 # encoding: [0x08,0x00,0x01,0x4c]
jal 21100 # CHECK: jal 21100 # encoding: [0x0c,0x00,0x14,0x9b]
jr.hb $4 # CHECK: jr.hb $4 # encoding: [0x00,0x80,0x04,0x08] jr.hb $4 # CHECK: jr.hb $4 # encoding: [0x00,0x80,0x04,0x08]
jalr.hb $4 # CHECK: jalr.hb $4 # encoding: [0x00,0x80,0xfc,0x09] jalr.hb $4 # CHECK: jalr.hb $4 # encoding: [0x00,0x80,0xfc,0x09]
jalr.hb $4, $5 # CHECK: jalr.hb $4, $5 # encoding: [0x00,0xa0,0x24,0x09] jalr.hb $4, $5 # CHECK: jalr.hb $4, $5 # encoding: [0x00,0xa0,0x24,0x09]

View File

@ -78,6 +78,7 @@ a:
j a # CHECK: j a # encoding: [0b000010AA,A,A,A] j a # CHECK: j a # encoding: [0b000010AA,A,A,A]
# CHECK: # fixup A - offset: 0, value: a, kind: fixup_Mips_26 # CHECK: # fixup A - offset: 0, value: a, kind: fixup_Mips_26
j 1328 # CHECK: j 1328 # encoding: [0x08,0x00,0x01,0x4c] j 1328 # CHECK: j 1328 # encoding: [0x08,0x00,0x01,0x4c]
jal 21100 # CHECK: jal 21100 # encoding: [0x0c,0x00,0x14,0x9b]
jr.hb $4 # CHECK: jr.hb $4 # encoding: [0x00,0x80,0x04,0x08] jr.hb $4 # CHECK: jr.hb $4 # encoding: [0x00,0x80,0x04,0x08]
jalr.hb $4 # CHECK: jalr.hb $4 # encoding: [0x00,0x80,0xfc,0x09] jalr.hb $4 # CHECK: jalr.hb $4 # encoding: [0x00,0x80,0xfc,0x09]
jalr.hb $4, $5 # CHECK: jalr.hb $4, $5 # encoding: [0x00,0xa0,0x24,0x09] jalr.hb $4, $5 # CHECK: jalr.hb $4, $5 # encoding: [0x00,0xa0,0x24,0x09]

View File

@ -159,6 +159,7 @@ a:
j a # CHECK: j a # encoding: [0b000010AA,A,A,A] j a # CHECK: j a # encoding: [0b000010AA,A,A,A]
# CHECK: # fixup A - offset: 0, value: a, kind: fixup_Mips_26 # CHECK: # fixup A - offset: 0, value: a, kind: fixup_Mips_26
j 1328 # CHECK: j 1328 # encoding: [0x08,0x00,0x01,0x4c] j 1328 # CHECK: j 1328 # encoding: [0x08,0x00,0x01,0x4c]
jal 21100 # CHECK: jal 21100 # encoding: [0x0c,0x00,0x14,0x9b]
jr.hb $4 # CHECK: jr.hb $4 # encoding: [0x00,0x80,0x04,0x09] jr.hb $4 # CHECK: jr.hb $4 # encoding: [0x00,0x80,0x04,0x09]
jalr.hb $4 # CHECK: jalr.hb $4 # encoding: [0x00,0x80,0xfc,0x09] jalr.hb $4 # CHECK: jalr.hb $4 # encoding: [0x00,0x80,0xfc,0x09]
jalr.hb $4, $5 # CHECK: jalr.hb $4, $5 # encoding: [0x00,0xa0,0x24,0x09] jalr.hb $4, $5 # CHECK: jalr.hb $4, $5 # encoding: [0x00,0xa0,0x24,0x09]

View File

@ -121,6 +121,7 @@ a:
j a # CHECK: j a # encoding: [0b000010AA,A,A,A] j a # CHECK: j a # encoding: [0b000010AA,A,A,A]
# CHECK: # fixup A - offset: 0, value: a, kind: fixup_Mips_26 # CHECK: # fixup A - offset: 0, value: a, kind: fixup_Mips_26
j 1328 # CHECK: j 1328 # encoding: [0x08,0x00,0x01,0x4c] j 1328 # CHECK: j 1328 # encoding: [0x08,0x00,0x01,0x4c]
jal 21100 # CHECK: jal 21100 # encoding: [0x0c,0x00,0x14,0x9b]
lb $24,-14515($10) lb $24,-14515($10)
lbu $8,30195($v1) lbu $8,30195($v1)
ld $sp,-28645($s1) ld $sp,-28645($s1)

View File

@ -121,6 +121,7 @@ a:
j a # CHECK: j a # encoding: [0b000010AA,A,A,A] j a # CHECK: j a # encoding: [0b000010AA,A,A,A]
# CHECK: # fixup A - offset: 0, value: a, kind: fixup_Mips_26 # CHECK: # fixup A - offset: 0, value: a, kind: fixup_Mips_26
j 1328 # CHECK: j 1328 # encoding: [0x08,0x00,0x01,0x4c] j 1328 # CHECK: j 1328 # encoding: [0x08,0x00,0x01,0x4c]
jal 21100 # CHECK: jal 21100 # encoding: [0x0c,0x00,0x14,0x9b]
lb $24,-14515($10) lb $24,-14515($10)
lbu $8,30195($v1) lbu $8,30195($v1)
ld $sp,-28645($s1) ld $sp,-28645($s1)

View File

@ -128,6 +128,7 @@ a:
j a # CHECK: j a # encoding: [0b000010AA,A,A,A] j a # CHECK: j a # encoding: [0b000010AA,A,A,A]
# CHECK: # fixup A - offset: 0, value: a, kind: fixup_Mips_26 # CHECK: # fixup A - offset: 0, value: a, kind: fixup_Mips_26
j 1328 # CHECK: j 1328 # encoding: [0x08,0x00,0x01,0x4c] j 1328 # CHECK: j 1328 # encoding: [0x08,0x00,0x01,0x4c]
jal 21100 # CHECK: jal 21100 # encoding: [0x0c,0x00,0x14,0x9b]
lb $24,-14515($10) lb $24,-14515($10)
lbu $8,30195($v1) lbu $8,30195($v1)
ld $sp,-28645($s1) ld $sp,-28645($s1)

View File

@ -141,6 +141,7 @@ a:
j a # CHECK: j a # encoding: [0b000010AA,A,A,A] j a # CHECK: j a # encoding: [0b000010AA,A,A,A]
# CHECK: # fixup A - offset: 0, value: a, kind: fixup_Mips_26 # CHECK: # fixup A - offset: 0, value: a, kind: fixup_Mips_26
j 1328 # CHECK: j 1328 # encoding: [0x08,0x00,0x01,0x4c] j 1328 # CHECK: j 1328 # encoding: [0x08,0x00,0x01,0x4c]
jal 21100 # CHECK: jal 21100 # encoding: [0x0c,0x00,0x14,0x9b]
jr.hb $4 # CHECK: jr.hb $4 # encoding: [0x00,0x80,0x04,0x08] jr.hb $4 # CHECK: jr.hb $4 # encoding: [0x00,0x80,0x04,0x08]
jalr.hb $4 # CHECK: jalr.hb $4 # encoding: [0x00,0x80,0xfc,0x09] jalr.hb $4 # CHECK: jalr.hb $4 # encoding: [0x00,0x80,0xfc,0x09]
jalr.hb $4, $5 # CHECK: jalr.hb $4, $5 # encoding: [0x00,0xa0,0x24,0x09] jalr.hb $4, $5 # CHECK: jalr.hb $4, $5 # encoding: [0x00,0xa0,0x24,0x09]

View File

@ -141,6 +141,7 @@ a:
j a # CHECK: j a # encoding: [0b000010AA,A,A,A] j a # CHECK: j a # encoding: [0b000010AA,A,A,A]
# CHECK: # fixup A - offset: 0, value: a, kind: fixup_Mips_26 # CHECK: # fixup A - offset: 0, value: a, kind: fixup_Mips_26
j 1328 # CHECK: j 1328 # encoding: [0x08,0x00,0x01,0x4c] j 1328 # CHECK: j 1328 # encoding: [0x08,0x00,0x01,0x4c]
jal 21100 # CHECK: jal 21100 # encoding: [0x0c,0x00,0x14,0x9b]
jr.hb $4 # CHECK: jr.hb $4 # encoding: [0x00,0x80,0x04,0x08] jr.hb $4 # CHECK: jr.hb $4 # encoding: [0x00,0x80,0x04,0x08]
jalr.hb $4 # CHECK: jalr.hb $4 # encoding: [0x00,0x80,0xfc,0x09] jalr.hb $4 # CHECK: jalr.hb $4 # encoding: [0x00,0x80,0xfc,0x09]
jalr.hb $4, $5 # CHECK: jalr.hb $4, $5 # encoding: [0x00,0xa0,0x24,0x09] jalr.hb $4, $5 # CHECK: jalr.hb $4, $5 # encoding: [0x00,0xa0,0x24,0x09]

View File

@ -142,6 +142,7 @@ a:
j a # CHECK: j a # encoding: [0b000010AA,A,A,A] j a # CHECK: j a # encoding: [0b000010AA,A,A,A]
# CHECK: # fixup A - offset: 0, value: a, kind: fixup_Mips_26 # CHECK: # fixup A - offset: 0, value: a, kind: fixup_Mips_26
j 1328 # CHECK: j 1328 # encoding: [0x08,0x00,0x01,0x4c] j 1328 # CHECK: j 1328 # encoding: [0x08,0x00,0x01,0x4c]
jal 21100 # CHECK: jal 21100 # encoding: [0x0c,0x00,0x14,0x9b]
jr.hb $4 # CHECK: jr.hb $4 # encoding: [0x00,0x80,0x04,0x08] jr.hb $4 # CHECK: jr.hb $4 # encoding: [0x00,0x80,0x04,0x08]
jalr.hb $4 # CHECK: jalr.hb $4 # encoding: [0x00,0x80,0xfc,0x09] jalr.hb $4 # CHECK: jalr.hb $4 # encoding: [0x00,0x80,0xfc,0x09]
jalr.hb $4, $5 # CHECK: jalr.hb $4, $5 # encoding: [0x00,0xa0,0x24,0x09] jalr.hb $4, $5 # CHECK: jalr.hb $4, $5 # encoding: [0x00,0xa0,0x24,0x09]

View File

@ -138,6 +138,7 @@ a:
j a # CHECK: j a # encoding: [0b000010AA,A,A,A] j a # CHECK: j a # encoding: [0b000010AA,A,A,A]
# CHECK: # fixup A - offset: 0, value: a, kind: fixup_Mips_26 # CHECK: # fixup A - offset: 0, value: a, kind: fixup_Mips_26
j 1328 # CHECK: j 1328 # encoding: [0x08,0x00,0x01,0x4c] j 1328 # CHECK: j 1328 # encoding: [0x08,0x00,0x01,0x4c]
jal 21100 # CHECK: jal 21100 # encoding: [0x0c,0x00,0x14,0x9b]
jr.hb $4 # CHECK: jr.hb $4 # encoding: [0x00,0x80,0x04,0x09] jr.hb $4 # CHECK: jr.hb $4 # encoding: [0x00,0x80,0x04,0x09]
jalr.hb $4 # CHECK: jalr.hb $4 # encoding: [0x00,0x80,0xfc,0x09] jalr.hb $4 # CHECK: jalr.hb $4 # encoding: [0x00,0x80,0xfc,0x09]
jalr.hb $4, $5 # CHECK: jalr.hb $4, $5 # encoding: [0x00,0xa0,0x24,0x09] jalr.hb $4, $5 # CHECK: jalr.hb $4, $5 # encoding: [0x00,0xa0,0x24,0x09]