blob: 27cf429fb91e6b25e9678492d056eeab2babec7c [file] [log] [blame]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001//===- InstrInfoEmitter.h - Generate a Instruction Set Desc. ----*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
Chris Lattnerfd6c2f02007-12-29 20:37:13 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00007//
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
22namespace llvm {
23
24class StringInit;
25class IntInit;
26class ListInit;
27class CodeGenInstruction;
28
29class InstrInfoEmitter : public TableGenBackend {
30 RecordKeeper &Records;
31 bool IsItineraries;
32 std::map<std::string, unsigned> ItinClassMap;
33
34public:
35 InstrInfoEmitter(RecordKeeper &R) : Records(R), IsItineraries(false) {}
36
37 // run - Output the instruction set description, returning true on failure.
38 void run(std::ostream &OS);
39
40 // runEnums - Print out enum values for all of the instructions.
41 void runEnums(std::ostream &OS);
42private:
43 void printDefList(const std::vector<Record*> &Uses, unsigned Num,
44 std::ostream &OS) const;
45 void emitRecord(const CodeGenInstruction &Inst, unsigned Num,
46 Record *InstrInfo,
47 std::map<std::vector<Record*>, unsigned> &EL,
48 std::map<std::vector<std::string>, unsigned> &OpInfo,
49 std::ostream &OS);
50 void GatherItinClasses();
51 unsigned ItinClassNumber(std::string ItinName);
52 void emitShiftedValue(Record *R, StringInit *Val, IntInit *Shift,
53 std::ostream &OS);
54 std::vector<std::string> GetOperandInfo(const CodeGenInstruction &Inst);
55};
56
57} // End llvm namespace
58
59#endif