mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-12-04 01:11:44 +00:00
llvm-mc: Add -triple, and start fetching the target asm printer.
llvm-svn: 76257
This commit is contained in:
parent
ec0fd7ebe5
commit
ab1316fbaf
19
lib/MC/TargetAsmParser.cpp
Normal file
19
lib/MC/TargetAsmParser.cpp
Normal file
@ -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() {
|
||||||
|
}
|
@ -1,7 +1,7 @@
|
|||||||
# RUN: llvm-mc %s | FileCheck %s
|
# RUN: llvm-mc -triple i386-unknown-unknown %s | FileCheck %s
|
||||||
|
|
||||||
# CHECK: TEST0:
|
# CHECK: TEST0:
|
||||||
# CHECK: a = 0
|
# CHECK: a = 0
|
||||||
TEST0:
|
TEST0:
|
||||||
a = 0
|
a = 0
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# RUN: llvm-mc %s | FileCheck %s
|
# RUN: llvm-mc -triple i386-unknown-unknown %s | FileCheck %s
|
||||||
|
|
||||||
# CHECK: TEST0:
|
# CHECK: TEST0:
|
||||||
# CHECK: .abort "please stop assembing"
|
# CHECK: .abort "please stop assembing"
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# RUN: llvm-mc %s | FileCheck %s
|
# RUN: llvm-mc -triple i386-unknown-unknown %s | FileCheck %s
|
||||||
|
|
||||||
# CHECK: TEST0:
|
# CHECK: TEST0:
|
||||||
# CHECK: .p2align 1, 0
|
# CHECK: .p2align 1, 0
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# RUN: llvm-mc %s | FileCheck %s
|
# RUN: llvm-mc -triple i386-unknown-unknown %s | FileCheck %s
|
||||||
|
|
||||||
# CHECK: TEST0:
|
# CHECK: TEST0:
|
||||||
TEST0:
|
TEST0:
|
||||||
@ -21,4 +21,4 @@ TEST2:
|
|||||||
TEST3:
|
TEST3:
|
||||||
.asciz "B", "C"
|
.asciz "B", "C"
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# RUN: llvm-mc %s | FileCheck %s
|
# RUN: llvm-mc -triple i386-unknown-unknown %s | FileCheck %s
|
||||||
|
|
||||||
# CHECK: TEST0:
|
# CHECK: TEST0:
|
||||||
# CHECK: .comm a,6,2
|
# CHECK: .comm a,6,2
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# RUN: llvm-mc %s | FileCheck %s
|
# RUN: llvm-mc -triple i386-unknown-unknown %s | FileCheck %s
|
||||||
|
|
||||||
# CHECK: TEST0:
|
# CHECK: TEST0:
|
||||||
# CHECK: .desc foo,16
|
# CHECK: .desc foo,16
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# RUN: llvm-mc %s | FileCheck %s
|
# RUN: llvm-mc -triple i386-unknown-unknown %s | FileCheck %s
|
||||||
|
|
||||||
# CHECK: TEST0:
|
# CHECK: TEST0:
|
||||||
# CHECK: .dump "somefile"
|
# CHECK: .dump "somefile"
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# RUN: llvm-mc %s | FileCheck %s
|
# RUN: llvm-mc -triple i386-unknown-unknown %s | FileCheck %s
|
||||||
|
|
||||||
# CHECK: TEST0:
|
# CHECK: TEST0:
|
||||||
# CHECK: .byte 10
|
# CHECK: .byte 10
|
||||||
|
@ -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: TESTA:
|
||||||
# CHECK: TEST0:
|
# CHECK: TEST0:
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# RUN: llvm-mc %s | FileCheck %s
|
# RUN: llvm-mc -triple i386-unknown-unknown %s | FileCheck %s
|
||||||
|
|
||||||
# CHECK: TEST0:
|
# CHECK: TEST0:
|
||||||
# CHECK: .lcomm a,7,4
|
# CHECK: .lcomm a,7,4
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# RUN: llvm-mc %s | FileCheck %s
|
# RUN: llvm-mc -triple i386-unknown-unknown %s | FileCheck %s
|
||||||
|
|
||||||
# CHECK: TEST0:
|
# CHECK: TEST0:
|
||||||
# CHECK: .lsym bar,foo
|
# CHECK: .lsym bar,foo
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# RUN: llvm-mc %s | FileCheck %s
|
# RUN: llvm-mc -triple i386-unknown-unknown %s | FileCheck %s
|
||||||
|
|
||||||
# CHECK: TEST0:
|
# CHECK: TEST0:
|
||||||
# CHECK: .org 1, 0
|
# CHECK: .org 1, 0
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
# RUN: llvm-mc %s | FileCheck %s
|
# RUN: llvm-mc -triple i386-unknown-unknown %s | FileCheck %s
|
||||||
|
|
||||||
# CHECK: TEST0:
|
# CHECK: TEST0:
|
||||||
# CHECK: .set a, 0
|
# CHECK: .set a, 0
|
||||||
TEST0:
|
TEST0:
|
||||||
.set a, 0
|
.set a, 0
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# RUN: llvm-mc %s | FileCheck %s
|
# RUN: llvm-mc -triple i386-unknown-unknown %s | FileCheck %s
|
||||||
|
|
||||||
# CHECK: TEST0:
|
# CHECK: TEST0:
|
||||||
# CHECK: .byte 0
|
# CHECK: .byte 0
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# RUN: llvm-mc %s | FileCheck %s
|
# RUN: llvm-mc -triple i386-unknown-unknown %s | FileCheck %s
|
||||||
|
|
||||||
# CHECK: TEST0:
|
# CHECK: TEST0:
|
||||||
# CHECK: .subsections_via_symbols
|
# CHECK: .subsections_via_symbols
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# RUN: llvm-mc %s | FileCheck %s
|
# RUN: llvm-mc -triple i386-unknown-unknown %s | FileCheck %s
|
||||||
|
|
||||||
# CHECK: TEST0:
|
# CHECK: TEST0:
|
||||||
# CHECK: .globl a
|
# CHECK: .globl a
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# RUN: llvm-mc %s | FileCheck %s
|
# RUN: llvm-mc -triple i386-unknown-unknown %s | FileCheck %s
|
||||||
|
|
||||||
# CHECK: TEST0:
|
# CHECK: TEST0:
|
||||||
# CHECK: .byte 0
|
# CHECK: .byte 0
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# RUN: llvm-mc %s | FileCheck %s
|
# RUN: llvm-mc -triple i386-unknown-unknown %s | FileCheck %s
|
||||||
|
|
||||||
# CHECK: TEST0:
|
# CHECK: TEST0:
|
||||||
# CHECK: .zerofill __FOO,__bar,x,1
|
# CHECK: .zerofill __FOO,__bar,x,1
|
||||||
|
@ -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
|
// .if, and .abort we can write a better test (without resorting to miles of
|
||||||
// greps).
|
// greps).
|
||||||
|
|
||||||
// RUN: llvm-mc %s > %t
|
// RUN: llvm-mc -triple i386-unknown-unknown %s > %t
|
||||||
|
|
||||||
.text
|
.text
|
||||||
g:
|
g:
|
||||||
@ -59,4 +59,4 @@ m:
|
|||||||
n:
|
n:
|
||||||
nop
|
nop
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
// FIXME: Actually test that we get the expected results.
|
// FIXME: Actually test that we get the expected results.
|
||||||
|
|
||||||
// RUN: llvm-mc %s > %t
|
// RUN: llvm-mc -triple i386-unknown-unknown %s > %t
|
||||||
|
|
||||||
# Immediates
|
# Immediates
|
||||||
push $1
|
push $1
|
||||||
|
@ -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
|
add_llvm_tool(llvm-mc
|
||||||
llvm-mc.cpp
|
llvm-mc.cpp
|
||||||
|
@ -9,9 +9,15 @@
|
|||||||
|
|
||||||
LEVEL = ../..
|
LEVEL = ../..
|
||||||
TOOLNAME = llvm-mc
|
TOOLNAME = llvm-mc
|
||||||
LINK_COMPONENTS := support MC
|
|
||||||
|
|
||||||
# This tool has no plugins, optimize startup time.
|
# This tool has no plugins, optimize startup time.
|
||||||
TOOL_NO_EXPORTS = 1
|
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
|
||||||
|
@ -22,6 +22,8 @@
|
|||||||
#include "llvm/Support/SourceMgr.h"
|
#include "llvm/Support/SourceMgr.h"
|
||||||
#include "llvm/Support/raw_ostream.h"
|
#include "llvm/Support/raw_ostream.h"
|
||||||
#include "llvm/System/Signals.h"
|
#include "llvm/System/Signals.h"
|
||||||
|
#include "llvm/Target/TargetRegistry.h"
|
||||||
|
#include "llvm/Target/TargetSelect.h"
|
||||||
#include "AsmParser.h"
|
#include "AsmParser.h"
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
@ -36,6 +38,11 @@ static cl::list<std::string>
|
|||||||
IncludeDirs("I", cl::desc("Directory of include files"),
|
IncludeDirs("I", cl::desc("Directory of include files"),
|
||||||
cl::value_desc("directory"), cl::Prefix);
|
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 {
|
enum ActionType {
|
||||||
AC_AsLex,
|
AC_AsLex,
|
||||||
AC_Assemble
|
AC_Assemble
|
||||||
@ -137,6 +144,23 @@ static int AsLexInput(const char *ProgName) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int AssembleInput(const char *ProgName) {
|
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;
|
std::string ErrorMessage;
|
||||||
MemoryBuffer *Buffer = MemoryBuffer::getFileOrSTDIN(InputFilename,
|
MemoryBuffer *Buffer = MemoryBuffer::getFileOrSTDIN(InputFilename,
|
||||||
&ErrorMessage);
|
&ErrorMessage);
|
||||||
@ -174,6 +198,11 @@ int main(int argc, char **argv) {
|
|||||||
sys::PrintStackTraceOnErrorSignal();
|
sys::PrintStackTraceOnErrorSignal();
|
||||||
PrettyStackTraceProgram X(argc, argv);
|
PrettyStackTraceProgram X(argc, argv);
|
||||||
llvm_shutdown_obj Y; // Call llvm_shutdown() on exit.
|
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");
|
cl::ParseCommandLineOptions(argc, argv, "llvm machine code playground\n");
|
||||||
|
|
||||||
switch (Action) {
|
switch (Action) {
|
||||||
|
Loading…
Reference in New Issue
Block a user