Add, and start using, the CodeGenInstruction class. This class represents
[oota-llvm.git] / utils / TableGen / InstrInfoEmitter.h
1 //===- InstrInfoEmitter.h - Generate a Instruction Set Desc. ----*- C++ -*-===//
2 // 
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file was developed by the LLVM research group and is distributed under
6 // the University of Illinois Open Source License. See LICENSE.TXT for details.
7 // 
8 //===----------------------------------------------------------------------===//
9 //
10 // This tablegen backend is responsible for emitting a description of the target
11 // instruction set for the code generator.
12 //
13 //===----------------------------------------------------------------------===//
14
15 #ifndef INSTRINFO_EMITTER_H
16 #define INSTRINFO_EMITTER_H
17
18 #include "TableGenBackend.h"
19
20 namespace llvm {
21
22 class StringInit;
23 class IntInit;
24 class ListInit;
25 class CodeGenInstruction;
26
27 class InstrInfoEmitter : public TableGenBackend {
28   RecordKeeper &Records;
29 public:
30   InstrInfoEmitter(RecordKeeper &R) : Records(R) {}
31   
32   // run - Output the instruction set description, returning true on failure.
33   void run(std::ostream &OS);
34
35   // runEnums - Print out enum values for all of the instructions.
36   void runEnums(std::ostream &OS);
37 private:
38   void printDefList(ListInit *LI, const std::string &Name,
39                     std::ostream &OS) const;
40   void emitRecord(const CodeGenInstruction &Inst, unsigned Num,
41                   Record *InstrInfo, std::ostream &OS);
42   void emitShiftedValue(Record *R, StringInit *Val, IntInit *Shift,
43                         std::ostream &OS);
44 };
45
46 } // End llvm namespace
47
48 #endif