catch unnamed inputs
[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 #include <vector>
20 #include <map>
21
22 namespace llvm {
23
24 class StringInit;
25 class IntInit;
26 class ListInit;
27 struct CodeGenInstruction;
28
29 class InstrInfoEmitter : public TableGenBackend {
30   RecordKeeper &Records;
31 public:
32   InstrInfoEmitter(RecordKeeper &R) : Records(R) {}
33
34   // run - Output the instruction set description, returning true on failure.
35   void run(std::ostream &OS);
36
37   // runEnums - Print out enum values for all of the instructions.
38   void runEnums(std::ostream &OS);
39 private:
40   void printDefList(const std::vector<Record*> &Uses, unsigned Num,
41                     std::ostream &OS) const;
42   void emitRecord(const CodeGenInstruction &Inst, unsigned Num,
43                   Record *InstrInfo, 
44                   std::map<ListInit*, unsigned> &ListNumbers,
45                   std::map<std::vector<Record*>, unsigned> &OpInfo,
46                   std::ostream &OS);
47   void emitShiftedValue(Record *R, StringInit *Val, IntInit *Shift,
48                         std::ostream &OS);
49 };
50
51 } // End llvm namespace
52
53 #endif