• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===- CodeEmitterGen.h - Code Emitter Generator ----------------*- 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 // FIXME: document
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef CODEMITTERGEN_H
15 #define CODEMITTERGEN_H
16 
17 #include "llvm/TableGen/TableGenBackend.h"
18 #include <vector>
19 #include <string>
20 
21 namespace llvm {
22 
23 class RecordVal;
24 class BitsInit;
25 class CodeGenTarget;
26 
27 class CodeEmitterGen : public TableGenBackend {
28   RecordKeeper &Records;
29 public:
CodeEmitterGen(RecordKeeper & R)30   CodeEmitterGen(RecordKeeper &R) : Records(R) {}
31 
32   // run - Output the code emitter
33   void run(raw_ostream &o);
34 private:
35   void emitMachineOpEmitter(raw_ostream &o, const std::string &Namespace);
36   void emitGetValueBit(raw_ostream &o, const std::string &Namespace);
37   void reverseBits(std::vector<Record*> &Insts);
38   int getVariableBit(const std::string &VarName, BitsInit *BI, int bit);
39   std::string getInstructionCase(Record *R, CodeGenTarget &Target);
40   void
41   AddCodeToMergeInOperand(Record *R, BitsInit *BI, const std::string &VarName,
42                           unsigned &NumberedOp,
43                           std::string &Case, CodeGenTarget &Target);
44 
45 };
46 
47 } // End llvm namespace
48 
49 #endif
50