Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1 | //===-- ARMISelLowering.h - ARM DAG Lowering Interface ----------*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
Chris Lattner | 081ce94 | 2007-12-29 20:36:04 +0000 | [diff] [blame] | 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This file defines the interfaces that ARM uses to lower LLVM code into a |
| 11 | // selection DAG. |
| 12 | // |
| 13 | //===----------------------------------------------------------------------===// |
| 14 | |
| 15 | #ifndef ARMISELLOWERING_H |
| 16 | #define ARMISELLOWERING_H |
| 17 | |
Rafael Espindola | dd867c7 | 2007-11-05 23:12:20 +0000 | [diff] [blame] | 18 | #include "ARMSubtarget.h" |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 19 | #include "llvm/Target/TargetLowering.h" |
| 20 | #include "llvm/CodeGen/SelectionDAG.h" |
| 21 | #include <vector> |
| 22 | |
| 23 | namespace llvm { |
| 24 | class ARMConstantPoolValue; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 25 | |
| 26 | namespace ARMISD { |
| 27 | // ARM Specific DAG Nodes |
| 28 | enum NodeType { |
| 29 | // Start the numbering where the builting ops and target ops leave off. |
Dan Gohman | 868636e | 2008-09-23 18:42:32 +0000 | [diff] [blame] | 30 | FIRST_NUMBER = ISD::BUILTIN_OP_END, |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 31 | |
| 32 | Wrapper, // Wrapper - A wrapper node for TargetConstantPool, |
| 33 | // TargetExternalSymbol, and TargetGlobalAddress. |
| 34 | WrapperJT, // WrapperJT - A wrapper node for TargetJumpTable |
| 35 | |
| 36 | CALL, // Function call. |
| 37 | CALL_PRED, // Function call that's predicable. |
| 38 | CALL_NOLINK, // Function call with branch not branch-and-link. |
| 39 | tCALL, // Thumb function call. |
| 40 | BRCOND, // Conditional branch. |
| 41 | BR_JT, // Jumptable branch. |
| 42 | RET_FLAG, // Return with a flag operand. |
| 43 | |
| 44 | PIC_ADD, // Add with a PC operand and a PIC label. |
| 45 | |
| 46 | CMP, // ARM compare instructions. |
| 47 | CMPNZ, // ARM compare that uses only N or Z flags. |
| 48 | CMPFP, // ARM VFP compare instruction, sets FPSCR. |
| 49 | CMPFPw0, // ARM VFP compare against zero instruction, sets FPSCR. |
| 50 | FMSTAT, // ARM fmstat instruction. |
| 51 | CMOV, // ARM conditional move instructions. |
| 52 | CNEG, // ARM conditional negate instructions. |
| 53 | |
| 54 | FTOSI, // FP to sint within a FP register. |
| 55 | FTOUI, // FP to uint within a FP register. |
| 56 | SITOF, // sint to FP within a FP register. |
| 57 | UITOF, // uint to FP within a FP register. |
| 58 | |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 59 | SRL_FLAG, // V,Flag = srl_flag X -> srl X, 1 + save carry out. |
| 60 | SRA_FLAG, // V,Flag = sra_flag X -> sra X, 1 + save carry out. |
| 61 | RRX, // V = RRX X, Flag -> srl X, 1 + shift in carry flag. |
| 62 | |
| 63 | FMRRD, // double to two gprs. |
| 64 | FMDRR, // Two gprs to double. |
| 65 | |
| 66 | THREAD_POINTER |
| 67 | }; |
| 68 | } |
| 69 | |
| 70 | //===----------------------------------------------------------------------===// |
| 71 | // ARMTargetLowering - ARM Implementation of the TargetLowering interface |
| 72 | |
| 73 | class ARMTargetLowering : public TargetLowering { |
| 74 | int VarArgsFrameIndex; // FrameIndex for start of varargs area. |
| 75 | public: |
Dan Gohman | 3a78bbf | 2007-08-02 21:21:54 +0000 | [diff] [blame] | 76 | explicit ARMTargetLowering(TargetMachine &TM); |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 77 | |
Dan Gohman | 8181bd1 | 2008-07-27 21:46:04 +0000 | [diff] [blame] | 78 | virtual SDValue LowerOperation(SDValue Op, SelectionDAG &DAG); |
Duncan Sands | 7d9834b | 2008-12-01 11:39:25 +0000 | [diff] [blame] | 79 | |
| 80 | /// ReplaceNodeResults - Replace the results of node with an illegal result |
| 81 | /// type with new values built out of custom code. |
| 82 | /// |
| 83 | virtual void ReplaceNodeResults(SDNode *N, SmallVectorImpl<SDValue>&Results, |
| 84 | SelectionDAG &DAG); |
| 85 | |
Dan Gohman | 8181bd1 | 2008-07-27 21:46:04 +0000 | [diff] [blame] | 86 | virtual SDValue PerformDAGCombine(SDNode *N, DAGCombinerInfo &DCI) const; |
Chris Lattner | 900cddb | 2007-11-27 22:36:16 +0000 | [diff] [blame] | 87 | |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 88 | virtual const char *getTargetNodeName(unsigned Opcode) const; |
| 89 | |
Evan Cheng | e637db1 | 2008-01-30 18:18:23 +0000 | [diff] [blame] | 90 | virtual MachineBasicBlock *EmitInstrWithCustomInserter(MachineInstr *MI, |
Dan Gohman | 96d6092 | 2009-02-07 16:15:20 +0000 | [diff] [blame] | 91 | MachineBasicBlock *MBB) const; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 92 | |
| 93 | /// isLegalAddressingMode - Return true if the addressing mode represented |
| 94 | /// by AM is legal for this target, for a load/store of the specified type. |
| 95 | virtual bool isLegalAddressingMode(const AddrMode &AM, const Type *Ty)const; |
| 96 | |
| 97 | /// getPreIndexedAddressParts - returns true by value, base pointer and |
| 98 | /// offset pointer and addressing mode by reference if the node's address |
| 99 | /// can be legally represented as pre-indexed load / store address. |
Dan Gohman | 8181bd1 | 2008-07-27 21:46:04 +0000 | [diff] [blame] | 100 | virtual bool getPreIndexedAddressParts(SDNode *N, SDValue &Base, |
| 101 | SDValue &Offset, |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 102 | ISD::MemIndexedMode &AM, |
Dan Gohman | b9e1026 | 2009-01-15 16:29:45 +0000 | [diff] [blame] | 103 | SelectionDAG &DAG) const; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 104 | |
| 105 | /// getPostIndexedAddressParts - returns true by value, base pointer and |
| 106 | /// offset pointer and addressing mode by reference if this node can be |
| 107 | /// combined with a load / store to form a post-indexed load / store. |
| 108 | virtual bool getPostIndexedAddressParts(SDNode *N, SDNode *Op, |
Dan Gohman | 8181bd1 | 2008-07-27 21:46:04 +0000 | [diff] [blame] | 109 | SDValue &Base, SDValue &Offset, |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 110 | ISD::MemIndexedMode &AM, |
Dan Gohman | b9e1026 | 2009-01-15 16:29:45 +0000 | [diff] [blame] | 111 | SelectionDAG &DAG) const; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 112 | |
Dan Gohman | 8181bd1 | 2008-07-27 21:46:04 +0000 | [diff] [blame] | 113 | virtual void computeMaskedBitsForTargetNode(const SDValue Op, |
Dan Gohman | d0dfc77 | 2008-02-13 22:28:48 +0000 | [diff] [blame] | 114 | const APInt &Mask, |
Dan Gohman | 229fa05 | 2008-02-13 00:35:47 +0000 | [diff] [blame] | 115 | APInt &KnownZero, |
| 116 | APInt &KnownOne, |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 117 | const SelectionDAG &DAG, |
| 118 | unsigned Depth) const; |
| 119 | ConstraintType getConstraintType(const std::string &Constraint) const; |
| 120 | std::pair<unsigned, const TargetRegisterClass*> |
| 121 | getRegForInlineAsmConstraint(const std::string &Constraint, |
Duncan Sands | 92c4391 | 2008-06-06 12:08:01 +0000 | [diff] [blame] | 122 | MVT VT) const; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 123 | std::vector<unsigned> |
| 124 | getRegClassForInlineAsmConstraint(const std::string &Constraint, |
Duncan Sands | 92c4391 | 2008-06-06 12:08:01 +0000 | [diff] [blame] | 125 | MVT VT) const; |
Rafael Espindola | dd867c7 | 2007-11-05 23:12:20 +0000 | [diff] [blame] | 126 | |
Bob Wilson | 221511d | 2009-04-01 17:58:54 +0000 | [diff] [blame^] | 127 | /// LowerAsmOperandForConstraint - Lower the specified operand into the Ops |
| 128 | /// vector. If it is invalid, don't add anything to Ops. If hasMemory is |
| 129 | /// true it means one of the asm constraint of the inline asm instruction |
| 130 | /// being processed is 'm'. |
| 131 | virtual void LowerAsmOperandForConstraint(SDValue Op, |
| 132 | char ConstraintLetter, |
| 133 | bool hasMemory, |
| 134 | std::vector<SDValue> &Ops, |
| 135 | SelectionDAG &DAG) const; |
| 136 | |
Dan Gohman | e8b391e | 2008-04-12 04:36:06 +0000 | [diff] [blame] | 137 | virtual const ARMSubtarget* getSubtarget() { |
| 138 | return Subtarget; |
Rafael Espindola | dd867c7 | 2007-11-05 23:12:20 +0000 | [diff] [blame] | 139 | } |
| 140 | |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 141 | private: |
| 142 | /// Subtarget - Keep a pointer to the ARMSubtarget around so that we can |
| 143 | /// make the right decision when generating code for different targets. |
| 144 | const ARMSubtarget *Subtarget; |
| 145 | |
| 146 | /// ARMPCLabelIndex - Keep track the number of ARM PC labels created. |
| 147 | /// |
| 148 | unsigned ARMPCLabelIndex; |
| 149 | |
Dan Gohman | 8181bd1 | 2008-07-27 21:46:04 +0000 | [diff] [blame] | 150 | SDValue LowerCALL(SDValue Op, SelectionDAG &DAG); |
| 151 | SDValue LowerGlobalAddressDarwin(SDValue Op, SelectionDAG &DAG); |
| 152 | SDValue LowerGlobalAddressELF(SDValue Op, SelectionDAG &DAG); |
| 153 | SDValue LowerGlobalTLSAddress(SDValue Op, SelectionDAG &DAG); |
| 154 | SDValue LowerToTLSGeneralDynamicModel(GlobalAddressSDNode *GA, |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 155 | SelectionDAG &DAG); |
Dan Gohman | 8181bd1 | 2008-07-27 21:46:04 +0000 | [diff] [blame] | 156 | SDValue LowerToTLSExecModels(GlobalAddressSDNode *GA, |
Evan Cheng | 857b89e | 2007-10-22 22:11:27 +0000 | [diff] [blame] | 157 | SelectionDAG &DAG); |
Dan Gohman | 8181bd1 | 2008-07-27 21:46:04 +0000 | [diff] [blame] | 158 | SDValue LowerGLOBAL_OFFSET_TABLE(SDValue Op, SelectionDAG &DAG); |
| 159 | SDValue LowerFORMAL_ARGUMENTS(SDValue Op, SelectionDAG &DAG); |
| 160 | SDValue LowerBR_JT(SDValue Op, SelectionDAG &DAG); |
Rafael Espindola | 0ec733a | 2007-10-19 14:35:17 +0000 | [diff] [blame] | 161 | |
Dale Johannesen | 7f2abf4 | 2009-02-03 22:26:09 +0000 | [diff] [blame] | 162 | SDValue EmitTargetCodeForMemcpy(SelectionDAG &DAG, DebugLoc dl, |
Dan Gohman | 8181bd1 | 2008-07-27 21:46:04 +0000 | [diff] [blame] | 163 | SDValue Chain, |
| 164 | SDValue Dst, SDValue Src, |
| 165 | SDValue Size, unsigned Align, |
Dan Gohman | e8b391e | 2008-04-12 04:36:06 +0000 | [diff] [blame] | 166 | bool AlwaysInline, |
Dan Gohman | 65118f4 | 2008-04-28 17:15:20 +0000 | [diff] [blame] | 167 | const Value *DstSV, uint64_t DstSVOff, |
| 168 | const Value *SrcSV, uint64_t SrcSVOff); |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 169 | }; |
| 170 | } |
| 171 | |
| 172 | #endif // ARMISELLOWERING_H |