Mark that the return is using EAX so that we don't use it for some other
[llvm.git] / utils / TableGen / ClangASTNodesEmitter.h
blob712333bd2d251216b83712681e801b89853da917
1 //===- ClangASTNodesEmitter.h - Generate Clang AST node tables -*- 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 // These tablegen backends emit Clang AST node tables
12 //===----------------------------------------------------------------------===//
14 #ifndef CLANGAST_EMITTER_H
15 #define CLANGAST_EMITTER_H
17 #include "TableGenBackend.h"
18 #include "Record.h"
19 #include <string>
20 #include <cctype>
21 #include <map>
23 namespace llvm {
25 /// ClangASTNodesEmitter - The top-level class emits .inc files containing
26 /// declarations of Clang statements.
27 ///
28 class ClangASTNodesEmitter : public TableGenBackend {
29 // A map from a node to each of its derived nodes.
30 typedef std::multimap<Record*, Record*> ChildMap;
31 typedef ChildMap::const_iterator ChildIterator;
33 RecordKeeper &Records;
34 Record Root;
35 const std::string &BaseSuffix;
37 // Create a macro-ized version of a name
38 static std::string macroName(std::string S) {
39 for (unsigned i = 0; i < S.size(); ++i)
40 S[i] = std::toupper(S[i]);
42 return S;
45 // Return the name to be printed in the base field. Normally this is
46 // the record's name plus the base suffix, but if it is the root node and
47 // the suffix is non-empty, it's just the suffix.
48 std::string baseName(Record &R) {
49 if (&R == &Root && !BaseSuffix.empty())
50 return BaseSuffix;
52 return R.getName() + BaseSuffix;
55 std::pair<Record *, Record *> EmitNode (const ChildMap &Tree, raw_ostream& OS,
56 Record *Base);
57 public:
58 explicit ClangASTNodesEmitter(RecordKeeper &R, const std::string &N,
59 const std::string &S)
60 : Records(R), Root(N, SMLoc(), R), BaseSuffix(S)
63 // run - Output the .inc file contents
64 void run(raw_ostream &OS);
67 /// ClangDeclContextEmitter - Emits an addendum to a .inc file to enumerate the
68 /// clang declaration contexts.
69 ///
70 class ClangDeclContextEmitter : public TableGenBackend {
71 RecordKeeper &Records;
73 public:
74 explicit ClangDeclContextEmitter(RecordKeeper &R)
75 : Records(R)
78 // run - Output the .inc file contents
79 void run(raw_ostream &OS);
82 } // End llvm namespace
84 #endif