Skip to content

Commit 1ef0b65

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

File tree

6 files changed

+27
-2
lines changed

6 files changed

+27
-2
lines changed

clang/include/clang/Basic/CodeGenOptions.def

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,8 @@ 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(Msa , 1, 0) ///< Set when -Wa,-mmsa is enabled.
182+
CODEGENOPT(NoMsa , 1, 0) ///< Set when -Wa,-mno-msa is enabled.
181183
CODEGENOPT(FatalWarnings , 1, 0) ///< Set when -Wa,--fatal-warnings is
182184
///< enabled.
183185
CODEGENOPT(NoWarn , 1, 0) ///< Set when -Wa,--no-warn is enabled.

clang/include/clang/Driver/Options.td

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5337,9 +5337,13 @@ 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, CC1AsOption]>,
5341+
HelpText<"Enable MSA ASE (MIPS only)">,
5342+
MarshallingInfoFlag<CodeGenOpts<"Msa">>;
53415343
def mno_msa : Flag<["-"], "mno-msa">, Group<m_mips_Features_Group>,
5342-
HelpText<"Disable MSA ASE (MIPS only)">;
5344+
Visibility<[ClangOption, CC1AsOption]>,
5345+
HelpText<"Disable MSA ASE (MIPS only)">,
5346+
MarshallingInfoFlag<CodeGenOpts<"NoMsa">>;
53435347
def mmt : Flag<["-"], "mmt">, Group<m_mips_Features_Group>,
53445348
HelpText<"Enable MT ASE (MIPS only)">;
53455349
def mno_mt : Flag<["-"], "mno-mt">, Group<m_mips_Features_Group>,

clang/lib/CodeGen/BackendUtil.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,8 @@ static bool initTargetOptions(DiagnosticsEngine &Diags,
463463
? llvm::MCTargetOptions::DisableDwarfDirectory
464464
: llvm::MCTargetOptions::EnableDwarfDirectory;
465465
Options.MCOptions.MCNoExecStack = CodeGenOpts.NoExecStack;
466+
Options.MCOptions.MCMsa = CodeGenOpts.Msa;
467+
Options.MCOptions.MCNoMsa = CodeGenOpts.NoMsa;
466468
Options.MCOptions.MCIncrementalLinkerCompatible =
467469
CodeGenOpts.IncrementalLinkerCompatible;
468470
Options.MCOptions.MCFatalWarnings = CodeGenOpts.FatalWarnings;

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2630,6 +2630,10 @@ static void CollectArgsForIntegratedAssembler(Compilation &C,
26302630
CmdArgs.push_back("-massembler-no-warn");
26312631
} else if (Value == "--noexecstack") {
26322632
UseNoExecStack = true;
2633+
} else if (Value == "-mmsa") {
2634+
CmdArgs.push_back("-mmsa");
2635+
} else if (Value == "-mno-msa") {
2636+
CmdArgs.push_back("-mno-msa");
26332637
} else if (Value.starts_with("-compress-debug-sections") ||
26342638
Value.starts_with("--compress-debug-sections") ||
26352639
Value == "-nocompress-debug-sections" ||

clang/tools/driver/cc1as_main.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,10 @@ struct AssemblerInvocation {
168168

169169
LLVM_PREFERRED_TYPE(bool)
170170
unsigned Crel : 1;
171+
LLVM_PREFERRED_TYPE(bool)
172+
unsigned Msa : 1;
173+
LLVM_PREFERRED_TYPE(bool)
174+
unsigned NoMsa : 1;
171175

172176
/// The name of the relocation model to use.
173177
std::string RelocationModel;
@@ -211,6 +215,8 @@ struct AssemblerInvocation {
211215
EmitDwarfUnwind = EmitDwarfUnwindType::Default;
212216
EmitCompactUnwindNonCanonical = false;
213217
Crel = false;
218+
Msa = 0;
219+
NoMsa = 0;
214220
}
215221

216222
static bool CreateFromArgs(AssemblerInvocation &Res,
@@ -382,6 +388,8 @@ bool AssemblerInvocation::CreateFromArgs(AssemblerInvocation &Opts,
382388
Opts.EmitCompactUnwindNonCanonical =
383389
Args.hasArg(OPT_femit_compact_unwind_non_canonical);
384390
Opts.Crel = Args.hasArg(OPT_crel);
391+
Opts.Msa = Args.hasArg(OPT_mmsa);
392+
Opts.NoMsa = Args.hasArg(OPT_mno_msa);
385393

386394
Opts.AsSecureLogFile = Args.getLastArgValue(OPT_as_secure_log_file);
387395

@@ -444,6 +452,8 @@ static bool ExecuteAssemblerImpl(AssemblerInvocation &Opts,
444452
MCOptions.X86Sse2Avx = Opts.SSE2AVX;
445453
MCOptions.CompressDebugSections = Opts.CompressDebugSections;
446454
MCOptions.AsSecureLogFile = Opts.AsSecureLogFile;
455+
MCOptions.MCMsa = Opts.Msa;
456+
MCOptions.MCNoMsa = Opts.NoMsa;
447457

448458
std::unique_ptr<MCAsmInfo> MAI(
449459
TheTarget->createMCAsmInfo(*MRI, Opts.Triple, MCOptions));

llvm/include/llvm/MC/MCTargetOptions.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,9 @@ class MCTargetOptions {
107107
// Whether or not to use full register names on PowerPC.
108108
bool PPCUseFullRegisterNames : 1;
109109

110+
bool MCMsa : 1;
111+
bool MCNoMsa : 1;
112+
110113
MCTargetOptions();
111114

112115
/// getABIName - If this returns a non-empty string this represents the

0 commit comments

Comments
 (0)