forked from OSchip/llvm-project
[Hexagon] Changing from literal numeric value to argument since #-1 will not parse when '-' is converted to a token.
llvm-svn: 288634
This commit is contained in:
parent
c5882a73a0
commit
8170754919
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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<string mnemonic, bits<3> 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<string mnemonic, bits<3> 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<string mnemonic, string BaseOp, bits<3> 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<string px, string op, bit np, string tnt>
|
||||
: 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;
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -107,6 +107,8 @@ let OperandType = "OPERAND_IMMEDIATE" in {
|
|||
def s3_7Imm : Operand<i32> { let PrintMethod = "prints3_7ImmOperand";
|
||||
let DecoderMethod = "s3_6ImmDecoder";}
|
||||
}
|
||||
def n1ConstOperand : AsmOperandClass { let Name = "n1Const"; }
|
||||
def n1Const : Operand<i32> { let ParserMatchClass = n1ConstOperand; }
|
||||
|
||||
//
|
||||
// Immediate predicates
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
Loading…
Reference in New Issue