Changeset View
Changeset View
Standalone View
Standalone View
llvm/lib/Target/LoongArch/LoongArchInstrInfo.td
Show First 20 Lines • Show All 100 Lines • ▼ Show 20 Lines | def simm14_lsl2 : Operand<GRLenVT> { | ||||
let DecoderMethod = "decodeSImmOperand<14, 2>"; | let DecoderMethod = "decodeSImmOperand<14, 2>"; | ||||
} | } | ||||
def simm16 : Operand<GRLenVT> { | def simm16 : Operand<GRLenVT> { | ||||
let ParserMatchClass = SImmAsmOperand<16>; | let ParserMatchClass = SImmAsmOperand<16>; | ||||
let DecoderMethod = "decodeSImmOperand<16>"; | let DecoderMethod = "decodeSImmOperand<16>"; | ||||
} | } | ||||
def simm16_lsl2 : Operand<GRLenVT> { | def simm16_lsl2 : Operand<GRLenVT>, | ||||
ImmLeaf<GRLenVT, [{return isInt<16>(Imm>>2);}]> { | |||||
let ParserMatchClass = SImmAsmOperand<16, "lsl2">; | |||||
let EncoderMethod = "getImmOpValueAsr2"; | |||||
let DecoderMethod = "decodeSImmOperand<16, 2>"; | |||||
} | |||||
def simm16_lsl2_br : Operand<OtherVT> { | |||||
let ParserMatchClass = SImmAsmOperand<16, "lsl2">; | let ParserMatchClass = SImmAsmOperand<16, "lsl2">; | ||||
let EncoderMethod = "getImmOpValueAsr2"; | let EncoderMethod = "getImmOpValueAsr2"; | ||||
let DecoderMethod = "decodeSImmOperand<16, 2>"; | let DecoderMethod = "decodeSImmOperand<16, 2>"; | ||||
} | } | ||||
def simm20 : Operand<GRLenVT> { | def simm20 : Operand<GRLenVT> { | ||||
let ParserMatchClass = SImmAsmOperand<20>; | let ParserMatchClass = SImmAsmOperand<20>; | ||||
let DecoderMethod = "decodeSImmOperand<20>"; | let DecoderMethod = "decodeSImmOperand<20>"; | ||||
} | } | ||||
def simm21_lsl2 : Operand<GRLenVT> { | def simm21_lsl2 : Operand<OtherVT> { | ||||
let ParserMatchClass = SImmAsmOperand<21, "lsl2">; | let ParserMatchClass = SImmAsmOperand<21, "lsl2">; | ||||
let EncoderMethod = "getImmOpValueAsr2"; | let EncoderMethod = "getImmOpValueAsr2"; | ||||
let DecoderMethod = "decodeSImmOperand<21, 2>"; | let DecoderMethod = "decodeSImmOperand<21, 2>"; | ||||
} | } | ||||
def simm26_lsl2 : Operand<GRLenVT> { | def simm26_lsl2 : Operand<OtherVT> { | ||||
let ParserMatchClass = SImmAsmOperand<26, "lsl2">; | let ParserMatchClass = SImmAsmOperand<26, "lsl2">; | ||||
let EncoderMethod = "getImmOpValueAsr2"; | let EncoderMethod = "getImmOpValueAsr2"; | ||||
let DecoderMethod = "decodeSImmOperand<26, 2>"; | let DecoderMethod = "decodeSImmOperand<26, 2>"; | ||||
} | } | ||||
// Standalone (codegen-only) immleaf patterns. | // Standalone (codegen-only) immleaf patterns. | ||||
// A 12-bit signed immediate plus one where the imm range will be [-2047, 2048]. | // A 12-bit signed immediate plus one where the imm range will be [-2047, 2048]. | ||||
▲ Show 20 Lines • Show All 45 Lines • ▼ Show 20 Lines | |||||
class MISC_I15<bits<17> op, string opstr> | class MISC_I15<bits<17> op, string opstr> | ||||
: FmtI15<op, (outs), (ins uimm15:$imm15), opstr, "$imm15">; | : FmtI15<op, (outs), (ins uimm15:$imm15), opstr, "$imm15">; | ||||
class RDTIME_2R<bits<22> op, string opstr> | class RDTIME_2R<bits<22> op, string opstr> | ||||
: Fmt2R<op, (outs GPR:$rd, GPR:$rj), (ins), opstr, "$rd, $rj">; | : Fmt2R<op, (outs GPR:$rd, GPR:$rj), (ins), opstr, "$rd, $rj">; | ||||
class BrCC_2RI16<bits<6> op, string opstr> | class BrCC_2RI16<bits<6> op, string opstr> | ||||
: Fmt2RI16<op, (outs), (ins GPR:$rj, GPR:$rd, simm16_lsl2:$imm16), opstr, | : Fmt2RI16<op, (outs), (ins GPR:$rj, GPR:$rd, simm16_lsl2_br:$imm16), opstr, | ||||
xen0n: Could you explain a bit on why this is needed? I can't easily understand this as the only… | |||||
Sorry, I also do not understand. wangleiat: Sorry, I also do not understand.
I had to change simm26ls12, simm21ls12 and simm16lsl12_br to… | |||||
"$rj, $rd, $imm16"> { | "$rj, $rd, $imm16"> { | ||||
let isBranch = 1; | let isBranch = 1; | ||||
let isTerminator = 1; | let isTerminator = 1; | ||||
} | } | ||||
class BrCCZ_1RI21<bits<6> op, string opstr> | class BrCCZ_1RI21<bits<6> op, string opstr> | ||||
: Fmt1RI21<op, (outs), (ins GPR:$rj, simm21_lsl2:$imm21), opstr, | : Fmt1RI21<op, (outs), (ins GPR:$rj, simm21_lsl2:$imm21), opstr, | ||||
"$rj, $imm21"> { | "$rj, $imm21"> { | ||||
let isBranch = 1; | let isBranch = 1; | ||||
▲ Show 20 Lines • Show All 447 Lines • ▼ Show 20 Lines | |||||
/// Select | /// Select | ||||
def : Pat<(select GPR:$cond, GPR:$t, GPR:$f), | def : Pat<(select GPR:$cond, GPR:$t, GPR:$f), | ||||
(OR (MASKEQZ GPR:$t, GPR:$cond), (MASKNEZ GPR:$f, GPR:$cond))>; | (OR (MASKEQZ GPR:$t, GPR:$cond), (MASKNEZ GPR:$f, GPR:$cond))>; | ||||
/// Branches and jumps | /// Branches and jumps | ||||
class BccPat<PatFrag CondOp, LAInst Inst> | |||||
: Pat<(brcond (GRLenVT (CondOp GPR:$rj, GPR:$rd)), bb:$imm16), | |||||
(Inst GPR:$rj, GPR:$rd, bb:$imm16)>; | |||||
def : BccPat<seteq, BEQ>; | |||||
def : BccPat<setne, BNE>; | |||||
def : BccPat<setlt, BLT>; | |||||
def : BccPat<setge, BGE>; | |||||
def : BccPat<setult, BLTU>; | |||||
def : BccPat<setuge, BGEU>; | |||||
class BccSwapPat<PatFrag CondOp, LAInst InstBcc> | |||||
: Pat<(brcond (GRLenVT (CondOp GPR:$rd, GPR:$rj)), bb:$imm16), | |||||
(InstBcc GPR:$rj, GPR:$rd, bb:$imm16)>; | |||||
// Condition codes that don't have matching LoongArch branch instructions, but | |||||
// are trivially supported by swapping the two input operands. | |||||
def : BccSwapPat<setgt, BLT>; | |||||
def : BccSwapPat<setle, BGE>; | |||||
def : BccSwapPat<setugt, BLTU>; | |||||
def : BccSwapPat<setule, BGEU>; | |||||
// An extra pattern is needed for a brcond without a setcc (i.e. where the | |||||
// condition was calculated elsewhere). | |||||
def : Pat<(brcond GPR:$rj, bb:$imm21), (BNEZ GPR:$rj, bb:$imm21)>; | |||||
let isBarrier = 1, isBranch = 1, isTerminator = 1 in | |||||
def PseudoBR : Pseudo<(outs), (ins simm26_lsl2:$imm26), [(br bb:$imm26)]>, | |||||
PseudoInstExpansion<(B simm26_lsl2:$imm26)>; | |||||
let isBarrier = 1, isBranch = 1, isIndirectBranch = 1, isTerminator = 1 in | |||||
def PseudoBRIND : Pseudo<(outs), (ins GPR:$rj, simm16_lsl2:$imm16), []>, | |||||
PseudoInstExpansion<(JIRL R0, GPR:$rj, simm16_lsl2:$imm16)>; | |||||
def : Pat<(brind GPR:$rj), (PseudoBRIND GPR:$rj, 0)>; | |||||
def : Pat<(brind (add GPR:$rj, simm16_lsl2:$imm16)), | |||||
(PseudoBRIND GPR:$rj, simm16_lsl2:$imm16)>; | |||||
let isBarrier = 1, isReturn = 1, isTerminator = 1 in | let isBarrier = 1, isReturn = 1, isTerminator = 1 in | ||||
def PseudoRET : Pseudo<(outs), (ins), [(loongarch_ret)]>, | def PseudoRET : Pseudo<(outs), (ins), [(loongarch_ret)]>, | ||||
PseudoInstExpansion<(JIRL R0, R1, 0)>; | PseudoInstExpansion<(JIRL R0, R1, 0)>; | ||||
/// BSTRPICK | /// BSTRPICK | ||||
let Predicates = [IsLA32] in | let Predicates = [IsLA32] in | ||||
def : Pat<(loongarch_bstrpick GPR:$rj, uimm5:$msbd, uimm5:$lsbd), | def : Pat<(loongarch_bstrpick GPR:$rj, uimm5:$msbd, uimm5:$lsbd), | ||||
▲ Show 20 Lines • Show All 111 Lines • Show Last 20 Lines |
Could you explain a bit on why this is needed? I can't easily understand this as the only change is on the "guard" of said definition but the dropped check seems too important to ignore. (Maybe because I haven't looked at LLVM source code as hard as you did.)