Rename SDOperand to SDValue.
[oota-llvm.git] / lib / Target / PIC16 / PIC16ISelLowering.h
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
18 #include "PIC16.h"
19 #include "PIC16Subtarget.h"
20 #include "llvm/CodeGen/SelectionDAG.h"
21 #include "llvm/Target/TargetLowering.h"
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
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).
42
43       // PIC16 comparison to be converted to either XOR or SUB
44       // Following instructions cater to those convertions.
45       XORCC,        
46       SUBCC,        
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.
67     virtual SDValue LowerOperation(SDValue Op, SelectionDAG &DAG);
68
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);
74
75     SDValue RemoveHiLo(SDNode *, SelectionDAG &DAG, 
76                          DAGCombinerInfo &DCI) const;
77     SDValue LowerADDSUB(SDNode *, SelectionDAG &DAG, 
78                           DAGCombinerInfo &DCI) const;
79     SDValue LowerLOAD(SDNode *, SelectionDAG &DAG, 
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;
85     virtual SDValue PerformDAGCombine(SDNode *N, DAGCombinerInfo &DCI) const;
86
87     // utility function.
88     const SDValue *findLoadi8(const SDValue &Src, SelectionDAG &DAG) const;
89   };
90 } // namespace llvm
91
92 #endif // PIC16ISELLOWERING_H