summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-mc/llvm-mc.cpp
diff options
context:
space:
mode:
authorKevin Enderby <enderby@apple.com>2009-09-04 21:45:34 +0000
committerKevin Enderby <enderby@apple.com>2009-09-04 21:45:34 +0000
commitf92f9909c4e5943cc115b9662fb5540a2eb59984 (patch)
tree5b851cb38e1660ae42dd09d01c15910838c6de57 /llvm/tools/llvm-mc/llvm-mc.cpp
parenta33c5a922d76248d11fb4a5567561095664986de (diff)
downloadbcm5719-llvm-f92f9909c4e5943cc115b9662fb5540a2eb59984.tar.gz
bcm5719-llvm-f92f9909c4e5943cc115b9662fb5540a2eb59984.zip
Added the AsmToken::Hash enum constant to MCAsmLexer.h in preparation of
supporting other targets. Changed the code to pass MCAsmInfo to the parser and the lexer. Then changed the lexer to use CommentString from MCAsmInfo instead of a literal '#' character. llvm-svn: 81046
Diffstat (limited to 'llvm/tools/llvm-mc/llvm-mc.cpp')
-rw-r--r--llvm/tools/llvm-mc/llvm-mc.cpp41
1 files changed, 24 insertions, 17 deletions
diff --git a/llvm/tools/llvm-mc/llvm-mc.cpp b/llvm/tools/llvm-mc/llvm-mc.cpp
index 84131c7ca66..bf3c01794bc 100644
--- a/llvm/tools/llvm-mc/llvm-mc.cpp
+++ b/llvm/tools/llvm-mc/llvm-mc.cpp
@@ -82,6 +82,18 @@ Action(cl::desc("Action to perform:"),
"Assemble a .s file (default)"),
clEnumValEnd));
+static const Target *GetTarget(const char *ProgName) {
+ // Get the target specific parser.
+ std::string Error;
+ const Target *TheTarget = TargetRegistry::lookupTarget(TripleName, Error);
+ if (TheTarget)
+ return TheTarget;
+
+ errs() << ProgName << ": error: unable to get target for '" << TripleName
+ << "', see --version and --triple.\n";
+ return 0;
+}
+
static int AsLexInput(const char *ProgName) {
std::string ErrorMessage;
MemoryBuffer *Buffer = MemoryBuffer::getFileOrSTDIN(InputFilename,
@@ -104,7 +116,14 @@ static int AsLexInput(const char *ProgName) {
// it later.
SrcMgr.setIncludeDirs(IncludeDirs);
- AsmLexer Lexer(SrcMgr);
+ const Target *TheTarget = GetTarget(ProgName);
+ if (!TheTarget)
+ return 1;
+
+ const MCAsmInfo *MAI = TheTarget->createAsmInfo(TripleName);
+ assert(MAI && "Unable to create target asm info!");
+
+ AsmLexer Lexer(SrcMgr, *MAI);
bool Error = false;
@@ -162,18 +181,6 @@ static int AsLexInput(const char *ProgName) {
return Error;
}
-static const Target *GetTarget(const char *ProgName) {
- // Get the target specific parser.
- std::string Error;
- const Target *TheTarget = TargetRegistry::lookupTarget(TripleName, Error);
- if (TheTarget)
- return TheTarget;
-
- errs() << ProgName << ": error: unable to get target for '" << TripleName
- << "', see --version and --triple.\n";
- return 0;
-}
-
static formatted_raw_ostream *GetOutputStream() {
if (OutputFilename == "")
OutputFilename = "-";
@@ -239,10 +246,10 @@ static int AssembleInput(const char *ProgName) {
OwningPtr<MCCodeEmitter> CE;
OwningPtr<MCStreamer> Str;
- if (FileType == OFT_AssemblyFile) {
- const MCAsmInfo *MAI = TheTarget->createAsmInfo(TripleName);
- assert(MAI && "Unable to create target asm info!");
+ const MCAsmInfo *MAI = TheTarget->createAsmInfo(TripleName);
+ assert(MAI && "Unable to create target asm info!");
+ if (FileType == OFT_AssemblyFile) {
AP.reset(TheTarget->createAsmPrinter(*Out, *TM, MAI, true));
if (ShowEncoding)
CE.reset(TheTarget->createCodeEmitter(*TM));
@@ -253,7 +260,7 @@ static int AssembleInput(const char *ProgName) {
Str.reset(createMachOStreamer(Ctx, *Out, CE.get()));
}
- AsmParser Parser(SrcMgr, Ctx, *Str.get());
+ AsmParser Parser(SrcMgr, Ctx, *Str.get(), *MAI);
OwningPtr<TargetAsmParser> TAP(TheTarget->createAsmParser(Parser));
if (!TAP) {
errs() << ProgName
OpenPOWER on IntegriCloud