llvm-6502/lib/TableGen/TGPreprocessor.h
Che-Liang Chiou f987425657 tblgen: add preprocessor as a separate mode
This patch adds a preprocessor that can expand nested for-loops for
saving some copy-n-paste in *.td files.

The preprocessor is not yet integrated with TGParser, and so it has
no direct effect on *.td inputs.  However, you may preprocess an td
input (and only preprocess it).

To test the proprecessor, type:
  tblgen -E -o $@ $<



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141079 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-04 15:14:51 +00:00

53 lines
1.3 KiB
C++

//===- TGPreprocessor.h - Preprocessor for TableGen Files -------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This class represents the Preprocessor for tablegen files.
//
//===----------------------------------------------------------------------===//
#ifndef TGPREPROCESSOR_H
#define TGPREPROCESSOR_H
#include <vector>
namespace llvm {
class MemoryBuffer;
class SourceMgr;
class tool_output_file;
class TGPPLexer;
class TGPPRange;
class TGPPRecord;
typedef std::vector<TGPPRecord> TGPPRecords;
class TGPreprocessor {
SourceMgr &SrcMgr;
tool_output_file &Out;
TGPPLexer *Lexer;
TGPPRecords *CurRecords;
bool ParseBlock(bool TopLevel);
bool ParseForLoop();
bool ParseRange(TGPPRange *Range);
public:
TGPreprocessor(SourceMgr &SM, tool_output_file &O)
: SrcMgr(SM), Out(O), Lexer(NULL), CurRecords(NULL) {
}
/// PreprocessFile - Main entrypoint for preprocess a tblgen file. These
/// preprocess routines return true on error, or false on success.
bool PreprocessFile();
};
} // namespace llvm
#endif /* TGPREPROCESSOR_H */