Chris Lattner | d23405e | 2008-03-17 03:21:36 +0000 | [diff] [blame] | 1 | //===-- SparcISelLowering.h - Sparc 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 Sparc uses to lower LLVM code into a |
| 11 | // selection DAG. |
| 12 | // |
| 13 | //===----------------------------------------------------------------------===// |
| 14 | |
| 15 | #ifndef SPARC_ISELLOWERING_H |
| 16 | #define SPARC_ISELLOWERING_H |
| 17 | |
| 18 | #include "llvm/Target/TargetLowering.h" |
| 19 | #include "Sparc.h" |
| 20 | |
| 21 | namespace llvm { |
| 22 | namespace SPISD { |
| 23 | enum { |
Dan Gohman | 0ba2bcf | 2008-09-23 18:42:32 +0000 | [diff] [blame] | 24 | FIRST_NUMBER = ISD::BUILTIN_OP_END, |
Chris Lattner | d23405e | 2008-03-17 03:21:36 +0000 | [diff] [blame] | 25 | CMPICC, // Compare two GPR operands, set icc. |
| 26 | CMPFCC, // Compare two FP operands, set fcc. |
| 27 | BRICC, // Branch to dest on icc condition |
| 28 | BRFCC, // Branch to dest on fcc condition |
| 29 | SELECT_ICC, // Select between two values using the current ICC flags. |
| 30 | SELECT_FCC, // Select between two values using the current FCC flags. |
Anton Korobeynikov | 0eefda1 | 2008-10-10 20:28:10 +0000 | [diff] [blame] | 31 | |
Chris Lattner | d23405e | 2008-03-17 03:21:36 +0000 | [diff] [blame] | 32 | Hi, Lo, // Hi/Lo operations, typically on a global address. |
Anton Korobeynikov | 0eefda1 | 2008-10-10 20:28:10 +0000 | [diff] [blame] | 33 | |
Chris Lattner | d23405e | 2008-03-17 03:21:36 +0000 | [diff] [blame] | 34 | FTOI, // FP to Int within a FP register. |
| 35 | ITOF, // Int to FP within a FP register. |
Anton Korobeynikov | 0eefda1 | 2008-10-10 20:28:10 +0000 | [diff] [blame] | 36 | |
Chris Lattner | d23405e | 2008-03-17 03:21:36 +0000 | [diff] [blame] | 37 | CALL, // A call instruction. |
| 38 | RET_FLAG // Return with a flag operand. |
| 39 | }; |
| 40 | } |
Anton Korobeynikov | 0eefda1 | 2008-10-10 20:28:10 +0000 | [diff] [blame] | 41 | |
Chris Lattner | d23405e | 2008-03-17 03:21:36 +0000 | [diff] [blame] | 42 | class SparcTargetLowering : public TargetLowering { |
| 43 | int VarArgsFrameOffset; // Frame offset to start of varargs area. |
| 44 | public: |
| 45 | SparcTargetLowering(TargetMachine &TM); |
Dan Gohman | 475871a | 2008-07-27 21:46:04 +0000 | [diff] [blame] | 46 | virtual SDValue LowerOperation(SDValue Op, SelectionDAG &DAG); |
Anton Korobeynikov | 0eefda1 | 2008-10-10 20:28:10 +0000 | [diff] [blame] | 47 | |
Chris Lattner | d23405e | 2008-03-17 03:21:36 +0000 | [diff] [blame] | 48 | int getVarArgsFrameOffset() const { return VarArgsFrameOffset; } |
Anton Korobeynikov | 0eefda1 | 2008-10-10 20:28:10 +0000 | [diff] [blame] | 49 | |
| 50 | /// computeMaskedBitsForTargetNode - Determine which of the bits specified |
| 51 | /// in Mask are known to be either zero or one and return them in the |
Chris Lattner | d23405e | 2008-03-17 03:21:36 +0000 | [diff] [blame] | 52 | /// KnownZero/KnownOne bitsets. |
Dan Gohman | 475871a | 2008-07-27 21:46:04 +0000 | [diff] [blame] | 53 | virtual void computeMaskedBitsForTargetNode(const SDValue Op, |
Chris Lattner | d23405e | 2008-03-17 03:21:36 +0000 | [diff] [blame] | 54 | const APInt &Mask, |
Anton Korobeynikov | 0eefda1 | 2008-10-10 20:28:10 +0000 | [diff] [blame] | 55 | APInt &KnownZero, |
Chris Lattner | d23405e | 2008-03-17 03:21:36 +0000 | [diff] [blame] | 56 | APInt &KnownOne, |
| 57 | const SelectionDAG &DAG, |
| 58 | unsigned Depth = 0) const; |
Anton Korobeynikov | 0eefda1 | 2008-10-10 20:28:10 +0000 | [diff] [blame] | 59 | |
Chris Lattner | d23405e | 2008-03-17 03:21:36 +0000 | [diff] [blame] | 60 | virtual MachineBasicBlock *EmitInstrWithCustomInserter(MachineInstr *MI, |
Dan Gohman | 1fdbc1d | 2009-02-07 16:15:20 +0000 | [diff] [blame] | 61 | MachineBasicBlock *MBB) const; |
Anton Korobeynikov | 0eefda1 | 2008-10-10 20:28:10 +0000 | [diff] [blame] | 62 | |
Chris Lattner | d23405e | 2008-03-17 03:21:36 +0000 | [diff] [blame] | 63 | virtual const char *getTargetNodeName(unsigned Opcode) const; |
Anton Korobeynikov | 0eefda1 | 2008-10-10 20:28:10 +0000 | [diff] [blame] | 64 | |
| 65 | ConstraintType getConstraintType(const std::string &Constraint) const; |
| 66 | std::pair<unsigned, const TargetRegisterClass*> |
Owen Anderson | e50ed30 | 2009-08-10 22:56:29 +0000 | [diff] [blame] | 67 | getRegForInlineAsmConstraint(const std::string &Constraint, EVT VT) const; |
Anton Korobeynikov | 0eefda1 | 2008-10-10 20:28:10 +0000 | [diff] [blame] | 68 | std::vector<unsigned> |
| 69 | getRegClassForInlineAsmConstraint(const std::string &Constraint, |
Owen Anderson | e50ed30 | 2009-08-10 22:56:29 +0000 | [diff] [blame] | 70 | EVT VT) const; |
Dan Gohman | 6520e20 | 2008-10-18 02:06:02 +0000 | [diff] [blame] | 71 | |
| 72 | virtual bool isOffsetFoldingLegal(const GlobalAddressSDNode *GA) const; |
Bill Wendling | 20c568f | 2009-06-30 22:38:32 +0000 | [diff] [blame] | 73 | |
Bill Wendling | b4202b8 | 2009-07-01 18:50:55 +0000 | [diff] [blame] | 74 | /// getFunctionAlignment - Return the Log2 alignment of this function. |
Bill Wendling | 20c568f | 2009-06-30 22:38:32 +0000 | [diff] [blame] | 75 | virtual unsigned getFunctionAlignment(const Function *F) const; |
Dan Gohman | 98ca4f2 | 2009-08-05 01:29:28 +0000 | [diff] [blame] | 76 | |
| 77 | virtual SDValue |
| 78 | LowerFormalArguments(SDValue Chain, |
Sandeep Patel | 65c3c8f | 2009-09-02 08:44:58 +0000 | [diff] [blame] | 79 | CallingConv::ID CallConv, |
Dan Gohman | 98ca4f2 | 2009-08-05 01:29:28 +0000 | [diff] [blame] | 80 | bool isVarArg, |
| 81 | const SmallVectorImpl<ISD::InputArg> &Ins, |
| 82 | DebugLoc dl, SelectionDAG &DAG, |
| 83 | SmallVectorImpl<SDValue> &InVals); |
| 84 | |
| 85 | virtual SDValue |
| 86 | LowerCall(SDValue Chain, SDValue Callee, |
Sandeep Patel | 65c3c8f | 2009-09-02 08:44:58 +0000 | [diff] [blame] | 87 | CallingConv::ID CallConv, bool isVarArg, |
Dan Gohman | 98ca4f2 | 2009-08-05 01:29:28 +0000 | [diff] [blame] | 88 | bool isTailCall, |
| 89 | const SmallVectorImpl<ISD::OutputArg> &Outs, |
| 90 | const SmallVectorImpl<ISD::InputArg> &Ins, |
| 91 | DebugLoc dl, SelectionDAG &DAG, |
| 92 | SmallVectorImpl<SDValue> &InVals); |
| 93 | |
| 94 | virtual SDValue |
| 95 | LowerReturn(SDValue Chain, |
Sandeep Patel | 65c3c8f | 2009-09-02 08:44:58 +0000 | [diff] [blame] | 96 | CallingConv::ID CallConv, bool isVarArg, |
Dan Gohman | 98ca4f2 | 2009-08-05 01:29:28 +0000 | [diff] [blame] | 97 | const SmallVectorImpl<ISD::OutputArg> &Outs, |
| 98 | DebugLoc dl, SelectionDAG &DAG); |
Chris Lattner | d23405e | 2008-03-17 03:21:36 +0000 | [diff] [blame] | 99 | }; |
| 100 | } // end namespace llvm |
| 101 | |
| 102 | #endif // SPARC_ISELLOWERING_H |