Chris Lattner | dbdbf0c | 2005-11-15 00:40:23 +0000 | [diff] [blame] | 1 | //===-- X86ISelLowering.h - X86 DAG Lowering Interface ----------*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file was developed by Chris Lattner and is distributed under |
| 6 | // the University of Illinois Open Source License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This file defines the interfaces that X86 uses to lower LLVM code into a |
| 11 | // selection DAG. |
| 12 | // |
| 13 | //===----------------------------------------------------------------------===// |
| 14 | |
| 15 | #ifndef X86ISELLOWERING_H |
| 16 | #define X86ISELLOWERING_H |
| 17 | |
| 18 | #include "llvm/Target/TargetLowering.h" |
| 19 | #include "llvm/CodeGen/SelectionDAG.h" |
| 20 | |
| 21 | namespace llvm { |
| 22 | // X86 Specific DAG Nodes |
| 23 | namespace X86ISD { |
| 24 | enum NodeType { |
| 25 | // Start the numbering where the builtin ops leave off. |
Evan Cheng | 7df96d6 | 2005-12-17 01:21:05 +0000 | [diff] [blame] | 26 | FIRST_NUMBER = ISD::BUILTIN_OP_END+X86::INSTRUCTION_LIST_END, |
Chris Lattner | dbdbf0c | 2005-11-15 00:40:23 +0000 | [diff] [blame] | 27 | |
| 28 | /// FILD64m - This instruction implements SINT_TO_FP with a |
| 29 | /// 64-bit source in memory and a FP reg result. This corresponds to |
| 30 | /// the X86::FILD64m instruction. It has two inputs (token chain and |
| 31 | /// address) and two outputs (FP value and token chain). |
| 32 | FILD64m, |
| 33 | |
| 34 | /// FP_TO_INT*_IN_MEM - This instruction implements FP_TO_SINT with the |
| 35 | /// integer destination in memory and a FP reg source. This corresponds |
| 36 | /// to the X86::FIST*m instructions and the rounding mode change stuff. It |
| 37 | /// has two inputs (token chain and address) and two outputs (FP value and |
| 38 | /// token chain). |
| 39 | FP_TO_INT16_IN_MEM, |
| 40 | FP_TO_INT32_IN_MEM, |
| 41 | FP_TO_INT64_IN_MEM, |
| 42 | |
| 43 | /// CALL/TAILCALL - These operations represent an abstract X86 call |
| 44 | /// instruction, which includes a bunch of information. In particular the |
| 45 | /// operands of these node are: |
| 46 | /// |
| 47 | /// #0 - The incoming token chain |
| 48 | /// #1 - The callee |
| 49 | /// #2 - The number of arg bytes the caller pushes on the stack. |
| 50 | /// #3 - The number of arg bytes the callee pops off the stack. |
| 51 | /// #4 - The value to pass in AL/AX/EAX (optional) |
| 52 | /// #5 - The value to pass in DL/DX/EDX (optional) |
| 53 | /// |
| 54 | /// The result values of these nodes are: |
| 55 | /// |
| 56 | /// #0 - The outgoing token chain |
| 57 | /// #1 - The first register result value (optional) |
| 58 | /// #2 - The second register result value (optional) |
| 59 | /// |
| 60 | /// The CALL vs TAILCALL distinction boils down to whether the callee is |
| 61 | /// known not to modify the caller's stack frame, as is standard with |
| 62 | /// LLVM. |
| 63 | CALL, |
| 64 | TAILCALL, |
Andrew Lenharth | b873ff3 | 2005-11-20 21:41:10 +0000 | [diff] [blame] | 65 | |
| 66 | /// RDTSC_DAG - This operation implements the lowering for |
| 67 | /// readcyclecounter |
| 68 | RDTSC_DAG, |
Evan Cheng | 7df96d6 | 2005-12-17 01:21:05 +0000 | [diff] [blame] | 69 | |
| 70 | /// X86 compare and logical compare instructions. |
| 71 | CMP, TEST, |
| 72 | |
| 73 | /// X86 conditional moves. |
| 74 | CMOV, |
Evan Cheng | 898101c | 2005-12-19 23:12:38 +0000 | [diff] [blame^] | 75 | |
| 76 | /// X86 conditional branches. |
| 77 | BRCOND, |
Chris Lattner | dbdbf0c | 2005-11-15 00:40:23 +0000 | [diff] [blame] | 78 | }; |
| 79 | } |
| 80 | |
| 81 | //===----------------------------------------------------------------------===// |
| 82 | // X86TargetLowering - X86 Implementation of the TargetLowering interface |
| 83 | class X86TargetLowering : public TargetLowering { |
| 84 | int VarArgsFrameIndex; // FrameIndex for start of varargs area. |
| 85 | int ReturnAddrIndex; // FrameIndex for return slot. |
| 86 | int BytesToPopOnReturn; // Number of arg bytes ret should pop. |
| 87 | int BytesCallerReserves; // Number of arg bytes caller makes. |
| 88 | public: |
| 89 | X86TargetLowering(TargetMachine &TM); |
| 90 | |
| 91 | // Return the number of bytes that a function should pop when it returns (in |
| 92 | // addition to the space used by the return address). |
| 93 | // |
| 94 | unsigned getBytesToPopOnReturn() const { return BytesToPopOnReturn; } |
| 95 | |
| 96 | // Return the number of bytes that the caller reserves for arguments passed |
| 97 | // to this function. |
| 98 | unsigned getBytesCallerReserves() const { return BytesCallerReserves; } |
| 99 | |
| 100 | /// LowerOperation - Provide custom lowering hooks for some operations. |
| 101 | /// |
| 102 | virtual SDOperand LowerOperation(SDOperand Op, SelectionDAG &DAG); |
| 103 | |
| 104 | /// LowerArguments - This hook must be implemented to indicate how we should |
| 105 | /// lower the arguments for the specified function, into the specified DAG. |
| 106 | virtual std::vector<SDOperand> |
| 107 | LowerArguments(Function &F, SelectionDAG &DAG); |
| 108 | |
| 109 | /// LowerCallTo - This hook lowers an abstract call to a function into an |
| 110 | /// actual call. |
| 111 | virtual std::pair<SDOperand, SDOperand> |
| 112 | LowerCallTo(SDOperand Chain, const Type *RetTy, bool isVarArg, unsigned CC, |
| 113 | bool isTailCall, SDOperand Callee, ArgListTy &Args, |
| 114 | SelectionDAG &DAG); |
| 115 | |
| 116 | virtual SDOperand LowerVAStart(SDOperand Chain, SDOperand VAListP, |
| 117 | Value *VAListV, SelectionDAG &DAG); |
| 118 | virtual std::pair<SDOperand,SDOperand> |
| 119 | LowerVAArg(SDOperand Chain, SDOperand VAListP, Value *VAListV, |
| 120 | const Type *ArgTy, SelectionDAG &DAG); |
| 121 | |
| 122 | virtual std::pair<SDOperand, SDOperand> |
| 123 | LowerFrameReturnAddress(bool isFrameAddr, SDOperand Chain, unsigned Depth, |
| 124 | SelectionDAG &DAG); |
| 125 | |
| 126 | SDOperand getReturnAddressFrameIndex(SelectionDAG &DAG); |
| 127 | |
| 128 | private: |
| 129 | // C Calling Convention implementation. |
| 130 | std::vector<SDOperand> LowerCCCArguments(Function &F, SelectionDAG &DAG); |
| 131 | std::pair<SDOperand, SDOperand> |
| 132 | LowerCCCCallTo(SDOperand Chain, const Type *RetTy, bool isVarArg, |
| 133 | bool isTailCall, |
| 134 | SDOperand Callee, ArgListTy &Args, SelectionDAG &DAG); |
| 135 | |
| 136 | // Fast Calling Convention implementation. |
| 137 | std::vector<SDOperand> LowerFastCCArguments(Function &F, SelectionDAG &DAG); |
| 138 | std::pair<SDOperand, SDOperand> |
| 139 | LowerFastCCCallTo(SDOperand Chain, const Type *RetTy, bool isTailCall, |
| 140 | SDOperand Callee, ArgListTy &Args, SelectionDAG &DAG); |
| 141 | }; |
| 142 | } |
| 143 | |
| 144 | #endif // X86ISELLOWERING_H |