[llvm-commits] [llvm] r117788 - /llvm/trunk/tools/llvm-mc/llvm-mc.cpp
Jim Grosbach
grosbach at apple.com
Sat Oct 30 08:57:50 PDT 2010
Author: grosbach
Date: Sat Oct 30 10:57:50 2010
New Revision: 117788
URL: http://llvm.org/viewvc/llvm-project?rev=117788&view=rev
Log:
Allow specifying a CPU to llvm-mc, so that we can properly set up subtarget
feature lists for instruction pattern predicates.
Modified:
llvm/trunk/tools/llvm-mc/llvm-mc.cpp
Modified: llvm/trunk/tools/llvm-mc/llvm-mc.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-mc/llvm-mc.cpp?rev=117788&r1=117787&r2=117788&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-mc/llvm-mc.cpp (original)
+++ llvm/trunk/tools/llvm-mc/llvm-mc.cpp Sat Oct 30 10:57:50 2010
@@ -23,6 +23,7 @@
#include "llvm/Target/TargetAsmParser.h"
#include "llvm/Target/TargetData.h"
#include "llvm/Target/TargetRegistry.h"
+#include "llvm/Target/SubtargetFeature.h" // FIXME.
#include "llvm/Target/TargetMachine.h" // FIXME.
#include "llvm/Target/TargetSelect.h"
#include "llvm/ADT/OwningPtr.h"
@@ -95,6 +96,12 @@
TripleName("triple", cl::desc("Target triple to assemble for, "
"see -version for available targets"));
+static cl::opt<std::string>
+MCPU("mcpu",
+ cl::desc("Target a specific cpu type (-mcpu=help for details)"),
+ cl::value_desc("cpu-name"),
+ cl::init(""));
+
static cl::opt<bool>
NoInitialTextSection("n", cl::desc(
"Don't assume assembly file starts in the text section"));
@@ -301,8 +308,20 @@
MCContext Ctx(*MAI);
+ // Package up features to be passed to target/subtarget
+ std::string FeaturesStr;
+ if (MCPU.size()) {
+ SubtargetFeatures Features;
+ Features.setCPU(MCPU);
+ FeaturesStr = Features.getString();
+ }
+
// FIXME: We shouldn't need to do this (and link in codegen).
- OwningPtr<TargetMachine> TM(TheTarget->createTargetMachine(TripleName, ""));
+ // When we split this out, we should do it in a way that makes
+ // it straightforward to switch subtargets on the fly (.e.g,
+ // the .cpu and .code16 directives).
+ OwningPtr<TargetMachine> TM(TheTarget->createTargetMachine(TripleName,
+ FeaturesStr));
if (!TM) {
errs() << ProgName << ": error: could not create target for triple '"
More information about the llvm-commits
mailing list