blob: 534326e926173aa76aeb243ca8f0b43f07344280 [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 Lattnerae506702008-01-06 01:10:31 +000027 CodeGenDAGPatterns CGP;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000028public:
Chris Lattner14948ea2008-01-05 22:58:54 +000029 DAGISelEmitter(RecordKeeper &R) : Records(R), CGP(R) {}
Dan Gohmanf17a25c2007-07-18 16:29:46 +000030
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:
Chris Lattner227da452008-01-05 22:54:53 +000036 void EmitNodeTransforms(std::ostream &OS);
Chris Lattner7fdd9342008-01-05 22:43:57 +000037 void EmitPredicateFunctions(std::ostream &OS);
38
Chris Lattner81915752008-01-05 22:30:17 +000039 void GenerateCodeForPattern(const PatternToMatch &Pattern,
Dan Gohmanf17a25c2007-07-18 16:29:46 +000040 std::vector<std::pair<unsigned, std::string> > &GeneratedCode,
41 std::set<std::string> &GeneratedDecl,
42 std::vector<std::string> &TargetOpcodes,
43 std::vector<std::string> &TargetVTs);
Chris Lattner81915752008-01-05 22:30:17 +000044 void EmitPatterns(std::vector<std::pair<const PatternToMatch*,
Dan Gohmanf17a25c2007-07-18 16:29:46 +000045 std::vector<std::pair<unsigned, std::string> > > > &Patterns,
46 unsigned Indent, std::ostream &OS);
Chris Lattner7fdd9342008-01-05 22:43:57 +000047
Dan Gohmanf17a25c2007-07-18 16:29:46 +000048 void EmitInstructionSelector(std::ostream &OS);
49};
50
51} // End llvm namespace
52
53#endif