[llvm] [SystemZ] Remove custom CCState pre-analysis (PR #154091)

via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 18 03:58:11 PDT 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-backend-systemz

Author: Nikita Popov (nikic)

<details>
<summary>Changes</summary>

The calling convention lowering now has access to OrigTy, so use that to detect short vectors.

---
Full diff: https://github.com/llvm/llvm-project/pull/154091.diff


3 Files Affected:

- (modified) llvm/lib/Target/SystemZ/SystemZCallingConv.h (-44) 
- (modified) llvm/lib/Target/SystemZ/SystemZCallingConv.td (+1-1) 
- (modified) llvm/lib/Target/SystemZ/SystemZISelLowering.cpp (+2-2) 


``````````diff
diff --git a/llvm/lib/Target/SystemZ/SystemZCallingConv.h b/llvm/lib/Target/SystemZ/SystemZCallingConv.h
index fbb98ffd38734..f5ffbf5c04d60 100644
--- a/llvm/lib/Target/SystemZ/SystemZCallingConv.h
+++ b/llvm/lib/Target/SystemZ/SystemZCallingConv.h
@@ -29,50 +29,6 @@ namespace SystemZ {
   extern const MCPhysReg XPLINK64ArgFPRs[XPLINK64NumArgFPRs];
 } // end namespace SystemZ
 
-class SystemZCCState : public CCState {
-private:
-  /// Records whether the value was widened from a short vector type.
-  SmallVector<bool, 4> ArgIsShortVector;
-
-  // Check whether ArgVT is a short vector type.
-  bool IsShortVectorType(EVT ArgVT) {
-    return ArgVT.isVector() && ArgVT.getStoreSize() <= 8;
-  }
-
-public:
-  SystemZCCState(CallingConv::ID CC, bool isVarArg, MachineFunction &MF,
-                 SmallVectorImpl<CCValAssign> &locs, LLVMContext &C)
-      : CCState(CC, isVarArg, MF, locs, C) {}
-
-  void AnalyzeFormalArguments(const SmallVectorImpl<ISD::InputArg> &Ins,
-                              CCAssignFn Fn) {
-    // Record whether the call operand was a short vector.
-    ArgIsShortVector.clear();
-    for (unsigned i = 0; i < Ins.size(); ++i)
-      ArgIsShortVector.push_back(IsShortVectorType(Ins[i].ArgVT));
-
-    CCState::AnalyzeFormalArguments(Ins, Fn);
-  }
-
-  void AnalyzeCallOperands(const SmallVectorImpl<ISD::OutputArg> &Outs,
-                           CCAssignFn Fn) {
-    // Record whether the call operand was a short vector.
-    ArgIsShortVector.clear();
-    for (unsigned i = 0; i < Outs.size(); ++i)
-      ArgIsShortVector.push_back(IsShortVectorType(Outs[i].ArgVT));
-
-    CCState::AnalyzeCallOperands(Outs, Fn);
-  }
-
-  // This version of AnalyzeCallOperands in the base class is not usable
-  // since we must provide a means of accessing ISD::OutputArg::IsShortVector.
-  void AnalyzeCallOperands(const SmallVectorImpl<MVT> &Outs,
-                           SmallVectorImpl<ISD::ArgFlagsTy> &Flags,
-                           CCAssignFn Fn) = delete;
-
-  bool IsShortVector(unsigned ValNo) { return ArgIsShortVector[ValNo]; }
-};
-
 // Handle i128 argument types.  These need to be passed by implicit
 // reference.  This could be as simple as the following .td line:
 //    CCIfType<[i128], CCPassIndirect<i64>>,
diff --git a/llvm/lib/Target/SystemZ/SystemZCallingConv.td b/llvm/lib/Target/SystemZ/SystemZCallingConv.td
index 059f31f6aec30..2795de5eeeb66 100644
--- a/llvm/lib/Target/SystemZ/SystemZCallingConv.td
+++ b/llvm/lib/Target/SystemZ/SystemZCallingConv.td
@@ -18,7 +18,7 @@ class CCIfSubtarget<string F, CCAction A>
 
 // Match if this specific argument was widened from a short vector type.
 class CCIfShortVector<CCAction A>
-    : CCIf<"static_cast<SystemZCCState *>(&State)->IsShortVector(ValNo)", A>;
+    : CCIf<"OrigTy->isVectorTy() && OrigTy->getPrimitiveSizeInBits() <= 64", A>;
 
 
 //===----------------------------------------------------------------------===//
diff --git a/llvm/lib/Target/SystemZ/SystemZISelLowering.cpp b/llvm/lib/Target/SystemZ/SystemZISelLowering.cpp
index 2f8637642d5c6..c73dc3021eb42 100644
--- a/llvm/lib/Target/SystemZ/SystemZISelLowering.cpp
+++ b/llvm/lib/Target/SystemZ/SystemZISelLowering.cpp
@@ -1941,7 +1941,7 @@ SDValue SystemZTargetLowering::LowerFormalArguments(
 
   // Assign locations to all of the incoming arguments.
   SmallVector<CCValAssign, 16> ArgLocs;
-  SystemZCCState CCInfo(CallConv, IsVarArg, MF, ArgLocs, *DAG.getContext());
+  CCState CCInfo(CallConv, IsVarArg, MF, ArgLocs, *DAG.getContext());
   CCInfo.AnalyzeFormalArguments(Ins, CC_SystemZ);
   FuncInfo->setSizeOfFnParams(CCInfo.getStackSize());
 
@@ -2251,7 +2251,7 @@ SystemZTargetLowering::LowerCall(CallLoweringInfo &CLI,
 
   // Analyze the operands of the call, assigning locations to each operand.
   SmallVector<CCValAssign, 16> ArgLocs;
-  SystemZCCState ArgCCInfo(CallConv, IsVarArg, MF, ArgLocs, Ctx);
+  CCState ArgCCInfo(CallConv, IsVarArg, MF, ArgLocs, Ctx);
   ArgCCInfo.AnalyzeCallOperands(Outs, CC_SystemZ);
 
   // We don't support GuaranteedTailCallOpt, only automatically-detected

``````````

</details>


https://github.com/llvm/llvm-project/pull/154091


More information about the llvm-commits mailing list