diff options
author | Simon Dardis <simon.dardis@mips.com> | 2017-11-09 16:02:18 +0000 |
---|---|---|
committer | Simon Dardis <simon.dardis@mips.com> | 2017-11-09 16:02:18 +0000 |
commit | c2d3e38ba6ee7e1ae61ed3682a17ee3c1690e15b (patch) | |
tree | a67104743414b27c69cbe2cb703b61b68e333359 /llvm/lib | |
parent | e5af5bde71e3730a2b5bfca6067764df13abdfc5 (diff) | |
download | bcm5719-llvm-c2d3e38ba6ee7e1ae61ed3682a17ee3c1690e15b.tar.gz bcm5719-llvm-c2d3e38ba6ee7e1ae61ed3682a17ee3c1690e15b.zip |
[mips] Correct microMIP's jump and add unconditional branch pseudo
Correct the definition of 'j' as being unavailable for microMIPS32R6 and
provide the 'b' assembly idiom for codegen purposes for microMIPS32r3.
Provide the necessary 'br' pattern for microMIPS32R6 as it now longer
incorrectly uses the 'j' instruction.
Reviewers: atanasyan
Differential Revision: https://reviews.llvm.org/D39741
llvm-svn: 317801
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/Target/Mips/MicroMips32r6InstrInfo.td | 4 | ||||
-rw-r--r-- | llvm/lib/Target/Mips/MicroMipsInstrInfo.td | 12 | ||||
-rw-r--r-- | llvm/lib/Target/Mips/MipsInstrInfo.td | 9 | ||||
-rw-r--r-- | llvm/lib/Target/Mips/MipsSEInstrInfo.cpp | 22 |
4 files changed, 29 insertions, 18 deletions
diff --git a/llvm/lib/Target/Mips/MicroMips32r6InstrInfo.td b/llvm/lib/Target/Mips/MicroMips32r6InstrInfo.td index 49d6ae3f98a..3ff3f07654d 100644 --- a/llvm/lib/Target/Mips/MicroMips32r6InstrInfo.td +++ b/llvm/lib/Target/Mips/MicroMips32r6InstrInfo.td @@ -383,7 +383,9 @@ class BALC_MMR6_DESC : BC_MMR6_DESC_BASE<"balc", brtarget26_mm, II_BALC> { bit isCall = 1; list<Register> Defs = [RA]; } -class BC_MMR6_DESC : BC_MMR6_DESC_BASE<"bc", brtarget26_mm, II_BC>; +class BC_MMR6_DESC : BC_MMR6_DESC_BASE<"bc", brtarget26_mm, II_BC> { + list<dag> Pattern = [(br bb:$offset)]; +} class BC16_MMR6_DESC : MicroMipsInst16<(outs), (ins brtarget10_mm:$offset), !strconcat("bc16", "\t$offset"), [], diff --git a/llvm/lib/Target/Mips/MicroMipsInstrInfo.td b/llvm/lib/Target/Mips/MicroMipsInstrInfo.td index 48c1d94d03c..19af30d4fbb 100644 --- a/llvm/lib/Target/Mips/MicroMipsInstrInfo.td +++ b/llvm/lib/Target/Mips/MicroMipsInstrInfo.td @@ -889,9 +889,14 @@ let DecoderNamespace = "MicroMips", Predicates = [InMicroMips] in { EXT_FM_MM<0x0c>; /// Jump Instructions +} +let DecoderNamespace = "MicroMips", DecoderMethod = "DecodeJumpTargetMM" in + def J_MM : MMRel, JumpFJ<jmptarget_mm, "j", br, bb, "j">, + J_FM_MM<0x35>, AdditionalRequires<[RelocNotPIC]>, + IsBranch, ISA_MICROMIPS32_NOT_MIPS32R6; + +let DecoderNamespace = "MicroMips", Predicates = [InMicroMips] in { let DecoderMethod = "DecodeJumpTargetMM" in { - def J_MM : MMRel, JumpFJ<jmptarget_mm, "j", br, bb, "j">, - J_FM_MM<0x35>; def JAL_MM : MMRel, JumpLink<"jal", calltarget_mm>, J_FM_MM<0x3d>; def JALX_MM : MMRel, JumpLink<"jalx", calltarget>, J_FM_MM<0x3c>; } @@ -926,6 +931,9 @@ let DecoderNamespace = "MicroMips", Predicates = [InMicroMips] in { GPR32Opnd>, BGEZAL_FM_MM<0x13>; def BLTZALS_MM : BranchCompareToZeroLinkMM<"bltzals", brtarget_mm, GPR32Opnd>, BGEZAL_FM_MM<0x11>; +} +def B_MM : UncondBranch<BEQ_MM, brtarget_mm>, IsBranch, ISA_MICROMIPS; +let DecoderNamespace = "MicroMips", Predicates = [InMicroMips] in { /// Control Instructions def SYNC_MM : MMRel, SYNC_FT<"sync">, SYNC_FM_MM; diff --git a/llvm/lib/Target/Mips/MipsInstrInfo.td b/llvm/lib/Target/Mips/MipsInstrInfo.td index 3502dbcdae9..4e6d493b91c 100644 --- a/llvm/lib/Target/Mips/MipsInstrInfo.td +++ b/llvm/lib/Target/Mips/MipsInstrInfo.td @@ -1488,9 +1488,9 @@ class JumpFJ<DAGOperand opnd, string opstr, SDPatternOperator operator, } // Unconditional branch -class UncondBranch<Instruction BEQInst> : +class UncondBranch<Instruction BEQInst, DAGOperand opnd> : PseudoSE<(outs), (ins brtarget:$offset), [(br bb:$offset)], II_B>, - PseudoInstExpansion<(BEQInst ZERO, ZERO, brtarget:$offset)> { + PseudoInstExpansion<(BEQInst ZERO, ZERO, opnd:$offset)> { let isBranch = 1; let isTerminator = 1; let isBarrier = 1; @@ -2045,7 +2045,7 @@ def SC : SCBase<"sc", GPR32Opnd>, LW_FM<0x38>, PTR_32, ISA_MIPS2_NOT_32R6_64R6; /// Jump and Branch Instructions def J : MMRel, JumpFJ<jmptarget, "j", br, bb, "j">, FJ<2>, - AdditionalRequires<[RelocNotPIC]>, IsBranch; + AdditionalRequires<[RelocNotPIC, NotInMicroMips]>, IsBranch; def JR : MMRel, IndirectBranch<"jr", GPR32Opnd>, MTLO_FM<8>, ISA_MIPS1_NOT_32R6_64R6; def BEQ : MMRel, CBranch<"beq", brtarget, seteq, GPR32Opnd>, BEQ_FM<4>; def BEQL : MMRel, CBranchLikely<"beql", brtarget, GPR32Opnd>, @@ -2069,7 +2069,8 @@ def BLTZ : MMRel, CBranchZero<"bltz", brtarget, setlt, GPR32Opnd>, BGEZ_FM<1, 0>; def BLTZL : MMRel, CBranchZeroLikely<"bltzl", brtarget, GPR32Opnd>, BGEZ_FM<1, 2>, ISA_MIPS2_NOT_32R6_64R6; -def B : UncondBranch<BEQ>; +def B : UncondBranch<BEQ, brtarget>, + AdditionalRequires<[NotInMicroMips]>; def JAL : MMRel, JumpLink<"jal", calltarget>, FJ<3>; let AdditionalPredicates = [NotInMicroMips] in { diff --git a/llvm/lib/Target/Mips/MipsSEInstrInfo.cpp b/llvm/lib/Target/Mips/MipsSEInstrInfo.cpp index b1311fbd90e..798d86622e5 100644 --- a/llvm/lib/Target/Mips/MipsSEInstrInfo.cpp +++ b/llvm/lib/Target/Mips/MipsSEInstrInfo.cpp @@ -540,17 +540,17 @@ unsigned MipsSEInstrInfo::getAnalyzableBrOpc(unsigned Opc) const { Opc == Mips::BNE64 || Opc == Mips::BGTZ64 || Opc == Mips::BGEZ64 || Opc == Mips::BLTZ64 || Opc == Mips::BLEZ64 || Opc == Mips::BC1T || Opc == Mips::BC1F || Opc == Mips::B || Opc == Mips::J || - Opc == Mips::BEQZC_MM || Opc == Mips::BNEZC_MM || Opc == Mips::BEQC || - Opc == Mips::BNEC || Opc == Mips::BLTC || Opc == Mips::BGEC || - Opc == Mips::BLTUC || Opc == Mips::BGEUC || Opc == Mips::BGTZC || - Opc == Mips::BLEZC || Opc == Mips::BGEZC || Opc == Mips::BLTZC || - Opc == Mips::BEQZC || Opc == Mips::BNEZC || Opc == Mips::BEQZC64 || - Opc == Mips::BNEZC64 || Opc == Mips::BEQC64 || Opc == Mips::BNEC64 || - Opc == Mips::BGEC64 || Opc == Mips::BGEUC64 || Opc == Mips::BLTC64 || - Opc == Mips::BLTUC64 || Opc == Mips::BGTZC64 || - Opc == Mips::BGEZC64 || Opc == Mips::BLTZC64 || - Opc == Mips::BLEZC64 || Opc == Mips::BC || Opc == Mips::BBIT0 || - Opc == Mips::BBIT1 || Opc == Mips::BBIT032 || + Opc == Mips::B_MM || Opc == Mips::BEQZC_MM || + Opc == Mips::BNEZC_MM || Opc == Mips::BEQC || Opc == Mips::BNEC || + Opc == Mips::BLTC || Opc == Mips::BGEC || Opc == Mips::BLTUC || + Opc == Mips::BGEUC || Opc == Mips::BGTZC || Opc == Mips::BLEZC || + Opc == Mips::BGEZC || Opc == Mips::BLTZC || Opc == Mips::BEQZC || + Opc == Mips::BNEZC || Opc == Mips::BEQZC64 || Opc == Mips::BNEZC64 || + Opc == Mips::BEQC64 || Opc == Mips::BNEC64 || Opc == Mips::BGEC64 || + Opc == Mips::BGEUC64 || Opc == Mips::BLTC64 || Opc == Mips::BLTUC64 || + Opc == Mips::BGTZC64 || Opc == Mips::BGEZC64 || + Opc == Mips::BLTZC64 || Opc == Mips::BLEZC64 || Opc == Mips::BC || + Opc == Mips::BBIT0 || Opc == Mips::BBIT1 || Opc == Mips::BBIT032 || Opc == Mips::BBIT132) ? Opc : 0; } |