Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1 | //===- InstrInfoEmitter.h - Generate a Instruction Set Desc. ----*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
Chris Lattner | fd6c2f0 | 2007-12-29 20:37:13 +0000 | [diff] [blame] | 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 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 | class CodeGenInstruction; |
| 28 | |
| 29 | class InstrInfoEmitter : public TableGenBackend { |
| 30 | RecordKeeper &Records; |
| 31 | bool IsItineraries; |
| 32 | std::map<std::string, unsigned> ItinClassMap; |
| 33 | |
| 34 | public: |
| 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 | |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 40 | private: |
| 41 | void printDefList(const std::vector<Record*> &Uses, unsigned Num, |
| 42 | std::ostream &OS) const; |
| 43 | void emitRecord(const CodeGenInstruction &Inst, unsigned Num, |
| 44 | Record *InstrInfo, |
| 45 | std::map<std::vector<Record*>, unsigned> &EL, |
| 46 | std::map<std::vector<std::string>, unsigned> &OpInfo, |
| 47 | std::ostream &OS); |
| 48 | void GatherItinClasses(); |
| 49 | unsigned ItinClassNumber(std::string ItinName); |
| 50 | void emitShiftedValue(Record *R, StringInit *Val, IntInit *Shift, |
| 51 | std::ostream &OS); |
| 52 | std::vector<std::string> GetOperandInfo(const CodeGenInstruction &Inst); |
| 53 | }; |
| 54 | |
| 55 | } // End llvm namespace |
| 56 | |
| 57 | #endif |