-
Notifications
You must be signed in to change notification settings - Fork 13.4k
[LoongArch] Add processor models la64v1.0 and la64v1.1 #110211
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Add support for the `la64v1.0` and `la64v1.1` processor models, enabling Rust to select features based on the version of the LoongArch instruction set. These values will align with those used in the C/C++ toolchain. [^1] [^1]: https://github.com/loongson/la-toolchain-conventions?tab=readme-ov-file#list
@llvm/pr-subscribers-backend-loongarch Author: hev (heiher) ChangesAdd support for the Full diff: https://github.com/llvm/llvm-project/pull/110211.diff 2 Files Affected:
diff --git a/llvm/lib/Target/LoongArch/LoongArch.td b/llvm/lib/Target/LoongArch/LoongArch.td
index ddb27dc6404fa8..c1bd94862b4e5e 100644
--- a/llvm/lib/Target/LoongArch/LoongArch.td
+++ b/llvm/lib/Target/LoongArch/LoongArch.td
@@ -128,30 +128,41 @@ include "LoongArchInstrInfo.td"
// LoongArch processors supported.
//===----------------------------------------------------------------------===//
-def : ProcessorModel<"generic-la32", NoSchedModel, [Feature32Bit]>;
-def : ProcessorModel<"generic-la64", NoSchedModel, [Feature64Bit, FeatureUAL]>;
+def ProcessorFeatures {
+ list<SubtargetFeature> LA32G = [Feature32Bit];
+ list<SubtargetFeature> LA64G = [Feature64Bit,
+ FeatureUAL];
+ list<SubtargetFeature> LA64GD = [Feature64Bit,
+ FeatureUAL,
+ FeatureBasicD];
+ list<SubtargetFeature> LA64V1_0 = [Feature64Bit,
+ FeatureUAL,
+ FeatureExtLASX,
+ FeatureExtLVZ,
+ FeatureExtLBT];
+ list<SubtargetFeature> LA64V1_1 = [Feature64Bit,
+ FeatureUAL,
+ FeatureExtLASX,
+ FeatureExtLVZ,
+ FeatureExtLBT,
+ FeatureFrecipe];
+}
+
+def : ProcessorModel<"generic-la32", NoSchedModel, ProcessorFeatures.LA32G>;
+def : ProcessorModel<"generic-la64", NoSchedModel, ProcessorFeatures.LA64G>;
// Generic 64-bit processor with double-precision floating-point support.
-def : ProcessorModel<"loongarch64", NoSchedModel, [Feature64Bit,
- FeatureUAL,
- FeatureBasicD]>;
+def : ProcessorModel<"loongarch64", NoSchedModel, ProcessorFeatures.LA64GD>;
// 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,
- FeatureUAL,
- FeatureExtLASX,
- FeatureExtLVZ,
- FeatureExtLBT]>;
-
-def : ProcessorModel<"la664", NoSchedModel, [Feature64Bit,
- FeatureUAL,
- FeatureExtLASX,
- FeatureExtLVZ,
- FeatureExtLBT,
- FeatureFrecipe]>;
+def : ProcessorModel<"la464", NoSchedModel, ProcessorFeatures.LA64V1_0>;
+def : ProcessorModel<"la64v1.0", NoSchedModel, ProcessorFeatures.LA64V1_0>;
+
+def : ProcessorModel<"la664", NoSchedModel, ProcessorFeatures.LA64V1_1>;
+def : ProcessorModel<"la64v1.1", NoSchedModel, ProcessorFeatures.LA64V1_1>;
//===----------------------------------------------------------------------===//
// Define the LoongArch target.
diff --git a/llvm/test/CodeGen/LoongArch/cpus.ll b/llvm/test/CodeGen/LoongArch/cpus.ll
index be3e05e394ff9a..aa5a81411a2d71 100644
--- a/llvm/test/CodeGen/LoongArch/cpus.ll
+++ b/llvm/test/CodeGen/LoongArch/cpus.ll
@@ -4,6 +4,8 @@
; RUN: llc < %s --mtriple=loongarch64 -mattr=+d --mcpu=loongarch64 2>&1 | FileCheck %s
; RUN: llc < %s --mtriple=loongarch64 -mattr=+d --mcpu=la464 2>&1 | FileCheck %s
; RUN: llc < %s --mtriple=loongarch64 -mattr=+d --mcpu=la664 2>&1 | FileCheck %s
+; RUN: llc < %s --mtriple=loongarch64 -mattr=+d --mcpu=la64v1.0 2>&1 | FileCheck %s
+; RUN: llc < %s --mtriple=loongarch64 -mattr=+d --mcpu=la64v1.1 2>&1 | FileCheck %s
; RUN: llc < %s --mtriple=loongarch64 -mattr=+d 2>&1 | FileCheck %s
; CHECK-NOT: {{.*}} is not a recognized processor for this target
@@ -23,3 +25,11 @@ define void @tune_cpu_la464() "tune-cpu"="la464" {
define void @tune_cpu_la664() "tune-cpu"="la664" {
ret void
}
+
+define void @tune_cpu_la64v1_0() "tune-cpu"="la64v1.0" {
+ ret void
+}
+
+define void @tune_cpu_la64v1_1() "tune-cpu"="la64v1.1" {
+ ret void
+}
Footnotes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While the changes here are good, I think it may be a good idea to also make the generic
target to support FP and LSX (but not LASX), as per the recommended general computing baseline by Loongson. This is tangential to the issue at hand though, and we can do it in a separate PR if you agree. (I'm surprised to realize that generic
does not support FP but the equally generic-sounding loongarch64
does -- this is very confusing and I always struggle to remember these details, even to this day.)
CLOSE: Internal reviewers believe that this change will make the The changes to |
This commit makes the `generic` target to support FP and LSX, as discussed in llvm#110211. Thereby, it allows 128-bit vector to be enabled by default in the loongarch64 backend.
BTW, what are the plans for adding |
|
This commit makes the `generic` target to support FP and LSX, as discussed in llvm#110211. Thereby, it allows 128-bit vector to be enabled by default in the loongarch64 backend.
This commit makes the `generic` target to support FP and LSX, as discussed in llvm#110211. Thereby, it allows 128-bit vector to be enabled by default in the loongarch64 backend.
This commit makes the `generic` target to support FP and LSX, as discussed in #110211. Thereby, it allows 128-bit vector to be enabled by default in the loongarch64 backend.
) This commit makes the `generic` target to support FP and LSX, as discussed in llvm#110211. Thereby, it allows 128-bit vector to be enabled by default in the loongarch64 backend.
) This commit makes the `generic` target to support FP and LSX, as discussed in llvm#110211. Thereby, it allows 128-bit vector to be enabled by default in the loongarch64 backend.
Add support for the
la64v1.0
andla64v1.1
processor models, enabling Rust to select features based on the version of the LoongArch instruction set. These values will align with those used in the C/C++ toolchain. 1Footnotes
https://github.com/loongson/la-toolchain-conventions?tab=readme-ov-file#list ↩