Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 1 | //===-- MipsISelLowering.h - Mips DAG Lowering Interface --------*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
Chris Lattner | 4ee451d | 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. |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This file defines the interfaces that Mips uses to lower LLVM code into a |
| 11 | // selection DAG. |
| 12 | // |
| 13 | //===----------------------------------------------------------------------===// |
| 14 | |
| 15 | #ifndef MipsISELLOWERING_H |
| 16 | #define MipsISELLOWERING_H |
| 17 | |
| 18 | #include "llvm/CodeGen/SelectionDAG.h" |
| 19 | #include "llvm/Target/TargetLowering.h" |
| 20 | #include "Mips.h" |
| 21 | #include "MipsSubtarget.h" |
| 22 | |
| 23 | namespace llvm { |
| 24 | namespace MipsISD { |
| 25 | enum NodeType { |
| 26 | // Start the numbering from where ISD NodeType finishes. |
| 27 | FIRST_NUMBER = ISD::BUILTIN_OP_END+Mips::INSTRUCTION_LIST_END, |
| 28 | |
| 29 | // Jump and link (call) |
| 30 | JmpLink, |
| 31 | |
| 32 | // Get the Higher 16 bits from a 32-bit immediate |
| 33 | // No relation with Mips Hi register |
| 34 | Hi, |
| 35 | |
| 36 | // Get the Lower 16 bits from a 32-bit immediate |
| 37 | // No relation with Mips Lo register |
| 38 | Lo, |
| 39 | |
Bruno Cardoso Lopes | 91fd532 | 2008-07-21 18:52:34 +0000 | [diff] [blame] | 40 | // Handle gp_rel (small data/bss sections) relocation. |
| 41 | GPRel, |
| 42 | |
Bruno Cardoso Lopes | 07cec75 | 2008-06-06 00:58:26 +0000 | [diff] [blame] | 43 | // Select CC Pseudo Instruction |
| 44 | SelectCC, |
| 45 | |
Bruno Cardoso Lopes | 6d399bd | 2008-07-29 19:05:28 +0000 | [diff] [blame] | 46 | // Floating Point Select CC Pseudo Instruction |
| 47 | FPSelectCC, |
| 48 | |
Bruno Cardoso Lopes | 7b76da1 | 2008-07-09 04:45:36 +0000 | [diff] [blame] | 49 | // Floating Point Branch Conditional |
Bruno Cardoso Lopes | 225ca9c | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 50 | FPBrcond, |
| 51 | |
Bruno Cardoso Lopes | 7b76da1 | 2008-07-09 04:45:36 +0000 | [diff] [blame] | 52 | // Floating Point Compare |
Bruno Cardoso Lopes | 225ca9c | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 53 | FPCmp, |
| 54 | |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 55 | // Return |
Bruno Cardoso Lopes | c7db561 | 2007-11-05 03:02:32 +0000 | [diff] [blame] | 56 | Ret |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 57 | }; |
| 58 | } |
| 59 | |
| 60 | //===--------------------------------------------------------------------===// |
| 61 | // TargetLowering Implementation |
| 62 | //===--------------------------------------------------------------------===// |
| 63 | class MipsTargetLowering : public TargetLowering |
| 64 | { |
| 65 | // FrameIndex for return slot. |
| 66 | int ReturnAddrIndex; |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 67 | public: |
| 68 | |
Dan Gohman | 61e729e | 2007-08-02 21:21:54 +0000 | [diff] [blame] | 69 | explicit MipsTargetLowering(MipsTargetMachine &TM); |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 70 | |
| 71 | /// LowerOperation - Provide custom lowering hooks for some operations. |
Dan Gohman | 475871a | 2008-07-27 21:46:04 +0000 | [diff] [blame] | 72 | virtual SDValue LowerOperation(SDValue Op, SelectionDAG &DAG); |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 73 | |
| 74 | /// getTargetNodeName - This method returns the name of a target specific |
| 75 | // DAG node. |
| 76 | virtual const char *getTargetNodeName(unsigned Opcode) const; |
| 77 | |
Scott Michel | 5b8f82e | 2008-03-10 15:42:14 +0000 | [diff] [blame] | 78 | /// getSetCCResultType - get the ISD::SETCC result ValueType |
Dan Gohman | 475871a | 2008-07-27 21:46:04 +0000 | [diff] [blame] | 79 | MVT getSetCCResultType(const SDValue &) const; |
Scott Michel | 5b8f82e | 2008-03-10 15:42:14 +0000 | [diff] [blame] | 80 | |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 81 | private: |
Bruno Cardoso Lopes | 225ca9c | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 82 | // Subtarget Info |
| 83 | const MipsSubtarget *Subtarget; |
| 84 | |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 85 | // Lower Operand helpers |
Dan Gohman | 475871a | 2008-07-27 21:46:04 +0000 | [diff] [blame] | 86 | SDNode *LowerCallResult(SDValue Chain, SDValue InFlag, SDNode*TheCall, |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 87 | unsigned CallingConv, SelectionDAG &DAG); |
Bruno Cardoso Lopes | 91fd532 | 2008-07-21 18:52:34 +0000 | [diff] [blame] | 88 | bool IsGlobalInSmallSection(GlobalValue *GV); |
Bruno Cardoso Lopes | 92e87f2 | 2008-07-23 16:01:50 +0000 | [diff] [blame] | 89 | bool IsInSmallSection(unsigned Size); |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 90 | |
| 91 | // Lower Operand specifics |
Bruno Cardoso Lopes | 1906c5a | 2008-08-02 19:37:33 +0000 | [diff] [blame] | 92 | SDValue LowerANDOR(SDValue Op, SelectionDAG &DAG); |
Bruno Cardoso Lopes | 7728377 | 2008-07-31 18:31:28 +0000 | [diff] [blame] | 93 | SDValue LowerBRCOND(SDValue Op, SelectionDAG &DAG); |
Dan Gohman | 475871a | 2008-07-27 21:46:04 +0000 | [diff] [blame] | 94 | SDValue LowerCALL(SDValue Op, SelectionDAG &DAG); |
Bruno Cardoso Lopes | 7728377 | 2008-07-31 18:31:28 +0000 | [diff] [blame] | 95 | SDValue LowerConstantPool(SDValue Op, SelectionDAG &DAG); |
Bruno Cardoso Lopes | 7da151c | 2008-08-07 19:08:11 +0000 | [diff] [blame^] | 96 | SDValue LowerDYNAMIC_STACKALLOC(SDValue Op, SelectionDAG &DAG); |
Dan Gohman | 475871a | 2008-07-27 21:46:04 +0000 | [diff] [blame] | 97 | SDValue LowerFORMAL_ARGUMENTS(SDValue Op, SelectionDAG &DAG); |
| 98 | SDValue LowerGlobalAddress(SDValue Op, SelectionDAG &DAG); |
| 99 | SDValue LowerGlobalTLSAddress(SDValue Op, SelectionDAG &DAG); |
| 100 | SDValue LowerJumpTable(SDValue Op, SelectionDAG &DAG); |
Bruno Cardoso Lopes | 7728377 | 2008-07-31 18:31:28 +0000 | [diff] [blame] | 101 | SDValue LowerRET(SDValue Op, SelectionDAG &DAG); |
Dan Gohman | 475871a | 2008-07-27 21:46:04 +0000 | [diff] [blame] | 102 | SDValue LowerSELECT_CC(SDValue Op, SelectionDAG &DAG); |
Bruno Cardoso Lopes | 7728377 | 2008-07-31 18:31:28 +0000 | [diff] [blame] | 103 | SDValue LowerSELECT(SDValue Op, SelectionDAG &DAG); |
Bruno Cardoso Lopes | 85e31e3 | 2008-07-28 19:11:24 +0000 | [diff] [blame] | 104 | SDValue LowerSETCC(SDValue Op, SelectionDAG &DAG); |
Bruno Cardoso Lopes | 07cec75 | 2008-06-06 00:58:26 +0000 | [diff] [blame] | 105 | |
| 106 | virtual MachineBasicBlock *EmitInstrWithCustomInserter(MachineInstr *MI, |
| 107 | MachineBasicBlock *MBB); |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 108 | |
Bruno Cardoso Lopes | 84f47c5 | 2007-08-21 16:09:25 +0000 | [diff] [blame] | 109 | // Inline asm support |
| 110 | ConstraintType getConstraintType(const std::string &Constraint) const; |
| 111 | |
| 112 | std::pair<unsigned, const TargetRegisterClass*> |
| 113 | getRegForInlineAsmConstraint(const std::string &Constraint, |
Duncan Sands | 83ec4b6 | 2008-06-06 12:08:01 +0000 | [diff] [blame] | 114 | MVT VT) const; |
Bruno Cardoso Lopes | 84f47c5 | 2007-08-21 16:09:25 +0000 | [diff] [blame] | 115 | |
| 116 | std::vector<unsigned> |
| 117 | getRegClassForInlineAsmConstraint(const std::string &Constraint, |
Duncan Sands | 83ec4b6 | 2008-06-06 12:08:01 +0000 | [diff] [blame] | 118 | MVT VT) const; |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 119 | }; |
| 120 | } |
| 121 | |
| 122 | #endif // MipsISELLOWERING_H |