Sanjiv Gupta | 085ae4f | 2008-11-19 11:00:54 +0000 | [diff] [blame] | 1 | //===-- 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" |
Sanjiv Gupta | 085ae4f | 2008-11-19 11:00:54 +0000 | [diff] [blame] | 17 | #include "PIC16RegisterInfo.h" |
| 18 | #include "PIC16TargetMachine.h" |
Dan Gohman | dbb121b | 2010-04-17 15:26:15 +0000 | [diff] [blame] | 19 | #include "PIC16MachineFunctionInfo.h" |
Sanjiv Gupta | 085ae4f | 2008-11-19 11:00:54 +0000 | [diff] [blame] | 20 | #include "llvm/CodeGen/SelectionDAGISel.h" |
| 21 | #include "llvm/Support/Compiler.h" |
Chris Lattner | d648a45 | 2010-02-22 22:14:47 +0000 | [diff] [blame] | 22 | #include "llvm/Support/raw_ostream.h" |
| 23 | #include "llvm/Support/Debug.h" |
Sanjiv Gupta | 085ae4f | 2008-11-19 11:00:54 +0000 | [diff] [blame] | 24 | #include "llvm/Intrinsics.h" |
| 25 | using namespace llvm; |
| 26 | |
| 27 | namespace { |
| 28 | |
Duncan Sands | 8717782 | 2010-05-11 20:16:09 +0000 | [diff] [blame] | 29 | class LLVM_LIBRARY_VISIBILITY PIC16DAGToDAGISel : public SelectionDAGISel { |
Sanjiv Gupta | 085ae4f | 2008-11-19 11:00:54 +0000 | [diff] [blame] | 30 | |
| 31 | /// TM - Keep a reference to PIC16TargetMachine. |
Dan Gohman | dbb121b | 2010-04-17 15:26:15 +0000 | [diff] [blame] | 32 | const PIC16TargetMachine &TM; |
Sanjiv Gupta | 085ae4f | 2008-11-19 11:00:54 +0000 | [diff] [blame] | 33 | |
| 34 | /// PIC16Lowering - This object fully describes how to lower LLVM code to an |
| 35 | /// PIC16-specific SelectionDAG. |
Dan Gohman | dbb121b | 2010-04-17 15:26:15 +0000 | [diff] [blame] | 36 | const PIC16TargetLowering &PIC16Lowering; |
Sanjiv Gupta | 085ae4f | 2008-11-19 11:00:54 +0000 | [diff] [blame] | 37 | |
| 38 | public: |
| 39 | explicit PIC16DAGToDAGISel(PIC16TargetMachine &tm) : |
Dan Gohman | 96eb47a | 2009-01-15 19:20:50 +0000 | [diff] [blame] | 40 | SelectionDAGISel(tm), |
Dan Gohman | dbb121b | 2010-04-17 15:26:15 +0000 | [diff] [blame] | 41 | TM(tm), PIC16Lowering(*TM.getTargetLowering()) {} |
Sanjiv Gupta | 085ae4f | 2008-11-19 11:00:54 +0000 | [diff] [blame] | 42 | |
| 43 | // Pass Name |
| 44 | virtual const char *getPassName() const { |
| 45 | return "PIC16 DAG->DAG Pattern Instruction Selection"; |
| 46 | } |
| 47 | |
Sanjiv Gupta | 085ae4f | 2008-11-19 11:00:54 +0000 | [diff] [blame] | 48 | private: |
| 49 | // Include the pieces autogenerated from the target description. |
| 50 | #include "PIC16GenDAGISel.inc" |
| 51 | |
Dan Gohman | 5f082a7 | 2010-01-05 01:24:18 +0000 | [diff] [blame] | 52 | SDNode *Select(SDNode *N); |
Sanjiv Gupta | 085ae4f | 2008-11-19 11:00:54 +0000 | [diff] [blame] | 53 | |
| 54 | // Match direct address complex pattern. |
Dan Gohman | 5f082a7 | 2010-01-05 01:24:18 +0000 | [diff] [blame] | 55 | bool SelectDirectAddr(SDNode *Op, SDValue N, SDValue &Address); |
Sanjiv Gupta | 085ae4f | 2008-11-19 11:00:54 +0000 | [diff] [blame] | 56 | |
| 57 | }; |
| 58 | |
| 59 | } |
| 60 | |