Skip to content

Commit 6605181

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

File tree

4 files changed

+35
-2
lines changed

4 files changed

+35
-2
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: 12 additions & 1 deletion
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 :
@@ -2598,7 +2599,14 @@ static void CollectArgsForIntegratedAssembler(Compilation &C,
25982599
CmdArgs.push_back("-soft-float");
25992600
continue;
26002601
}
2601-
2602+
if (Value == "-mmsa") {
2603+
Msa = true;
2604+
continue;
2605+
}
2606+
if (Value == "-mno-msa") {
2607+
Msa = false;
2608+
continue;
2609+
}
26022610
MipsTargetFeature = llvm::StringSwitch<const char *>(Value)
26032611
.Case("-mips1", "+mips1")
26042612
.Case("-mips2", "+mips2")
@@ -2618,6 +2626,7 @@ static void CollectArgsForIntegratedAssembler(Compilation &C,
26182626
.Default(nullptr);
26192627
if (MipsTargetFeature)
26202628
continue;
2629+
break;
26212630
}
26222631

26232632
if (Value == "-force_cpusubtype_ALL") {
@@ -2716,6 +2725,8 @@ static void CollectArgsForIntegratedAssembler(Compilation &C,
27162725
<< "-Wa,--crel" << D.getTargetTriple();
27172726
}
27182727
}
2728+
if (Msa && *Msa)
2729+
CmdArgs.push_back("-mmsa");
27192730
if (!UseRelaxRelocations)
27202731
CmdArgs.push_back("-mrelax-relocations=no");
27212732
if (UseNoExecStack)

clang/test/Driver/mips-msa.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
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"

0 commit comments

Comments
 (0)