[llvm-commits] [llvm] r76257 - in /llvm/trunk: lib/MC/ test/MC/AsmParser/ tools/llvm-mc/
Daniel Dunbar
daniel at zuster.org
Fri Jul 17 15:38:59 PDT 2009
Author: ddunbar
Date: Fri Jul 17 17:38:58 2009
New Revision: 76257
URL: http://llvm.org/viewvc/llvm-project?rev=76257&view=rev
Log:
llvm-mc: Add -triple, and start fetching the target asm printer.
Added:
llvm/trunk/lib/MC/TargetAsmParser.cpp
Modified:
llvm/trunk/test/MC/AsmParser/assignment.s
llvm/trunk/test/MC/AsmParser/directive_abort.s
llvm/trunk/test/MC/AsmParser/directive_align.s
llvm/trunk/test/MC/AsmParser/directive_ascii.s
llvm/trunk/test/MC/AsmParser/directive_comm.s
llvm/trunk/test/MC/AsmParser/directive_desc.s
llvm/trunk/test/MC/AsmParser/directive_dump_and_load.s
llvm/trunk/test/MC/AsmParser/directive_fill.s
llvm/trunk/test/MC/AsmParser/directive_include.s
llvm/trunk/test/MC/AsmParser/directive_lcomm.s
llvm/trunk/test/MC/AsmParser/directive_lsym.s
llvm/trunk/test/MC/AsmParser/directive_org.s
llvm/trunk/test/MC/AsmParser/directive_set.s
llvm/trunk/test/MC/AsmParser/directive_space.s
llvm/trunk/test/MC/AsmParser/directive_subsections_via_symbols.s
llvm/trunk/test/MC/AsmParser/directive_symbol_attrs.s
llvm/trunk/test/MC/AsmParser/directive_values.s
llvm/trunk/test/MC/AsmParser/directive_zerofill.s
llvm/trunk/test/MC/AsmParser/exprs.s
llvm/trunk/test/MC/AsmParser/x86_operands.s
llvm/trunk/tools/llvm-mc/CMakeLists.txt
llvm/trunk/tools/llvm-mc/Makefile
llvm/trunk/tools/llvm-mc/llvm-mc.cpp
Added: llvm/trunk/lib/MC/TargetAsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/TargetAsmParser.cpp?rev=76257&view=auto
==============================================================================
--- llvm/trunk/lib/MC/TargetAsmParser.cpp (added)
+++ llvm/trunk/lib/MC/TargetAsmParser.cpp Fri Jul 17 17:38:58 2009
@@ -0,0 +1,19 @@
+//===-- 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() {
+}
Modified: llvm/trunk/test/MC/AsmParser/assignment.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/AsmParser/assignment.s?rev=76257&r1=76256&r2=76257&view=diff
==============================================================================
--- llvm/trunk/test/MC/AsmParser/assignment.s (original)
+++ llvm/trunk/test/MC/AsmParser/assignment.s Fri Jul 17 17:38:58 2009
@@ -1,7 +1,7 @@
-# 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
+
Modified: llvm/trunk/test/MC/AsmParser/directive_abort.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/AsmParser/directive_abort.s?rev=76257&r1=76256&r2=76257&view=diff
==============================================================================
--- llvm/trunk/test/MC/AsmParser/directive_abort.s (original)
+++ llvm/trunk/test/MC/AsmParser/directive_abort.s Fri Jul 17 17:38:58 2009
@@ -1,4 +1,4 @@
-# RUN: llvm-mc %s | FileCheck %s
+# RUN: llvm-mc -triple i386-unknown-unknown %s | FileCheck %s
# CHECK: TEST0:
# CHECK: .abort "please stop assembing"
Modified: llvm/trunk/test/MC/AsmParser/directive_align.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/AsmParser/directive_align.s?rev=76257&r1=76256&r2=76257&view=diff
==============================================================================
--- llvm/trunk/test/MC/AsmParser/directive_align.s (original)
+++ llvm/trunk/test/MC/AsmParser/directive_align.s Fri Jul 17 17:38:58 2009
@@ -1,4 +1,4 @@
-# RUN: llvm-mc %s | FileCheck %s
+# RUN: llvm-mc -triple i386-unknown-unknown %s | FileCheck %s
# CHECK: TEST0:
# CHECK: .p2align 1, 0
Modified: llvm/trunk/test/MC/AsmParser/directive_ascii.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/AsmParser/directive_ascii.s?rev=76257&r1=76256&r2=76257&view=diff
==============================================================================
--- llvm/trunk/test/MC/AsmParser/directive_ascii.s (original)
+++ llvm/trunk/test/MC/AsmParser/directive_ascii.s Fri Jul 17 17:38:58 2009
@@ -1,4 +1,4 @@
-# RUN: llvm-mc %s | FileCheck %s
+# RUN: llvm-mc -triple i386-unknown-unknown %s | FileCheck %s
# CHECK: TEST0:
TEST0:
@@ -21,4 +21,4 @@
TEST3:
.asciz "B", "C"
-
\ No newline at end of file
+
Modified: llvm/trunk/test/MC/AsmParser/directive_comm.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/AsmParser/directive_comm.s?rev=76257&r1=76256&r2=76257&view=diff
==============================================================================
--- llvm/trunk/test/MC/AsmParser/directive_comm.s (original)
+++ llvm/trunk/test/MC/AsmParser/directive_comm.s Fri Jul 17 17:38:58 2009
@@ -1,4 +1,4 @@
-# RUN: llvm-mc %s | FileCheck %s
+# RUN: llvm-mc -triple i386-unknown-unknown %s | FileCheck %s
# CHECK: TEST0:
# CHECK: .comm a,6,2
Modified: llvm/trunk/test/MC/AsmParser/directive_desc.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/AsmParser/directive_desc.s?rev=76257&r1=76256&r2=76257&view=diff
==============================================================================
--- llvm/trunk/test/MC/AsmParser/directive_desc.s (original)
+++ llvm/trunk/test/MC/AsmParser/directive_desc.s Fri Jul 17 17:38:58 2009
@@ -1,4 +1,4 @@
-# RUN: llvm-mc %s | FileCheck %s
+# RUN: llvm-mc -triple i386-unknown-unknown %s | FileCheck %s
# CHECK: TEST0:
# CHECK: .desc foo,16
Modified: llvm/trunk/test/MC/AsmParser/directive_dump_and_load.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/AsmParser/directive_dump_and_load.s?rev=76257&r1=76256&r2=76257&view=diff
==============================================================================
--- llvm/trunk/test/MC/AsmParser/directive_dump_and_load.s (original)
+++ llvm/trunk/test/MC/AsmParser/directive_dump_and_load.s Fri Jul 17 17:38:58 2009
@@ -1,4 +1,4 @@
-# RUN: llvm-mc %s | FileCheck %s
+# RUN: llvm-mc -triple i386-unknown-unknown %s | FileCheck %s
# CHECK: TEST0:
# CHECK: .dump "somefile"
Modified: llvm/trunk/test/MC/AsmParser/directive_fill.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/AsmParser/directive_fill.s?rev=76257&r1=76256&r2=76257&view=diff
==============================================================================
--- llvm/trunk/test/MC/AsmParser/directive_fill.s (original)
+++ llvm/trunk/test/MC/AsmParser/directive_fill.s Fri Jul 17 17:38:58 2009
@@ -1,4 +1,4 @@
-# RUN: llvm-mc %s | FileCheck %s
+# RUN: llvm-mc -triple i386-unknown-unknown %s | FileCheck %s
# CHECK: TEST0:
# CHECK: .byte 10
Modified: llvm/trunk/test/MC/AsmParser/directive_include.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/AsmParser/directive_include.s?rev=76257&r1=76256&r2=76257&view=diff
==============================================================================
--- llvm/trunk/test/MC/AsmParser/directive_include.s (original)
+++ llvm/trunk/test/MC/AsmParser/directive_include.s Fri Jul 17 17:38:58 2009
@@ -1,4 +1,4 @@
-# RUN: llvm-mc %s -I %p | FileCheck %s
+# RUN: llvm-mc -triple i386-unknown-unknown %s -I %p | FileCheck %s
# CHECK: TESTA:
# CHECK: TEST0:
Modified: llvm/trunk/test/MC/AsmParser/directive_lcomm.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/AsmParser/directive_lcomm.s?rev=76257&r1=76256&r2=76257&view=diff
==============================================================================
--- llvm/trunk/test/MC/AsmParser/directive_lcomm.s (original)
+++ llvm/trunk/test/MC/AsmParser/directive_lcomm.s Fri Jul 17 17:38:58 2009
@@ -1,4 +1,4 @@
-# RUN: llvm-mc %s | FileCheck %s
+# RUN: llvm-mc -triple i386-unknown-unknown %s | FileCheck %s
# CHECK: TEST0:
# CHECK: .lcomm a,7,4
Modified: llvm/trunk/test/MC/AsmParser/directive_lsym.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/AsmParser/directive_lsym.s?rev=76257&r1=76256&r2=76257&view=diff
==============================================================================
--- llvm/trunk/test/MC/AsmParser/directive_lsym.s (original)
+++ llvm/trunk/test/MC/AsmParser/directive_lsym.s Fri Jul 17 17:38:58 2009
@@ -1,4 +1,4 @@
-# RUN: llvm-mc %s | FileCheck %s
+# RUN: llvm-mc -triple i386-unknown-unknown %s | FileCheck %s
# CHECK: TEST0:
# CHECK: .lsym bar,foo
Modified: llvm/trunk/test/MC/AsmParser/directive_org.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/AsmParser/directive_org.s?rev=76257&r1=76256&r2=76257&view=diff
==============================================================================
--- llvm/trunk/test/MC/AsmParser/directive_org.s (original)
+++ llvm/trunk/test/MC/AsmParser/directive_org.s Fri Jul 17 17:38:58 2009
@@ -1,4 +1,4 @@
-# RUN: llvm-mc %s | FileCheck %s
+# RUN: llvm-mc -triple i386-unknown-unknown %s | FileCheck %s
# CHECK: TEST0:
# CHECK: .org 1, 0
Modified: llvm/trunk/test/MC/AsmParser/directive_set.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/AsmParser/directive_set.s?rev=76257&r1=76256&r2=76257&view=diff
==============================================================================
--- llvm/trunk/test/MC/AsmParser/directive_set.s (original)
+++ llvm/trunk/test/MC/AsmParser/directive_set.s Fri Jul 17 17:38:58 2009
@@ -1,7 +1,7 @@
-# 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
+
Modified: llvm/trunk/test/MC/AsmParser/directive_space.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/AsmParser/directive_space.s?rev=76257&r1=76256&r2=76257&view=diff
==============================================================================
--- llvm/trunk/test/MC/AsmParser/directive_space.s (original)
+++ llvm/trunk/test/MC/AsmParser/directive_space.s Fri Jul 17 17:38:58 2009
@@ -1,4 +1,4 @@
-# RUN: llvm-mc %s | FileCheck %s
+# RUN: llvm-mc -triple i386-unknown-unknown %s | FileCheck %s
# CHECK: TEST0:
# CHECK: .byte 0
Modified: llvm/trunk/test/MC/AsmParser/directive_subsections_via_symbols.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/AsmParser/directive_subsections_via_symbols.s?rev=76257&r1=76256&r2=76257&view=diff
==============================================================================
--- llvm/trunk/test/MC/AsmParser/directive_subsections_via_symbols.s (original)
+++ llvm/trunk/test/MC/AsmParser/directive_subsections_via_symbols.s Fri Jul 17 17:38:58 2009
@@ -1,4 +1,4 @@
-# RUN: llvm-mc %s | FileCheck %s
+# RUN: llvm-mc -triple i386-unknown-unknown %s | FileCheck %s
# CHECK: TEST0:
# CHECK: .subsections_via_symbols
Modified: llvm/trunk/test/MC/AsmParser/directive_symbol_attrs.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/AsmParser/directive_symbol_attrs.s?rev=76257&r1=76256&r2=76257&view=diff
==============================================================================
--- llvm/trunk/test/MC/AsmParser/directive_symbol_attrs.s (original)
+++ llvm/trunk/test/MC/AsmParser/directive_symbol_attrs.s Fri Jul 17 17:38:58 2009
@@ -1,4 +1,4 @@
-# RUN: llvm-mc %s | FileCheck %s
+# RUN: llvm-mc -triple i386-unknown-unknown %s | FileCheck %s
# CHECK: TEST0:
# CHECK: .globl a
Modified: llvm/trunk/test/MC/AsmParser/directive_values.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/AsmParser/directive_values.s?rev=76257&r1=76256&r2=76257&view=diff
==============================================================================
--- llvm/trunk/test/MC/AsmParser/directive_values.s (original)
+++ llvm/trunk/test/MC/AsmParser/directive_values.s Fri Jul 17 17:38:58 2009
@@ -1,4 +1,4 @@
-# RUN: llvm-mc %s | FileCheck %s
+# RUN: llvm-mc -triple i386-unknown-unknown %s | FileCheck %s
# CHECK: TEST0:
# CHECK: .byte 0
Modified: llvm/trunk/test/MC/AsmParser/directive_zerofill.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/AsmParser/directive_zerofill.s?rev=76257&r1=76256&r2=76257&view=diff
==============================================================================
--- llvm/trunk/test/MC/AsmParser/directive_zerofill.s (original)
+++ llvm/trunk/test/MC/AsmParser/directive_zerofill.s Fri Jul 17 17:38:58 2009
@@ -1,4 +1,4 @@
-# RUN: llvm-mc %s | FileCheck %s
+# RUN: llvm-mc -triple i386-unknown-unknown %s | FileCheck %s
# CHECK: TEST0:
# CHECK: .zerofill __FOO,__bar,x,1
Modified: llvm/trunk/test/MC/AsmParser/exprs.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/AsmParser/exprs.s?rev=76257&r1=76256&r2=76257&view=diff
==============================================================================
--- llvm/trunk/test/MC/AsmParser/exprs.s (original)
+++ llvm/trunk/test/MC/AsmParser/exprs.s Fri Jul 17 17:38:58 2009
@@ -1,8 +1,8 @@
-// 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:
@@ -59,4 +59,4 @@
n:
nop
-
\ No newline at end of file
+
Modified: llvm/trunk/test/MC/AsmParser/x86_operands.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/AsmParser/x86_operands.s?rev=76257&r1=76256&r2=76257&view=diff
==============================================================================
--- llvm/trunk/test/MC/AsmParser/x86_operands.s (original)
+++ llvm/trunk/test/MC/AsmParser/x86_operands.s Fri Jul 17 17:38:58 2009
@@ -1,6 +1,6 @@
// 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
Modified: llvm/trunk/tools/llvm-mc/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-mc/CMakeLists.txt?rev=76257&r1=76256&r2=76257&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-mc/CMakeLists.txt (original)
+++ llvm/trunk/tools/llvm-mc/CMakeLists.txt Fri Jul 17 17:38:58 2009
@@ -1,4 +1,4 @@
-set(LLVM_LINK_COMPONENTS support MC)
+set(LLVM_LINK_COMPONENTS ${LLVM_TARGETS_TO_BUILD} support MC)
add_llvm_tool(llvm-mc
llvm-mc.cpp
Modified: llvm/trunk/tools/llvm-mc/Makefile
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-mc/Makefile?rev=76257&r1=76256&r2=76257&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-mc/Makefile (original)
+++ llvm/trunk/tools/llvm-mc/Makefile Fri Jul 17 17:38:58 2009
@@ -9,9 +9,15 @@
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
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=76257&r1=76256&r2=76257&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-mc/llvm-mc.cpp (original)
+++ llvm/trunk/tools/llvm-mc/llvm-mc.cpp Fri Jul 17 17:38:58 2009
@@ -22,6 +22,8 @@
#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;
@@ -36,6 +38,11 @@
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
@@ -137,6 +144,23 @@
}
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);
@@ -174,6 +198,11 @@
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) {
More information about the llvm-commits
mailing list