blob: 2389f3a951443acd8b43d9304e3eba750c3b9baa [file] [log] [blame]
Chris Lattner33ccf7e2003-08-03 17:24:10 +00001//===- InstrInfoEmitter.h - Generate a Instruction Set Desc. ----*- C++ -*-===//
Misha Brukman3da94ae2005-04-22 00:00:37 +00002//
John Criswell01d45822003-10-20 20:20:30 +00003// 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.
Misha Brukman3da94ae2005-04-22 00:00:37 +00007//
John Criswell01d45822003-10-20 20:20:30 +00008//===----------------------------------------------------------------------===//
Chris Lattner33ccf7e2003-08-03 17:24:10 +00009//
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
Chris Lattnerbc017232003-08-06 04:32:07 +000018#include "TableGenBackend.h"
Chris Lattnera3ac88d2005-08-18 21:36:47 +000019#include <vector>
20#include <map>
Brian Gaeked0fde302003-11-11 22:41:34 +000021
22namespace llvm {
23
Chris Lattnera3ae6142003-08-03 21:57:51 +000024class StringInit;
25class IntInit;
Chris Lattnerbc017232003-08-06 04:32:07 +000026class ListInit;
Chris Lattner1fca5ff2004-10-27 16:14:51 +000027struct CodeGenInstruction;
Chris Lattner33ccf7e2003-08-03 17:24:10 +000028
Chris Lattnerbc017232003-08-06 04:32:07 +000029class InstrInfoEmitter : public TableGenBackend {
Chris Lattner33ccf7e2003-08-03 17:24:10 +000030 RecordKeeper &Records;
Jim Laskeyb5a0c0e2005-10-31 17:16:46 +000031 bool IsItineraries;
32 std::map<std::string, unsigned> ItinClassMap;
33
Chris Lattner33ccf7e2003-08-03 17:24:10 +000034public:
Jim Laskeyb5a0c0e2005-10-31 17:16:46 +000035 InstrInfoEmitter(RecordKeeper &R) : Records(R), IsItineraries(false) {}
Misha Brukman3da94ae2005-04-22 00:00:37 +000036
Chris Lattner33ccf7e2003-08-03 17:24:10 +000037 // run - Output the instruction set description, returning true on failure.
Chris Lattnera3ae6142003-08-03 21:57:51 +000038 void run(std::ostream &OS);
Chris Lattner33ccf7e2003-08-03 17:24:10 +000039
40 // runEnums - Print out enum values for all of the instructions.
Chris Lattnera3ae6142003-08-03 21:57:51 +000041 void runEnums(std::ostream &OS);
42private:
Chris Lattnera3ac88d2005-08-18 21:36:47 +000043 void printDefList(const std::vector<Record*> &Uses, unsigned Num,
Chris Lattnerbc017232003-08-06 04:32:07 +000044 std::ostream &OS) const;
Chris Lattnerec352402004-08-01 05:04:00 +000045 void emitRecord(const CodeGenInstruction &Inst, unsigned Num,
Chris Lattnera3ac88d2005-08-18 21:36:47 +000046 Record *InstrInfo,
Chris Lattner366080c2005-10-28 22:59:53 +000047 std::map<std::vector<Record*>, unsigned> &EL,
Chris Lattnerd5aa3e22005-08-19 18:46:26 +000048 std::map<std::vector<Record*>, unsigned> &OpInfo,
Chris Lattnera3ac88d2005-08-18 21:36:47 +000049 std::ostream &OS);
Jim Laskeyb5a0c0e2005-10-31 17:16:46 +000050 void GatherItinClasses();
51 unsigned ItinClassNumber(std::string ItinName);
Chris Lattnera3ae6142003-08-03 21:57:51 +000052 void emitShiftedValue(Record *R, StringInit *Val, IntInit *Shift,
53 std::ostream &OS);
Chris Lattner33ccf7e2003-08-03 17:24:10 +000054};
55
Brian Gaeked0fde302003-11-11 22:41:34 +000056} // End llvm namespace
57
Chris Lattner33ccf7e2003-08-03 17:24:10 +000058#endif