blob: fd706bebd415112567572a6342d95642bf093318 [file] [log] [blame]
Chris Lattnerd23405e2008-03-17 03:21:36 +00001//===-- 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
Chris Lattnerd23405e2008-03-17 03:21:36 +000018#include "Sparc.h"
Craig Topper79aa3412012-03-17 18:46:09 +000019#include "llvm/Target/TargetLowering.h"
Chris Lattnerd23405e2008-03-17 03:21:36 +000020
21namespace llvm {
Jakob Stoklund Olesenfcb25e62013-04-02 04:08:54 +000022 class SparcSubtarget;
23
Chris Lattnerd23405e2008-03-17 03:21:36 +000024 namespace SPISD {
25 enum {
Dan Gohman0ba2bcf2008-09-23 18:42:32 +000026 FIRST_NUMBER = ISD::BUILTIN_OP_END,
Jakob Stoklund Olesen8534e992013-04-03 04:41:44 +000027 CMPICC, // Compare two GPR operands, set icc+xcc.
Chris Lattnerd23405e2008-03-17 03:21:36 +000028 CMPFCC, // Compare two FP operands, set fcc.
29 BRICC, // Branch to dest on icc condition
Jakob Stoklund Olesen8534e992013-04-03 04:41:44 +000030 BRXCC, // Branch to dest on xcc condition (64-bit only).
Chris Lattnerd23405e2008-03-17 03:21:36 +000031 BRFCC, // Branch to dest on fcc condition
32 SELECT_ICC, // Select between two values using the current ICC flags.
Jakob Stoklund Olesen0e164882013-04-04 03:08:00 +000033 SELECT_XCC, // Select between two values using the current XCC flags.
Chris Lattnerd23405e2008-03-17 03:21:36 +000034 SELECT_FCC, // Select between two values using the current FCC flags.
Anton Korobeynikov0eefda12008-10-10 20:28:10 +000035
Chris Lattnerd23405e2008-03-17 03:21:36 +000036 Hi, Lo, // Hi/Lo operations, typically on a global address.
Anton Korobeynikov0eefda12008-10-10 20:28:10 +000037
Chris Lattnerd23405e2008-03-17 03:21:36 +000038 FTOI, // FP to Int within a FP register.
39 ITOF, // Int to FP within a FP register.
Anton Korobeynikov0eefda12008-10-10 20:28:10 +000040
Chris Lattnerd23405e2008-03-17 03:21:36 +000041 CALL, // A call instruction.
Chris Lattnerdb486a62009-09-15 17:46:24 +000042 RET_FLAG, // Return with a flag operand.
Venkatraman Govindaraju860b64c2011-01-12 05:08:36 +000043 GLOBAL_BASE_REG, // Global base reg for PIC
Venkatraman Govindarajufc3faa72011-01-21 22:00:00 +000044 FLUSHW // FLUSH register windows to stack
Chris Lattnerd23405e2008-03-17 03:21:36 +000045 };
46 }
Anton Korobeynikov0eefda12008-10-10 20:28:10 +000047
Chris Lattnerd23405e2008-03-17 03:21:36 +000048 class SparcTargetLowering : public TargetLowering {
Jakob Stoklund Olesenfcb25e62013-04-02 04:08:54 +000049 const SparcSubtarget *Subtarget;
Chris Lattnerd23405e2008-03-17 03:21:36 +000050 public:
51 SparcTargetLowering(TargetMachine &TM);
Dan Gohmand858e902010-04-17 15:26:15 +000052 virtual SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const;
Anton Korobeynikov0eefda12008-10-10 20:28:10 +000053
Anton Korobeynikov0eefda12008-10-10 20:28:10 +000054 /// computeMaskedBitsForTargetNode - Determine which of the bits specified
55 /// in Mask are known to be either zero or one and return them in the
Chris Lattnerd23405e2008-03-17 03:21:36 +000056 /// KnownZero/KnownOne bitsets.
Dan Gohman475871a2008-07-27 21:46:04 +000057 virtual void computeMaskedBitsForTargetNode(const SDValue Op,
Anton Korobeynikov0eefda12008-10-10 20:28:10 +000058 APInt &KnownZero,
Chris Lattnerd23405e2008-03-17 03:21:36 +000059 APInt &KnownOne,
60 const SelectionDAG &DAG,
61 unsigned Depth = 0) const;
Anton Korobeynikov0eefda12008-10-10 20:28:10 +000062
Dan Gohmanaf1d8ca2010-05-01 00:01:06 +000063 virtual MachineBasicBlock *
64 EmitInstrWithCustomInserter(MachineInstr *MI,
65 MachineBasicBlock *MBB) const;
Anton Korobeynikov0eefda12008-10-10 20:28:10 +000066
Chris Lattnerd23405e2008-03-17 03:21:36 +000067 virtual const char *getTargetNodeName(unsigned Opcode) const;
Anton Korobeynikov0eefda12008-10-10 20:28:10 +000068
69 ConstraintType getConstraintType(const std::string &Constraint) const;
70 std::pair<unsigned, const TargetRegisterClass*>
Owen Andersone50ed302009-08-10 22:56:29 +000071 getRegForInlineAsmConstraint(const std::string &Constraint, EVT VT) const;
Dan Gohman6520e202008-10-18 02:06:02 +000072
73 virtual bool isOffsetFoldingLegal(const GlobalAddressSDNode *GA) const;
Jakob Stoklund Olesend9f88da2013-04-14 05:48:50 +000074 virtual MVT getScalarShiftAmountTy(EVT LHSTy) const { return MVT::i32; }
Bill Wendling20c568f2009-06-30 22:38:32 +000075
Dan Gohman98ca4f22009-08-05 01:29:28 +000076 virtual SDValue
77 LowerFormalArguments(SDValue Chain,
Sandeep Patel65c3c8f2009-09-02 08:44:58 +000078 CallingConv::ID CallConv,
Dan Gohman98ca4f22009-08-05 01:29:28 +000079 bool isVarArg,
80 const SmallVectorImpl<ISD::InputArg> &Ins,
81 DebugLoc dl, SelectionDAG &DAG,
Dan Gohmand858e902010-04-17 15:26:15 +000082 SmallVectorImpl<SDValue> &InVals) const;
Jakob Stoklund Olesenf37812e2013-04-02 04:09:02 +000083 SDValue LowerFormalArguments_32(SDValue Chain,
84 CallingConv::ID CallConv,
85 bool isVarArg,
86 const SmallVectorImpl<ISD::InputArg> &Ins,
87 DebugLoc dl, SelectionDAG &DAG,
88 SmallVectorImpl<SDValue> &InVals) const;
89 SDValue LowerFormalArguments_64(SDValue Chain,
90 CallingConv::ID CallConv,
91 bool isVarArg,
92 const SmallVectorImpl<ISD::InputArg> &Ins,
93 DebugLoc dl, SelectionDAG &DAG,
94 SmallVectorImpl<SDValue> &InVals) const;
Dan Gohman98ca4f22009-08-05 01:29:28 +000095
96 virtual SDValue
Justin Holewinskid2ea0e12012-05-25 16:35:28 +000097 LowerCall(TargetLowering::CallLoweringInfo &CLI,
Dan Gohmand858e902010-04-17 15:26:15 +000098 SmallVectorImpl<SDValue> &InVals) const;
Jakob Stoklund Olesen18fdb392013-04-07 19:10:57 +000099 SDValue LowerCall_32(TargetLowering::CallLoweringInfo &CLI,
100 SmallVectorImpl<SDValue> &InVals) const;
101 SDValue LowerCall_64(TargetLowering::CallLoweringInfo &CLI,
102 SmallVectorImpl<SDValue> &InVals) const;
Dan Gohman98ca4f22009-08-05 01:29:28 +0000103
104 virtual SDValue
105 LowerReturn(SDValue Chain,
Sandeep Patel65c3c8f2009-09-02 08:44:58 +0000106 CallingConv::ID CallConv, bool isVarArg,
Dan Gohman98ca4f22009-08-05 01:29:28 +0000107 const SmallVectorImpl<ISD::OutputArg> &Outs,
Dan Gohmanc9403652010-07-07 15:54:55 +0000108 const SmallVectorImpl<SDValue> &OutVals,
Dan Gohmand858e902010-04-17 15:26:15 +0000109 DebugLoc dl, SelectionDAG &DAG) const;
Jakob Stoklund Olesen53d4bcf2013-04-06 23:57:33 +0000110 SDValue LowerReturn_32(SDValue Chain,
111 CallingConv::ID CallConv, bool IsVarArg,
112 const SmallVectorImpl<ISD::OutputArg> &Outs,
113 const SmallVectorImpl<SDValue> &OutVals,
114 DebugLoc DL, SelectionDAG &DAG) const;
115 SDValue LowerReturn_64(SDValue Chain,
116 CallingConv::ID CallConv, bool IsVarArg,
117 const SmallVectorImpl<ISD::OutputArg> &Outs,
118 const SmallVectorImpl<SDValue> &OutVals,
119 DebugLoc DL, SelectionDAG &DAG) const;
Chris Lattnerdb486a62009-09-15 17:46:24 +0000120
Dan Gohmand858e902010-04-17 15:26:15 +0000121 SDValue LowerGlobalAddress(SDValue Op, SelectionDAG &DAG) const;
122 SDValue LowerConstantPool(SDValue Op, SelectionDAG &DAG) const;
Venkatraman Govindaraju58269b92011-02-21 03:42:44 +0000123
124 unsigned getSRetArgSize(SelectionDAG &DAG, SDValue Callee) const;
Jakob Stoklund Olesen0ec587e2013-04-14 01:33:32 +0000125 SDValue withTargetFlags(SDValue Op, unsigned TF, SelectionDAG &DAG) const;
126 SDValue makeHiLoPair(SDValue Op, unsigned HiTF, unsigned LoTF,
127 SelectionDAG &DAG) const;
Jakob Stoklund Olesen26932102013-04-14 04:35:16 +0000128 SDValue makeAddress(SDValue Op, SelectionDAG &DAG) const;
Chris Lattnerd23405e2008-03-17 03:21:36 +0000129 };
130} // end namespace llvm
131
132#endif // SPARC_ISELLOWERING_H