summaryrefslogtreecommitdiff
path: root/lib/Target/Mips
diff options
context:
space:
mode:
authorSimon Dardis <simon.dardis@mips.com>2018-06-20 19:59:58 +0000
committerSimon Dardis <simon.dardis@mips.com>2018-06-20 19:59:58 +0000
commit2bdc7ff150b96c3c1c4247239218f4b13c2bce16 (patch)
tree24a7516979c3a3ea2c5bbc00d9ffd82ad065efd6 /lib/Target/Mips
parenteb6f9a11dbdf9a729b278a16a70bdd6ab5079a57 (diff)
[mips] Correct predicates for loads, bit manipulation instructions and some pseudos
Additionally, correct the definition of the rdhwr instruction. Reviewers: atanasyan, abeserminji, smaksimovic Differential Revision: https://reviews.llvm.org/D48216 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@335162 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/Mips')
-rw-r--r--lib/Target/Mips/MicroMipsInstrInfo.td7
-rw-r--r--lib/Target/Mips/MipsInstrFormats.td4
-rw-r--r--lib/Target/Mips/MipsInstrInfo.td38
-rw-r--r--lib/Target/Mips/MipsSEISelDAGToDAG.cpp6
4 files changed, 33 insertions, 22 deletions
diff --git a/lib/Target/Mips/MicroMipsInstrInfo.td b/lib/Target/Mips/MicroMipsInstrInfo.td
index 5c18d5eb928..cd19f1c5cc0 100644
--- a/lib/Target/Mips/MicroMipsInstrInfo.td
+++ b/lib/Target/Mips/MicroMipsInstrInfo.td
@@ -776,7 +776,8 @@ let DecoderNamespace = "MicroMips" in {
ADD_FM_MM<0, 0x290>, ISA_MICROMIPS32_NOT_MIPS32R6;
def XOR_MM : MMRel, ArithLogicR<"xor", GPR32Opnd, 1, II_XOR, xor>,
ADD_FM_MM<0, 0x310>, ISA_MICROMIPS32_NOT_MIPS32R6;
- def NOR_MM : MMRel, LogicNOR<"nor", GPR32Opnd>, ADD_FM_MM<0, 0x2d0>;
+ def NOR_MM : MMRel, LogicNOR<"nor", GPR32Opnd>, ADD_FM_MM<0, 0x2d0>,
+ ISA_MICROMIPS32_NOT_MIPS32R6;
def MULT_MM : MMRel, Mult<"mult", II_MULT, GPR32Opnd, [HI0, LO0]>,
MULT_FM_MM<0x22c>, ISA_MICROMIPS32_NOT_MIPS32R6;
def MULTu_MM : MMRel, Mult<"multu", II_MULTU, GPR32Opnd, [HI0, LO0]>,
@@ -1397,6 +1398,10 @@ let EncodingPredicates = [InMicroMips] in {
def : MipsInstAlias<"j $rs", (JR_MM GPR32Opnd:$rs), 0>,
ISA_MICROMIPS32_NOT_MIPS32R6;
}
+def : MipsInstAlias<"rdhwr $rt, $rs",
+ (RDHWR_MM GPR32Opnd:$rt, HWRegsOpnd:$rs, 0), 1>,
+ ISA_MICROMIPS32_NOT_MIPS32R6;
+
def : MipsInstAlias<"hypcall", (HYPCALL_MM 0), 1>,
ISA_MICROMIPS32R5, ASE_VIRT;
def : MipsInstAlias<"mfgc0 $rt, $rs",
diff --git a/lib/Target/Mips/MipsInstrFormats.td b/lib/Target/Mips/MipsInstrFormats.td
index 549f8b24b58..04bb7101014 100644
--- a/lib/Target/Mips/MipsInstrFormats.td
+++ b/lib/Target/Mips/MipsInstrFormats.td
@@ -508,6 +508,7 @@ class EXT_FM<bits<6> funct> : StdArch {
class RDHWR_FM : StdArch {
bits<5> rt;
bits<5> rd;
+ bits<3> sel;
bits<32> Inst;
@@ -515,7 +516,8 @@ class RDHWR_FM : StdArch {
let Inst{25-21} = 0;
let Inst{20-16} = rt;
let Inst{15-11} = rd;
- let Inst{10-6} = 0;
+ let Inst{10-9} = 0b00;
+ let Inst{8-6} = sel;
let Inst{5-0} = 0x3b;
}
diff --git a/lib/Target/Mips/MipsInstrInfo.td b/lib/Target/Mips/MipsInstrInfo.td
index 3271cd13055..d4ab92b8014 100644
--- a/lib/Target/Mips/MipsInstrInfo.td
+++ b/lib/Target/Mips/MipsInstrInfo.td
@@ -1824,8 +1824,8 @@ class SubwordSwap<string opstr, RegisterOperand RO,
// Read Hardware
class ReadHardware<RegisterOperand CPURegOperand, RegisterOperand RO> :
- InstSE<(outs CPURegOperand:$rt), (ins RO:$rd), "rdhwr\t$rt, $rd", [],
- II_RDHWR, FrmR, "rdhwr">;
+ InstSE<(outs CPURegOperand:$rt), (ins RO:$rd, uimm8:$sel),
+ "rdhwr\t$rt, $rd, $sel", [], II_RDHWR, FrmR, "rdhwr">;
// Ext and Ins
class ExtBase<string opstr, RegisterOperand RO, Operand PosOpnd,
@@ -1834,7 +1834,7 @@ class ExtBase<string opstr, RegisterOperand RO, Operand PosOpnd,
InstSE<(outs RO:$rt), (ins RO:$rs, PosOpnd:$pos, SizeOpnd:$size),
!strconcat(opstr, "\t$rt, $rs, $pos, $size"),
[(set RO:$rt, (Op RO:$rs, PosImm:$pos, SizeImm:$size))], II_EXT,
- FrmR, opstr>, ISA_MIPS32R2;
+ FrmR, opstr>;
// 'ins' and its' 64 bit variants are matched by C++ code.
class InsBase<string opstr, RegisterOperand RO, Operand PosOpnd,
@@ -1843,7 +1843,7 @@ class InsBase<string opstr, RegisterOperand RO, Operand PosOpnd,
!strconcat(opstr, "\t$rt, $rs, $pos, $size"),
[(set RO:$rt, (null_frag RO:$rs, PosImm:$pos, SizeImm:$size,
RO:$src))],
- II_INS, FrmR, opstr>, ISA_MIPS32R2 {
+ II_INS, FrmR, opstr> {
let Constraints = "$src = $rt";
}
@@ -2050,19 +2050,20 @@ let AdditionalPredicates = [NotInMicroMips] in {
/// aligned
let AdditionalPredicates = [NotInMicroMips] in {
def LB : LoadMemory<"lb", GPR32Opnd, mem_simmptr, sextloadi8, II_LB>, MMRel,
- LW_FM<0x20>;
+ LW_FM<0x20>, ISA_MIPS1;
def LBu : LoadMemory<"lbu", GPR32Opnd, mem_simmptr, zextloadi8, II_LBU,
- addrDefault>, MMRel, LW_FM<0x24>;
+ addrDefault>, MMRel, LW_FM<0x24>, ISA_MIPS1;
def LH : LoadMemory<"lh", GPR32Opnd, mem_simmptr, sextloadi16, II_LH,
- addrDefault>, MMRel, LW_FM<0x21>;
+ addrDefault>, MMRel, LW_FM<0x21>, ISA_MIPS1;
def LHu : LoadMemory<"lhu", GPR32Opnd, mem_simmptr, zextloadi16, II_LHU>,
- MMRel, LW_FM<0x25>;
+ MMRel, LW_FM<0x25>, ISA_MIPS1;
def LW : StdMMR6Rel, Load<"lw", GPR32Opnd, load, II_LW, addrDefault>, MMRel,
- LW_FM<0x23>;
+ LW_FM<0x23>, ISA_MIPS1;
def SB : StdMMR6Rel, Store<"sb", GPR32Opnd, truncstorei8, II_SB>, MMRel,
- LW_FM<0x28>;
- def SH : Store<"sh", GPR32Opnd, truncstorei16, II_SH>, MMRel, LW_FM<0x29>;
- def SW : Store<"sw", GPR32Opnd, store, II_SW>, MMRel, LW_FM<0x2b>;
+ LW_FM<0x28>, ISA_MIPS1;
+ def SH : Store<"sh", GPR32Opnd, truncstorei16, II_SH>, MMRel, LW_FM<0x29>,
+ ISA_MIPS1;
+ def SW : Store<"sw", GPR32Opnd, store, II_SW>, MMRel, LW_FM<0x2b>, ISA_MIPS1;
}
/// load/store left/right
@@ -2210,10 +2211,10 @@ let AdditionalPredicates = [NotInMicroMips] in {
ISA_MIPS1_NOT_32R6_64R6;
def BLTZALL : MMRel, BGEZAL_FT<"bltzall", brtarget, GPR32Opnd>,
BGEZAL_FM<0x12>, ISA_MIPS2_NOT_32R6_64R6;
- def BAL_BR : BAL_BR_Pseudo<BGEZAL, brtarget>;
+ def BAL_BR : BAL_BR_Pseudo<BGEZAL, brtarget>, ISA_MIPS1;
}
let AdditionalPredicates = [NotInMips16Mode, NotInMicroMips] in {
- def TAILCALL : TailCall<J, jmptarget>;
+ def TAILCALL : TailCall<J, jmptarget>, ISA_MIPS1;
}
let AdditionalPredicates = [NotInMips16Mode, NotInMicroMips,
NoIndirectJumpGuards] in
@@ -2357,15 +2358,15 @@ let AdditionalPredicates = [NotInMicroMips] in {
0, 1, 1>, ISA_MIPS1_NOT_32R6_64R6;
def PseudoUDIV : MultDivPseudo<UDIV, ACC64, GPR32Opnd, MipsDivRemU, II_DIVU,
0, 1, 1>, ISA_MIPS1_NOT_32R6_64R6;
- def RDHWR : MMRel, ReadHardware<GPR32Opnd, HWRegsOpnd>, RDHWR_FM;
+ def RDHWR : MMRel, ReadHardware<GPR32Opnd, HWRegsOpnd>, RDHWR_FM, ISA_MIPS1;
// TODO: Add '0 < pos+size <= 32' constraint check to ext instruction
def EXT : MMRel, StdMMR6Rel, ExtBase<"ext", GPR32Opnd, uimm5, uimm5_plus1,
immZExt5, immZExt5Plus1, MipsExt>,
- EXT_FM<0>;
+ EXT_FM<0>, ISA_MIPS32R2;
def INS : MMRel, StdMMR6Rel, InsBase<"ins", GPR32Opnd, uimm5,
uimm5_inssize_plus1, immZExt5,
immZExt5Plus1>,
- EXT_FM<4>;
+ EXT_FM<4>, ISA_MIPS32R2;
}
/// Move Control Registers From/To CPU Registers
let AdditionalPredicates = [NotInMicroMips] in {
@@ -2711,6 +2712,9 @@ let AdditionalPredicates = [NotInMicroMips] in {
(TLTU GPR32Opnd:$rs, GPR32Opnd:$rt, 0), 1>, ISA_MIPS2;
def : MipsInstAlias<"tne $rs, $rt",
(TNE GPR32Opnd:$rs, GPR32Opnd:$rt, 0), 1>, ISA_MIPS2;
+ def : MipsInstAlias<"rdhwr $rt, $rs",
+ (RDHWR GPR32Opnd:$rt, HWRegsOpnd:$rs, 0), 1>, ISA_MIPS1;
+
}
def : MipsInstAlias<"sub, $rd, $rs, $imm",
(ADDi GPR32Opnd:$rd, GPR32Opnd:$rs,
diff --git a/lib/Target/Mips/MipsSEISelDAGToDAG.cpp b/lib/Target/Mips/MipsSEISelDAGToDAG.cpp
index 97e9a83d7df..599c1e913ac 100644
--- a/lib/Target/Mips/MipsSEISelDAGToDAG.cpp
+++ b/lib/Target/Mips/MipsSEISelDAGToDAG.cpp
@@ -976,9 +976,9 @@ bool MipsSEDAGToDAGISel::trySelect(SDNode *Node) {
}
SDNode *Rdhwr =
- CurDAG->getMachineNode(RdhwrOpc, DL,
- Node->getValueType(0),
- CurDAG->getRegister(Mips::HWR29, MVT::i32));
+ CurDAG->getMachineNode(RdhwrOpc, DL, Node->getValueType(0),
+ CurDAG->getRegister(Mips::HWR29, MVT::i32),
+ CurDAG->getTargetConstant(0, DL, MVT::i32));
SDValue Chain = CurDAG->getCopyToReg(CurDAG->getEntryNode(), DL, DestReg,
SDValue(Rdhwr, 0));
SDValue ResNode = CurDAG->getCopyFromReg(Chain, DL, DestReg, PtrVT);