[PATCH] D134412: [LoongArch] Support 'generic' as a valid CPU name

WÁNG Xuěruì via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 21 23:39:16 PDT 2022


xen0n created this revision.
xen0n added reviewers: SixWeining, wangleiat, xry111, MaskRay, gonglingqin.
Herald added subscribers: StephenFan, luismarques, s.egerton, PkmX, simoncook, hiraditya, arichardson.
Herald added a project: All.
xen0n requested review of this revision.
Herald added subscribers: llvm-commits, pcwang-thead.
Herald added a project: LLVM.

As the LoongArch port is largely modeled after RISCV it has the same
behavior of not accepting `generic` as a CPU name. For better
compatibility with consumers of LLVM (e.g. mesa) follow D121149 <https://reviews.llvm.org/D121149>'s suit
and treat `generic` the same as an empty CPU name.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D134412

Files:
  llvm/lib/Target/LoongArch/LoongArch.td
  llvm/lib/Target/LoongArch/LoongArchSubtarget.cpp
  llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchMCTargetDesc.cpp


Index: llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchMCTargetDesc.cpp
===================================================================
--- llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchMCTargetDesc.cpp
+++ llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchMCTargetDesc.cpp
@@ -54,7 +54,7 @@
 
 static MCSubtargetInfo *
 createLoongArchMCSubtargetInfo(const Triple &TT, StringRef CPU, StringRef FS) {
-  if (CPU.empty())
+  if (CPU.empty() || CPU == "generic")
     CPU = TT.isArch64Bit() ? "la464" : "generic-la32";
   return createLoongArchMCSubtargetInfoImpl(TT, CPU, /*TuneCPU*/ CPU, FS);
 }
Index: llvm/lib/Target/LoongArch/LoongArchSubtarget.cpp
===================================================================
--- llvm/lib/Target/LoongArch/LoongArchSubtarget.cpp
+++ llvm/lib/Target/LoongArch/LoongArchSubtarget.cpp
@@ -27,7 +27,7 @@
     const Triple &TT, StringRef CPU, StringRef TuneCPU, StringRef FS,
     StringRef ABIName) {
   bool Is64Bit = TT.isArch64Bit();
-  if (CPU.empty())
+  if (CPU.empty() || CPU == "generic")
     CPU = Is64Bit ? "generic-la64" : "generic-la32";
 
   if (TuneCPU.empty())
Index: llvm/lib/Target/LoongArch/LoongArch.td
===================================================================
--- llvm/lib/Target/LoongArch/LoongArch.td
+++ llvm/lib/Target/LoongArch/LoongArch.td
@@ -100,6 +100,10 @@
 def : ProcessorModel<"generic-la32", NoSchedModel, []>;
 def : ProcessorModel<"generic-la64", NoSchedModel, [Feature64Bit]>;
 
+// Support generic for compatibility with other targets. The triple will be used
+// to change to the appropriate la32/la64 version.
+def : ProcessorModel<"generic", NoSchedModel, []>;
+
 def : ProcessorModel<"la464", NoSchedModel, [Feature64Bit,
                                              FeatureExtLASX,
                                              FeatureExtLVZ,


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D134412.462086.patch
Type: text/x-patch
Size: 1841 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220922/03b9c376/attachment.bin>


More information about the llvm-commits mailing list