Skip to content

Commit b076fbb

Browse files
authored
[TargetLowering] Use Type* instead of EVT in shouldSignExtendTypeInLibCall. (#118587)
I want to use this function for GISel too so Type * is a better common interface. All of the callers already convert EVT to Type * as needed by calling lowering anyway.
1 parent 5e7c88b commit b076fbb

11 files changed

+22
-21
lines changed

llvm/include/llvm/CodeGen/TargetLowering.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -2292,7 +2292,7 @@ class TargetLoweringBase {
22922292
virtual void emitAtomicCmpXchgNoStoreLLBalance(IRBuilderBase &Builder) const {}
22932293

22942294
/// Returns true if arguments should be sign-extended in lib calls.
2295-
virtual bool shouldSignExtendTypeInLibCall(EVT Type, bool IsSigned) const {
2295+
virtual bool shouldSignExtendTypeInLibCall(Type *Ty, bool IsSigned) const {
22962296
return IsSigned;
22972297
}
22982298

llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -2104,7 +2104,7 @@ std::pair<SDValue, SDValue> SelectionDAGLegalize::ExpandLibCall(RTLIB::Libcall L
21042104
InChain = TCChain;
21052105

21062106
TargetLowering::CallLoweringInfo CLI(DAG);
2107-
bool signExtend = TLI.shouldSignExtendTypeInLibCall(RetVT, isSigned);
2107+
bool signExtend = TLI.shouldSignExtendTypeInLibCall(RetTy, isSigned);
21082108
CLI.setDebugLoc(SDLoc(Node))
21092109
.setChain(InChain)
21102110
.setLibCallee(TLI.getLibcallCallingConv(LC), RetTy, Callee,
@@ -2135,7 +2135,7 @@ std::pair<SDValue, SDValue> SelectionDAGLegalize::ExpandLibCall(RTLIB::Libcall L
21352135
Type *ArgTy = ArgVT.getTypeForEVT(*DAG.getContext());
21362136
Entry.Node = Op;
21372137
Entry.Ty = ArgTy;
2138-
Entry.IsSExt = TLI.shouldSignExtendTypeInLibCall(ArgVT, isSigned);
2138+
Entry.IsSExt = TLI.shouldSignExtendTypeInLibCall(ArgTy, isSigned);
21392139
Entry.IsZExt = !Entry.IsSExt;
21402140
Args.push_back(Entry);
21412141
}

llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,8 @@ TargetLowering::makeLibCall(SelectionDAG &DAG, RTLIB::Libcall LC, EVT RetVT,
159159
SDValue NewOp = Ops[i];
160160
Entry.Node = NewOp;
161161
Entry.Ty = Entry.Node.getValueType().getTypeForEVT(*DAG.getContext());
162-
Entry.IsSExt = shouldSignExtendTypeInLibCall(NewOp.getValueType(),
163-
CallOptions.IsSigned);
162+
Entry.IsSExt =
163+
shouldSignExtendTypeInLibCall(Entry.Ty, CallOptions.IsSigned);
164164
Entry.IsZExt = !Entry.IsSExt;
165165

166166
if (CallOptions.IsSoften &&
@@ -177,7 +177,7 @@ TargetLowering::makeLibCall(SelectionDAG &DAG, RTLIB::Libcall LC, EVT RetVT,
177177

178178
Type *RetTy = RetVT.getTypeForEVT(*DAG.getContext());
179179
TargetLowering::CallLoweringInfo CLI(DAG);
180-
bool signExtend = shouldSignExtendTypeInLibCall(RetVT, CallOptions.IsSigned);
180+
bool signExtend = shouldSignExtendTypeInLibCall(RetTy, CallOptions.IsSigned);
181181
bool zeroExtend = !signExtend;
182182

183183
if (CallOptions.IsSoften &&

llvm/lib/Target/LoongArch/LoongArchISelLowering.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -6404,8 +6404,8 @@ ISD::NodeType LoongArchTargetLowering::getExtendForAtomicCmpSwapArg() const {
64046404
}
64056405

64066406
bool LoongArchTargetLowering::shouldSignExtendTypeInLibCall(
6407-
EVT Type, bool IsSigned) const {
6408-
if (Subtarget.is64Bit() && Type == MVT::i32)
6407+
Type *Ty, bool IsSigned) const {
6408+
if (Subtarget.is64Bit() && Ty->isIntegerTy(32))
64096409
return true;
64106410

64116411
return IsSigned;

llvm/lib/Target/LoongArch/LoongArchISelLowering.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ class LoongArchTargetLowering : public TargetLowering {
273273
return false;
274274
}
275275
bool shouldConsiderGEPOffsetSplit() const override { return true; }
276-
bool shouldSignExtendTypeInLibCall(EVT Type, bool IsSigned) const override;
276+
bool shouldSignExtendTypeInLibCall(Type *Ty, bool IsSigned) const override;
277277
bool shouldExtendTypeInLibCall(EVT Type) const override;
278278

279279
bool shouldAlignPointerArgs(CallInst *CI, unsigned &MinSize,

llvm/lib/Target/Mips/MipsISelLowering.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -3871,10 +3871,10 @@ MipsTargetLowering::CanLowerReturn(CallingConv::ID CallConv,
38713871
return CCInfo.CheckReturn(Outs, RetCC_Mips);
38723872
}
38733873

3874-
bool MipsTargetLowering::shouldSignExtendTypeInLibCall(EVT Type,
3874+
bool MipsTargetLowering::shouldSignExtendTypeInLibCall(Type *Ty,
38753875
bool IsSigned) const {
3876-
if ((ABI.IsN32() || ABI.IsN64()) && Type == MVT::i32)
3877-
return true;
3876+
if ((ABI.IsN32() || ABI.IsN64()) && Ty->isIntegerTy(32))
3877+
return true;
38783878

38793879
return IsSigned;
38803880
}

llvm/lib/Target/Mips/MipsISelLowering.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,7 @@ class TargetRegisterClass;
623623
SDValue LowerInterruptReturn(SmallVectorImpl<SDValue> &RetOps,
624624
const SDLoc &DL, SelectionDAG &DAG) const;
625625

626-
bool shouldSignExtendTypeInLibCall(EVT Type, bool IsSigned) const override;
626+
bool shouldSignExtendTypeInLibCall(Type *Ty, bool IsSigned) const override;
627627

628628
// Inline asm support
629629
ConstraintType getConstraintType(StringRef Constraint) const override;

llvm/lib/Target/PowerPC/PPCISelLowering.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -18828,15 +18828,15 @@ SDValue PPCTargetLowering::lowerToLibCall(const char *LibCallName, SDValue Op,
1882818828
Type *RetTy = RetVT.getTypeForEVT(*DAG.getContext());
1882918829
SDValue Callee =
1883018830
DAG.getExternalSymbol(LibCallName, TLI.getPointerTy(DAG.getDataLayout()));
18831-
bool SignExtend = TLI.shouldSignExtendTypeInLibCall(RetVT, false);
18831+
bool SignExtend = TLI.shouldSignExtendTypeInLibCall(RetTy, false);
1883218832
TargetLowering::ArgListTy Args;
1883318833
TargetLowering::ArgListEntry Entry;
1883418834
for (const SDValue &N : Op->op_values()) {
1883518835
EVT ArgVT = N.getValueType();
1883618836
Type *ArgTy = ArgVT.getTypeForEVT(*DAG.getContext());
1883718837
Entry.Node = N;
1883818838
Entry.Ty = ArgTy;
18839-
Entry.IsSExt = TLI.shouldSignExtendTypeInLibCall(ArgVT, SignExtend);
18839+
Entry.IsSExt = TLI.shouldSignExtendTypeInLibCall(ArgTy, SignExtend);
1884018840
Entry.IsZExt = !Entry.IsSExt;
1884118841
Args.push_back(Entry);
1884218842
}

llvm/lib/Target/RISCV/RISCVISelLowering.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -21299,8 +21299,9 @@ bool RISCVTargetLowering::shouldExtendTypeInLibCall(EVT Type) const {
2129921299
return true;
2130021300
}
2130121301

21302-
bool RISCVTargetLowering::shouldSignExtendTypeInLibCall(EVT Type, bool IsSigned) const {
21303-
if (Subtarget.is64Bit() && Type == MVT::i32)
21302+
bool RISCVTargetLowering::shouldSignExtendTypeInLibCall(Type *Ty,
21303+
bool IsSigned) const {
21304+
if (Subtarget.is64Bit() && Ty->isIntegerTy(32))
2130421305
return true;
2130521306

2130621307
return IsSigned;

llvm/lib/Target/RISCV/RISCVISelLowering.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -746,7 +746,7 @@ class RISCVTargetLowering : public TargetLowering {
746746
getExceptionSelectorRegister(const Constant *PersonalityFn) const override;
747747

748748
bool shouldExtendTypeInLibCall(EVT Type) const override;
749-
bool shouldSignExtendTypeInLibCall(EVT Type, bool IsSigned) const override;
749+
bool shouldSignExtendTypeInLibCall(Type *Ty, bool IsSigned) const override;
750750

751751
/// Returns the register with the specified architectural or ABI name. This
752752
/// method is necessary to lower the llvm.read_register.* and

llvm/lib/Target/SystemZ/SystemZISelLowering.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -2147,8 +2147,8 @@ std::pair<SDValue, SDValue> SystemZTargetLowering::makeExternalCall(
21472147
for (SDValue Op : Ops) {
21482148
Entry.Node = Op;
21492149
Entry.Ty = Entry.Node.getValueType().getTypeForEVT(*DAG.getContext());
2150-
Entry.IsSExt = shouldSignExtendTypeInLibCall(Op.getValueType(), IsSigned);
2151-
Entry.IsZExt = !shouldSignExtendTypeInLibCall(Op.getValueType(), IsSigned);
2150+
Entry.IsSExt = shouldSignExtendTypeInLibCall(Entry.Ty, IsSigned);
2151+
Entry.IsZExt = !Entry.IsSExt;
21522152
Args.push_back(Entry);
21532153
}
21542154

@@ -2157,7 +2157,7 @@ std::pair<SDValue, SDValue> SystemZTargetLowering::makeExternalCall(
21572157

21582158
Type *RetTy = RetVT.getTypeForEVT(*DAG.getContext());
21592159
TargetLowering::CallLoweringInfo CLI(DAG);
2160-
bool SignExtend = shouldSignExtendTypeInLibCall(RetVT, IsSigned);
2160+
bool SignExtend = shouldSignExtendTypeInLibCall(RetTy, IsSigned);
21612161
CLI.setDebugLoc(DL)
21622162
.setChain(Chain)
21632163
.setCallee(CallConv, RetTy, Callee, std::move(Args))

0 commit comments

Comments
 (0)