--- /dev/null
+//===-- TargetAsmParser.cpp - Target Assembly Parser -----------------------==//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/Target/TargetAsmParser.h"
+using namespace llvm;
+
+TargetAsmParser::TargetAsmParser(const Target &T)
+ : TheTarget(T)
+{
+}
+
+TargetAsmParser::~TargetAsmParser() {
+}
-# RUN: llvm-mc %s | FileCheck %s
+# RUN: llvm-mc -triple i386-unknown-unknown %s | FileCheck %s
# CHECK: TEST0:
# CHECK: a = 0
TEST0:
a = 0
-
\ No newline at end of file
+
-# RUN: llvm-mc %s | FileCheck %s
+# RUN: llvm-mc -triple i386-unknown-unknown %s | FileCheck %s
# CHECK: TEST0:
# CHECK: .abort "please stop assembing"
-# RUN: llvm-mc %s | FileCheck %s
+# RUN: llvm-mc -triple i386-unknown-unknown %s | FileCheck %s
# CHECK: TEST0:
# CHECK: .p2align 1, 0
-# RUN: llvm-mc %s | FileCheck %s
+# RUN: llvm-mc -triple i386-unknown-unknown %s | FileCheck %s
# CHECK: TEST0:
TEST0:
TEST3:
.asciz "B", "C"
-
\ No newline at end of file
+
-# RUN: llvm-mc %s | FileCheck %s
+# RUN: llvm-mc -triple i386-unknown-unknown %s | FileCheck %s
# CHECK: TEST0:
# CHECK: .comm a,6,2
-# RUN: llvm-mc %s | FileCheck %s
+# RUN: llvm-mc -triple i386-unknown-unknown %s | FileCheck %s
# CHECK: TEST0:
# CHECK: .desc foo,16
-# RUN: llvm-mc %s | FileCheck %s
+# RUN: llvm-mc -triple i386-unknown-unknown %s | FileCheck %s
# CHECK: TEST0:
# CHECK: .dump "somefile"
-# RUN: llvm-mc %s | FileCheck %s
+# RUN: llvm-mc -triple i386-unknown-unknown %s | FileCheck %s
# CHECK: TEST0:
# CHECK: .byte 10
-# RUN: llvm-mc %s -I %p | FileCheck %s
+# RUN: llvm-mc -triple i386-unknown-unknown %s -I %p | FileCheck %s
# CHECK: TESTA:
# CHECK: TEST0:
-# RUN: llvm-mc %s | FileCheck %s
+# RUN: llvm-mc -triple i386-unknown-unknown %s | FileCheck %s
# CHECK: TEST0:
# CHECK: .lcomm a,7,4
-# RUN: llvm-mc %s | FileCheck %s
+# RUN: llvm-mc -triple i386-unknown-unknown %s | FileCheck %s
# CHECK: TEST0:
# CHECK: .lsym bar,foo
-# RUN: llvm-mc %s | FileCheck %s
+# RUN: llvm-mc -triple i386-unknown-unknown %s | FileCheck %s
# CHECK: TEST0:
# CHECK: .org 1, 0
-# RUN: llvm-mc %s | FileCheck %s
+# RUN: llvm-mc -triple i386-unknown-unknown %s | FileCheck %s
# CHECK: TEST0:
# CHECK: .set a, 0
TEST0:
.set a, 0
-
\ No newline at end of file
+
-# RUN: llvm-mc %s | FileCheck %s
+# RUN: llvm-mc -triple i386-unknown-unknown %s | FileCheck %s
# CHECK: TEST0:
# CHECK: .byte 0
-# RUN: llvm-mc %s | FileCheck %s
+# RUN: llvm-mc -triple i386-unknown-unknown %s | FileCheck %s
# CHECK: TEST0:
# CHECK: .subsections_via_symbols
-# RUN: llvm-mc %s | FileCheck %s
+# RUN: llvm-mc -triple i386-unknown-unknown %s | FileCheck %s
# CHECK: TEST0:
# CHECK: .globl a
-# RUN: llvm-mc %s | FileCheck %s
+# RUN: llvm-mc -triple i386-unknown-unknown %s | FileCheck %s
# CHECK: TEST0:
# CHECK: .byte 0
-# RUN: llvm-mc %s | FileCheck %s
+# RUN: llvm-mc -triple i386-unknown-unknown %s | FileCheck %s
# CHECK: TEST0:
# CHECK: .zerofill __FOO,__bar,x,1
-// FIXME: For now this test just checks that llvm-mc works. Once we have .macro,
+// FIXME: For now this test just checks that llvm-mc -triple i386-unknown-unknown works. Once we have .macro,
// .if, and .abort we can write a better test (without resorting to miles of
// greps).
-// RUN: llvm-mc %s > %t
+// RUN: llvm-mc -triple i386-unknown-unknown %s > %t
.text
g:
n:
nop
-
\ No newline at end of file
+
// FIXME: Actually test that we get the expected results.
-// RUN: llvm-mc %s > %t
+// RUN: llvm-mc -triple i386-unknown-unknown %s > %t
# Immediates
push $1
-set(LLVM_LINK_COMPONENTS support MC)
+set(LLVM_LINK_COMPONENTS ${LLVM_TARGETS_TO_BUILD} support MC)
add_llvm_tool(llvm-mc
llvm-mc.cpp
LEVEL = ../..
TOOLNAME = llvm-mc
-LINK_COMPONENTS := support MC
# This tool has no plugins, optimize startup time.
TOOL_NO_EXPORTS = 1
-include $(LEVEL)/Makefile.common
+# Include this here so we can get the configuration of the targets
+# that have been configured for construction. We have to do this
+# early so we can set up LINK_COMPONENTS before including Makefile.rules
+include $(LEVEL)/Makefile.config
+
+LINK_COMPONENTS := $(TARGETS_TO_BUILD) MC support
+
+include $(LLVM_SRC_ROOT)/Makefile.rules
#include "llvm/Support/SourceMgr.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/System/Signals.h"
+#include "llvm/Target/TargetRegistry.h"
+#include "llvm/Target/TargetSelect.h"
#include "AsmParser.h"
using namespace llvm;
IncludeDirs("I", cl::desc("Directory of include files"),
cl::value_desc("directory"), cl::Prefix);
+static cl::opt<std::string>
+Triple("triple", cl::desc("Target triple to assemble for,"
+ "see -version for available targets"),
+ cl::init(""));
+
enum ActionType {
AC_AsLex,
AC_Assemble
}
static int AssembleInput(const char *ProgName) {
+ // Get the target specific parser.
+ std::string Error;
+ const Target *TheTarget =
+ TargetRegistry::getClosestStaticTargetForTriple(Triple, Error);
+ if (TheTarget == 0) {
+ errs() << ProgName << ": error: unable to get target for '" << Triple
+ << "', see --version and --triple.\n";
+ return 1;
+ }
+
+ TargetAsmParser *TAP = TheTarget->createAsmParser();
+ if (!TAP) {
+ errs() << ProgName
+ << ": error: this target does not support assembly parsing.\n";
+ return 1;
+ }
+
std::string ErrorMessage;
MemoryBuffer *Buffer = MemoryBuffer::getFileOrSTDIN(InputFilename,
&ErrorMessage);
sys::PrintStackTraceOnErrorSignal();
PrettyStackTraceProgram X(argc, argv);
llvm_shutdown_obj Y; // Call llvm_shutdown() on exit.
+
+ // Initialize targets and assembly parsers.
+ llvm::InitializeAllTargetInfos();
+ llvm::InitializeAllAsmParsers();
+
cl::ParseCommandLineOptions(argc, argv, "llvm machine code playground\n");
switch (Action) {