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. |
Chris Lattner | db486a6 | 2009-09-15 17:46:24 +0000 | [diff] [blame] | 38 | RET_FLAG, // Return with a flag operand. |
| 39 | GLOBAL_BASE_REG // Global base reg for PIC |
Chris Lattner | d23405e | 2008-03-17 03:21:36 +0000 | [diff] [blame] | 40 | }; |
| 41 | } |
Anton Korobeynikov | 0eefda1 | 2008-10-10 20:28:10 +0000 | [diff] [blame] | 42 | |
Chris Lattner | d23405e | 2008-03-17 03:21:36 +0000 | [diff] [blame] | 43 | class SparcTargetLowering : public TargetLowering { |
| 44 | int VarArgsFrameOffset; // Frame offset to start of varargs area. |
| 45 | public: |
| 46 | SparcTargetLowering(TargetMachine &TM); |
Dan Gohman | 475871a | 2008-07-27 21:46:04 +0000 | [diff] [blame] | 47 | virtual SDValue LowerOperation(SDValue Op, SelectionDAG &DAG); |
Anton Korobeynikov | 0eefda1 | 2008-10-10 20:28:10 +0000 | [diff] [blame] | 48 | |
Chris Lattner | d23405e | 2008-03-17 03:21:36 +0000 | [diff] [blame] | 49 | int getVarArgsFrameOffset() const { return VarArgsFrameOffset; } |
Anton Korobeynikov | 0eefda1 | 2008-10-10 20:28:10 +0000 | [diff] [blame] | 50 | |
| 51 | /// computeMaskedBitsForTargetNode - Determine which of the bits specified |
| 52 | /// 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] | 53 | /// KnownZero/KnownOne bitsets. |
Dan Gohman | 475871a | 2008-07-27 21:46:04 +0000 | [diff] [blame] | 54 | virtual void computeMaskedBitsForTargetNode(const SDValue Op, |
Chris Lattner | d23405e | 2008-03-17 03:21:36 +0000 | [diff] [blame] | 55 | const APInt &Mask, |
Anton Korobeynikov | 0eefda1 | 2008-10-10 20:28:10 +0000 | [diff] [blame] | 56 | APInt &KnownZero, |
Chris Lattner | d23405e | 2008-03-17 03:21:36 +0000 | [diff] [blame] | 57 | APInt &KnownOne, |
| 58 | const SelectionDAG &DAG, |
| 59 | unsigned Depth = 0) const; |
Anton Korobeynikov | 0eefda1 | 2008-10-10 20:28:10 +0000 | [diff] [blame] | 60 | |
Chris Lattner | d23405e | 2008-03-17 03:21:36 +0000 | [diff] [blame] | 61 | virtual MachineBasicBlock *EmitInstrWithCustomInserter(MachineInstr *MI, |
Evan Cheng | fb2e752 | 2009-09-18 21:02:19 +0000 | [diff] [blame] | 62 | MachineBasicBlock *MBB, |
| 63 | DenseMap<MachineBasicBlock*, MachineBasicBlock*> *EM) const; |
Anton Korobeynikov | 0eefda1 | 2008-10-10 20:28:10 +0000 | [diff] [blame] | 64 | |
Chris Lattner | d23405e | 2008-03-17 03:21:36 +0000 | [diff] [blame] | 65 | virtual const char *getTargetNodeName(unsigned Opcode) const; |
Anton Korobeynikov | 0eefda1 | 2008-10-10 20:28:10 +0000 | [diff] [blame] | 66 | |
| 67 | ConstraintType getConstraintType(const std::string &Constraint) const; |
| 68 | std::pair<unsigned, const TargetRegisterClass*> |
Owen Anderson | e50ed30 | 2009-08-10 22:56:29 +0000 | [diff] [blame] | 69 | getRegForInlineAsmConstraint(const std::string &Constraint, EVT VT) const; |
Anton Korobeynikov | 0eefda1 | 2008-10-10 20:28:10 +0000 | [diff] [blame] | 70 | std::vector<unsigned> |
| 71 | getRegClassForInlineAsmConstraint(const std::string &Constraint, |
Owen Anderson | e50ed30 | 2009-08-10 22:56:29 +0000 | [diff] [blame] | 72 | EVT VT) const; |
Dan Gohman | 6520e20 | 2008-10-18 02:06:02 +0000 | [diff] [blame] | 73 | |
| 74 | virtual bool isOffsetFoldingLegal(const GlobalAddressSDNode *GA) const; |
Bill Wendling | 20c568f | 2009-06-30 22:38:32 +0000 | [diff] [blame] | 75 | |
Bill Wendling | b4202b8 | 2009-07-01 18:50:55 +0000 | [diff] [blame] | 76 | /// getFunctionAlignment - Return the Log2 alignment of this function. |
Bill Wendling | 20c568f | 2009-06-30 22:38:32 +0000 | [diff] [blame] | 77 | virtual unsigned getFunctionAlignment(const Function *F) const; |
Dan Gohman | 98ca4f2 | 2009-08-05 01:29:28 +0000 | [diff] [blame] | 78 | |
| 79 | virtual SDValue |
| 80 | LowerFormalArguments(SDValue Chain, |
Sandeep Patel | 65c3c8f | 2009-09-02 08:44:58 +0000 | [diff] [blame] | 81 | CallingConv::ID CallConv, |
Dan Gohman | 98ca4f2 | 2009-08-05 01:29:28 +0000 | [diff] [blame] | 82 | bool isVarArg, |
| 83 | const SmallVectorImpl<ISD::InputArg> &Ins, |
| 84 | DebugLoc dl, SelectionDAG &DAG, |
| 85 | SmallVectorImpl<SDValue> &InVals); |
| 86 | |
| 87 | virtual SDValue |
| 88 | LowerCall(SDValue Chain, SDValue Callee, |
Sandeep Patel | 65c3c8f | 2009-09-02 08:44:58 +0000 | [diff] [blame] | 89 | CallingConv::ID CallConv, bool isVarArg, |
Evan Cheng | 0c439eb | 2010-01-27 00:07:07 +0000 | [diff] [blame] | 90 | bool &isTailCall, |
Dan Gohman | 98ca4f2 | 2009-08-05 01:29:28 +0000 | [diff] [blame] | 91 | const SmallVectorImpl<ISD::OutputArg> &Outs, |
| 92 | const SmallVectorImpl<ISD::InputArg> &Ins, |
| 93 | DebugLoc dl, SelectionDAG &DAG, |
| 94 | SmallVectorImpl<SDValue> &InVals); |
| 95 | |
| 96 | virtual SDValue |
| 97 | LowerReturn(SDValue Chain, |
Sandeep Patel | 65c3c8f | 2009-09-02 08:44:58 +0000 | [diff] [blame] | 98 | CallingConv::ID CallConv, bool isVarArg, |
Dan Gohman | 98ca4f2 | 2009-08-05 01:29:28 +0000 | [diff] [blame] | 99 | const SmallVectorImpl<ISD::OutputArg> &Outs, |
| 100 | DebugLoc dl, SelectionDAG &DAG); |
Chris Lattner | db486a6 | 2009-09-15 17:46:24 +0000 | [diff] [blame] | 101 | |
| 102 | SDValue LowerGlobalAddress(SDValue Op, SelectionDAG &DAG); |
| 103 | SDValue LowerConstantPool(SDValue Op, SelectionDAG &DAG); |
Chris Lattner | d23405e | 2008-03-17 03:21:36 +0000 | [diff] [blame] | 104 | }; |
| 105 | } // end namespace llvm |
| 106 | |
| 107 | #endif // SPARC_ISELLOWERING_H |