blob: 8fb5d6f24975d441284d2ab950bfdae6251fa52a [file] [log] [blame]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001//===- DAGISelEmitter.h - Generate an instruction selector ------*- 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 emits a DAG instruction selector.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef DAGISEL_EMITTER_H
15#define DAGISEL_EMITTER_H
16
Chris Lattner4ca8ff02008-01-05 22:25:12 +000017#include "CodeGenDAGPatterns.h"
Dan Gohmanf17a25c2007-07-18 16:29:46 +000018#include <set>
19
20namespace llvm {
Dan Gohmanf17a25c2007-07-18 16:29:46 +000021
22/// DAGISelEmitter - The top-level class which coordinates construction
23/// and emission of the instruction selector.
24///
25class DAGISelEmitter : public TableGenBackend {
Dan Gohmanf17a25c2007-07-18 16:29:46 +000026 RecordKeeper &Records;
Chris Lattner4ca8ff02008-01-05 22:25:12 +000027 CodegenDAGPatterns *CGP;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000028public:
29 DAGISelEmitter(RecordKeeper &R) : Records(R) {}
30
31 // run - Output the isel, returning true on failure.
32 void run(std::ostream &OS);
33
Dan Gohmanf17a25c2007-07-18 16:29:46 +000034
35private:
Dan Gohmanf17a25c2007-07-18 16:29:46 +000036 void GenerateCodeForPattern(PatternToMatch &Pattern,
37 std::vector<std::pair<unsigned, std::string> > &GeneratedCode,
38 std::set<std::string> &GeneratedDecl,
39 std::vector<std::string> &TargetOpcodes,
40 std::vector<std::string> &TargetVTs);
41 void EmitPatterns(std::vector<std::pair<PatternToMatch*,
42 std::vector<std::pair<unsigned, std::string> > > > &Patterns,
43 unsigned Indent, std::ostream &OS);
44 void EmitInstructionSelector(std::ostream &OS);
45};
46
47} // End llvm namespace
48
49#endif