Silence -Wunused-variable in release builds.
[llvm/stm8.git] / utils / TableGen / FixedLenDecoderEmitter.h
blobd46a495540ea81a2ca6316ed08b3632b626d473d
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.
13 //===----------------------------------------------------------------------===//
15 #ifndef FixedLenDECODEREMITTER_H
16 #define FixedLenDECODEREMITTER_H
18 #include "CodeGenTarget.h"
19 #include "TableGenBackend.h"
21 #include "llvm/Support/DataTypes.h"
23 namespace llvm {
25 struct OperandInfo {
26 unsigned FieldBase;
27 unsigned FieldLength;
28 std::string Decoder;
30 OperandInfo(unsigned FB, unsigned FL, std::string D)
31 : FieldBase(FB), FieldLength(FL), Decoder(D) { }
34 class FixedLenDecoderEmitter : public TableGenBackend {
35 public:
36 FixedLenDecoderEmitter(RecordKeeper &R) :
37 Records(R), Target(R),
38 NumberedInstructions(Target.getInstructionsByEnumValue()) {}
40 // run - Output the code emitter
41 void run(raw_ostream &o);
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;
50 bool populateInstruction(const CodeGenInstruction &CGI, unsigned Opc);
51 void populateInstructions();
54 } // end llvm namespace
56 #endif