split the giant encoder loop into two new helper functions.
[oota-llvm.git] / utils / TableGen / CodeEmitterGen.h
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 "TableGenBackend.h"
18 #include <map>
19 #include <vector>
20 #include <string>
21
22 namespace llvm {
23
24 class RecordVal;
25 class BitsInit;
26 class CodeGenTarget;
27
28 class CodeEmitterGen : public TableGenBackend {
29   RecordKeeper &Records;
30 public:
31   CodeEmitterGen(RecordKeeper &R) : Records(R) {}
32
33   // run - Output the code emitter
34   void run(raw_ostream &o);
35 private:
36   void emitMachineOpEmitter(raw_ostream &o, const std::string &Namespace);
37   void emitGetValueBit(raw_ostream &o, const std::string &Namespace);
38   void reverseBits(std::vector<Record*> &Insts);
39   int getVariableBit(const std::string &VarName, BitsInit *BI, int bit);
40   std::string getInstructionCase(Record *R, CodeGenTarget &Target);
41   void
42   AddCodeToMergeInOperand(Record *R, BitsInit *BI, const std::string &VarName,
43                           unsigned &NumberedOp,
44                           std::string &Case, CodeGenTarget &Target);
45     
46 };
47
48 } // End llvm namespace
49
50 #endif