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 | cae1b62 | 2009-04-06 10:54:50 +0000 | [diff] [blame] | 22 | #include <map> |
Sanjiv Gupta | 0e68771 | 2008-05-13 09:02:57 +0000 | [diff] [blame] | 23 | |
| 24 | namespace llvm { |
| 25 | namespace PIC16ISD { |
| 26 | enum NodeType { |
| 27 | // Start the numbering from where ISD NodeType finishes. |
Dan Gohman | 0ba2bcf | 2008-09-23 18:42:32 +0000 | [diff] [blame] | 28 | FIRST_NUMBER = ISD::BUILTIN_OP_END, |
Sanjiv Gupta | 0e68771 | 2008-05-13 09:02:57 +0000 | [diff] [blame] | 29 | |
Sanjiv Gupta | b1b5ffd | 2008-11-19 11:00:54 +0000 | [diff] [blame] | 30 | Lo, // Low 8-bits of GlobalAddress. |
| 31 | Hi, // High 8-bits of GlobalAddress. |
| 32 | PIC16Load, |
Sanjiv Gupta | b84d5a4 | 2009-04-02 17:42:00 +0000 | [diff] [blame] | 33 | PIC16LdArg, // This is replica of PIC16Load but used to load function |
| 34 | // arguments and is being used for facilitating for some |
| 35 | // store removal optimizations. |
| 36 | |
Sanjiv Gupta | 1b04694 | 2009-01-13 19:18:47 +0000 | [diff] [blame] | 37 | PIC16LdWF, |
Sanjiv Gupta | b1b5ffd | 2008-11-19 11:00:54 +0000 | [diff] [blame] | 38 | PIC16Store, |
Sanjiv Gupta | 1b04694 | 2009-01-13 19:18:47 +0000 | [diff] [blame] | 39 | PIC16StWF, |
Sanjiv Gupta | b1b5ffd | 2008-11-19 11:00:54 +0000 | [diff] [blame] | 40 | Banksel, |
Sanjiv Gupta | 7836fc1 | 2009-04-08 05:38:48 +0000 | [diff] [blame] | 41 | MTLO, // Move to low part of FSR |
| 42 | MTHI, // Move to high part of FSR |
| 43 | MTPCLATH, // Move to PCLATCH |
| 44 | PIC16Connect, // General connector for PIC16 nodes |
Sanjiv Gupta | b1b5ffd | 2008-11-19 11:00:54 +0000 | [diff] [blame] | 45 | BCF, |
| 46 | LSLF, // PIC16 Logical shift left |
| 47 | LRLF, // PIC16 Logical shift right |
| 48 | RLF, // Rotate left through carry |
| 49 | RRF, // Rotate right through carry |
Sanjiv Gupta | 1b04694 | 2009-01-13 19:18:47 +0000 | [diff] [blame] | 50 | CALL, // PIC16 Call instruction |
Sanjiv Gupta | 7836fc1 | 2009-04-08 05:38:48 +0000 | [diff] [blame] | 51 | CALLW, // PIC16 CALLW instruction |
Bill Wendling | 51b16f4 | 2009-05-30 01:09:53 +0000 | [diff] [blame] | 52 | SUBCC, // Compare for equality or inequality. |
Sanjiv Gupta | 1b04694 | 2009-01-13 19:18:47 +0000 | [diff] [blame] | 53 | SELECT_ICC, // Psuedo to be caught in schedular and expanded to brcond. |
| 54 | BRCOND, // Conditional branch. |
Dan Gohman | 98ca4f2 | 2009-08-05 01:29:28 +0000 | [diff] [blame] | 55 | RET, // Return. |
Sanjiv Gupta | b1b5ffd | 2008-11-19 11:00:54 +0000 | [diff] [blame] | 56 | Dummy |
| 57 | }; |
Sanjiv Gupta | 0e68771 | 2008-05-13 09:02:57 +0000 | [diff] [blame] | 58 | |
Sanjiv Gupta | b1b5ffd | 2008-11-19 11:00:54 +0000 | [diff] [blame] | 59 | // Keep track of different address spaces. |
| 60 | enum AddressSpace { |
| 61 | RAM_SPACE = 0, // RAM address space |
| 62 | ROM_SPACE = 1 // ROM address space number is 1 |
Sanjiv Gupta | 0e68771 | 2008-05-13 09:02:57 +0000 | [diff] [blame] | 63 | }; |
Sanjiv Gupta | 08b9b05 | 2009-01-21 05:44:05 +0000 | [diff] [blame] | 64 | enum PIC16Libcall { |
Sanjiv Gupta | e0b4b0e | 2009-05-11 08:52:04 +0000 | [diff] [blame] | 65 | MUL_I8 = RTLIB::UNKNOWN_LIBCALL + 1, |
Sanjiv Gupta | 1b04694 | 2009-01-13 19:18:47 +0000 | [diff] [blame] | 66 | SRA_I8, |
| 67 | SLL_I8, |
| 68 | SRL_I8, |
Sanjiv Gupta | 1b04694 | 2009-01-13 19:18:47 +0000 | [diff] [blame] | 69 | PIC16UnknownCall |
| 70 | }; |
Sanjiv Gupta | 0e68771 | 2008-05-13 09:02:57 +0000 | [diff] [blame] | 71 | } |
| 72 | |
Sanjiv Gupta | 1b04694 | 2009-01-13 19:18:47 +0000 | [diff] [blame] | 73 | |
Sanjiv Gupta | 0e68771 | 2008-05-13 09:02:57 +0000 | [diff] [blame] | 74 | //===--------------------------------------------------------------------===// |
| 75 | // TargetLowering Implementation |
| 76 | //===--------------------------------------------------------------------===// |
Sanjiv Gupta | b1b5ffd | 2008-11-19 11:00:54 +0000 | [diff] [blame] | 77 | class PIC16TargetLowering : public TargetLowering { |
Sanjiv Gupta | 0e68771 | 2008-05-13 09:02:57 +0000 | [diff] [blame] | 78 | public: |
Sanjiv Gupta | 0e68771 | 2008-05-13 09:02:57 +0000 | [diff] [blame] | 79 | explicit PIC16TargetLowering(PIC16TargetMachine &TM); |
| 80 | |
Sanjiv Gupta | b1b5ffd | 2008-11-19 11:00:54 +0000 | [diff] [blame] | 81 | /// getTargetNodeName - This method returns the name of a target specific |
| 82 | /// DAG node. |
Sanjiv Gupta | 0e68771 | 2008-05-13 09:02:57 +0000 | [diff] [blame] | 83 | virtual const char *getTargetNodeName(unsigned Opcode) const; |
Sanjiv Gupta | 1b04694 | 2009-01-13 19:18:47 +0000 | [diff] [blame] | 84 | /// getSetCCResultType - Return the ISD::SETCC ValueType |
Owen Anderson | 825b72b | 2009-08-11 20:47:22 +0000 | [diff] [blame] | 85 | virtual MVT::SimpleValueType getSetCCResultType(EVT ValType) const; |
Sanjiv Gupta | 8f17a36 | 2009-12-28 02:40:33 +0000 | [diff] [blame] | 86 | virtual MVT::SimpleValueType getCmpLibcallReturnType() const; |
Dan Gohman | d858e90 | 2010-04-17 15:26:15 +0000 | [diff] [blame] | 87 | SDValue LowerShift(SDValue Op, SelectionDAG &DAG) const; |
| 88 | SDValue LowerMUL(SDValue Op, SelectionDAG &DAG) const; |
| 89 | SDValue LowerADD(SDValue Op, SelectionDAG &DAG) const; |
| 90 | SDValue LowerSUB(SDValue Op, SelectionDAG &DAG) const; |
| 91 | SDValue LowerBinOp(SDValue Op, SelectionDAG &DAG) const; |
Sanjiv Gupta | 7836fc1 | 2009-04-08 05:38:48 +0000 | [diff] [blame] | 92 | // Call returns |
| 93 | SDValue |
Dan Gohman | 98ca4f2 | 2009-08-05 01:29:28 +0000 | [diff] [blame] | 94 | LowerDirectCallReturn(SDValue RetLabel, SDValue Chain, SDValue InFlag, |
| 95 | const SmallVectorImpl<ISD::InputArg> &Ins, |
| 96 | DebugLoc dl, SelectionDAG &DAG, |
Dan Gohman | d858e90 | 2010-04-17 15:26:15 +0000 | [diff] [blame] | 97 | SmallVectorImpl<SDValue> &InVals) const; |
Sanjiv Gupta | 7836fc1 | 2009-04-08 05:38:48 +0000 | [diff] [blame] | 98 | SDValue |
Dan Gohman | 98ca4f2 | 2009-08-05 01:29:28 +0000 | [diff] [blame] | 99 | LowerIndirectCallReturn(SDValue Chain, SDValue InFlag, |
| 100 | SDValue DataAddr_Lo, SDValue DataAddr_Hi, |
| 101 | const SmallVectorImpl<ISD::InputArg> &Ins, |
| 102 | DebugLoc dl, SelectionDAG &DAG, |
Dan Gohman | d858e90 | 2010-04-17 15:26:15 +0000 | [diff] [blame] | 103 | SmallVectorImpl<SDValue> &InVals) const; |
Sanjiv Gupta | 7836fc1 | 2009-04-08 05:38:48 +0000 | [diff] [blame] | 104 | |
| 105 | // Call arguments |
| 106 | SDValue |
Dan Gohman | 98ca4f2 | 2009-08-05 01:29:28 +0000 | [diff] [blame] | 107 | LowerDirectCallArguments(SDValue ArgLabel, SDValue Chain, SDValue InFlag, |
| 108 | const SmallVectorImpl<ISD::OutputArg> &Outs, |
Dan Gohman | c940365 | 2010-07-07 15:54:55 +0000 | [diff] [blame] | 109 | const SmallVectorImpl<SDValue> &OutVals, |
Dan Gohman | d858e90 | 2010-04-17 15:26:15 +0000 | [diff] [blame] | 110 | DebugLoc dl, SelectionDAG &DAG) const; |
Sanjiv Gupta | 7836fc1 | 2009-04-08 05:38:48 +0000 | [diff] [blame] | 111 | |
| 112 | SDValue |
Dan Gohman | 98ca4f2 | 2009-08-05 01:29:28 +0000 | [diff] [blame] | 113 | LowerIndirectCallArguments(SDValue Chain, SDValue InFlag, |
Sanjiv Gupta | 7836fc1 | 2009-04-08 05:38:48 +0000 | [diff] [blame] | 114 | SDValue DataAddr_Lo, SDValue DataAddr_Hi, |
Dan Gohman | 98ca4f2 | 2009-08-05 01:29:28 +0000 | [diff] [blame] | 115 | const SmallVectorImpl<ISD::OutputArg> &Outs, |
Dan Gohman | c940365 | 2010-07-07 15:54:55 +0000 | [diff] [blame] | 116 | const SmallVectorImpl<SDValue> &OutVals, |
Sanjiv Gupta | a418628 | 2009-08-11 01:51:55 +0000 | [diff] [blame] | 117 | const SmallVectorImpl<ISD::InputArg> &Ins, |
Dan Gohman | d858e90 | 2010-04-17 15:26:15 +0000 | [diff] [blame] | 118 | DebugLoc dl, SelectionDAG &DAG) const; |
Sanjiv Gupta | 7836fc1 | 2009-04-08 05:38:48 +0000 | [diff] [blame] | 119 | |
Dan Gohman | d858e90 | 2010-04-17 15:26:15 +0000 | [diff] [blame] | 120 | SDValue LowerBR_CC(SDValue Op, SelectionDAG &DAG) const; |
| 121 | SDValue LowerSELECT_CC(SDValue Op, SelectionDAG &DAG) const; |
Sanjiv Gupta | 1b04694 | 2009-01-13 19:18:47 +0000 | [diff] [blame] | 122 | SDValue getPIC16Cmp(SDValue LHS, SDValue RHS, unsigned OrigCC, SDValue &CC, |
Dan Gohman | d858e90 | 2010-04-17 15:26:15 +0000 | [diff] [blame] | 123 | SelectionDAG &DAG, DebugLoc dl) const; |
Dan Gohman | af1d8ca | 2010-05-01 00:01:06 +0000 | [diff] [blame] | 124 | virtual MachineBasicBlock * |
| 125 | EmitInstrWithCustomInserter(MachineInstr *MI, |
| 126 | MachineBasicBlock *MBB) const; |
Sanjiv Gupta | 1b04694 | 2009-01-13 19:18:47 +0000 | [diff] [blame] | 127 | |
Dan Gohman | d858e90 | 2010-04-17 15:26:15 +0000 | [diff] [blame] | 128 | virtual SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const; |
Sanjiv Gupta | 1b04694 | 2009-01-13 19:18:47 +0000 | [diff] [blame] | 129 | virtual void ReplaceNodeResults(SDNode *N, |
| 130 | SmallVectorImpl<SDValue> &Results, |
Dan Gohman | d858e90 | 2010-04-17 15:26:15 +0000 | [diff] [blame] | 131 | SelectionDAG &DAG) const; |
Duncan Sands | 9fbc7e2 | 2009-01-21 09:00:29 +0000 | [diff] [blame] | 132 | virtual void LowerOperationWrapper(SDNode *N, |
| 133 | SmallVectorImpl<SDValue> &Results, |
Dan Gohman | d858e90 | 2010-04-17 15:26:15 +0000 | [diff] [blame] | 134 | SelectionDAG &DAG) const; |
Sanjiv Gupta | 08b9b05 | 2009-01-21 05:44:05 +0000 | [diff] [blame] | 135 | |
Dan Gohman | 98ca4f2 | 2009-08-05 01:29:28 +0000 | [diff] [blame] | 136 | virtual SDValue |
| 137 | LowerFormalArguments(SDValue Chain, |
Sandeep Patel | 65c3c8f | 2009-09-02 08:44:58 +0000 | [diff] [blame] | 138 | CallingConv::ID CallConv, |
Dan Gohman | 98ca4f2 | 2009-08-05 01:29:28 +0000 | [diff] [blame] | 139 | bool isVarArg, |
| 140 | const SmallVectorImpl<ISD::InputArg> &Ins, |
| 141 | DebugLoc dl, SelectionDAG &DAG, |
Dan Gohman | d858e90 | 2010-04-17 15:26:15 +0000 | [diff] [blame] | 142 | SmallVectorImpl<SDValue> &InVals) const; |
Dan Gohman | 98ca4f2 | 2009-08-05 01:29:28 +0000 | [diff] [blame] | 143 | |
| 144 | virtual SDValue |
Evan Cheng | 022d9e1 | 2010-02-02 23:55:14 +0000 | [diff] [blame] | 145 | LowerCall(SDValue Chain, SDValue Callee, |
Evan Cheng | 0c439eb | 2010-01-27 00:07:07 +0000 | [diff] [blame] | 146 | CallingConv::ID CallConv, bool isVarArg, bool &isTailCall, |
Dan Gohman | 98ca4f2 | 2009-08-05 01:29:28 +0000 | [diff] [blame] | 147 | const SmallVectorImpl<ISD::OutputArg> &Outs, |
Dan Gohman | c940365 | 2010-07-07 15:54:55 +0000 | [diff] [blame] | 148 | const SmallVectorImpl<SDValue> &OutVals, |
Dan Gohman | 98ca4f2 | 2009-08-05 01:29:28 +0000 | [diff] [blame] | 149 | const SmallVectorImpl<ISD::InputArg> &Ins, |
| 150 | DebugLoc dl, SelectionDAG &DAG, |
Dan Gohman | d858e90 | 2010-04-17 15:26:15 +0000 | [diff] [blame] | 151 | SmallVectorImpl<SDValue> &InVals) const; |
Dan Gohman | 98ca4f2 | 2009-08-05 01:29:28 +0000 | [diff] [blame] | 152 | |
| 153 | virtual SDValue |
| 154 | LowerReturn(SDValue Chain, |
Sandeep Patel | 65c3c8f | 2009-09-02 08:44:58 +0000 | [diff] [blame] | 155 | CallingConv::ID CallConv, bool isVarArg, |
Dan Gohman | 98ca4f2 | 2009-08-05 01:29:28 +0000 | [diff] [blame] | 156 | const SmallVectorImpl<ISD::OutputArg> &Outs, |
Dan Gohman | c940365 | 2010-07-07 15:54:55 +0000 | [diff] [blame] | 157 | const SmallVectorImpl<SDValue> &OutVals, |
Dan Gohman | d858e90 | 2010-04-17 15:26:15 +0000 | [diff] [blame] | 158 | DebugLoc dl, SelectionDAG &DAG) const; |
Dan Gohman | 98ca4f2 | 2009-08-05 01:29:28 +0000 | [diff] [blame] | 159 | |
Dan Gohman | d858e90 | 2010-04-17 15:26:15 +0000 | [diff] [blame] | 160 | SDValue ExpandStore(SDNode *N, SelectionDAG &DAG) const; |
| 161 | SDValue ExpandLoad(SDNode *N, SelectionDAG &DAG) const; |
| 162 | SDValue ExpandGlobalAddress(SDNode *N, SelectionDAG &DAG) const; |
| 163 | SDValue ExpandExternalSymbol(SDNode *N, SelectionDAG &DAG) const; |
| 164 | SDValue ExpandFrameIndex(SDNode *N, SelectionDAG &DAG) const; |
Sanjiv Gupta | b1b5ffd | 2008-11-19 11:00:54 +0000 | [diff] [blame] | 165 | |
| 166 | SDValue PerformDAGCombine(SDNode *N, DAGCombinerInfo &DCI) const; |
| 167 | SDValue PerformPIC16LoadCombine(SDNode *N, DAGCombinerInfo &DCI) const; |
Sanjiv Gupta | b84d5a4 | 2009-04-02 17:42:00 +0000 | [diff] [blame] | 168 | SDValue PerformStoreCombine(SDNode *N, DAGCombinerInfo &DCI) const; |
Sanjiv Gupta | b1b5ffd | 2008-11-19 11:00:54 +0000 | [diff] [blame] | 169 | |
Sanjiv Gupta | cae1b62 | 2009-04-06 10:54:50 +0000 | [diff] [blame] | 170 | // This function returns the Tmp Offset for FrameIndex. If any TmpOffset |
| 171 | // already exists for the FI then it returns the same else it creates the |
| 172 | // new offset and returns. |
Dan Gohman | 1e93df6 | 2010-04-17 14:41:14 +0000 | [diff] [blame] | 173 | unsigned GetTmpOffsetForFI(unsigned FI, unsigned slot_size, |
Dan Gohman | d858e90 | 2010-04-17 15:26:15 +0000 | [diff] [blame] | 174 | MachineFunction &MF) const; |
| 175 | void ResetTmpOffsetMap(SelectionDAG &DAG) const; |
Dan Gohman | 1e93df6 | 2010-04-17 14:41:14 +0000 | [diff] [blame] | 176 | void InitReservedFrameCount(const Function *F, |
Dan Gohman | d858e90 | 2010-04-17 15:26:15 +0000 | [diff] [blame] | 177 | SelectionDAG &DAG) const; |
Sanjiv Gupta | cae1b62 | 2009-04-06 10:54:50 +0000 | [diff] [blame] | 178 | |
Bill Wendling | b4202b8 | 2009-07-01 18:50:55 +0000 | [diff] [blame] | 179 | /// getFunctionAlignment - Return the Log2 alignment of this function. |
Bill Wendling | 20c568f | 2009-06-30 22:38:32 +0000 | [diff] [blame] | 180 | virtual unsigned getFunctionAlignment(const Function *) const { |
| 181 | // FIXME: The function never seems to be aligned. |
| 182 | return 1; |
| 183 | } |
Evan Cheng | 4f6b467 | 2010-07-21 06:09:07 +0000 | [diff] [blame^] | 184 | protected: |
| 185 | std::pair<const TargetRegisterClass*, uint8_t> |
| 186 | findRepresentativeClass(EVT VT) const; |
Sanjiv Gupta | b1b5ffd | 2008-11-19 11:00:54 +0000 | [diff] [blame] | 187 | private: |
Sanjiv Gupta | b84d5a4 | 2009-04-02 17:42:00 +0000 | [diff] [blame] | 188 | // If the Node is a BUILD_PAIR representing a direct Address, |
| 189 | // then this function will return true. |
Dan Gohman | d858e90 | 2010-04-17 15:26:15 +0000 | [diff] [blame] | 190 | bool isDirectAddress(const SDValue &Op) const; |
Sanjiv Gupta | b1b5ffd | 2008-11-19 11:00:54 +0000 | [diff] [blame] | 191 | |
| 192 | // If the Node is a DirectAddress in ROM_SPACE then this |
| 193 | // function will return true |
Dan Gohman | d858e90 | 2010-04-17 15:26:15 +0000 | [diff] [blame] | 194 | bool isRomAddress(const SDValue &Op) const; |
Sanjiv Gupta | b1b5ffd | 2008-11-19 11:00:54 +0000 | [diff] [blame] | 195 | |
Sanjiv Gupta | b1b5ffd | 2008-11-19 11:00:54 +0000 | [diff] [blame] | 196 | // Extract the Lo and Hi component of Op. |
| 197 | void GetExpandedParts(SDValue Op, SelectionDAG &DAG, SDValue &Lo, |
Dan Gohman | d858e90 | 2010-04-17 15:26:15 +0000 | [diff] [blame] | 198 | SDValue &Hi) const; |
Sanjiv Gupta | b1b5ffd | 2008-11-19 11:00:54 +0000 | [diff] [blame] | 199 | |
| 200 | |
| 201 | // Load pointer can be a direct or indirect address. In PIC16 direct |
| 202 | // addresses need Banksel and Indirect addresses need to be loaded to |
| 203 | // FSR first. Handle address specific cases here. |
| 204 | void LegalizeAddress(SDValue Ptr, SelectionDAG &DAG, SDValue &Chain, |
Dan Gohman | d858e90 | 2010-04-17 15:26:15 +0000 | [diff] [blame] | 205 | SDValue &NewPtr, unsigned &Offset, DebugLoc dl) const; |
Sanjiv Gupta | b1b5ffd | 2008-11-19 11:00:54 +0000 | [diff] [blame] | 206 | |
Sanjiv Gupta | 1b04694 | 2009-01-13 19:18:47 +0000 | [diff] [blame] | 207 | // FrameIndex should be broken down into ExternalSymbol and FrameOffset. |
| 208 | void LegalizeFrameIndex(SDValue Op, SelectionDAG &DAG, SDValue &ES, |
Dan Gohman | d858e90 | 2010-04-17 15:26:15 +0000 | [diff] [blame] | 209 | int &Offset) const; |
Sanjiv Gupta | 1b04694 | 2009-01-13 19:18:47 +0000 | [diff] [blame] | 210 | |
Sanjiv Gupta | 7836fc1 | 2009-04-08 05:38:48 +0000 | [diff] [blame] | 211 | // For indirect calls data address of the callee frame need to be |
| 212 | // extracted. This function fills the arguments DataAddr_Lo and |
| 213 | // DataAddr_Hi with the address of the callee frame. |
| 214 | void GetDataAddress(DebugLoc dl, SDValue Callee, SDValue &Chain, |
| 215 | SDValue &DataAddr_Lo, SDValue &DataAddr_Hi, |
Dan Gohman | d858e90 | 2010-04-17 15:26:15 +0000 | [diff] [blame] | 216 | SelectionDAG &DAG) const; |
Sanjiv Gupta | 7836fc1 | 2009-04-08 05:38:48 +0000 | [diff] [blame] | 217 | |
Sanjiv Gupta | b1b5ffd | 2008-11-19 11:00:54 +0000 | [diff] [blame] | 218 | // We can not have both operands of a binary operation in W. |
| 219 | // This function is used to put one operand on stack and generate a load. |
Dan Gohman | d858e90 | 2010-04-17 15:26:15 +0000 | [diff] [blame] | 220 | SDValue ConvertToMemOperand(SDValue Op, SelectionDAG &DAG, |
| 221 | DebugLoc dl) const; |
Sanjiv Gupta | b1b5ffd | 2008-11-19 11:00:54 +0000 | [diff] [blame] | 222 | |
Sanjiv Gupta | 1b04694 | 2009-01-13 19:18:47 +0000 | [diff] [blame] | 223 | // This function checks if we need to put an operand of an operation on |
| 224 | // stack and generate a load or not. |
Sanjiv Gupta | 76d2f9a | 2009-12-23 11:19:09 +0000 | [diff] [blame] | 225 | // DAG parameter is required to access DAG information during |
| 226 | // analysis. |
Dan Gohman | d858e90 | 2010-04-17 15:26:15 +0000 | [diff] [blame] | 227 | bool NeedToConvertToMemOp(SDValue Op, unsigned &MemOp, |
| 228 | SelectionDAG &DAG) const; |
Sanjiv Gupta | 1b04694 | 2009-01-13 19:18:47 +0000 | [diff] [blame] | 229 | |
Sanjiv Gupta | b1b5ffd | 2008-11-19 11:00:54 +0000 | [diff] [blame] | 230 | /// Subtarget - Keep a pointer to the PIC16Subtarget around so that we can |
| 231 | /// make the right decision when generating code for different targets. |
| 232 | const PIC16Subtarget *Subtarget; |
Sanjiv Gupta | 1b04694 | 2009-01-13 19:18:47 +0000 | [diff] [blame] | 233 | |
| 234 | |
| 235 | // Extending the LIB Call framework of LLVM |
Sanjiv Gupta | b84d5a4 | 2009-04-02 17:42:00 +0000 | [diff] [blame] | 236 | // to hold the names of PIC16Libcalls. |
Sanjiv Gupta | 08b9b05 | 2009-01-21 05:44:05 +0000 | [diff] [blame] | 237 | const char *PIC16LibcallNames[PIC16ISD::PIC16UnknownCall]; |
Sanjiv Gupta | 1b04694 | 2009-01-13 19:18:47 +0000 | [diff] [blame] | 238 | |
Sanjiv Gupta | b84d5a4 | 2009-04-02 17:42:00 +0000 | [diff] [blame] | 239 | // To set and retrieve the lib call names. |
Sanjiv Gupta | 08b9b05 | 2009-01-21 05:44:05 +0000 | [diff] [blame] | 240 | void setPIC16LibcallName(PIC16ISD::PIC16Libcall Call, const char *Name); |
Dan Gohman | d858e90 | 2010-04-17 15:26:15 +0000 | [diff] [blame] | 241 | const char *getPIC16LibcallName(PIC16ISD::PIC16Libcall Call) const; |
Sanjiv Gupta | 1b04694 | 2009-01-13 19:18:47 +0000 | [diff] [blame] | 242 | |
Sanjiv Gupta | b84d5a4 | 2009-04-02 17:42:00 +0000 | [diff] [blame] | 243 | // Make PIC16 Libcall. |
Owen Anderson | e50ed30 | 2009-08-10 22:56:29 +0000 | [diff] [blame] | 244 | SDValue MakePIC16Libcall(PIC16ISD::PIC16Libcall Call, EVT RetVT, |
Sanjiv Gupta | 1b04694 | 2009-01-13 19:18:47 +0000 | [diff] [blame] | 245 | const SDValue *Ops, unsigned NumOps, bool isSigned, |
Dan Gohman | d858e90 | 2010-04-17 15:26:15 +0000 | [diff] [blame] | 246 | SelectionDAG &DAG, DebugLoc dl) const; |
Sanjiv Gupta | 1b04694 | 2009-01-13 19:18:47 +0000 | [diff] [blame] | 247 | |
| 248 | // Check if operation has a direct load operand. |
Dan Gohman | d858e90 | 2010-04-17 15:26:15 +0000 | [diff] [blame] | 249 | inline bool isDirectLoad(const SDValue Op) const; |
Sanjiv Gupta | 0e68771 | 2008-05-13 09:02:57 +0000 | [diff] [blame] | 250 | }; |
| 251 | } // namespace llvm |
| 252 | |
| 253 | #endif // PIC16ISELLOWERING_H |