blob: a2d14c44f7ba5395e4f8fcead2e9362dc662179f [file] [log] [blame]
Sanjiv Gupta085ae4f2008-11-19 11:00:54 +00001//===-- PIC16ISelDAGToDAG.cpp - A dag to dag inst selector for PIC16 ------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file defines an instruction selector for the PIC16 target.
11//
12//===----------------------------------------------------------------------===//
13
14#define DEBUG_TYPE "pic16-isel"
15
16#include "PIC16.h"
17#include "PIC16ISelLowering.h"
18#include "PIC16RegisterInfo.h"
19#include "PIC16TargetMachine.h"
20#include "llvm/CodeGen/SelectionDAGISel.h"
21#include "llvm/Support/Compiler.h"
Chris Lattnerd648a452010-02-22 22:14:47 +000022#include "llvm/Support/raw_ostream.h"
23#include "llvm/Support/Debug.h"
Sanjiv Gupta085ae4f2008-11-19 11:00:54 +000024#include "llvm/Intrinsics.h"
25using namespace llvm;
26
27namespace {
28
29class VISIBILITY_HIDDEN PIC16DAGToDAGISel : public SelectionDAGISel {
30
31 /// TM - Keep a reference to PIC16TargetMachine.
32 PIC16TargetMachine &TM;
33
34 /// PIC16Lowering - This object fully describes how to lower LLVM code to an
35 /// PIC16-specific SelectionDAG.
Chris Lattner03708c52009-07-28 03:05:40 +000036 PIC16TargetLowering &PIC16Lowering;
Sanjiv Gupta085ae4f2008-11-19 11:00:54 +000037
38public:
39 explicit PIC16DAGToDAGISel(PIC16TargetMachine &tm) :
Dan Gohman96eb47a2009-01-15 19:20:50 +000040 SelectionDAGISel(tm),
Sanjiv Guptac7768832009-12-23 11:19:09 +000041 TM(tm), PIC16Lowering(*TM.getTargetLowering()) {
42 // Keep PIC16 specific DAGISel to use during the lowering
43 PIC16Lowering.ISel = this;
44 }
Sanjiv Gupta085ae4f2008-11-19 11:00:54 +000045
46 // Pass Name
47 virtual const char *getPassName() const {
48 return "PIC16 DAG->DAG Pattern Instruction Selection";
49 }
50
51 virtual void InstructionSelect();
52
53private:
54 // Include the pieces autogenerated from the target description.
55#include "PIC16GenDAGISel.inc"
56
Dan Gohman5f082a72010-01-05 01:24:18 +000057 SDNode *Select(SDNode *N);
Sanjiv Gupta085ae4f2008-11-19 11:00:54 +000058
59 // Match direct address complex pattern.
Dan Gohman5f082a72010-01-05 01:24:18 +000060 bool SelectDirectAddr(SDNode *Op, SDValue N, SDValue &Address);
Sanjiv Gupta085ae4f2008-11-19 11:00:54 +000061
62};
63
64}
65