[llvm] [Target] Use templated MachineFunction::getSubtarget in *CallingConv.td. NFC (PR #107311)
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 4 14:00:13 PDT 2024
https://github.com/topperc created https://github.com/llvm/llvm-project/pull/107311
This hides away the static_cast to get the target specific Subtarget object.
>From 993d4bc860a23f9befa1162c3ea3adbe04024154 Mon Sep 17 00:00:00 2001
From: Craig Topper <craig.topper at sifive.com>
Date: Wed, 4 Sep 2024 13:58:00 -0700
Subject: [PATCH] [Target] Use templated MachineFunction::getSubtarget in
*CallingConv.td. NFC
This hides away the static_cast to get the target specific Subtarget
object.
---
llvm/lib/Target/AMDGPU/AMDGPUCallingConv.td | 10 ++++------
llvm/lib/Target/M68k/M68kCallingConv.td | 4 ++--
llvm/lib/Target/Mips/MipsCallingConv.td | 3 +--
llvm/lib/Target/PowerPC/PPCCallingConv.td | 6 ++----
llvm/lib/Target/SystemZ/SystemZCallingConv.td | 4 ++--
llvm/lib/Target/X86/X86CallingConv.td | 8 ++++----
6 files changed, 15 insertions(+), 20 deletions(-)
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUCallingConv.td b/llvm/lib/Target/AMDGPU/AMDGPUCallingConv.td
index 4be64629ddac82..21412044d5a013 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUCallingConv.td
+++ b/llvm/lib/Target/AMDGPU/AMDGPUCallingConv.td
@@ -214,13 +214,11 @@ def RetCC_AMDGPU_Func : CallingConv<[
]>;
def CC_AMDGPU : CallingConv<[
- CCIf<"static_cast<const GCNSubtarget&>"
- "(State.getMachineFunction().getSubtarget()).getGeneration() >= "
- "AMDGPUSubtarget::SOUTHERN_ISLANDS",
+ CCIf<"State.getMachineFunction().getSubtarget<GCNSubtarget>().getGeneration() >= "
+ "AMDGPUSubtarget::SOUTHERN_ISLANDS",
CCDelegateTo<CC_SI_SHADER>>,
- CCIf<"static_cast<const GCNSubtarget&>"
- "(State.getMachineFunction().getSubtarget()).getGeneration() >= "
- "AMDGPUSubtarget::SOUTHERN_ISLANDS && State.getCallingConv() == CallingConv::C",
+ CCIf<"State.getMachineFunction().getSubtarget<GCNSubtarget>().getGeneration() >= "
+ "AMDGPUSubtarget::SOUTHERN_ISLANDS && State.getCallingConv() == CallingConv::C",
CCDelegateTo<CC_AMDGPU_Func>>
]>;
diff --git a/llvm/lib/Target/M68k/M68kCallingConv.td b/llvm/lib/Target/M68k/M68kCallingConv.td
index 523f08e6461515..cf7e5ef69463e6 100644
--- a/llvm/lib/Target/M68k/M68kCallingConv.td
+++ b/llvm/lib/Target/M68k/M68kCallingConv.td
@@ -15,8 +15,8 @@
// TODO Verify C convention follows SysV M68K ABI
class CCIfSubtarget<string F, CCAction A>
- : CCIf<!strconcat("static_cast<const M68kSubtarget &>"
- "(State.getMachineFunction().getSubtarget()).", F), A>;
+ : CCIf<!strconcat("State.getMachineFunction()."
+ "getSubtarget<M68kSubtarget>().", F), A>;
//===----------------------------------------------------------------------===//
// Return Value Calling Conventions
diff --git a/llvm/lib/Target/Mips/MipsCallingConv.td b/llvm/lib/Target/Mips/MipsCallingConv.td
index 204f11f1107cf9..866161bf50638d 100644
--- a/llvm/lib/Target/Mips/MipsCallingConv.td
+++ b/llvm/lib/Target/Mips/MipsCallingConv.td
@@ -11,8 +11,7 @@
/// CCIfSubtarget - Match if the current subtarget has a feature F.
class CCIfSubtarget<string F, CCAction A, string Invert = "">
: CCIf<!strconcat(Invert,
- "static_cast<const MipsSubtarget&>"
- "(State.getMachineFunction().getSubtarget()).",
+ "State.getMachineFunction().getSubtarget<MipsSubtarget>().",
F),
A>;
diff --git a/llvm/lib/Target/PowerPC/PPCCallingConv.td b/llvm/lib/Target/PowerPC/PPCCallingConv.td
index 825c1a29ed62cb..899326ad466567 100644
--- a/llvm/lib/Target/PowerPC/PPCCallingConv.td
+++ b/llvm/lib/Target/PowerPC/PPCCallingConv.td
@@ -13,13 +13,11 @@
/// CCIfSubtarget - Match if the current subtarget has a feature F.
class CCIfSubtarget<string F, CCAction A>
- : CCIf<!strconcat("static_cast<const PPCSubtarget&>"
- "(State.getMachineFunction().getSubtarget()).",
+ : CCIf<!strconcat("State.getMachineFunction().getSubtarget<PPCSubtarget>().",
F),
A>;
class CCIfNotSubtarget<string F, CCAction A>
- : CCIf<!strconcat("!static_cast<const PPCSubtarget&>"
- "(State.getMachineFunction().getSubtarget()).",
+ : CCIf<!strconcat("!State.getMachineFunction().getSubtarget<PPCSubtarget>().",
F),
A>;
class CCIfOrigArgWasNotPPCF128<CCAction A>
diff --git a/llvm/lib/Target/SystemZ/SystemZCallingConv.td b/llvm/lib/Target/SystemZ/SystemZCallingConv.td
index b0618aafa5da6e..99bb697ce20142 100644
--- a/llvm/lib/Target/SystemZ/SystemZCallingConv.td
+++ b/llvm/lib/Target/SystemZ/SystemZCallingConv.td
@@ -12,8 +12,8 @@ class CCIfExtend<CCAction A>
: CCIf<"ArgFlags.isSExt() || ArgFlags.isZExt()", A>;
class CCIfSubtarget<string F, CCAction A>
- : CCIf<!strconcat("static_cast<const SystemZSubtarget&>"
- "(State.getMachineFunction().getSubtarget()).", F),
+ : CCIf<!strconcat("State.getMachineFunction()."
+ "getSubtarget<SystemZSubtarget>().", F),
A>;
// Match if this specific argument is a fixed (i.e. named) argument.
diff --git a/llvm/lib/Target/X86/X86CallingConv.td b/llvm/lib/Target/X86/X86CallingConv.td
index c55ff3dfc9c8e1..307aeb2ea4c6fd 100644
--- a/llvm/lib/Target/X86/X86CallingConv.td
+++ b/llvm/lib/Target/X86/X86CallingConv.td
@@ -13,14 +13,14 @@
/// CCIfSubtarget - Match if the current subtarget has a feature F.
class CCIfSubtarget<string F, CCAction A>
- : CCIf<!strconcat("static_cast<const X86Subtarget&>"
- "(State.getMachineFunction().getSubtarget()).", F),
+ : CCIf<!strconcat("State.getMachineFunction()."
+ "getSubtarget<X86Subtarget>().", F),
A>;
/// CCIfNotSubtarget - Match if the current subtarget doesn't has a feature F.
class CCIfNotSubtarget<string F, CCAction A>
- : CCIf<!strconcat("!static_cast<const X86Subtarget&>"
- "(State.getMachineFunction().getSubtarget()).", F),
+ : CCIf<!strconcat("!State.getMachineFunction()."
+ "getSubtarget<X86Subtarget>().", F),
A>;
/// CCIfRegCallv4 - Match if RegCall ABIv4 is respected.
More information about the llvm-commits
mailing list