Skip to content

Commit c26657f

Browse files
committed
[LoongArch] Add processor models la64v1.0 and la64v1.1
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
1 parent 631bcbe commit c26657f

File tree

2 files changed

+38
-17
lines changed

2 files changed

+38
-17
lines changed

llvm/lib/Target/LoongArch/LoongArch.td

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -128,30 +128,41 @@ include "LoongArchInstrInfo.td"
128128
// LoongArch processors supported.
129129
//===----------------------------------------------------------------------===//
130130

131-
def : ProcessorModel<"generic-la32", NoSchedModel, [Feature32Bit]>;
132-
def : ProcessorModel<"generic-la64", NoSchedModel, [Feature64Bit, FeatureUAL]>;
131+
def ProcessorFeatures {
132+
list<SubtargetFeature> LA32G = [Feature32Bit];
133+
list<SubtargetFeature> LA64G = [Feature64Bit,
134+
FeatureUAL];
135+
list<SubtargetFeature> LA64GD = [Feature64Bit,
136+
FeatureUAL,
137+
FeatureBasicD];
138+
list<SubtargetFeature> LA64V1_0 = [Feature64Bit,
139+
FeatureUAL,
140+
FeatureExtLASX,
141+
FeatureExtLVZ,
142+
FeatureExtLBT];
143+
list<SubtargetFeature> LA64V1_1 = [Feature64Bit,
144+
FeatureUAL,
145+
FeatureExtLASX,
146+
FeatureExtLVZ,
147+
FeatureExtLBT,
148+
FeatureFrecipe];
149+
}
150+
151+
def : ProcessorModel<"generic-la32", NoSchedModel, ProcessorFeatures.LA32G>;
152+
def : ProcessorModel<"generic-la64", NoSchedModel, ProcessorFeatures.LA64G>;
133153

134154
// Generic 64-bit processor with double-precision floating-point support.
135-
def : ProcessorModel<"loongarch64", NoSchedModel, [Feature64Bit,
136-
FeatureUAL,
137-
FeatureBasicD]>;
155+
def : ProcessorModel<"loongarch64", NoSchedModel, ProcessorFeatures.LA64GD>;
138156

139157
// Support generic for compatibility with other targets. The triple will be used
140158
// to change to the appropriate la32/la64 version.
141159
def : ProcessorModel<"generic", NoSchedModel, []>;
142160

143-
def : ProcessorModel<"la464", NoSchedModel, [Feature64Bit,
144-
FeatureUAL,
145-
FeatureExtLASX,
146-
FeatureExtLVZ,
147-
FeatureExtLBT]>;
148-
149-
def : ProcessorModel<"la664", NoSchedModel, [Feature64Bit,
150-
FeatureUAL,
151-
FeatureExtLASX,
152-
FeatureExtLVZ,
153-
FeatureExtLBT,
154-
FeatureFrecipe]>;
161+
def : ProcessorModel<"la464", NoSchedModel, ProcessorFeatures.LA64V1_0>;
162+
def : ProcessorModel<"la64v1.0", NoSchedModel, ProcessorFeatures.LA64V1_0>;
163+
164+
def : ProcessorModel<"la664", NoSchedModel, ProcessorFeatures.LA64V1_1>;
165+
def : ProcessorModel<"la64v1.1", NoSchedModel, ProcessorFeatures.LA64V1_1>;
155166

156167
//===----------------------------------------------------------------------===//
157168
// Define the LoongArch target.

llvm/test/CodeGen/LoongArch/cpus.ll

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
; RUN: llc < %s --mtriple=loongarch64 -mattr=+d --mcpu=loongarch64 2>&1 | FileCheck %s
55
; RUN: llc < %s --mtriple=loongarch64 -mattr=+d --mcpu=la464 2>&1 | FileCheck %s
66
; RUN: llc < %s --mtriple=loongarch64 -mattr=+d --mcpu=la664 2>&1 | FileCheck %s
7+
; RUN: llc < %s --mtriple=loongarch64 -mattr=+d --mcpu=la64v1.0 2>&1 | FileCheck %s
8+
; RUN: llc < %s --mtriple=loongarch64 -mattr=+d --mcpu=la64v1.1 2>&1 | FileCheck %s
79
; RUN: llc < %s --mtriple=loongarch64 -mattr=+d 2>&1 | FileCheck %s
810

911
; CHECK-NOT: {{.*}} is not a recognized processor for this target
@@ -23,3 +25,11 @@ define void @tune_cpu_la464() "tune-cpu"="la464" {
2325
define void @tune_cpu_la664() "tune-cpu"="la664" {
2426
ret void
2527
}
28+
29+
define void @tune_cpu_la64v1_0() "tune-cpu"="la64v1.0" {
30+
ret void
31+
}
32+
33+
define void @tune_cpu_la64v1_1() "tune-cpu"="la64v1.1" {
34+
ret void
35+
}

0 commit comments

Comments
 (0)