File tree Expand file tree Collapse file tree 4 files changed +58
-1
lines changed Expand file tree Collapse file tree 4 files changed +58
-1
lines changed Original file line number Diff line number Diff line change 11
11
#define LLVM_MC_MCASMMACRO_H
12
12
13
13
#include " llvm/MC/MCParser/MCAsmLexer.h"
14
+ #include " llvm/Support/Debug.h"
14
15
15
16
namespace llvm {
16
17
@@ -21,6 +22,9 @@ struct MCAsmMacroParameter {
21
22
bool Vararg = false ;
22
23
23
24
MCAsmMacroParameter () = default ;
25
+
26
+ void dump () const { dump (dbgs ()); }
27
+ void dump (raw_ostream &OS) const ;
24
28
};
25
29
26
30
typedef std::vector<MCAsmMacroParameter> MCAsmMacroParameters;
@@ -32,6 +36,9 @@ struct MCAsmMacro {
32
36
public:
33
37
MCAsmMacro (StringRef N, StringRef B, MCAsmMacroParameters P)
34
38
: Name(N), Body(B), Parameters(std::move(P)) {}
39
+
40
+ void dump () const { dump (dbgs ()); }
41
+ void dump (raw_ostream &OS) const ;
35
42
};
36
43
} // namespace llvm
37
44
Original file line number Diff line number Diff line change @@ -634,10 +634,17 @@ namespace llvm {
634
634
}
635
635
636
636
void defineMacro (StringRef Name, MCAsmMacro Macro) {
637
+ DEBUG_WITH_TYPE (" asm-macros" , dbgs () << " Defining new macro:\n " ;
638
+ Macro.dump ());
637
639
MacroMap.insert (std::make_pair (Name, std::move (Macro)));
638
640
}
639
641
640
- void undefineMacro (StringRef Name) { MacroMap.erase (Name); }
642
+ void undefineMacro (StringRef Name) {
643
+ if (MacroMap.erase (Name)) {
644
+ DEBUG_WITH_TYPE (" asm-macros" ,
645
+ dbgs () << " Un-defining macro: " << Name << " \n " );
646
+ }
647
+ }
641
648
};
642
649
643
650
} // end namespace llvm
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ add_llvm_library(LLVMMC
7
7
MCAsmInfoDarwin.cpp
8
8
MCAsmInfoELF.cpp
9
9
MCAsmInfoWasm.cpp
10
+ MCAsmMacro.cpp
10
11
MCAsmStreamer.cpp
11
12
MCAssembler.cpp
12
13
MCCodeEmitter.cpp
Original file line number Diff line number Diff line change
1
+ // ===- MCAsmMacro.h - Assembly Macros ---------------------------*- C++ -*-===//
2
+ //
3
+ // The LLVM Compiler Infrastructure
4
+ //
5
+ // This file is distributed under the University of Illinois Open Source
6
+ // License. See LICENSE.TXT for details.
7
+ //
8
+ // ===----------------------------------------------------------------------===//
9
+
10
+ #include " llvm/MC/MCAsmMacro.h"
11
+ #include " llvm/Support/raw_ostream.h"
12
+
13
+ using namespace llvm ;
14
+
15
+ void MCAsmMacroParameter::dump (raw_ostream &OS) const {
16
+ OS << " \" " << Name << " \" " ;
17
+ if (Required)
18
+ OS << " :req" ;
19
+ if (Vararg)
20
+ OS << " :vararg" ;
21
+ if (!Value.empty ()) {
22
+ OS << " = " ;
23
+ bool first = true ;
24
+ for (const AsmToken &T : Value) {
25
+ if (!first)
26
+ OS << " , " ;
27
+ first = false ;
28
+ T.dump ();
29
+ }
30
+ }
31
+ OS << " \n " ;
32
+ }
33
+
34
+ void MCAsmMacro::dump (raw_ostream &OS) const {
35
+ OS << " Macro " << Name << " :\n " ;
36
+ OS << " Parameters:\n " ;
37
+ for (const MCAsmMacroParameter &P : Parameters) {
38
+ OS << " " ;
39
+ P.dump ();
40
+ }
41
+ OS << " (BEGIN BODY)" << Body << " (END BODY)\n " ;
42
+ }
You can’t perform that action at this time.
0 commit comments