llvmorg-github-actions[bot] wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-backend-risc-v

Author: Matt Arsenault (arsenm)

<details>
<summary>Changes</summary>

Generate RISCVTargetParserDef.inc from a reduced td file which
includes only the features, profiles and processors, instead of all of
RISCV.td. The processors reference scheduling models, which are
defined with the scheduling information for the instructions, so the
new file defines empty placeholder models instead, as was done for
AArch64 in #<!-- -->231954.

RISCV was the last TargetParser input that parsed the full target, and
took 1.74 of the 1.78 seconds spent in the TargetParser tablegen jobs.

llvm-min-tblgen -gen-riscv-target-def, mean of 5 runs

                             Gigainstructions  Seconds  Peak RSS  .td deps
  RISCV.td                   7.47              1.74     407 MB    139
  RISCVTargetParserDef.td    0.04              0.01       7 MB      9

Co-authored-by: Claude Opus 5.5 &lt;noreply@<!-- -->anthropic.com&gt;

---

&lt;sub&gt;Stack created with &lt;a 
href="https://github.com/github/gh-stack"&gt;GitHub Stacks CLI&lt;/a&gt; • 
&lt;a href="https://gh.io/stacks-feedback"&gt;Give Feedback 
💬&lt;/a&gt;&lt;/sub&gt;

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


6 Files Affected:

- (modified) llvm/include/llvm/TargetParser/CMakeLists.txt (+1-1) 
- (modified) llvm/lib/Target/RISCV/RISCVFeatures.td (-3) 
- (modified) llvm/lib/Target/RISCV/RISCVRegisterInfo.td (+3) 
- (added) llvm/lib/Target/RISCV/RISCVTargetParserDef.td (+44) 
- (modified) llvm/utils/gn/secondary/llvm/include/llvm/TargetParser/BUILD.gn 
(+1-1) 
- (modified) utils/bazel/llvm-project-overlay/llvm/BUILD.bazel (+1-1) 


``````````diff
diff --git a/llvm/include/llvm/TargetParser/CMakeLists.txt 
b/llvm/include/llvm/TargetParser/CMakeLists.txt
index 527fbca1fec6a1..eab3e38baa14f5 100644
--- a/llvm/include/llvm/TargetParser/CMakeLists.txt
+++ b/llvm/include/llvm/TargetParser/CMakeLists.txt
@@ -1,7 +1,7 @@
 set(LLVM_TARGET_DEFINITIONS 
${PROJECT_SOURCE_DIR}/lib/Target/AArch64/AArch64TargetParserDef.td)
 llvm_tablegen(AArch64TargetParserDef.inc -gen-arm-target-def EXTRA_INCLUDES 
${PROJECT_SOURCE_DIR}/lib/Target/AArch64)
 
-set(LLVM_TARGET_DEFINITIONS ${PROJECT_SOURCE_DIR}/lib/Target/RISCV/RISCV.td)
+set(LLVM_TARGET_DEFINITIONS 
${PROJECT_SOURCE_DIR}/lib/Target/RISCV/RISCVTargetParserDef.td)
 llvm_tablegen(RISCVTargetParserDef.inc -gen-riscv-target-def EXTRA_INCLUDES 
${PROJECT_SOURCE_DIR}/lib/Target/RISCV)
 
 set(LLVM_TARGET_DEFINITIONS 
${PROJECT_SOURCE_DIR}/lib/Target/PowerPC/PPCTargetParserDef.td)
diff --git a/llvm/lib/Target/RISCV/RISCVFeatures.td 
b/llvm/lib/Target/RISCV/RISCVFeatures.td
index 83a4be1cd7bc69..98e9b09a3a3f5d 100644
--- a/llvm/lib/Target/RISCV/RISCVFeatures.td
+++ b/llvm/lib/Target/RISCV/RISCVFeatures.td
@@ -2028,9 +2028,6 @@ def IsRV32 : Predicate<"!Subtarget->is64Bit()">,
              AssemblerPredicate<(none_of Feature64Bit),
                                 "RV32I Base Instruction Set">;
 
-defvar RV32 = DefaultMode;
-def RV64 : HwMode<[IsRV64]>;
-
 def FeatureRelax
     : SubtargetFeature<"relax", "EnableLinkerRelax", "true",
                        "Enable Linker relaxation">;
diff --git a/llvm/lib/Target/RISCV/RISCVRegisterInfo.td 
b/llvm/lib/Target/RISCV/RISCVRegisterInfo.td
index 42637beacb8ce8..d7fc157e54bc46 100644
--- a/llvm/lib/Target/RISCV/RISCVRegisterInfo.td
+++ b/llvm/lib/Target/RISCV/RISCVRegisterInfo.td
@@ -10,6 +10,9 @@
 //  Declarations that describe the RISC-V register files
 
//===----------------------------------------------------------------------===//
 
+defvar RV32 = DefaultMode;
+def RV64 : HwMode<[IsRV64]>;
+
 let Namespace = "RISCV" in {
 class RISCVReg<bits<5> Enc, string n, list<string> alt = []> : Register<n> {
   let HWEncoding{4-0} = Enc;
diff --git a/llvm/lib/Target/RISCV/RISCVTargetParserDef.td 
b/llvm/lib/Target/RISCV/RISCVTargetParserDef.td
new file mode 100644
index 00000000000000..9b082d2e5cc803
--- /dev/null
+++ b/llvm/lib/Target/RISCV/RISCVTargetParserDef.td
@@ -0,0 +1,44 @@
+//===-- RISCVTargetParserDef.td - RISC-V TargetParser ------*- tablegen 
-*-===//
+//
+// 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 "llvm/Target/TargetSubtarget.td"
+include "llvm/TableGen/SearchableTable.td"
+
+include "RISCVFeatures.td"
+include "RISCVProfiles.td"
+
+// The TargetParser tables do not use the scheduling models, which depend on
+// the instruction definitions. Define placeholders for the models referenced
+// by the processor definitions.
+def Andes45Model : SchedMachineModel;
+def GenericOOOModel : SchedMachineModel;
+def MIPSP8700Model : SchedMachineModel;
+def RocketModel : SchedMachineModel;
+def SiFive7Model : SchedMachineModel;
+def SiFiveP400Model : SchedMachineModel;
+def SiFiveP500Model : SchedMachineModel;
+def SiFiveP600Model : SchedMachineModel;
+def SiFiveP800Model : SchedMachineModel;
+def SiFiveX100Model : SchedMachineModel;
+def SiFiveX390Model : SchedMachineModel;
+def SpacemitX100Model : SchedMachineModel;
+def SpacemitX60Model : SchedMachineModel;
+def SyntacoreSCR1Model : SchedMachineModel;
+def SyntacoreSCR3RV32Model : SchedMachineModel;
+def SyntacoreSCR3RV64Model : SchedMachineModel;
+def SyntacoreSCR4RV32Model : SchedMachineModel;
+def SyntacoreSCR4RV64Model : SchedMachineModel;
+def SyntacoreSCR5RV32Model : SchedMachineModel;
+def SyntacoreSCR5RV64Model : SchedMachineModel;
+def SyntacoreSCR7Model : SchedMachineModel;
+def TTAscalonXGModel : SchedMachineModel;
+def TTAscalonXModel : SchedMachineModel;
+def XiangShanKunMingHuModel : SchedMachineModel;
+def XiangShanNanHuModel : SchedMachineModel;
+
+include "RISCVProcessors.td"
diff --git a/llvm/utils/gn/secondary/llvm/include/llvm/TargetParser/BUILD.gn 
b/llvm/utils/gn/secondary/llvm/include/llvm/TargetParser/BUILD.gn
index 7ec386f320bbb9..58c25731279af9 100644
--- a/llvm/utils/gn/secondary/llvm/include/llvm/TargetParser/BUILD.gn
+++ b/llvm/utils/gn/secondary/llvm/include/llvm/TargetParser/BUILD.gn
@@ -17,7 +17,7 @@ tablegen("PPCGenTargetFeatures") {
 tablegen("RISCVTargetParserDef") {
   visibility = [ ":gen" ]
   args = [ "-gen-riscv-target-def" ]
-  td_file = "//llvm/lib/Target/RISCV/RISCV.td"
+  td_file = "//llvm/lib/Target/RISCV/RISCVTargetParserDef.td"
   tblgen_target = "//llvm/utils/TableGen:llvm-min-tblgen"
 }
 
diff --git a/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel 
b/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel
index 709ad691ad5100..83f333554f6a95 100644
--- a/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel
@@ -1792,7 +1792,7 @@ gentbl_cc_library(
     name = "RISCVTargetParserDefGen",
     tbl_outs = {"include/llvm/TargetParser/RISCVTargetParserDef.inc": 
["-gen-riscv-target-def"]},
     tblgen = ":llvm-min-tblgen",
-    td_file = "lib/Target/RISCV/RISCV.td",
+    td_file = "lib/Target/RISCV/RISCVTargetParserDef.td",
     deps = [
         ":CommonTargetTdFiles",
         ":RISCVTargetTdFiles",

``````````

</details>


https://github.com/llvm/llvm-project/pull/239104
_______________________________________________
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits

Reply via email to