blob: 93f0e605abd5c0a864341347158a33e5f5ff971e [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;
31public:
32 InstrInfoEmitter(RecordKeeper &R) : Records(R) {}
Misha Brukman3da94ae2005-04-22 00:00:37 +000033
Chris Lattner33ccf7e2003-08-03 17:24:10 +000034 // run - Output the instruction set description, returning true on failure.
Chris Lattnera3ae6142003-08-03 21:57:51 +000035 void run(std::ostream &OS);
Chris Lattner33ccf7e2003-08-03 17:24:10 +000036
37 // runEnums - Print out enum values for all of the instructions.
Chris Lattnera3ae6142003-08-03 21:57:51 +000038 void runEnums(std::ostream &OS);
39private:
Chris Lattnera3ac88d2005-08-18 21:36:47 +000040 void printDefList(const std::vector<Record*> &Uses, unsigned Num,
Chris Lattnerbc017232003-08-06 04:32:07 +000041 std::ostream &OS) const;
Chris Lattnerec352402004-08-01 05:04:00 +000042 void emitRecord(const CodeGenInstruction &Inst, unsigned Num,
Chris Lattnera3ac88d2005-08-18 21:36:47 +000043 Record *InstrInfo,
Chris Lattner366080c2005-10-28 22:59:53 +000044 std::map<std::vector<Record*>, unsigned> &EL,
Chris Lattnerd5aa3e22005-08-19 18:46:26 +000045 std::map<std::vector<Record*>, unsigned> &OpInfo,
Chris Lattnera3ac88d2005-08-18 21:36:47 +000046 std::ostream &OS);
Chris Lattnera3ae6142003-08-03 21:57:51 +000047 void emitShiftedValue(Record *R, StringInit *Val, IntInit *Shift,
48 std::ostream &OS);
Chris Lattner33ccf7e2003-08-03 17:24:10 +000049};
50
Brian Gaeked0fde302003-11-11 22:41:34 +000051} // End llvm namespace
52
Chris Lattner33ccf7e2003-08-03 17:24:10 +000053#endif