Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3677,7 +3677,7 @@ bool MipsAsmParser::expandBranchImm(MCInst &Inst, SMLoc IDLoc, MCStreamer &Out,
Out, STI))
return true;

if (IsLikely) {
if (IsLikely && MemOffsetOp.isExpr()) {
TOut.emitRRX(OpCode, DstRegOp.getReg(), ATReg,
MCOperand::createExpr(MemOffsetOp.getExpr()), IDLoc, STI);
TOut.emitRRI(Mips::SLL, Mips::ZERO, Mips::ZERO, 0, IDLoc, STI);
Expand Down
16 changes: 13 additions & 3 deletions llvm/lib/Target/Mips/MipsInstrInfo.td
Original file line number Diff line number Diff line change
Expand Up @@ -857,6 +857,16 @@ def calltarget : Operand<iPTR> {

def imm64: Operand<i64>;

def ConstantImmAsmOperandClass : AsmOperandClass {
let Name = "ConstantImm";
let PredicateMethod = "isConstantImm";
let RenderMethod = "addImmOperands";
}

def ConstantImm64: Operand<i64> {
let ParserMatchClass = ConstantImmAsmOperandClass;
}

def simm19_lsl2 : Operand<i32> {
let EncoderMethod = "getSimm19Lsl2Encoding";
let DecoderMethod = "DecodeSimm19Lsl2";
Expand Down Expand Up @@ -2949,10 +2959,10 @@ def : MipsInstAlias<"nor\t$rs, $imm", (NORImm GPR32Opnd:$rs, GPR32Opnd:$rs,

let hasDelaySlot = 1, isCTI = 1 in {
def BneImm : MipsAsmPseudoInst<(outs GPR32Opnd:$rt),
(ins imm64:$imm64, brtarget:$offset),
(ins ConstantImm64:$imm64, brtarget:$offset),
"bne\t$rt, $imm64, $offset">;
def BeqImm : MipsAsmPseudoInst<(outs GPR32Opnd:$rt),
(ins imm64:$imm64, brtarget:$offset),
(ins ConstantImm64:$imm64, brtarget:$offset),
"beq\t$rt, $imm64, $offset">;

class CondBranchPseudo<string instr_asm> :
Expand Down Expand Up @@ -2980,7 +2990,7 @@ def BGTUL: CondBranchPseudo<"bgtul">, ISA_MIPS2_NOT_32R6_64R6;

let isCTI = 1 in
class CondBranchImmPseudo<string instr_asm> :
MipsAsmPseudoInst<(outs), (ins GPR32Opnd:$rs, imm64:$imm, brtarget:$offset),
MipsAsmPseudoInst<(outs), (ins GPR32Opnd:$rs, ConstantImm64:$imm, brtarget:$offset),
!strconcat(instr_asm, "\t$rs, $imm, $offset")>;

def BEQLImmMacro : CondBranchImmPseudo<"beql">, ISA_MIPS2_NOT_32R6_64R6;
Expand Down
8 changes: 8 additions & 0 deletions llvm/test/MC/Mips/branch-pseudos-bad.s
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# RUN: not llvm-mc %s -triple=mips -mcpu=mips32 2>&1 | FileCheck %s

# CHECK: error: invalid operand for instruction
beql $t0, ($t0), 1
# CHECK: error: invalid operand for instruction
bne $t0, ($t0), 1
# CHECK: error: invalid operand for instruction
beq $t0, ($t0), 1


# Check for errors when using conditional branch pseudos after .set noat.
.set noat
local_label:
Expand Down