From: Colin LeMahieu Date: Mon, 5 Dec 2016 04:29:00 +0000 (+0000) Subject: [Hexagon] Changing from literal numeric value to argument since #-1 will not parse... X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=81707549191eae0aa7b571165ebd030dd82a50f3;p=platform%2Fupstream%2Fllvm.git [Hexagon] Changing from literal numeric value to argument since #-1 will not parse when '-' is converted to a token. llvm-svn: 288634 --- diff --git a/llvm/lib/Target/Hexagon/AsmParser/HexagonAsmParser.cpp b/llvm/lib/Target/Hexagon/AsmParser/HexagonAsmParser.cpp index 50f529e..024a634 100644 --- a/llvm/lib/Target/Hexagon/AsmParser/HexagonAsmParser.cpp +++ b/llvm/lib/Target/Hexagon/AsmParser/HexagonAsmParser.cpp @@ -314,6 +314,14 @@ public: bool ism6_0Imm() const { return CheckImmRange(6, 0, false, false, false); } bool isn8_0Imm() const { return CheckImmRange(8, 0, false, false, false); } + bool isn1Const() const { + if (!isImm()) + return false; + int64_t Value; + if (!getImm()->evaluateAsAbsolute(Value)) + return false; + return Value == -1; + } bool iss16_0Ext() const { return CheckImmRange(16 + 26, 0, true, true, true); } bool iss12_0Ext() const { return CheckImmRange(12 + 26, 0, true, true, true); } @@ -506,6 +514,9 @@ public: void adds11_3ExtOperands(MCInst &Inst, unsigned N) const { addSignedImmOperands(Inst, N); } + void addn1ConstOperands(MCInst &Inst, unsigned N) const { + addImmOperands(Inst, N); + } void addu7_0ExtOperands(MCInst &Inst, unsigned N) const { addImmOperands(Inst, N); diff --git a/llvm/lib/Target/Hexagon/Disassembler/HexagonDisassembler.cpp b/llvm/lib/Target/Hexagon/Disassembler/HexagonDisassembler.cpp index 92c2036..5c3e5df 100644 --- a/llvm/lib/Target/Hexagon/Disassembler/HexagonDisassembler.cpp +++ b/llvm/lib/Target/Hexagon/Disassembler/HexagonDisassembler.cpp @@ -340,6 +340,37 @@ DecodeStatus HexagonDisassembler::getSingleInstruction( } } + switch(MI.getOpcode()) { + case Hexagon::J4_cmpeqn1_f_jumpnv_nt: + case Hexagon::J4_cmpeqn1_f_jumpnv_t: + case Hexagon::J4_cmpeqn1_fp0_jump_nt: + case Hexagon::J4_cmpeqn1_fp0_jump_t: + case Hexagon::J4_cmpeqn1_fp1_jump_nt: + case Hexagon::J4_cmpeqn1_fp1_jump_t: + case Hexagon::J4_cmpeqn1_t_jumpnv_nt: + case Hexagon::J4_cmpeqn1_t_jumpnv_t: + case Hexagon::J4_cmpeqn1_tp0_jump_nt: + case Hexagon::J4_cmpeqn1_tp0_jump_t: + case Hexagon::J4_cmpeqn1_tp1_jump_nt: + case Hexagon::J4_cmpeqn1_tp1_jump_t: + case Hexagon::J4_cmpgtn1_f_jumpnv_nt: + case Hexagon::J4_cmpgtn1_f_jumpnv_t: + case Hexagon::J4_cmpgtn1_fp0_jump_nt: + case Hexagon::J4_cmpgtn1_fp0_jump_t: + case Hexagon::J4_cmpgtn1_fp1_jump_nt: + case Hexagon::J4_cmpgtn1_fp1_jump_t: + case Hexagon::J4_cmpgtn1_t_jumpnv_nt: + case Hexagon::J4_cmpgtn1_t_jumpnv_t: + case Hexagon::J4_cmpgtn1_tp0_jump_nt: + case Hexagon::J4_cmpgtn1_tp0_jump_t: + case Hexagon::J4_cmpgtn1_tp1_jump_nt: + case Hexagon::J4_cmpgtn1_tp1_jump_t: + MI.insert(MI.begin() + 1, MCOperand::createExpr(MCConstantExpr::create(-1, getContext()))); + break; + default: + break; + } + if (HexagonMCInstrInfo::isNewValue(*MCII, MI)) { unsigned OpIndex = HexagonMCInstrInfo::getNewValueOp(*MCII, MI); MCOperand &MCO = MI.getOperand(OpIndex); diff --git a/llvm/lib/Target/Hexagon/HexagonInstrInfoV4.td b/llvm/lib/Target/Hexagon/HexagonInstrInfoV4.td index 7df2987..4ae1892 100644 --- a/llvm/lib/Target/Hexagon/HexagonInstrInfoV4.td +++ b/llvm/lib/Target/Hexagon/HexagonInstrInfoV4.td @@ -1379,12 +1379,14 @@ let isPredicated = 1, isBranch = 1, isNewValue = 1, isTerminator = 1, // with a register and an hardcoded 0/-1 immediate value. //===----------------------------------------------------------------------===// -let isExtendable = 1, opExtendable = 1, isExtentSigned = 1, opExtentBits = 11, +let isExtendable = 1, isExtentSigned = 1, opExtentBits = 11, opExtentAlign = 2 in class NVJ_ConstImm_template majOp, string ImmVal, bit isNegCond, bit isTak> : NVInst_V4<(outs), - (ins IntRegs:$src1, brtarget:$offset), + !if(!eq(ImmVal, "{-1}"), + (ins IntRegs:$src1, n1Const:$n1, brtarget:$offset), + (ins IntRegs:$src1, brtarget:$offset)), "if ("#!if(isNegCond, "!","")#mnemonic #"($src1.new, #" # ImmVal # ")) jump:" #!if(isTak, "t","nt")#" $offset", []> { @@ -1392,6 +1394,7 @@ class NVJ_ConstImm_template majOp, string ImmVal, let isTaken = isTak; let isPredicatedFalse = isNegCond; let isTaken = isTak; + let opExtendable = !if(!eq(ImmVal, "{-1}"), 2, 1); bits<3> src1; bits<11> offset; @@ -1428,8 +1431,8 @@ multiclass NVJ_ConstImm_base majOp, let isPredicated = 1, isBranch = 1, isNewValue = 1, isTerminator=1, Defs = [PC], hasSideEffects = 0 in { defm J4_tstbit0 : NVJ_ConstImm_base<"tstbit", "TSTBIT", 0b011, "0">, PredRel; - defm J4_cmpeqn1 : NVJ_ConstImm_base<"cmp.eq", "CMPEQ", 0b100, "-1">, PredRel; - defm J4_cmpgtn1 : NVJ_ConstImm_base<"cmp.gt", "CMPGT", 0b101, "-1">, PredRel; + defm J4_cmpeqn1 : NVJ_ConstImm_base<"cmp.eq", "CMPEQ", 0b100, "{-1}">, PredRel; + defm J4_cmpgtn1 : NVJ_ConstImm_base<"cmp.gt", "CMPGT", 0b101, "{-1}">, PredRel; } // J4_hintjumpr: Hint indirect conditional jump. @@ -3202,11 +3205,11 @@ defm gtu : T_pnp_CJInst_RU5<"gtu">; let isBranch = 1, hasSideEffects = 0, isExtentSigned = 1, isPredicated = 1, isPredicatedFalse = 1, isPredicatedNew = 1, - isExtendable = 1, opExtentBits = 11, opExtentAlign = 2, opExtendable = 1, + isExtendable = 1, opExtentBits = 11, opExtentAlign = 2, opExtendable = 2, isTerminator = 1 in class CJInst_Rn1 - : InstHexagon<(outs), (ins IntRegs:$Rs, brtarget:$r9_2), - ""#px#" = cmp."#op#"($Rs,#-1); if (" + : InstHexagon<(outs), (ins IntRegs:$Rs, n1Const:$n1, brtarget:$r9_2), + ""#px#" = cmp."#op#"($Rs,#$n1); if (" #!if(np, "!","")#""#px#".new) jump:"#tnt#" $r9_2", [], "", COMPOUND_CJ_ARCHDEPSLOT, TypeCOMPOUND>, OpcodeHexagon { bits<4> Rs; diff --git a/llvm/lib/Target/Hexagon/HexagonNewValueJump.cpp b/llvm/lib/Target/Hexagon/HexagonNewValueJump.cpp index b5e8c84..72d8011 100644 --- a/llvm/lib/Target/Hexagon/HexagonNewValueJump.cpp +++ b/llvm/lib/Target/Hexagon/HexagonNewValueJump.cpp @@ -667,16 +667,6 @@ bool HexagonNewValueJump::runOnMachineFunction(MachineFunction &MF) { .addReg(cmpOp2, getKillRegState(MO2IsKill)) .addMBB(jmpTarget); - else if ((cmpInstr->getOpcode() == Hexagon::C2_cmpeqi || - cmpInstr->getOpcode() == Hexagon::C2_cmpgti) && - cmpOp2 == -1 ) - // Corresponding new-value compare jump instructions don't have the - // operand for -1 immediate value. - NewMI = BuildMI(*MBB, jmpPos, dl, - QII->get(opc)) - .addReg(cmpReg1, getKillRegState(MO1IsKill)) - .addMBB(jmpTarget); - else NewMI = BuildMI(*MBB, jmpPos, dl, QII->get(opc)) diff --git a/llvm/lib/Target/Hexagon/HexagonOperands.td b/llvm/lib/Target/Hexagon/HexagonOperands.td index 80af52c..9833105 100644 --- a/llvm/lib/Target/Hexagon/HexagonOperands.td +++ b/llvm/lib/Target/Hexagon/HexagonOperands.td @@ -107,6 +107,8 @@ let OperandType = "OPERAND_IMMEDIATE" in { def s3_7Imm : Operand { let PrintMethod = "prints3_7ImmOperand"; let DecoderMethod = "s3_6ImmDecoder";} } +def n1ConstOperand : AsmOperandClass { let Name = "n1Const"; } +def n1Const : Operand { let ParserMatchClass = n1ConstOperand; } // // Immediate predicates diff --git a/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCCompound.cpp b/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCCompound.cpp index d194bea..5feaffe 100644 --- a/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCCompound.cpp +++ b/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCCompound.cpp @@ -290,8 +290,7 @@ MCInst *getCompoundInsn(MCContext &Context, MCInst const &L, MCInst const &R) { CompoundInsn = new (Context) MCInst; CompoundInsn->setOpcode(compoundOpcode); CompoundInsn->addOperand(Rs); - if (Value != -1) - CompoundInsn->addOperand(L.getOperand(2)); + CompoundInsn->addOperand(L.getOperand(2)); CompoundInsn->addOperand(R.getOperand(1)); break; @@ -309,8 +308,7 @@ MCInst *getCompoundInsn(MCContext &Context, MCInst const &L, MCInst const &R) { CompoundInsn = new (Context) MCInst; CompoundInsn->setOpcode(compoundOpcode); CompoundInsn->addOperand(Rs); - if (Value != -1) - CompoundInsn->addOperand(L.getOperand(2)); + CompoundInsn->addOperand(L.getOperand(2)); CompoundInsn->addOperand(R.getOperand(1)); break;