Skip to content

Commit f8a34c8

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

File tree

5 files changed

+43
-1
lines changed

5 files changed

+43
-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/Basic/DiagnosticDriverKinds.td

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -827,4 +827,7 @@ def err_drv_triple_version_invalid : Error<
827827

828828
def warn_missing_include_dirs : Warning<
829829
"no such include directory: '%0'">, InGroup<MissingIncludeDirs>, DefaultIgnore;
830+
831+
def err_drv_msa_and_nomsa : Error<
832+
"-Wa,-mmsa,-mno-msa is meaningless">;
830833
}

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: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2507,6 +2507,8 @@ static void CollectArgsForIntegratedAssembler(Compilation &C,
25072507
bool Crel = false, ExperimentalCrel = false;
25082508
bool UseRelaxRelocations = C.getDefaultToolChain().useRelaxRelocations();
25092509
bool UseNoExecStack = false;
2510+
bool Msa = false;
2511+
bool NoMsa = false;
25102512
const char *MipsTargetFeature = nullptr;
25112513
StringRef ImplicitIt;
25122514
for (const Arg *A :
@@ -2630,6 +2632,10 @@ static void CollectArgsForIntegratedAssembler(Compilation &C,
26302632
CmdArgs.push_back("-massembler-no-warn");
26312633
} else if (Value == "--noexecstack") {
26322634
UseNoExecStack = true;
2635+
} else if (Value == "-mmsa") {
2636+
Msa = true;
2637+
} else if (Value == "-mno-msa") {
2638+
NoMsa = true;
26332639
} else if (Value.starts_with("-compress-debug-sections") ||
26342640
Value.starts_with("--compress-debug-sections") ||
26352641
Value == "-nocompress-debug-sections" ||
@@ -2716,6 +2722,16 @@ static void CollectArgsForIntegratedAssembler(Compilation &C,
27162722
<< "-Wa,--crel" << D.getTargetTriple();
27172723
}
27182724
}
2725+
if (Msa) {
2726+
if (NoMsa)
2727+
D.Diag(diag::err_drv_msa_and_nomsa);
2728+
else if (Triple.isMIPS())
2729+
CmdArgs.push_back("-mmsa");
2730+
else {
2731+
D.Diag(diag::err_drv_unsupported_opt_for_target)
2732+
<< "-Wa,-mmsa" << D.getTargetTriple();
2733+
}
2734+
}
27192735
if (!UseRelaxRelocations)
27202736
CmdArgs.push_back("-mrelax-relocations=no");
27212737
if (UseNoExecStack)

clang/test/Driver/mips-msa.c

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

0 commit comments

Comments
 (0)