Skip to content

Commit 26ae316

Browse files
yingopqMaskRay
andauthored
[clang] Support -Wa, options -mmsa and -mno-msa (#99615)
Co-authored-by: Fangrui Song <[email protected]>
1 parent 33e18b2 commit 26ae316

File tree

4 files changed

+28
-2
lines changed

4 files changed

+28
-2
lines changed

clang/include/clang/Basic/CodeGenOptions.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ CODEGENOPT(MergeAllConstants , 1, 1) ///< Merge identical constants.
176176
CODEGENOPT(MergeFunctions , 1, 0) ///< Set when -fmerge-functions is enabled.
177177
CODEGENOPT(NoCommon , 1, 0) ///< Set when -fno-common or C++ is enabled.
178178
CODEGENOPT(NoExecStack , 1, 0) ///< Set when -Wa,--noexecstack is enabled.
179+
CODEGENOPT(MipsMsa , 1, 0) ///< Set when -Wa,-mmsa is enabled.
179180
CODEGENOPT(FatalWarnings , 1, 0) ///< Set when -Wa,--fatal-warnings is
180181
///< enabled.
181182
CODEGENOPT(NoWarn , 1, 0) ///< Set when -Wa,--no-warn is enabled.

clang/include/clang/Driver/Options.td

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5383,7 +5383,9 @@ def mmadd4 : Flag<["-"], "mmadd4">, Group<m_mips_Features_Group>,
53835383
def mno_madd4 : Flag<["-"], "mno-madd4">, Group<m_mips_Features_Group>,
53845384
HelpText<"Disable the generation of 4-operand madd.s, madd.d and related instructions.">;
53855385
def mmsa : Flag<["-"], "mmsa">, Group<m_mips_Features_Group>,
5386-
HelpText<"Enable MSA ASE (MIPS only)">;
5386+
Visibility<[ClangOption, CC1Option, CC1AsOption]>,
5387+
HelpText<"Enable MSA ASE (MIPS only)">,
5388+
MarshallingInfoFlag<CodeGenOpts<"MipsMsa">>;
53875389
def mno_msa : Flag<["-"], "mno-msa">, Group<m_mips_Features_Group>,
53885390
HelpText<"Disable MSA ASE (MIPS only)">;
53895391
def mmt : Flag<["-"], "mmt">, Group<m_mips_Features_Group>,

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2556,6 +2556,7 @@ static void CollectArgsForIntegratedAssembler(Compilation &C,
25562556
bool Crel = false, ExperimentalCrel = false;
25572557
bool UseRelaxRelocations = C.getDefaultToolChain().useRelaxRelocations();
25582558
bool UseNoExecStack = false;
2559+
bool Msa = false;
25592560
const char *MipsTargetFeature = nullptr;
25602561
StringRef ImplicitIt;
25612562
for (const Arg *A :
@@ -2665,7 +2666,14 @@ static void CollectArgsForIntegratedAssembler(Compilation &C,
26652666
CmdArgs.push_back("-soft-float");
26662667
continue;
26672668
}
2668-
2669+
if (Value == "-mmsa") {
2670+
Msa = true;
2671+
continue;
2672+
}
2673+
if (Value == "-mno-msa") {
2674+
Msa = false;
2675+
continue;
2676+
}
26692677
MipsTargetFeature = llvm::StringSwitch<const char *>(Value)
26702678
.Case("-mips1", "+mips1")
26712679
.Case("-mips2", "+mips2")
@@ -2685,6 +2693,7 @@ static void CollectArgsForIntegratedAssembler(Compilation &C,
26852693
.Default(nullptr);
26862694
if (MipsTargetFeature)
26872695
continue;
2696+
break;
26882697
}
26892698

26902699
if (Value == "-force_cpusubtype_ALL") {
@@ -2777,6 +2786,8 @@ static void CollectArgsForIntegratedAssembler(Compilation &C,
27772786
<< "-Wa,--crel" << D.getTargetTriple();
27782787
}
27792788
}
2789+
if (Msa)
2790+
CmdArgs.push_back("-mmsa");
27802791
if (!UseRelaxRelocations)
27812792
CmdArgs.push_back("-mrelax-relocations=no");
27822793
if (UseNoExecStack)

clang/test/Driver/mips-msa.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// RUN: %clang -### -c --target=mips64el-unknown-linux-gnuabi64 \
2+
// RUN: -Wa,-mmsa %s -Werror 2>&1 | FileCheck %s --check-prefix=CHECK-MMSA
3+
// CHECK-MMSA: "-cc1" {{.*}}"-mmsa"
4+
5+
// RUN: %clang -### -c --target=mips64el-unknown-linux-gnuabi64 \
6+
// RUN: -Wa,-mmsa,-mno-msa %s -Werror 2>&1 | FileCheck %s --check-prefix=CHECK-NOMMSA
7+
// CHECK-NOMMSA: "-cc1"
8+
// CHECK-NOMMSA-NOT: "-mssa"
9+
10+
// RUN: not %clang -### -c --target=x86_64 -Wa,-mmsa -Wa,-mno-msa %s 2>&1 | FileCheck %s --check-prefix=ERR
11+
// ERR: error: unsupported argument '-mmsa' to option '-Wa,'
12+
// ERR: error: unsupported argument '-mno-msa' to option '-Wa,'

0 commit comments

Comments
 (0)