mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-31 20:51:52 +01:00
[Asm] Add debug printing for assembler macros
This adds some debug printing (gated behind the "asm-macros" debug flag) which can help tracing complicated assembly macros. Differential revision: https://reviews.llvm.org/D43937 llvm-svn: 326795
This commit is contained in:
parent
9a6731204f
commit
2ba15f7247
@ -11,6 +11,7 @@
|
||||
#define LLVM_MC_MCASMMACRO_H
|
||||
|
||||
#include "llvm/MC/MCParser/MCAsmLexer.h"
|
||||
#include "llvm/Support/Debug.h"
|
||||
|
||||
namespace llvm {
|
||||
|
||||
@ -21,6 +22,9 @@ struct MCAsmMacroParameter {
|
||||
bool Vararg = false;
|
||||
|
||||
MCAsmMacroParameter() = default;
|
||||
|
||||
void dump() const { dump(dbgs()); }
|
||||
void dump(raw_ostream &OS) const;
|
||||
};
|
||||
|
||||
typedef std::vector<MCAsmMacroParameter> MCAsmMacroParameters;
|
||||
@ -32,6 +36,9 @@ struct MCAsmMacro {
|
||||
public:
|
||||
MCAsmMacro(StringRef N, StringRef B, MCAsmMacroParameters P)
|
||||
: Name(N), Body(B), Parameters(std::move(P)) {}
|
||||
|
||||
void dump() const { dump(dbgs()); }
|
||||
void dump(raw_ostream &OS) const;
|
||||
};
|
||||
} // namespace llvm
|
||||
|
||||
|
@ -634,10 +634,17 @@ namespace llvm {
|
||||
}
|
||||
|
||||
void defineMacro(StringRef Name, MCAsmMacro Macro) {
|
||||
DEBUG_WITH_TYPE("asm-macros", dbgs() << "Defining new macro:\n";
|
||||
Macro.dump());
|
||||
MacroMap.insert(std::make_pair(Name, std::move(Macro)));
|
||||
}
|
||||
|
||||
void undefineMacro(StringRef Name) { MacroMap.erase(Name); }
|
||||
void undefineMacro(StringRef Name) {
|
||||
if (MacroMap.erase(Name)) {
|
||||
DEBUG_WITH_TYPE("asm-macros",
|
||||
dbgs() << "Un-defining macro: " << Name << "\n");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
} // end namespace llvm
|
||||
|
@ -7,6 +7,7 @@ add_llvm_library(LLVMMC
|
||||
MCAsmInfoDarwin.cpp
|
||||
MCAsmInfoELF.cpp
|
||||
MCAsmInfoWasm.cpp
|
||||
MCAsmMacro.cpp
|
||||
MCAsmStreamer.cpp
|
||||
MCAssembler.cpp
|
||||
MCCodeEmitter.cpp
|
||||
|
42
lib/MC/MCAsmMacro.cpp
Normal file
42
lib/MC/MCAsmMacro.cpp
Normal file
@ -0,0 +1,42 @@
|
||||
//===- MCAsmMacro.h - Assembly Macros ---------------------------*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "llvm/MC/MCAsmMacro.h"
|
||||
#include "llvm/Support/raw_ostream.h"
|
||||
|
||||
using namespace llvm;
|
||||
|
||||
void MCAsmMacroParameter::dump(raw_ostream &OS) const {
|
||||
OS << "\"" << Name << "\"";
|
||||
if (Required)
|
||||
OS << ":req";
|
||||
if (Vararg)
|
||||
OS << ":vararg";
|
||||
if (!Value.empty()) {
|
||||
OS << " = ";
|
||||
bool first = true;
|
||||
for (const AsmToken &T : Value) {
|
||||
if (!first)
|
||||
OS << ", ";
|
||||
first = false;
|
||||
T.dump();
|
||||
}
|
||||
}
|
||||
OS << "\n";
|
||||
}
|
||||
|
||||
void MCAsmMacro::dump(raw_ostream &OS) const {
|
||||
OS << "Macro " << Name << ":\n";
|
||||
OS << " Parameters:\n";
|
||||
for (const MCAsmMacroParameter &P : Parameters) {
|
||||
OS << " ";
|
||||
P.dump();
|
||||
}
|
||||
OS << " (BEGIN BODY)" << Body << "(END BODY)\n";
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user