Skip to content

Commit 9a0ad04

Browse files
committed
[clang] Support -Wa, options -mmsa and -mno-msa
1 parent c813667 commit 9a0ad04

File tree

4 files changed

+48
-1
lines changed

4 files changed

+48
-1
lines changed

clang/include/clang/Basic/CodeGenOptions.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ CODEGENOPT(MergeAllConstants , 1, 1) ///< Merge identical constants.
178178
CODEGENOPT(MergeFunctions , 1, 0) ///< Set when -fmerge-functions is enabled.
179179
CODEGENOPT(NoCommon , 1, 0) ///< Set when -fno-common or C++ is enabled.
180180
CODEGENOPT(NoExecStack , 1, 0) ///< Set when -Wa,--noexecstack is enabled.
181+
CODEGENOPT(MipsMsa , 1, 0) ///< Set when -Wa,-mmsa is enabled.
181182
CODEGENOPT(FatalWarnings , 1, 0) ///< Set when -Wa,--fatal-warnings is
182183
///< enabled.
183184
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
@@ -5337,7 +5337,9 @@ def mmadd4 : Flag<["-"], "mmadd4">, Group<m_mips_Features_Group>,
53375337
def mno_madd4 : Flag<["-"], "mno-madd4">, Group<m_mips_Features_Group>,
53385338
HelpText<"Disable the generation of 4-operand madd.s, madd.d and related instructions.">;
53395339
def mmsa : Flag<["-"], "mmsa">, Group<m_mips_Features_Group>,
5340-
HelpText<"Enable MSA ASE (MIPS only)">;
5340+
Visibility<[ClangOption, CC1Option, CC1AsOption]>,
5341+
HelpText<"Enable MSA ASE (MIPS only)">,
5342+
MarshallingInfoFlag<CodeGenOpts<"MipsMsa">>;
53415343
def mno_msa : Flag<["-"], "mno-msa">, Group<m_mips_Features_Group>,
53425344
HelpText<"Disable MSA ASE (MIPS only)">;
53435345
def mmt : Flag<["-"], "mmt">, Group<m_mips_Features_Group>,

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2507,6 +2507,7 @@ static void CollectArgsForIntegratedAssembler(Compilation &C,
25072507
bool Crel = false, ExperimentalCrel = false;
25082508
bool UseRelaxRelocations = C.getDefaultToolChain().useRelaxRelocations();
25092509
bool UseNoExecStack = false;
2510+
std::optional<bool> Msa;
25102511
const char *MipsTargetFeature = nullptr;
25112512
StringRef ImplicitIt;
25122513
for (const Arg *A :
@@ -2630,6 +2631,10 @@ static void CollectArgsForIntegratedAssembler(Compilation &C,
26302631
CmdArgs.push_back("-massembler-no-warn");
26312632
} else if (Value == "--noexecstack") {
26322633
UseNoExecStack = true;
2634+
} else if (Value == "-mmsa") {
2635+
Msa = true;
2636+
} else if (Value == "-mno-msa") {
2637+
Msa = false;
26332638
} else if (Value.starts_with("-compress-debug-sections") ||
26342639
Value.starts_with("--compress-debug-sections") ||
26352640
Value == "-nocompress-debug-sections" ||
@@ -2716,6 +2721,18 @@ static void CollectArgsForIntegratedAssembler(Compilation &C,
27162721
<< "-Wa,--crel" << D.getTargetTriple();
27172722
}
27182723
}
2724+
if (Msa) {
2725+
if (!Triple.isMIPS()) {
2726+
if (*Msa)
2727+
D.Diag(diag::err_drv_unsupported_opt_for_target)
2728+
<< "-Wa,-mmsa" << D.getTargetTriple();
2729+
else
2730+
D.Diag(diag::err_drv_unsupported_opt_for_target)
2731+
<< "-Wa,-mno-msa" << D.getTargetTriple();
2732+
} else if (*Msa) {
2733+
CmdArgs.push_back("-mmsa");
2734+
}
2735+
}
27192736
if (!UseRelaxRelocations)
27202737
CmdArgs.push_back("-mrelax-relocations=no");
27212738
if (UseNoExecStack)

clang/test/Driver/mips-msa.c

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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,-mno-msa,-mmsa %s -Werror 2>&1 | FileCheck %s --check-prefix=CHECK-MMSA
7+
8+
// RUN: %clang -### -c --target=mips64el-unknown-linux-gnuabi64 \
9+
// RUN: -Wa,-mmsa,-mno-msa %s -Werror 2>&1 | FileCheck %s --check-prefix=CHECK-NOMMSA
10+
// CHECK-NOMMSA: "-cc1"
11+
12+
// RUN: %clang -### -c --target=mips64el-unknown-linux-gnuabi64 \
13+
// RUN: -fno-integrated-as -Wa,-mmsa %s -Werror 2>&1 | FileCheck %s --check-prefix=MIPS-MSA
14+
// MIPS-MSA: as{{(.exe)?}}" "-march" "mips64r2" "-mabi" "64" "-EL" "-KPIC" "-mmsa"
15+
16+
// RUN: %clang -### -c --target=mips64el-unknown-linux-gnuabi64 \
17+
// RUN: -fno-integrated-as -Wa,-mno-msa %s -Werror 2>&1 | FileCheck %s --check-prefix=MIPS-NOMSA
18+
// MIPS-NOMSA: as{{(.exe)?}}"
19+
// MIPS-NOMSA-NOT: "-mmsa"
20+
21+
// RUN: not %clang -### -c --target=x86_64-unknown-linux-gnu \
22+
// RUN: -Wa,-mmsa %s -Werror 2>&1 | FileCheck %s --check-prefix=ERR-MSA
23+
// ERR-MSA: error: unsupported option '-Wa,-mmsa' for target '{{.*}}'
24+
25+
// RUN: not %clang -### -c --target=x86_64-unknown-linux-gnu \
26+
// RUN: -Wa,-mno-msa %s -Werror 2>&1 | FileCheck %s --check-prefix=ERR-NOMSA
27+
// ERR-NOMSA: error: unsupported option '-Wa,-mno-msa' for target '{{.*}}'

0 commit comments

Comments
 (0)