mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-08-21 18:29:46 +00:00
Add the skeleton of an asm parser for mips.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@147923 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
08c66642d7
commit
fddf804597
6
lib/Target/Mips/AsmParser/CMakeLists.txt
Normal file
6
lib/Target/Mips/AsmParser/CMakeLists.txt
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
include_directories( ${CMAKE_CURRENT_BINARY_DIR}/.. ${CMAKE_CURRENT_SOURCE_DIR}/.. )
|
||||||
|
|
||||||
|
add_llvm_library(LLVMMipsAsmParser
|
||||||
|
MipsAsmParser.cpp
|
||||||
|
)
|
||||||
|
|
23
lib/Target/Mips/AsmParser/LLVMBuild.txt
Normal file
23
lib/Target/Mips/AsmParser/LLVMBuild.txt
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
;===- ./lib/Target/Mips/AsmParser/LLVMBuild.txt ----------------*- Conf -*--===;
|
||||||
|
;
|
||||||
|
; The LLVM Compiler Infrastructure
|
||||||
|
;
|
||||||
|
; This file is distributed under the University of Illinois Open Source
|
||||||
|
; License. See LICENSE.TXT for details.
|
||||||
|
;
|
||||||
|
;===------------------------------------------------------------------------===;
|
||||||
|
;
|
||||||
|
; This is an LLVMBuild description file for the components in this subdirectory.
|
||||||
|
;
|
||||||
|
; For more information on the LLVMBuild system, please see:
|
||||||
|
;
|
||||||
|
; http://llvm.org/docs/LLVMBuild.html
|
||||||
|
;
|
||||||
|
;===------------------------------------------------------------------------===;
|
||||||
|
|
||||||
|
[component_0]
|
||||||
|
type = Library
|
||||||
|
name = MipsAsmParser
|
||||||
|
parent = Mips
|
||||||
|
required_libraries = MC MCParser Support MipsDesc MipsInfo
|
||||||
|
add_to_library_groups = Mips
|
15
lib/Target/Mips/AsmParser/Makefile
Normal file
15
lib/Target/Mips/AsmParser/Makefile
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
##===- lib/Target/Mips/AsmParser/Makefile ------------------*- Makefile -*-===##
|
||||||
|
#
|
||||||
|
# The LLVM Compiler Infrastructure
|
||||||
|
#
|
||||||
|
# This file is distributed under the University of Illinois Open Source
|
||||||
|
# License. See LICENSE.TXT for details.
|
||||||
|
#
|
||||||
|
##===----------------------------------------------------------------------===##
|
||||||
|
LEVEL = ../../../..
|
||||||
|
LIBRARYNAME = LLVMMipsAsmParser
|
||||||
|
|
||||||
|
# Hack: we need to include 'main' mips target directory to grab private headers
|
||||||
|
CPP.Flags += -I$(PROJ_OBJ_DIR)/.. -I$(PROJ_SRC_DIR)/..
|
||||||
|
|
||||||
|
include $(LEVEL)/Makefile.common
|
66
lib/Target/Mips/AsmParser/MipsAsmParser.cpp
Normal file
66
lib/Target/Mips/AsmParser/MipsAsmParser.cpp
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
//===-- MipsAsmParser.cpp - Parse Mips assembly to MCInst instructions ----===//
|
||||||
|
//
|
||||||
|
// The LLVM Compiler Infrastructure
|
||||||
|
//
|
||||||
|
// This file is distributed under the University of Illinois Open Source
|
||||||
|
// License. See LICENSE.TXT for details.
|
||||||
|
//
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
#include "MCTargetDesc/MipsMCTargetDesc.h"
|
||||||
|
#include "llvm/MC/MCParser/MCAsmLexer.h"
|
||||||
|
#include "llvm/MC/MCTargetAsmParser.h"
|
||||||
|
#include "llvm/Support/TargetRegistry.h"
|
||||||
|
|
||||||
|
using namespace llvm;
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
class MipsAsmParser : public MCTargetAsmParser {
|
||||||
|
bool MatchAndEmitInstruction(SMLoc IDLoc,
|
||||||
|
SmallVectorImpl<MCParsedAsmOperand*> &Operands,
|
||||||
|
MCStreamer &Out);
|
||||||
|
|
||||||
|
bool ParseRegister(unsigned &RegNo, SMLoc &StartLoc, SMLoc &EndLoc);
|
||||||
|
|
||||||
|
bool ParseInstruction(StringRef Name, SMLoc NameLoc,
|
||||||
|
SmallVectorImpl<MCParsedAsmOperand*> &Operands);
|
||||||
|
|
||||||
|
bool ParseDirective(AsmToken DirectiveID);
|
||||||
|
|
||||||
|
public:
|
||||||
|
MipsAsmParser(MCSubtargetInfo &sti, MCAsmParser &parser)
|
||||||
|
: MCTargetAsmParser() {
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
bool MipsAsmParser::
|
||||||
|
MatchAndEmitInstruction(SMLoc IDLoc,
|
||||||
|
SmallVectorImpl<MCParsedAsmOperand*> &Operands,
|
||||||
|
MCStreamer &Out) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool MipsAsmParser::
|
||||||
|
ParseRegister(unsigned &RegNo, SMLoc &StartLoc, SMLoc &EndLoc) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool MipsAsmParser::
|
||||||
|
ParseInstruction(StringRef Name, SMLoc NameLoc,
|
||||||
|
SmallVectorImpl<MCParsedAsmOperand*> &Operands) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool MipsAsmParser::
|
||||||
|
ParseDirective(AsmToken DirectiveID) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
extern "C" void LLVMInitializeMipsAsmParser() {
|
||||||
|
RegisterMCAsmParser<MipsAsmParser> X(TheMipsTarget);
|
||||||
|
RegisterMCAsmParser<MipsAsmParser> Y(TheMipselTarget);
|
||||||
|
RegisterMCAsmParser<MipsAsmParser> A(TheMips64Target);
|
||||||
|
RegisterMCAsmParser<MipsAsmParser> B(TheMips64elTarget);
|
||||||
|
}
|
@ -33,3 +33,4 @@ add_llvm_target(MipsCodeGen
|
|||||||
add_subdirectory(InstPrinter)
|
add_subdirectory(InstPrinter)
|
||||||
add_subdirectory(TargetInfo)
|
add_subdirectory(TargetInfo)
|
||||||
add_subdirectory(MCTargetDesc)
|
add_subdirectory(MCTargetDesc)
|
||||||
|
add_subdirectory(AsmParser)
|
||||||
|
@ -16,12 +16,13 @@
|
|||||||
;===------------------------------------------------------------------------===;
|
;===------------------------------------------------------------------------===;
|
||||||
|
|
||||||
[common]
|
[common]
|
||||||
subdirectories = InstPrinter MCTargetDesc TargetInfo
|
subdirectories = AsmParser InstPrinter MCTargetDesc TargetInfo
|
||||||
|
|
||||||
[component_0]
|
[component_0]
|
||||||
type = TargetGroup
|
type = TargetGroup
|
||||||
name = Mips
|
name = Mips
|
||||||
parent = Target
|
parent = Target
|
||||||
|
has_asmparser = 1
|
||||||
has_asmprinter = 1
|
has_asmprinter = 1
|
||||||
has_jit = 1
|
has_jit = 1
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ BUILT_SOURCES = MipsGenRegisterInfo.inc MipsGenInstrInfo.inc \
|
|||||||
MipsGenDAGISel.inc MipsGenCallingConv.inc \
|
MipsGenDAGISel.inc MipsGenCallingConv.inc \
|
||||||
MipsGenSubtargetInfo.inc MipsGenMCCodeEmitter.inc
|
MipsGenSubtargetInfo.inc MipsGenMCCodeEmitter.inc
|
||||||
|
|
||||||
DIRS = InstPrinter TargetInfo MCTargetDesc
|
DIRS = InstPrinter AsmParser TargetInfo MCTargetDesc
|
||||||
|
|
||||||
include $(LEVEL)/Makefile.common
|
include $(LEVEL)/Makefile.common
|
||||||
|
|
||||||
|
5
test/MC/Mips/elf_basic.s
Normal file
5
test/MC/Mips/elf_basic.s
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
; RUN: llc -filetype=obj -mtriple mipsel-unknown-linux %s -o - | elf-dump --dump-section-data | FileCheck -check-prefix=CHECK-LE %s
|
||||||
|
|
||||||
|
; Check that we produce the correct endian.
|
||||||
|
|
||||||
|
; CHECK-LE: ('e_indent[EI_DATA]', 0x01)
|
Loading…
Reference in New Issue
Block a user