Skip to content

Commit aa2c0f3

Browse files
[ARM] [AArch32] Add support for Arm China STAR-MC1 CPU (#110085)
STAR-MC1 is an Armv8m CPU. Technical specifications available at: https://www.armchina.com/download/Documents/Application-Notes/Technical-Reference-Manual?infoId=160
1 parent 839344f commit aa2c0f3

File tree

7 files changed

+30
-1
lines changed

7 files changed

+30
-1
lines changed

clang/test/Driver/arm-cortex-cpus-2.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -559,8 +559,10 @@
559559
// CHECK-CPUV8MBASE: "-cc1"{{.*}} "-triple" "thumbv8m.base-
560560

561561
// RUN: %clang -target arm -mcpu=cortex-m33 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CORTEX-M33 %s
562+
// RUN: %clang -target arm -mcpu=star-mc1 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-STAR-MC1 %s
562563
// RUN: %clang -target arm -mcpu=cortex-m35p -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CORTEX-M35P %s
563564
// CHECK-CORTEX-M33: "-cc1"{{.*}} "-triple" "thumbv8m.main-{{.*}} "-target-cpu" "cortex-m33"
565+
// CHECK-STAR-MC1: "-cc1"{{.*}} "-triple" "thumbv8m.main-{{.*}} "-target-cpu" "star-mc1"
564566
// CHECK-CORTEX-M35P: "-cc1"{{.*}} "-triple" "thumbv8m.main-{{.*}} "-target-cpu" "cortex-m35p"
565567

566568
// RUN: %clang -target arm -mcpu=cortex-m55 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CORTEX-M55 %s

clang/test/Misc/target-invalid-cpu-note/arm.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
// CHECK-SAME: {{^}}, cortex-m7
6666
// CHECK-SAME: {{^}}, cortex-m23
6767
// CHECK-SAME: {{^}}, cortex-m33
68+
// CHECK-SAME: {{^}}, star-mc1
6869
// CHECK-SAME: {{^}}, cortex-m35p
6970
// CHECK-SAME: {{^}}, cortex-m55
7071
// CHECK-SAME: {{^}}, cortex-m85

llvm/include/llvm/TargetParser/ARMTargetParser.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,7 @@ ARM_CPU_NAME("cortex-m4", ARMV7EM, FK_FPV4_SP_D16, true, ARM::AEK_NONE)
342342
ARM_CPU_NAME("cortex-m7", ARMV7EM, FK_FPV5_D16, false, ARM::AEK_NONE)
343343
ARM_CPU_NAME("cortex-m23", ARMV8MBaseline, FK_NONE, false, ARM::AEK_NONE)
344344
ARM_CPU_NAME("cortex-m33", ARMV8MMainline, FK_FPV5_SP_D16, false, ARM::AEK_DSP)
345+
ARM_CPU_NAME("star-mc1", ARMV8MMainline, FK_FPV5_SP_D16, false, ARM::AEK_DSP)
345346
ARM_CPU_NAME("cortex-m35p", ARMV8MMainline, FK_FPV5_SP_D16, false, ARM::AEK_DSP)
346347
ARM_CPU_NAME("cortex-m55", ARMV8_1MMainline, FK_FP_ARMV8_FULLFP16_D16, false,
347348
(ARM::AEK_DSP | ARM::AEK_SIMD | ARM::AEK_FP | ARM::AEK_FP16))

llvm/lib/Target/ARM/ARMProcessors.td

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,16 @@ def : ProcessorModel<"cortex-m33", CortexM4Model, [ARMv8mMainline,
362362
FeatureHasNoBranchPredictor,
363363
FeatureFixCMSE_CVE_2021_35465]>;
364364

365+
def : ProcessorModel<"star-mc1", CortexM4Model, [ARMv8mMainline,
366+
FeatureDSP,
367+
FeatureFPARMv8_D16_SP,
368+
FeaturePreferBranchAlign32,
369+
FeatureHasSlowFPVMLx,
370+
FeatureHasSlowFPVFMx,
371+
FeatureUseMISched,
372+
FeatureHasNoBranchPredictor,
373+
FeatureFixCMSE_CVE_2021_35465]>;
374+
365375
def : ProcessorModel<"cortex-m35p", CortexM4Model, [ARMv8mMainline,
366376
FeatureDSP,
367377
FeatureFPARMv8_D16_SP,

llvm/lib/TargetParser/Host.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,12 @@ StringRef sys::detail::getHostCPUNameForARM(StringRef ProcCpuinfoContent) {
342342
}
343343
}
344344

345+
if (Implementer == "0x63") { // Arm China.
346+
return StringSwitch<const char *>(Part)
347+
.Case("0x132", "star-mc1")
348+
.Default("generic");
349+
}
350+
345351
if (Implementer == "0x6d") { // Microsoft Corporation.
346352
// The Microsoft Azure Cobalt 100 CPU is handled as a Neoverse N2.
347353
return StringSwitch<const char *>(Part)

llvm/test/CodeGen/ARM/cmse-cve-2021-35465.ll

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
; RUN: llc %s -o - -mtriple=thumbv8m.main -mcpu=cortex-m33 -verify-machineinstrs | \
88
; RUN: FileCheck %s --check-prefix=CHECK-8M-FP-CVE-2021-35465
99
;
10+
; RUN: llc %s -o - -mtriple=thumbv8m.main -mcpu=star-mc1 -verify-machineinstrs | \
11+
; RUN: FileCheck %s --check-prefix=CHECK-8M-FP-CVE-2021-35465
12+
;
1013
; RUN: llc %s -o - -mtriple=thumbv8m.main -mcpu=cortex-m35p -verify-machineinstrs | \
1114
; RUN: FileCheck %s --check-prefix=CHECK-8M-FP-CVE-2021-35465
1215
;
@@ -17,6 +20,9 @@
1720
; RUN: llc %s -o - -mtriple=thumbv8m.main -mcpu=cortex-m33 -mattr=-fpregs -verify-machineinstrs | \
1821
; RUN: FileCheck %s --check-prefix=CHECK-8M-NOFP-CVE-2021-35465
1922
;
23+
; RUN: llc %s -o - -mtriple=thumbv8m.main -mcpu=star-mc1 -mattr=-fpregs -verify-machineinstrs | \
24+
; RUN: FileCheck %s --check-prefix=CHECK-8M-NOFP-CVE-2021-35465
25+
;
2026
; RUN: llc %s -o - -mtriple=thumbv8m.main -mcpu=cortex-m35p -mattr=-fpregs -verify-machineinstrs | \
2127
; RUN: FileCheck %s --check-prefix=CHECK-8M-NOFP-CVE-2021-35465
2228
;

llvm/unittests/TargetParser/TargetParserTest.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,9 @@ INSTANTIATE_TEST_SUITE_P(
490490
ARMCPUTestParams<uint64_t>("cortex-m33", "armv8-m.main", "fpv5-sp-d16",
491491
ARM::AEK_HWDIVTHUMB | ARM::AEK_DSP,
492492
"8-M.Mainline"),
493+
ARMCPUTestParams<uint64_t>("star-mc1", "armv8-m.main", "fpv5-sp-d16",
494+
ARM::AEK_HWDIVTHUMB | ARM::AEK_DSP,
495+
"8-M.Mainline"),
493496
ARMCPUTestParams<uint64_t>("cortex-m35p", "armv8-m.main", "fpv5-sp-d16",
494497
ARM::AEK_HWDIVTHUMB | ARM::AEK_DSP,
495498
"8-M.Mainline"),
@@ -518,7 +521,7 @@ INSTANTIATE_TEST_SUITE_P(
518521
"7-S")),
519522
ARMCPUTestParams<uint64_t>::PrintToStringParamName);
520523

521-
static constexpr unsigned NumARMCPUArchs = 92;
524+
static constexpr unsigned NumARMCPUArchs = 93;
522525

523526
TEST(TargetParserTest, testARMCPUArchList) {
524527
SmallVector<StringRef, NumARMCPUArchs> List;

0 commit comments

Comments
 (0)