blob: d5b889b0551019d33ff7205da012cbc2c6f0efd7 [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
Dan Gohman907df572008-04-03 00:02:49 +000017#include "TableGenBackend.h"
Chris Lattner4ca8ff02008-01-05 22:25:12 +000018#include "CodeGenDAGPatterns.h"
Dan Gohmanf17a25c2007-07-18 16:29:46 +000019#include <set>
20
21namespace llvm {
Dan Gohmanf17a25c2007-07-18 16:29:46 +000022
23/// DAGISelEmitter - The top-level class which coordinates construction
24/// and emission of the instruction selector.
25///
26class DAGISelEmitter : public TableGenBackend {
Dan Gohmanf17a25c2007-07-18 16:29:46 +000027 RecordKeeper &Records;
Chris Lattnerae506702008-01-06 01:10:31 +000028 CodeGenDAGPatterns CGP;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000029public:
Dan Gohmanedd345c2009-02-18 16:37:45 +000030 explicit DAGISelEmitter(RecordKeeper &R) : Records(R), CGP(R) {}
Dan Gohmanf17a25c2007-07-18 16:29:46 +000031
32 // run - Output the isel, returning true on failure.
Daniel Dunbard4287062009-07-03 00:10:29 +000033 void run(raw_ostream &OS);
Dan Gohmanf17a25c2007-07-18 16:29:46 +000034
Dan Gohmanf17a25c2007-07-18 16:29:46 +000035
36private:
Daniel Dunbard4287062009-07-03 00:10:29 +000037 void EmitNodeTransforms(raw_ostream &OS);
38 void EmitPredicateFunctions(raw_ostream &OS);
Chris Lattner7fdd9342008-01-05 22:43:57 +000039
Chris Lattner81915752008-01-05 22:30:17 +000040 void GenerateCodeForPattern(const PatternToMatch &Pattern,
Dan Gohmanf17a25c2007-07-18 16:29:46 +000041 std::vector<std::pair<unsigned, std::string> > &GeneratedCode,
42 std::set<std::string> &GeneratedDecl,
43 std::vector<std::string> &TargetOpcodes,
Dan Gohman2c4be2a2008-05-31 02:11:25 +000044 std::vector<std::string> &TargetVTs,
45 bool &OutputIsVariadic,
46 unsigned &NumInputRootOps);
Chris Lattner81915752008-01-05 22:30:17 +000047 void EmitPatterns(std::vector<std::pair<const PatternToMatch*,
Dan Gohmanf17a25c2007-07-18 16:29:46 +000048 std::vector<std::pair<unsigned, std::string> > > > &Patterns,
Daniel Dunbard4287062009-07-03 00:10:29 +000049 unsigned Indent, raw_ostream &OS);
Chris Lattner7fdd9342008-01-05 22:43:57 +000050
Daniel Dunbard4287062009-07-03 00:10:29 +000051 void EmitInstructionSelector(raw_ostream &OS);
Dan Gohmanf17a25c2007-07-18 16:29:46 +000052};
53
54} // End llvm namespace
55
56#endif