Skip to content

[TargetLowering] Use Type* instead of EVT in shouldSignExtendTypeInLibCall. #118587

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 4, 2024
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/include/llvm/CodeGen/TargetLowering.h
Original file line number Diff line number Diff line change
Expand Up @@ -2292,7 +2292,7 @@ class TargetLoweringBase {
virtual void emitAtomicCmpXchgNoStoreLLBalance(IRBuilderBase &Builder) const {}

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

Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2104,7 +2104,7 @@ std::pair<SDValue, SDValue> SelectionDAGLegalize::ExpandLibCall(RTLIB::Libcall L
InChain = TCChain;

TargetLowering::CallLoweringInfo CLI(DAG);
bool signExtend = TLI.shouldSignExtendTypeInLibCall(RetVT, isSigned);
bool signExtend = TLI.shouldSignExtendTypeInLibCall(RetTy, isSigned);
CLI.setDebugLoc(SDLoc(Node))
.setChain(InChain)
.setLibCallee(TLI.getLibcallCallingConv(LC), RetTy, Callee,
Expand Down Expand Up @@ -2135,7 +2135,7 @@ std::pair<SDValue, SDValue> SelectionDAGLegalize::ExpandLibCall(RTLIB::Libcall L
Type *ArgTy = ArgVT.getTypeForEVT(*DAG.getContext());
Entry.Node = Op;
Entry.Ty = ArgTy;
Entry.IsSExt = TLI.shouldSignExtendTypeInLibCall(ArgVT, isSigned);
Entry.IsSExt = TLI.shouldSignExtendTypeInLibCall(ArgTy, isSigned);
Entry.IsZExt = !Entry.IsSExt;
Args.push_back(Entry);
}
Expand Down
6 changes: 3 additions & 3 deletions llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,8 @@ TargetLowering::makeLibCall(SelectionDAG &DAG, RTLIB::Libcall LC, EVT RetVT,
SDValue NewOp = Ops[i];
Entry.Node = NewOp;
Entry.Ty = Entry.Node.getValueType().getTypeForEVT(*DAG.getContext());
Entry.IsSExt = shouldSignExtendTypeInLibCall(NewOp.getValueType(),
CallOptions.IsSigned);
Entry.IsSExt =
shouldSignExtendTypeInLibCall(Entry.Ty, CallOptions.IsSigned);
Entry.IsZExt = !Entry.IsSExt;

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

Type *RetTy = RetVT.getTypeForEVT(*DAG.getContext());
TargetLowering::CallLoweringInfo CLI(DAG);
bool signExtend = shouldSignExtendTypeInLibCall(RetVT, CallOptions.IsSigned);
bool signExtend = shouldSignExtendTypeInLibCall(RetTy, CallOptions.IsSigned);
bool zeroExtend = !signExtend;

if (CallOptions.IsSoften &&
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/Target/LoongArch/LoongArchISelLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6404,8 +6404,8 @@ ISD::NodeType LoongArchTargetLowering::getExtendForAtomicCmpSwapArg() const {
}

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

return IsSigned;
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Target/LoongArch/LoongArchISelLowering.h
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ class LoongArchTargetLowering : public TargetLowering {
return false;
}
bool shouldConsiderGEPOffsetSplit() const override { return true; }
bool shouldSignExtendTypeInLibCall(EVT Type, bool IsSigned) const override;
bool shouldSignExtendTypeInLibCall(Type *Ty, bool IsSigned) const override;
bool shouldExtendTypeInLibCall(EVT Type) const override;

bool shouldAlignPointerArgs(CallInst *CI, unsigned &MinSize,
Expand Down
6 changes: 3 additions & 3 deletions llvm/lib/Target/Mips/MipsISelLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3871,10 +3871,10 @@ MipsTargetLowering::CanLowerReturn(CallingConv::ID CallConv,
return CCInfo.CheckReturn(Outs, RetCC_Mips);
}

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

return IsSigned;
}
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Target/Mips/MipsISelLowering.h
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,7 @@ class TargetRegisterClass;
SDValue LowerInterruptReturn(SmallVectorImpl<SDValue> &RetOps,
const SDLoc &DL, SelectionDAG &DAG) const;

bool shouldSignExtendTypeInLibCall(EVT Type, bool IsSigned) const override;
bool shouldSignExtendTypeInLibCall(Type *Ty, bool IsSigned) const override;

// Inline asm support
ConstraintType getConstraintType(StringRef Constraint) const override;
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/Target/PowerPC/PPCISelLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18828,15 +18828,15 @@ SDValue PPCTargetLowering::lowerToLibCall(const char *LibCallName, SDValue Op,
Type *RetTy = RetVT.getTypeForEVT(*DAG.getContext());
SDValue Callee =
DAG.getExternalSymbol(LibCallName, TLI.getPointerTy(DAG.getDataLayout()));
bool SignExtend = TLI.shouldSignExtendTypeInLibCall(RetVT, false);
bool SignExtend = TLI.shouldSignExtendTypeInLibCall(RetTy, false);
TargetLowering::ArgListTy Args;
TargetLowering::ArgListEntry Entry;
for (const SDValue &N : Op->op_values()) {
EVT ArgVT = N.getValueType();
Type *ArgTy = ArgVT.getTypeForEVT(*DAG.getContext());
Entry.Node = N;
Entry.Ty = ArgTy;
Entry.IsSExt = TLI.shouldSignExtendTypeInLibCall(ArgVT, SignExtend);
Entry.IsSExt = TLI.shouldSignExtendTypeInLibCall(ArgTy, SignExtend);
Entry.IsZExt = !Entry.IsSExt;
Args.push_back(Entry);
}
Expand Down
5 changes: 3 additions & 2 deletions llvm/lib/Target/RISCV/RISCVISelLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21285,8 +21285,9 @@ bool RISCVTargetLowering::shouldExtendTypeInLibCall(EVT Type) const {
return true;
}

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

return IsSigned;
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Target/RISCV/RISCVISelLowering.h
Original file line number Diff line number Diff line change
Expand Up @@ -746,7 +746,7 @@ class RISCVTargetLowering : public TargetLowering {
getExceptionSelectorRegister(const Constant *PersonalityFn) const override;

bool shouldExtendTypeInLibCall(EVT Type) const override;
bool shouldSignExtendTypeInLibCall(EVT Type, bool IsSigned) const override;
bool shouldSignExtendTypeInLibCall(Type *Ty, bool IsSigned) const override;

/// Returns the register with the specified architectural or ABI name. This
/// method is necessary to lower the llvm.read_register.* and
Expand Down
6 changes: 3 additions & 3 deletions llvm/lib/Target/SystemZ/SystemZISelLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2147,8 +2147,8 @@ std::pair<SDValue, SDValue> SystemZTargetLowering::makeExternalCall(
for (SDValue Op : Ops) {
Entry.Node = Op;
Entry.Ty = Entry.Node.getValueType().getTypeForEVT(*DAG.getContext());
Entry.IsSExt = shouldSignExtendTypeInLibCall(Op.getValueType(), IsSigned);
Entry.IsZExt = !shouldSignExtendTypeInLibCall(Op.getValueType(), IsSigned);
Entry.IsSExt = shouldSignExtendTypeInLibCall(Entry.Ty, IsSigned);
Entry.IsZExt = !Entry.IsSExt;
Args.push_back(Entry);
}

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

Type *RetTy = RetVT.getTypeForEVT(*DAG.getContext());
TargetLowering::CallLoweringInfo CLI(DAG);
bool SignExtend = shouldSignExtendTypeInLibCall(RetVT, IsSigned);
bool SignExtend = shouldSignExtendTypeInLibCall(RetTy, IsSigned);
CLI.setDebugLoc(DL)
.setChain(Chain)
.setCallee(CallConv, RetTy, Callee, std::move(Args))
Expand Down
Loading