[llvm] [PowerPC] Remove custom original type tracking (NFCI) (PR #154090)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 18 03:50:52 PDT 2025


https://github.com/nikic created https://github.com/llvm/llvm-project/pull/154090

The OrigTy is passed to CC lowering nowadays, so use it directly instead of custom pre-analysis.

>From 08e35d7c5f3ba0db8be1533feda58a44ad56baee Mon Sep 17 00:00:00 2001
From: Nikita Popov <npopov at redhat.com>
Date: Mon, 18 Aug 2025 12:47:57 +0200
Subject: [PATCH] [PowerPC] Remove custom original type tracking (NFCI)

The OrigTy is passed to CC lowering nowadays, so use it directly
instead of custom pre-analysis.
---
 llvm/lib/Target/PowerPC/CMakeLists.txt      |  1 -
 llvm/lib/Target/PowerPC/PPCCCState.cpp      | 33 ----------------
 llvm/lib/Target/PowerPC/PPCCCState.h        | 43 ---------------------
 llvm/lib/Target/PowerPC/PPCCallingConv.cpp  |  1 -
 llvm/lib/Target/PowerPC/PPCCallingConv.td   |  6 +--
 llvm/lib/Target/PowerPC/PPCISelLowering.cpp | 12 +-----
 6 files changed, 4 insertions(+), 92 deletions(-)
 delete mode 100644 llvm/lib/Target/PowerPC/PPCCCState.cpp
 delete mode 100644 llvm/lib/Target/PowerPC/PPCCCState.h

diff --git a/llvm/lib/Target/PowerPC/CMakeLists.txt b/llvm/lib/Target/PowerPC/CMakeLists.txt
index 3808a26a0b92a..1e39f01fd7aa5 100644
--- a/llvm/lib/Target/PowerPC/CMakeLists.txt
+++ b/llvm/lib/Target/PowerPC/CMakeLists.txt
@@ -25,7 +25,6 @@ add_llvm_target(PowerPCCodeGen
   PPCBranchSelector.cpp
   PPCBranchCoalescing.cpp
   PPCCallingConv.cpp
-  PPCCCState.cpp
   PPCCTRLoops.cpp
   PPCCTRLoopsVerify.cpp
   PPCExpandAtomicPseudoInsts.cpp
diff --git a/llvm/lib/Target/PowerPC/PPCCCState.cpp b/llvm/lib/Target/PowerPC/PPCCCState.cpp
deleted file mode 100644
index e08aaf89e8dbe..0000000000000
--- a/llvm/lib/Target/PowerPC/PPCCCState.cpp
+++ /dev/null
@@ -1,33 +0,0 @@
-//===---- PPCCCState.cpp - CCState with PowerPC specific extensions ---------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#include "PPCCCState.h"
-using namespace llvm;
-
-// Identify lowered values that originated from ppcf128 arguments and record
-// this.
-void PPCCCState::PreAnalyzeCallOperands(
-    const SmallVectorImpl<ISD::OutputArg> &Outs) {
-  for (const auto &I : Outs) {
-    if (I.ArgVT == llvm::MVT::ppcf128)
-      OriginalArgWasPPCF128.push_back(true);
-    else
-      OriginalArgWasPPCF128.push_back(false);
-  }
-}
-
-void PPCCCState::PreAnalyzeFormalArguments(
-    const SmallVectorImpl<ISD::InputArg> &Ins) {
-  for (const auto &I : Ins) {
-    if (I.ArgVT == llvm::MVT::ppcf128) {
-      OriginalArgWasPPCF128.push_back(true);
-    } else {
-      OriginalArgWasPPCF128.push_back(false);
-    }
-  }
-}
diff --git a/llvm/lib/Target/PowerPC/PPCCCState.h b/llvm/lib/Target/PowerPC/PPCCCState.h
deleted file mode 100644
index feab9c58e650a..0000000000000
--- a/llvm/lib/Target/PowerPC/PPCCCState.h
+++ /dev/null
@@ -1,43 +0,0 @@
-//===---- PPCCCState.h - CCState with PowerPC specific extensions -----------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef PPCCCSTATE_H
-#define PPCCCSTATE_H
-
-#include "PPCISelLowering.h"
-#include "llvm/ADT/BitVector.h"
-#include "llvm/ADT/SmallVector.h"
-#include "llvm/CodeGen/CallingConvLower.h"
-
-namespace llvm {
-
-class PPCCCState : public CCState {
-public:
-
-  void
-  PreAnalyzeCallOperands(const SmallVectorImpl<ISD::OutputArg> &Outs);
-  void
-  PreAnalyzeFormalArguments(const SmallVectorImpl<ISD::InputArg> &Ins);
-
-private:
-
-  // Records whether the value has been lowered from an ppcf128.
-  SmallVector<bool, 4> OriginalArgWasPPCF128;
-
-public:
-  PPCCCState(CallingConv::ID CC, bool isVarArg, MachineFunction &MF,
-             SmallVectorImpl<CCValAssign> &locs, LLVMContext &C)
-        : CCState(CC, isVarArg, MF, locs, C) {}
-
-  bool WasOriginalArgPPCF128(unsigned ValNo) { return OriginalArgWasPPCF128[ValNo]; }
-  void clearWasPPCF128() { OriginalArgWasPPCF128.clear(); }
-};
-
-} // end namespace llvm
-
-#endif
diff --git a/llvm/lib/Target/PowerPC/PPCCallingConv.cpp b/llvm/lib/Target/PowerPC/PPCCallingConv.cpp
index b00d70bbe263b..332b5e07d3d5d 100644
--- a/llvm/lib/Target/PowerPC/PPCCallingConv.cpp
+++ b/llvm/lib/Target/PowerPC/PPCCallingConv.cpp
@@ -8,7 +8,6 @@
 
 #include "PPCCallingConv.h"
 #include "PPCSubtarget.h"
-#include "PPCCCState.h"
 using namespace llvm;
 
 inline bool CC_PPC_AnyReg_Error(unsigned &, MVT &, MVT &,
diff --git a/llvm/lib/Target/PowerPC/PPCCallingConv.td b/llvm/lib/Target/PowerPC/PPCCallingConv.td
index 899326ad46656..5d4fe06ebdddd 100644
--- a/llvm/lib/Target/PowerPC/PPCCallingConv.td
+++ b/llvm/lib/Target/PowerPC/PPCCallingConv.td
@@ -21,11 +21,9 @@ class CCIfNotSubtarget<string F, CCAction A>
                      F),
           A>;
 class CCIfOrigArgWasNotPPCF128<CCAction A>
-    : CCIf<"!static_cast<PPCCCState *>(&State)->WasOriginalArgPPCF128(ValNo)",
-           A>;
+    : CCIf<"!OrigTy->isPPC_FP128Ty()", A>;
 class CCIfOrigArgWasPPCF128<CCAction A>
-    : CCIf<"static_cast<PPCCCState *>(&State)->WasOriginalArgPPCF128(ValNo)",
-           A>;
+    : CCIf<"OrigTy->isPPC_FP128Ty()", A>;
 
 //===----------------------------------------------------------------------===//
 // Return Value Calling Convention
diff --git a/llvm/lib/Target/PowerPC/PPCISelLowering.cpp b/llvm/lib/Target/PowerPC/PPCISelLowering.cpp
index b97d0e235c019..87a6b262c47ff 100644
--- a/llvm/lib/Target/PowerPC/PPCISelLowering.cpp
+++ b/llvm/lib/Target/PowerPC/PPCISelLowering.cpp
@@ -14,7 +14,6 @@
 #include "MCTargetDesc/PPCMCTargetDesc.h"
 #include "MCTargetDesc/PPCPredicates.h"
 #include "PPC.h"
-#include "PPCCCState.h"
 #include "PPCCallingConv.h"
 #include "PPCFrameLowering.h"
 #include "PPCInstrInfo.h"
@@ -4330,17 +4329,13 @@ SDValue PPCTargetLowering::LowerFormalArguments_32SVR4(
 
   // Assign locations to all of the incoming arguments.
   SmallVector<CCValAssign, 16> ArgLocs;
-  PPCCCState CCInfo(CallConv, isVarArg, DAG.getMachineFunction(), ArgLocs,
+  CCState CCInfo(CallConv, isVarArg, DAG.getMachineFunction(), ArgLocs,
                  *DAG.getContext());
 
   // Reserve space for the linkage area on the stack.
   unsigned LinkageSize = Subtarget.getFrameLowering()->getLinkageSize();
   CCInfo.AllocateStack(LinkageSize, PtrAlign);
-  if (useSoftFloat())
-    CCInfo.PreAnalyzeFormalArguments(Ins);
-
   CCInfo.AnalyzeFormalArguments(Ins, CC_PPC32_SVR4);
-  CCInfo.clearWasPPCF128();
 
   for (unsigned i = 0, e = ArgLocs.size(); i != e; ++i) {
     CCValAssign &VA = ArgLocs[i];
@@ -6062,13 +6057,11 @@ SDValue PPCTargetLowering::LowerCall_32SVR4(
 
   // Assign locations to all of the outgoing arguments.
   SmallVector<CCValAssign, 16> ArgLocs;
-  PPCCCState CCInfo(CallConv, IsVarArg, MF, ArgLocs, *DAG.getContext());
+  CCState CCInfo(CallConv, IsVarArg, MF, ArgLocs, *DAG.getContext());
 
   // Reserve space for the linkage area on the stack.
   CCInfo.AllocateStack(Subtarget.getFrameLowering()->getLinkageSize(),
                        PtrAlign);
-  if (useSoftFloat())
-    CCInfo.PreAnalyzeCallOperands(Outs);
 
   if (IsVarArg) {
     // Handle fixed and variable vector arguments differently.
@@ -6101,7 +6094,6 @@ SDValue PPCTargetLowering::LowerCall_32SVR4(
     // All arguments are treated the same.
     CCInfo.AnalyzeCallOperands(Outs, CC_PPC32_SVR4);
   }
-  CCInfo.clearWasPPCF128();
 
   // Assign locations to all of the outgoing aggregate by value arguments.
   SmallVector<CCValAssign, 16> ByValArgLocs;



More information about the llvm-commits mailing list