aboutsummaryrefslogtreecommitdiff
path: root/utils/TableGen/SimpleInstrSelEmitter.h
blob: 19ab444a3eb116cba16a6b44766f170196a9bbe7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
//===- SimpleInstrSelEmitter.h - Generate a Simple Instruction Selector ----*- C++ -*-===//
// 
//                     The LLVM Compiler Infrastructure
//
// This file was developed by the LLVM research group and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
// 
//===----------------------------------------------------------------------===//
//
// This tablegen backend is responsible for emitting a simple instruction selector
// 
//
//===----------------------------------------------------------------------===//

#ifndef SIMPLE_INSTR_SELECTOR_EMITTER_H
#define SIMPLE_INSTR_SELECTOR_EMITTER_H

#include "TableGenBackend.h"
#include "CodeGenWrappers.h"
#include <vector>
#include <map>
#include <cassert>

namespace llvm {

class Init;
class InstrSelectorEmitter;


/// InstrSelectorEmitter - The top-level class which coordinates construction
/// and emission of the instruction selector.
///
class SimpleInstrSelEmitter : public TableGenBackend {
  RecordKeeper &Records;
  std::string globalSpacing;

public:
  SimpleInstrSelEmitter(RecordKeeper &R) : Records(R) {globalSpacing = "  ";}
  
  // run - Output the instruction set description, returning true on failure.
  void run(std::ostream &OS);

  Record* SimpleInstrSelEmitter::findInstruction(std::ostream &OS, std::string cl, std::vector<std::string>& vi);

  Record* SimpleInstrSelEmitter::findRegister(std::ostream &OS, std::string regname);

  std::string SimpleInstrSelEmitter::formatRegister(std::ostream &OS, std::string regname);

  void SimpleInstrSelEmitter::generateBMIcall(std::ostream &OS, std::string MBB, std::string IP, std::string Opcode, int NumOperands, ListInit &l, ListInit &r);

  void SimpleInstrSelEmitter::InstrSubclasses(std::ostream &OS, std::string prefix, std::string InstrClassName, ListInit* SupportedSubclasses, std::vector<std::string>& vi, unsigned depth);

  std::string spacing();
  std::string addspacing();
  std::string remspacing();

};

} // End llvm namespace

#endif