Sanjiv Gupta | 0e68771 | 2008-05-13 09:02:57 +0000 | [diff] [blame] | 1 | //===-- PIC16ISelLowering.h - PIC16 DAG Lowering Interface ------*- C++ -*-===// |
| 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 the interfaces that PIC16 uses to lower LLVM code into a |
| 11 | // selection DAG. |
| 12 | // |
| 13 | //===----------------------------------------------------------------------===// |
| 14 | |
| 15 | #ifndef PIC16ISELLOWERING_H |
| 16 | #define PIC16ISELLOWERING_H |
| 17 | |
Sanjiv Gupta | 0e68771 | 2008-05-13 09:02:57 +0000 | [diff] [blame] | 18 | #include "PIC16.h" |
| 19 | #include "PIC16Subtarget.h" |
Sanjiv Gupta | 2010b3e | 2008-05-14 11:31:39 +0000 | [diff] [blame] | 20 | #include "llvm/CodeGen/SelectionDAG.h" |
| 21 | #include "llvm/Target/TargetLowering.h" |
Sanjiv Gupta | 0e68771 | 2008-05-13 09:02:57 +0000 | [diff] [blame] | 22 | |
| 23 | namespace llvm { |
| 24 | namespace PIC16ISD { |
| 25 | enum NodeType { |
| 26 | // Start the numbering from where ISD NodeType finishes. |
| 27 | FIRST_NUMBER = ISD::BUILTIN_OP_END+PIC16::INSTRUCTION_LIST_END, |
| 28 | |
| 29 | // used for encapsulating the expanded nodes into one node. |
| 30 | Package, |
| 31 | |
| 32 | // Get the Higher 16 bits from a 32-bit immediate |
| 33 | Hi, |
| 34 | |
| 35 | // Get the Lower 16 bits from a 32-bit immediate |
| 36 | Lo, |
| 37 | |
Sanjiv Gupta | 2010b3e | 2008-05-14 11:31:39 +0000 | [diff] [blame] | 38 | Cmp, // PIC16 Generic Comparison instruction. |
| 39 | Branch, // PIC16 Generic Branch Instruction. |
| 40 | BTFSS, // PIC16 BitTest Instruction (Skip if set). |
| 41 | BTFSC, // PIC16 BitTest Instruction (Skip if clear). |
Sanjiv Gupta | 0e68771 | 2008-05-13 09:02:57 +0000 | [diff] [blame] | 42 | |
| 43 | // PIC16 comparison to be converted to either XOR or SUB |
| 44 | // Following instructions cater to those convertions. |
Sanjiv Gupta | 2010b3e | 2008-05-14 11:31:39 +0000 | [diff] [blame] | 45 | XORCC, |
| 46 | SUBCC, |
Sanjiv Gupta | 0e68771 | 2008-05-13 09:02:57 +0000 | [diff] [blame] | 47 | |
| 48 | // Get the Global Address wrapped into a wrapper that also captures |
| 49 | // the bank or page. |
| 50 | Wrapper, |
| 51 | SetBank, |
| 52 | SetPage |
| 53 | }; |
| 54 | } |
| 55 | |
| 56 | //===--------------------------------------------------------------------===// |
| 57 | // TargetLowering Implementation |
| 58 | //===--------------------------------------------------------------------===// |
| 59 | class PIC16TargetLowering : public TargetLowering |
| 60 | { |
| 61 | public: |
| 62 | typedef std::map<SDNode *, SDNode *> NodeMap_t; |
| 63 | |
| 64 | explicit PIC16TargetLowering(PIC16TargetMachine &TM); |
| 65 | |
| 66 | /// LowerOperation - Provide custom lowering hooks for some operations. |
Dan Gohman | 475871a | 2008-07-27 21:46:04 +0000 | [diff] [blame^] | 67 | virtual SDValue LowerOperation(SDValue Op, SelectionDAG &DAG); |
Sanjiv Gupta | 0e68771 | 2008-05-13 09:02:57 +0000 | [diff] [blame] | 68 | |
Dan Gohman | 475871a | 2008-07-27 21:46:04 +0000 | [diff] [blame^] | 69 | SDValue LowerGlobalAddress(SDValue Op, SelectionDAG &DAG); |
| 70 | SDValue LowerFORMAL_ARGUMENTS(SDValue Op, SelectionDAG &DAG); |
| 71 | SDValue LowerRET(SDValue Op, SelectionDAG &DAG); |
| 72 | SDValue LowerFrameIndex(SDValue Op, SelectionDAG &DAG); |
| 73 | SDValue LowerBR_CC(SDValue Op, SelectionDAG &DAG); |
Sanjiv Gupta | 0e68771 | 2008-05-13 09:02:57 +0000 | [diff] [blame] | 74 | |
Dan Gohman | 475871a | 2008-07-27 21:46:04 +0000 | [diff] [blame^] | 75 | SDValue RemoveHiLo(SDNode *, SelectionDAG &DAG, |
Sanjiv Gupta | 2010b3e | 2008-05-14 11:31:39 +0000 | [diff] [blame] | 76 | DAGCombinerInfo &DCI) const; |
Dan Gohman | 475871a | 2008-07-27 21:46:04 +0000 | [diff] [blame^] | 77 | SDValue LowerADDSUB(SDNode *, SelectionDAG &DAG, |
Sanjiv Gupta | 2010b3e | 2008-05-14 11:31:39 +0000 | [diff] [blame] | 78 | DAGCombinerInfo &DCI) const; |
Dan Gohman | 475871a | 2008-07-27 21:46:04 +0000 | [diff] [blame^] | 79 | SDValue LowerLOAD(SDNode *, SelectionDAG &DAG, |
Sanjiv Gupta | 0e68771 | 2008-05-13 09:02:57 +0000 | [diff] [blame] | 80 | DAGCombinerInfo &DCI) const; |
| 81 | |
| 82 | /// getTargetNodeName - This method returns the name of a target specific |
| 83 | // DAG node. |
| 84 | virtual const char *getTargetNodeName(unsigned Opcode) const; |
Dan Gohman | 475871a | 2008-07-27 21:46:04 +0000 | [diff] [blame^] | 85 | virtual SDValue PerformDAGCombine(SDNode *N, DAGCombinerInfo &DCI) const; |
Sanjiv Gupta | 0e68771 | 2008-05-13 09:02:57 +0000 | [diff] [blame] | 86 | |
| 87 | // utility function. |
Dan Gohman | 475871a | 2008-07-27 21:46:04 +0000 | [diff] [blame^] | 88 | const SDValue *findLoadi8(const SDValue &Src, SelectionDAG &DAG) const; |
Sanjiv Gupta | 0e68771 | 2008-05-13 09:02:57 +0000 | [diff] [blame] | 89 | }; |
| 90 | } // namespace llvm |
| 91 | |
| 92 | #endif // PIC16ISELLOWERING_H |