mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-12-13 19:24:21 +00:00
[SelectionDAG][RISCV][PowerPC][X86] Use TargetConstant for immediates for ISD::PREFETCH. (#66601)
The intrinsic uses ImmArg so TargetConstant would be consistent with how other intrinsics are handled. This hides the constants from type legalization so we can remove the promotion support. isel patterns are updated accordingly.
This commit is contained in:
parent
39f1860dcc
commit
f71a9e8bb7
@ -1818,8 +1818,6 @@ bool DAGTypeLegalizer::PromoteIntegerOperand(SDNode *N, unsigned OpNo) {
|
||||
case ISD::FRAMEADDR:
|
||||
case ISD::RETURNADDR: Res = PromoteIntOp_FRAMERETURNADDR(N); break;
|
||||
|
||||
case ISD::PREFETCH: Res = PromoteIntOp_PREFETCH(N, OpNo); break;
|
||||
|
||||
case ISD::SMULFIX:
|
||||
case ISD::SMULFIXSAT:
|
||||
case ISD::UMULFIX:
|
||||
@ -2333,18 +2331,6 @@ SDValue DAGTypeLegalizer::PromoteIntOp_FRAMERETURNADDR(SDNode *N) {
|
||||
return SDValue(DAG.UpdateNodeOperands(N, Op), 0);
|
||||
}
|
||||
|
||||
SDValue DAGTypeLegalizer::PromoteIntOp_PREFETCH(SDNode *N, unsigned OpNo) {
|
||||
assert(OpNo > 1 && "Don't know how to promote this operand!");
|
||||
// Promote the rw, locality, and cache type arguments to a supported integer
|
||||
// width.
|
||||
SDValue Op2 = ZExtPromotedInteger(N->getOperand(2));
|
||||
SDValue Op3 = ZExtPromotedInteger(N->getOperand(3));
|
||||
SDValue Op4 = ZExtPromotedInteger(N->getOperand(4));
|
||||
return SDValue(DAG.UpdateNodeOperands(N, N->getOperand(0), N->getOperand(1),
|
||||
Op2, Op3, Op4),
|
||||
0);
|
||||
}
|
||||
|
||||
SDValue DAGTypeLegalizer::PromoteIntOp_ExpOp(SDNode *N) {
|
||||
bool IsStrict = N->isStrictFPOpcode();
|
||||
SDValue Chain = IsStrict ? N->getOperand(0) : SDValue();
|
||||
|
@ -401,7 +401,6 @@ private:
|
||||
SDValue PromoteIntOp_MGATHER(MaskedGatherSDNode *N, unsigned OpNo);
|
||||
SDValue PromoteIntOp_ADDSUBO_CARRY(SDNode *N, unsigned OpNo);
|
||||
SDValue PromoteIntOp_FRAMERETURNADDR(SDNode *N);
|
||||
SDValue PromoteIntOp_PREFETCH(SDNode *N, unsigned OpNo);
|
||||
SDValue PromoteIntOp_FIX(SDNode *N);
|
||||
SDValue PromoteIntOp_ExpOp(SDNode *N);
|
||||
SDValue PromoteIntOp_VECREDUCE(SDNode *N);
|
||||
|
@ -7089,9 +7089,12 @@ void SelectionDAGBuilder::visitIntrinsicCall(const CallInst &I,
|
||||
auto Flags = rw == 0 ? MachineMemOperand::MOLoad :MachineMemOperand::MOStore;
|
||||
Ops[0] = DAG.getRoot();
|
||||
Ops[1] = getValue(I.getArgOperand(0));
|
||||
Ops[2] = getValue(I.getArgOperand(1));
|
||||
Ops[3] = getValue(I.getArgOperand(2));
|
||||
Ops[4] = getValue(I.getArgOperand(3));
|
||||
Ops[2] = DAG.getTargetConstant(*cast<ConstantInt>(I.getArgOperand(1)), sdl,
|
||||
MVT::i32);
|
||||
Ops[3] = DAG.getTargetConstant(*cast<ConstantInt>(I.getArgOperand(2)), sdl,
|
||||
MVT::i32);
|
||||
Ops[4] = DAG.getTargetConstant(*cast<ConstantInt>(I.getArgOperand(3)), sdl,
|
||||
MVT::i32);
|
||||
SDValue Result = DAG.getMemIntrinsicNode(
|
||||
ISD::PREFETCH, sdl, DAG.getVTList(MVT::Other), Ops,
|
||||
EVT::getIntegerVT(*Context, 8), MachinePointerInfo(I.getArgOperand(0)),
|
||||
|
@ -1713,11 +1713,11 @@ def : Pat<(int_ppc_dcbf xoaddr:$dst),
|
||||
def : Pat<(int_ppc_icbt xoaddr:$dst),
|
||||
(ICBT 0, xoaddr:$dst)>;
|
||||
|
||||
def : Pat<(prefetch xoaddr:$dst, (i32 0), imm, (i32 1)),
|
||||
def : Pat<(prefetch xoaddr:$dst, (i32 0), timm, (i32 1)),
|
||||
(DCBT 0, xoaddr:$dst)>; // data prefetch for loads
|
||||
def : Pat<(prefetch xoaddr:$dst, (i32 1), imm, (i32 1)),
|
||||
def : Pat<(prefetch xoaddr:$dst, (i32 1), timm, (i32 1)),
|
||||
(DCBTST 0, xoaddr:$dst)>; // data prefetch for stores
|
||||
def : Pat<(prefetch xoaddr:$dst, (i32 0), imm, (i32 0)),
|
||||
def : Pat<(prefetch xoaddr:$dst, (i32 0), timm, (i32 0)),
|
||||
(ICBT 0, xoaddr:$dst)>, Requires<[HasICBT]>; // inst prefetch (for read)
|
||||
|
||||
def : Pat<(int_ppc_dcbt_with_hint xoaddr:$dst, i32:$TH),
|
||||
|
@ -76,10 +76,10 @@ def PREFETCH_W : Prefetch_ri<0b00011, "prefetch.w">, Sched<[]>;
|
||||
|
||||
let Predicates = [HasStdExtZicbop] in {
|
||||
// FIXME: Match address with offset
|
||||
def : Pat<(prefetch GPR:$rs1, imm, imm, (XLenVT 0)),
|
||||
def : Pat<(prefetch GPR:$rs1, timm, timm, (i32 0)),
|
||||
(PREFETCH_I GPR:$rs1, 0)>;
|
||||
def : Pat<(prefetch GPR:$rs1, (XLenVT 0), imm, (XLenVT 1)),
|
||||
def : Pat<(prefetch GPR:$rs1, (i32 0), timm, (i32 1)),
|
||||
(PREFETCH_R GPR:$rs1, 0)>;
|
||||
def : Pat<(prefetch GPR:$rs1, (XLenVT 1), imm, (XLenVT 1)),
|
||||
def : Pat<(prefetch GPR:$rs1, (i32 1), timm, (i32 1)),
|
||||
(PREFETCH_W GPR:$rs1, 0)>;
|
||||
}
|
||||
|
@ -80,12 +80,12 @@ def FEMMS : I3DNow<0x0E, RawFrm, (outs), (ins), "femms",
|
||||
[(int_x86_mmx_femms)]>, TB;
|
||||
|
||||
// PREFETCHWT1 is supported we want to use it for everything but T0.
|
||||
def PrefetchWLevel : PatFrag<(ops), (i32 imm), [{
|
||||
def PrefetchWLevel : PatFrag<(ops), (i32 timm), [{
|
||||
return N->getSExtValue() == 3 || !Subtarget->hasPREFETCHWT1();
|
||||
}]>;
|
||||
|
||||
// Use PREFETCHWT1 for NTA, T2, T1.
|
||||
def PrefetchWT1Level : ImmLeaf<i32, [{
|
||||
def PrefetchWT1Level : TImmLeaf<i32, [{
|
||||
return Imm < 3;
|
||||
}]>;
|
||||
|
||||
@ -93,7 +93,7 @@ let SchedRW = [WriteLoad] in {
|
||||
let Predicates = [Has3DNow, NoSSEPrefetch] in
|
||||
def PREFETCH : I3DNow<0x0D, MRM0m, (outs), (ins i8mem:$addr),
|
||||
"prefetch\t$addr",
|
||||
[(prefetch addr:$addr, imm, imm, (i32 1))]>, TB;
|
||||
[(prefetch addr:$addr, timm, timm, (i32 1))]>, TB;
|
||||
|
||||
def PREFETCHW : I<0x0D, MRM1m, (outs), (ins i8mem:$addr), "prefetchw\t$addr",
|
||||
[(prefetch addr:$addr, (i32 1), (i32 PrefetchWLevel), (i32 1))]>,
|
||||
|
@ -3212,13 +3212,13 @@ let Predicates = [UseSSE2] in {
|
||||
// Prefetch intrinsic.
|
||||
let Predicates = [HasSSEPrefetch], SchedRW = [WriteLoad] in {
|
||||
def PREFETCHT0 : I<0x18, MRM1m, (outs), (ins i8mem:$src),
|
||||
"prefetcht0\t$src", [(prefetch addr:$src, imm, (i32 3), (i32 1))]>, TB;
|
||||
"prefetcht0\t$src", [(prefetch addr:$src, timm, (i32 3), (i32 1))]>, TB;
|
||||
def PREFETCHT1 : I<0x18, MRM2m, (outs), (ins i8mem:$src),
|
||||
"prefetcht1\t$src", [(prefetch addr:$src, imm, (i32 2), (i32 1))]>, TB;
|
||||
"prefetcht1\t$src", [(prefetch addr:$src, timm, (i32 2), (i32 1))]>, TB;
|
||||
def PREFETCHT2 : I<0x18, MRM3m, (outs), (ins i8mem:$src),
|
||||
"prefetcht2\t$src", [(prefetch addr:$src, imm, (i32 1), (i32 1))]>, TB;
|
||||
"prefetcht2\t$src", [(prefetch addr:$src, timm, (i32 1), (i32 1))]>, TB;
|
||||
def PREFETCHNTA : I<0x18, MRM0m, (outs), (ins i8mem:$src),
|
||||
"prefetchnta\t$src", [(prefetch addr:$src, imm, (i32 0), (i32 1))]>, TB;
|
||||
"prefetchnta\t$src", [(prefetch addr:$src, timm, (i32 0), (i32 1))]>, TB;
|
||||
}
|
||||
|
||||
// FIXME: How should flush instruction be modeled?
|
||||
|
@ -11,9 +11,9 @@ entry:
|
||||
|
||||
; FIXME: Crashing is not really the correct behavior here, we really should just emit nothing
|
||||
; CHECK: Cannot select: {{0x[0-9,a-f]+|t[0-9]+}}: ch = Prefetch
|
||||
; CHECK: {{0x[0-9,a-f]+|t[0-9]+}}: i32 = Constant<0>
|
||||
; CHECK-NEXT: {{0x[0-9,a-f]+|t[0-9]+}}: i32 = Constant<3>
|
||||
; CHECK-NEXT: {{0x[0-9,a-f]+|t[0-9]+}}: i32 = Constant<0>
|
||||
; CHECK: {{0x[0-9,a-f]+|t[0-9]+}}: i32 = TargetConstant<0>
|
||||
; CHECK-NEXT: {{0x[0-9,a-f]+|t[0-9]+}}: i32 = TargetConstant<3>
|
||||
; CHECK-NEXT: {{0x[0-9,a-f]+|t[0-9]+}}: i32 = TargetConstant<0>
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user