diff options
author | Jim Grosbach <grosbach@apple.com> | 2012-02-10 20:37:10 +0000 |
---|---|---|
committer | Jim Grosbach <grosbach@apple.com> | 2012-02-10 20:37:10 +0000 |
commit | fc30829694e62040c14f329f5491724fe7476241 (patch) | |
tree | c8368e7940cfd63d519f4dfe3c497ec97260d643 /tools/driver/cc1as_main.cpp | |
parent | 911d717307e0d90980699cf75204c22e4462b45d (diff) |
Have the driver pass CPU and target feature information to cc1as.
When creating the MCSubtargetInfo, the assembler driver uses the CPU and
feature string to construct a more accurate model of what instructions
are and are not legal.
rdar://10840476
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150273 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/driver/cc1as_main.cpp')
-rw-r--r-- | tools/driver/cc1as_main.cpp | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/tools/driver/cc1as_main.cpp b/tools/driver/cc1as_main.cpp index 84aeced411..fc8c5dca99 100644 --- a/tools/driver/cc1as_main.cpp +++ b/tools/driver/cc1as_main.cpp @@ -63,8 +63,17 @@ struct AssemblerInvocation { /// @name Target Options /// @{ + /// The name of the target triple to assemble for. std::string Triple; + /// If given, the name of the target CPU to determine which instructions + /// are legal. + std::string CPU; + + /// The list of target specific features to enable or disable -- this should + /// be a list of strings starting with '+' or '-'. + std::vector<std::string> Features; + /// @} /// @name Language Options /// @{ @@ -158,9 +167,13 @@ bool AssemblerInvocation::CreateFromArgs(AssemblerInvocation &Opts, // Construct the invocation. // Target Options - Opts.Triple = Triple::normalize(Args->getLastArgValue(OPT_triple)); - if (Opts.Triple.empty()) // Use the default target triple if unspecified. - Opts.Triple = sys::getDefaultTargetTriple(); + Opts.Triple = llvm::Triple::normalize(Args->getLastArgValue(OPT_triple)); + Opts.CPU = Args->getLastArgValue(OPT_target_cpu); + Opts.Features = Args->getAllArgValues(OPT_target_feature); + + // Use the default target triple if unspecified. + if (Opts.Triple.empty()) + Opts.Triple = llvm::sys::getDefaultTargetTriple(); // Language Options Opts.IncludePaths = Args->getAllArgValues(OPT_I); @@ -293,11 +306,19 @@ static bool ExecuteAssembler(AssemblerInvocation &Opts, if (!Opts.DwarfDebugFlags.empty()) Ctx.setDwarfDebugFlags(StringRef(Opts.DwarfDebugFlags)); + // Build up the feature string from the target feature list. + std::string FS; + if (!Opts.Features.empty()) { + FS = Opts.Features[0]; + for (unsigned i = 1, e = Opts.Features.size(); i != e; ++i) + FS += "," + Opts.Features[i]; + } + OwningPtr<MCStreamer> Str; OwningPtr<MCInstrInfo> MCII(TheTarget->createMCInstrInfo()); OwningPtr<MCSubtargetInfo> - STI(TheTarget->createMCSubtargetInfo(Opts.Triple, "", "")); + STI(TheTarget->createMCSubtargetInfo(Opts.Triple, Opts.CPU, FS)); // FIXME: There is a bit of code duplication with addPassesToEmitFile. if (Opts.OutputType == AssemblerInvocation::FT_Asm) { |