Sanjiv Gupta | 09bb420 | 2008-05-13 09:02:57 +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 | |
Edwin Török | 4d9756a | 2009-07-08 20:53:28 +0000 | [diff] [blame] | 16 | #include "llvm/Support/ErrorHandling.h" |
Chris Lattner | d648a45 | 2010-02-22 22:14:47 +0000 | [diff] [blame] | 17 | #include "PIC16ISelDAGToDAG.h" |
Sanjiv Gupta | 09bb420 | 2008-05-13 09:02:57 +0000 | [diff] [blame] | 18 | using namespace llvm; |
| 19 | |
Sanjiv Gupta | 085ae4f | 2008-11-19 11:00:54 +0000 | [diff] [blame] | 20 | /// createPIC16ISelDag - This pass converts a legalized DAG into a |
Sanjiv Gupta | 09bb420 | 2008-05-13 09:02:57 +0000 | [diff] [blame] | 21 | /// PIC16-specific DAG, ready for instruction scheduling. |
| 22 | FunctionPass *llvm::createPIC16ISelDag(PIC16TargetMachine &TM) { |
| 23 | return new PIC16DAGToDAGISel(TM); |
| 24 | } |
| 25 | |
Sanjiv Gupta | 085ae4f | 2008-11-19 11:00:54 +0000 | [diff] [blame] | 26 | |
Sanjiv Gupta | 085ae4f | 2008-11-19 11:00:54 +0000 | [diff] [blame] | 27 | /// Select - Select instructions not customized! Used for |
| 28 | /// expanded, promoted and normal instructions. |
Dan Gohman | 5f082a7 | 2010-01-05 01:24:18 +0000 | [diff] [blame] | 29 | SDNode* PIC16DAGToDAGISel::Select(SDNode *N) { |
Sanjiv Gupta | 085ae4f | 2008-11-19 11:00:54 +0000 | [diff] [blame] | 30 | |
| 31 | // Select the default instruction. |
| 32 | SDNode *ResNode = SelectCode(N); |
| 33 | |
| 34 | return ResNode; |
| 35 | } |
| 36 | |
| 37 | |
| 38 | // SelectDirectAddr - Match a direct address for DAG. |
| 39 | // A direct address could be a globaladdress or externalsymbol. |
Dan Gohman | 5f082a7 | 2010-01-05 01:24:18 +0000 | [diff] [blame] | 40 | bool PIC16DAGToDAGISel::SelectDirectAddr(SDNode *Op, SDValue N, |
Sanjiv Gupta | 085ae4f | 2008-11-19 11:00:54 +0000 | [diff] [blame] | 41 | SDValue &Address) { |
| 42 | // Return true if TGA or ES. |
| 43 | if (N.getOpcode() == ISD::TargetGlobalAddress |
| 44 | || N.getOpcode() == ISD::TargetExternalSymbol) { |
| 45 | Address = N; |
| 46 | return true; |
| 47 | } |
| 48 | |
| 49 | return false; |
| 50 | } |