[llvm] [TargetLowering] Use Type* instead of EVT in shouldSignExtendTypeInLi… (PR #118587)
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 3 19:45:36 PST 2024
https://github.com/topperc created https://github.com/llvm/llvm-project/pull/118587
…bCall.
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 * for other reasons anyway.
>From dd31e5c7df2b3faebdfe5013abec240c472e4855 Mon Sep 17 00:00:00 2001
From: Craig Topper <craig.topper at sifive.com>
Date: Tue, 3 Dec 2024 19:43:07 -0800
Subject: [PATCH] [TargetLowering] Use Type* instead of EVT in
shouldSignExtendTypeInLibCall.
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 *
for other reasons anyway.
---
llvm/include/llvm/CodeGen/TargetLowering.h | 2 +-
llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp | 4 ++--
llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp | 6 +++---
llvm/lib/Target/LoongArch/LoongArchISelLowering.cpp | 4 ++--
llvm/lib/Target/LoongArch/LoongArchISelLowering.h | 2 +-
llvm/lib/Target/Mips/MipsISelLowering.cpp | 6 +++---
llvm/lib/Target/Mips/MipsISelLowering.h | 2 +-
llvm/lib/Target/PowerPC/PPCISelLowering.cpp | 4 ++--
llvm/lib/Target/RISCV/RISCVISelLowering.cpp | 5 +++--
llvm/lib/Target/RISCV/RISCVISelLowering.h | 2 +-
llvm/lib/Target/SystemZ/SystemZISelLowering.cpp | 6 +++---
11 files changed, 22 insertions(+), 21 deletions(-)
diff --git a/llvm/include/llvm/CodeGen/TargetLowering.h b/llvm/include/llvm/CodeGen/TargetLowering.h
index e9c02806385806..a207f3886bd0e8 100644
--- a/llvm/include/llvm/CodeGen/TargetLowering.h
+++ b/llvm/include/llvm/CodeGen/TargetLowering.h
@@ -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;
}
diff --git a/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
index 2b595b26c9c1c5..ca87168929f964 100644
--- a/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
@@ -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,
@@ -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);
}
diff --git a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
index 5d9e8b35e24ef5..68fbd36cf6e621 100644
--- a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
@@ -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 &&
@@ -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 &&
diff --git a/llvm/lib/Target/LoongArch/LoongArchISelLowering.cpp b/llvm/lib/Target/LoongArch/LoongArchISelLowering.cpp
index 16bceacfaa222c..5a21ac7ebba0d6 100644
--- a/llvm/lib/Target/LoongArch/LoongArchISelLowering.cpp
+++ b/llvm/lib/Target/LoongArch/LoongArchISelLowering.cpp
@@ -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;
diff --git a/llvm/lib/Target/LoongArch/LoongArchISelLowering.h b/llvm/lib/Target/LoongArch/LoongArchISelLowering.h
index 605093b01476d0..e6de0dc4e361a2 100644
--- a/llvm/lib/Target/LoongArch/LoongArchISelLowering.h
+++ b/llvm/lib/Target/LoongArch/LoongArchISelLowering.h
@@ -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,
diff --git a/llvm/lib/Target/Mips/MipsISelLowering.cpp b/llvm/lib/Target/Mips/MipsISelLowering.cpp
index d90348153fd3e1..036b59c57d5b05 100644
--- a/llvm/lib/Target/Mips/MipsISelLowering.cpp
+++ b/llvm/lib/Target/Mips/MipsISelLowering.cpp
@@ -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;
}
diff --git a/llvm/lib/Target/Mips/MipsISelLowering.h b/llvm/lib/Target/Mips/MipsISelLowering.h
index 8033898091c756..e245c056de6491 100644
--- a/llvm/lib/Target/Mips/MipsISelLowering.h
+++ b/llvm/lib/Target/Mips/MipsISelLowering.h
@@ -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;
diff --git a/llvm/lib/Target/PowerPC/PPCISelLowering.cpp b/llvm/lib/Target/PowerPC/PPCISelLowering.cpp
index e917ef3f5e8c9a..564fa29bce7d22 100644
--- a/llvm/lib/Target/PowerPC/PPCISelLowering.cpp
+++ b/llvm/lib/Target/PowerPC/PPCISelLowering.cpp
@@ -18828,7 +18828,7 @@ 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()) {
@@ -18836,7 +18836,7 @@ SDValue PPCTargetLowering::lowerToLibCall(const char *LibCallName, SDValue Op,
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);
}
diff --git a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
index 4544a922def1a3..641433688bbab4 100644
--- a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
+++ b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
@@ -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;
diff --git a/llvm/lib/Target/RISCV/RISCVISelLowering.h b/llvm/lib/Target/RISCV/RISCVISelLowering.h
index c753469562ebac..bb0d9a71abf7e6 100644
--- a/llvm/lib/Target/RISCV/RISCVISelLowering.h
+++ b/llvm/lib/Target/RISCV/RISCVISelLowering.h
@@ -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
diff --git a/llvm/lib/Target/SystemZ/SystemZISelLowering.cpp b/llvm/lib/Target/SystemZ/SystemZISelLowering.cpp
index 8f505b7e198cfa..975a0f5050d166 100644
--- a/llvm/lib/Target/SystemZ/SystemZISelLowering.cpp
+++ b/llvm/lib/Target/SystemZ/SystemZISelLowering.cpp
@@ -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);
}
@@ -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))
More information about the llvm-commits
mailing list