Don't keep the log files around. Just pipe to a log file instead.
[oota-llvm.git] / utils / TableGen / FixedLenDecoderEmitter.h
1 //===------------ FixedLenDecoderEmitter.h - Decoder 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 // It contains the tablegen backend that emits the decoder functions for
11 // targets with fixed length instruction set.
12 //
13 //===----------------------------------------------------------------------===//
14
15 #ifndef FixedLenDECODEREMITTER_H
16 #define FixedLenDECODEREMITTER_H
17
18 #include "CodeGenTarget.h"
19 #include "TableGenBackend.h"
20
21 #include "llvm/Support/DataTypes.h"
22
23 namespace llvm {
24
25 struct OperandInfo {
26   unsigned FieldBase;
27   unsigned FieldLength;
28   std::string Decoder;
29
30   OperandInfo(unsigned FB, unsigned FL, std::string D)
31     : FieldBase(FB), FieldLength(FL), Decoder(D) { }
32 };
33
34 class FixedLenDecoderEmitter : public TableGenBackend {
35 public:
36   FixedLenDecoderEmitter(RecordKeeper &R) :
37     Records(R), Target(R),
38     NumberedInstructions(Target.getInstructionsByEnumValue()) {}
39
40   // run - Output the code emitter
41   void run(raw_ostream &o);
42
43 private:
44   RecordKeeper &Records;
45   CodeGenTarget Target;
46   std::vector<const CodeGenInstruction*> NumberedInstructions;
47   std::vector<unsigned> Opcodes;
48   std::map<unsigned, std::vector<OperandInfo> > Operands;
49
50   bool populateInstruction(const CodeGenInstruction &CGI, unsigned Opc);
51   void populateInstructions();
52 };
53
54 } // end llvm namespace
55
56 #endif