From 84e2cd6c021a1564e77c2f099f9d3a3c21906e90 Mon Sep 17 00:00:00 2001 From: Eric Christopher Date: Mon, 2 Apr 2018 23:17:55 +0000 Subject: [PATCH] Remove llvm-mcmarkup. It was never used and I've checked with the original authors. llvm-svn: 329029 --- llvm/test/CMakeLists.txt | 1 - llvm/test/MC/Markup/basic-markup.mc | 16 --- llvm/test/MC/Markup/lit.local.cfg | 2 - llvm/test/lit.cfg.py | 2 +- llvm/tools/LLVMBuild.txt | 1 - llvm/tools/llvm-mcmarkup/CMakeLists.txt | 5 - llvm/tools/llvm-mcmarkup/LLVMBuild.txt | 22 --- llvm/tools/llvm-mcmarkup/llvm-mcmarkup.cpp | 223 ----------------------------- 8 files changed, 1 insertion(+), 271 deletions(-) delete mode 100644 llvm/test/MC/Markup/basic-markup.mc delete mode 100644 llvm/test/MC/Markup/lit.local.cfg delete mode 100644 llvm/tools/llvm-mcmarkup/CMakeLists.txt delete mode 100644 llvm/tools/llvm-mcmarkup/LLVMBuild.txt delete mode 100644 llvm/tools/llvm-mcmarkup/llvm-mcmarkup.cpp diff --git a/llvm/test/CMakeLists.txt b/llvm/test/CMakeLists.txt index 5a97677..457509c 100644 --- a/llvm/test/CMakeLists.txt +++ b/llvm/test/CMakeLists.txt @@ -67,7 +67,6 @@ set(LLVM_TEST_DEPENDS llvm-lto2 llvm-mc llvm-mca - llvm-mcmarkup llvm-modextract llvm-mt llvm-nm diff --git a/llvm/test/MC/Markup/basic-markup.mc b/llvm/test/MC/Markup/basic-markup.mc deleted file mode 100644 index 2fa5ebb..0000000 --- a/llvm/test/MC/Markup/basic-markup.mc +++ /dev/null @@ -1,16 +0,0 @@ -// RUN: llvm-mcmarkup %s | FileCheck %s - - push {, , } - sub , - ldr , , ]> - - -// CHECK: reg -// CHECK: reg -// CHECK: reg -// CHECK: reg -// CHECK: imm -// CHECK: reg -// CHECK: mem -// CHECK: reg -// CHECK: imm diff --git a/llvm/test/MC/Markup/lit.local.cfg b/llvm/test/MC/Markup/lit.local.cfg deleted file mode 100644 index ab28eed..0000000 --- a/llvm/test/MC/Markup/lit.local.cfg +++ /dev/null @@ -1,2 +0,0 @@ -config.suffixes = ['.mc'] - diff --git a/llvm/test/lit.cfg.py b/llvm/test/lit.cfg.py index 4c01992..2c63e84 100644 --- a/llvm/test/lit.cfg.py +++ b/llvm/test/lit.cfg.py @@ -141,7 +141,7 @@ tools.extend([ 'dsymutil', 'lli', 'lli-child-target', 'llvm-ar', 'llvm-as', 'llvm-bcanalyzer', 'llvm-config', 'llvm-cov', 'llvm-cxxdump', 'llvm-cvtres', 'llvm-diff', 'llvm-dis', 'llvm-dwarfdump', 'llvm-extract', 'llvm-isel-fuzzer', 'llvm-opt-fuzzer', 'llvm-lib', - 'llvm-link', 'llvm-lto', 'llvm-lto2', 'llvm-mc', 'llvm-mca','llvm-mcmarkup', + 'llvm-link', 'llvm-lto', 'llvm-lto2', 'llvm-mc', 'llvm-mca', 'llvm-modextract', 'llvm-nm', 'llvm-objcopy', 'llvm-objdump', 'llvm-pdbutil', 'llvm-profdata', 'llvm-ranlib', 'llvm-readobj', 'llvm-rtdyld', 'llvm-size', 'llvm-split', 'llvm-strings', 'llvm-tblgen', diff --git a/llvm/tools/LLVMBuild.txt b/llvm/tools/LLVMBuild.txt index fca089c..8fe289c 100644 --- a/llvm/tools/LLVMBuild.txt +++ b/llvm/tools/LLVMBuild.txt @@ -38,7 +38,6 @@ subdirectories = llvm-lto llvm-mc llvm-mca - llvm-mcmarkup llvm-modextract llvm-mt llvm-nm diff --git a/llvm/tools/llvm-mcmarkup/CMakeLists.txt b/llvm/tools/llvm-mcmarkup/CMakeLists.txt deleted file mode 100644 index 0a51e99f..0000000 --- a/llvm/tools/llvm-mcmarkup/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -set(LLVM_LINK_COMPONENTS support) - -add_llvm_tool(llvm-mcmarkup - llvm-mcmarkup.cpp - ) diff --git a/llvm/tools/llvm-mcmarkup/LLVMBuild.txt b/llvm/tools/llvm-mcmarkup/LLVMBuild.txt deleted file mode 100644 index 6423493..0000000 --- a/llvm/tools/llvm-mcmarkup/LLVMBuild.txt +++ /dev/null @@ -1,22 +0,0 @@ -;===- ./tools/llvm-mcmarkup/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 = Tool -name = llvm-mcmarkup -parent = Tools -required_libraries = Support diff --git a/llvm/tools/llvm-mcmarkup/llvm-mcmarkup.cpp b/llvm/tools/llvm-mcmarkup/llvm-mcmarkup.cpp deleted file mode 100644 index 711493a..0000000 --- a/llvm/tools/llvm-mcmarkup/llvm-mcmarkup.cpp +++ /dev/null @@ -1,223 +0,0 @@ -//===-- llvm-mcmarkup.cpp - Parse the MC assembly markup tags -------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// Example simple parser implementation for the MC assembly markup language. -// -//===----------------------------------------------------------------------===// - -#include "llvm/Support/CommandLine.h" -#include "llvm/Support/ManagedStatic.h" -#include "llvm/Support/MemoryBuffer.h" -#include "llvm/Support/PrettyStackTrace.h" -#include "llvm/Support/Signals.h" -#include "llvm/Support/SourceMgr.h" -#include "llvm/Support/raw_ostream.h" -using namespace llvm; - -static cl::list - InputFilenames(cl::Positional, cl::desc(""), - cl::ZeroOrMore); -static cl::opt -DumpTags("dump-tags", cl::desc("List all tags encountered in input")); - -static StringRef ToolName; - -/// Trivial lexer for the markup parser. Input is always handled a character -/// at a time. The lexer just encapsulates EOF and lookahead handling. -class MarkupLexer { - StringRef::const_iterator Start; - StringRef::const_iterator CurPtr; - StringRef::const_iterator End; -public: - MarkupLexer(StringRef Source) - : Start(Source.begin()), CurPtr(Source.begin()), End(Source.end()) {} - // When processing non-markup, input is consumed a character at a time. - bool isEOF() { return CurPtr == End; } - int getNextChar() { - if (CurPtr == End) return EOF; - return *CurPtr++; - } - int peekNextChar() { - if (CurPtr == End) return EOF; - return *CurPtr; - } - StringRef::const_iterator getPosition() const { return CurPtr; } -}; - -/// A markup tag is a name and a (usually empty) list of modifiers. -class MarkupTag { - StringRef Name; - StringRef Modifiers; - SMLoc StartLoc; -public: - MarkupTag(StringRef n, StringRef m, SMLoc Loc) - : Name(n), Modifiers(m), StartLoc(Loc) {} - StringRef getName() const { return Name; } - StringRef getModifiers() const { return Modifiers; } - SMLoc getLoc() const { return StartLoc; } -}; - -/// A simple parser implementation for creating MarkupTags from input text. -class MarkupParser { - MarkupLexer &Lex; - SourceMgr &SM; -public: - MarkupParser(MarkupLexer &lex, SourceMgr &SrcMgr) : Lex(lex), SM(SrcMgr) {} - /// Create a MarkupTag from the current position in the MarkupLexer. - /// The parseTag() method should be called when the lexer has processed - /// the opening '<' character. Input will be consumed up to and including - /// the ':' which terminates the tag open. - MarkupTag parseTag(); - /// Issue a diagnostic and terminate program execution. - void FatalError(SMLoc Loc, StringRef Msg); -}; - -void MarkupParser::FatalError(SMLoc Loc, StringRef Msg) { - SM.PrintMessage(Loc, SourceMgr::DK_Error, Msg); - exit(1); -} - -// Example handler for when a tag is recognized. -static void processStartTag(MarkupTag &Tag) { - // If we're just printing the tags, do that, otherwise do some simple - // colorization. - if (DumpTags) { - outs() << Tag.getName(); - if (Tag.getModifiers().size()) - outs() << " " << Tag.getModifiers(); - outs() << "\n"; - return; - } - - if (!outs().has_colors()) - return; - // Color registers as red and immediates as cyan. Those don't have nested - // tags, so don't bother keeping a stack of colors to reset to. - if (Tag.getName() == "reg") - outs().changeColor(raw_ostream::RED); - else if (Tag.getName() == "imm") - outs().changeColor(raw_ostream::CYAN); -} - -// Example handler for when the end of a tag is recognized. -static void processEndTag(MarkupTag &Tag) { - // If we're printing the tags, there's nothing more to do here. Otherwise, - // set the color back the normal. - if (DumpTags) - return; - if (!outs().has_colors()) - return; - // Just reset to basic white. - outs().changeColor(raw_ostream::WHITE, false); -} - -MarkupTag MarkupParser::parseTag() { - // First off, extract the tag into it's own StringRef so we can look at it - // outside of the context of consuming input. - StringRef::const_iterator Start = Lex.getPosition(); - SMLoc Loc = SMLoc::getFromPointer(Start - 1); - while(Lex.getNextChar() != ':') { - // EOF is an error. - if (Lex.isEOF()) - FatalError(SMLoc::getFromPointer(Start), "unterminated markup tag"); - } - StringRef RawTag(Start, Lex.getPosition() - Start - 1); - std::pair SplitTag = RawTag.split(' '); - return MarkupTag(SplitTag.first, SplitTag.second, Loc); -} - -static void parseMCMarkup(StringRef Filename) { - ErrorOr> BufferPtr = - MemoryBuffer::getFileOrSTDIN(Filename); - if (std::error_code EC = BufferPtr.getError()) { - errs() << ToolName << ": " << EC.message() << '\n'; - return; - } - std::unique_ptr &Buffer = BufferPtr.get(); - - SourceMgr SrcMgr; - - StringRef InputSource = Buffer->getBuffer(); - - // Tell SrcMgr about this buffer, which is what the parser will pick up. - SrcMgr.AddNewSourceBuffer(std::move(Buffer), SMLoc()); - - MarkupLexer Lex(InputSource); - MarkupParser Parser(Lex, SrcMgr); - - SmallVector TagStack; - - for (int CurChar = Lex.getNextChar(); - CurChar != EOF; - CurChar = Lex.getNextChar()) { - switch (CurChar) { - case '<': { - // A "<<" is output as a literal '<' and does not start a markup tag. - if (Lex.peekNextChar() == '<') { - (void)Lex.getNextChar(); - break; - } - // Parse the markup entry. - TagStack.push_back(Parser.parseTag()); - - // Do any special handling for the start of a tag. - processStartTag(TagStack.back()); - continue; - } - case '>': { - SMLoc Loc = SMLoc::getFromPointer(Lex.getPosition() - 1); - // A ">>" is output as a literal '>' and does not end a markup tag. - if (Lex.peekNextChar() == '>') { - (void)Lex.getNextChar(); - break; - } - // Close out the innermost tag. - if (TagStack.empty()) - Parser.FatalError(Loc, "'>' without matching '<'"); - - // Do any special handling for the end of a tag. - processEndTag(TagStack.back()); - - TagStack.pop_back(); - continue; - } - default: - break; - } - // For anything else, just echo the character back out. - if (!DumpTags && CurChar != EOF) - outs() << (char)CurChar; - } - - // If there are any unterminated markup tags, issue diagnostics for them. - while (!TagStack.empty()) { - MarkupTag &Tag = TagStack.back(); - SrcMgr.PrintMessage(Tag.getLoc(), SourceMgr::DK_Error, - "unterminated markup tag"); - TagStack.pop_back(); - } -} - -int main(int argc, char **argv) { - // Print a stack trace if we signal out. - sys::PrintStackTraceOnErrorSignal(argv[0]); - PrettyStackTraceProgram X(argc, argv); - - llvm_shutdown_obj Y; // Call llvm_shutdown() on exit. - cl::ParseCommandLineOptions(argc, argv, "llvm MC markup parser\n"); - - ToolName = argv[0]; - - // If no input files specified, read from stdin. - if (InputFilenames.size() == 0) - InputFilenames.push_back("-"); - - llvm::for_each(InputFilenames, parseMCMarkup); - return 0; -} -- 2.7.4