#define LLVM_MC_MCASMMACRO_H
#include "llvm/MC/MCParser/MCAsmLexer.h"
+#include "llvm/Support/Debug.h"
namespace llvm {
bool Vararg = false;
MCAsmMacroParameter() = default;
+
+ void dump() const { dump(dbgs()); }
+ void dump(raw_ostream &OS) const;
};
typedef std::vector<MCAsmMacroParameter> MCAsmMacroParameters;
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
}
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
MCAsmInfoDarwin.cpp
MCAsmInfoELF.cpp
MCAsmInfoWasm.cpp
+ MCAsmMacro.cpp
MCAsmStreamer.cpp
MCAssembler.cpp
MCCodeEmitter.cpp
--- /dev/null
+//===- 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";
+}