blob: 57ef0995e71c45074b2192b22f19f34f2c5c30a5 [file] [log] [blame]
Chris Lattner0a1762e2008-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 Lattner0a1762e2008-03-17 03:21:36 +000018#include "Sparc.h"
Craig Topperb25fda92012-03-17 18:46:09 +000019#include "llvm/Target/TargetLowering.h"
Chris Lattner0a1762e2008-03-17 03:21:36 +000020
21namespace llvm {
Jakob Stoklund Olesen5ad3b352013-04-02 04:08:54 +000022 class SparcSubtarget;
23
Chris Lattner0a1762e2008-03-17 03:21:36 +000024 namespace SPISD {
25 enum {
Dan Gohmaned1cf1a2008-09-23 18:42:32 +000026 FIRST_NUMBER = ISD::BUILTIN_OP_END,
Jakob Stoklund Olesend9bbdfd2013-04-03 04:41:44 +000027 CMPICC, // Compare two GPR operands, set icc+xcc.
Chris Lattner0a1762e2008-03-17 03:21:36 +000028 CMPFCC, // Compare two FP operands, set fcc.
29 BRICC, // Branch to dest on icc condition
Jakob Stoklund Olesend9bbdfd2013-04-03 04:41:44 +000030 BRXCC, // Branch to dest on xcc condition (64-bit only).
Chris Lattner0a1762e2008-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 Olesen8cfaffa2013-04-04 03:08:00 +000033 SELECT_XCC, // Select between two values using the current XCC flags.
Chris Lattner0a1762e2008-03-17 03:21:36 +000034 SELECT_FCC, // Select between two values using the current FCC flags.
Anton Korobeynikov281cf242008-10-10 20:28:10 +000035
Chris Lattner0a1762e2008-03-17 03:21:36 +000036 Hi, Lo, // Hi/Lo operations, typically on a global address.
Anton Korobeynikov281cf242008-10-10 20:28:10 +000037
Chris Lattner0a1762e2008-03-17 03:21:36 +000038 FTOI, // FP to Int within a FP register.
39 ITOF, // Int to FP within a FP register.
Anton Korobeynikov281cf242008-10-10 20:28:10 +000040
Chris Lattner0a1762e2008-03-17 03:21:36 +000041 CALL, // A call instruction.
Chris Lattner840c7002009-09-15 17:46:24 +000042 RET_FLAG, // Return with a flag operand.
Venkatraman Govindarajucb1dca62013-09-22 06:48:52 +000043 GLOBAL_BASE_REG, // Global base reg for PIC.
44 FLUSHW, // FLUSH register windows to stack.
45
46 TLS_ADD, // For Thread Local Storage (TLS).
47 TLS_LD,
48 TLS_CALL
Chris Lattner0a1762e2008-03-17 03:21:36 +000049 };
50 }
Anton Korobeynikov281cf242008-10-10 20:28:10 +000051
Chris Lattner0a1762e2008-03-17 03:21:36 +000052 class SparcTargetLowering : public TargetLowering {
Jakob Stoklund Olesen5ad3b352013-04-02 04:08:54 +000053 const SparcSubtarget *Subtarget;
Chris Lattner0a1762e2008-03-17 03:21:36 +000054 public:
55 SparcTargetLowering(TargetMachine &TM);
Dan Gohman21cea8a2010-04-17 15:26:15 +000056 virtual SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const;
Anton Korobeynikov281cf242008-10-10 20:28:10 +000057
Anton Korobeynikov281cf242008-10-10 20:28:10 +000058 /// computeMaskedBitsForTargetNode - Determine which of the bits specified
59 /// in Mask are known to be either zero or one and return them in the
Chris Lattner0a1762e2008-03-17 03:21:36 +000060 /// KnownZero/KnownOne bitsets.
Dan Gohman2ce6f2a2008-07-27 21:46:04 +000061 virtual void computeMaskedBitsForTargetNode(const SDValue Op,
Anton Korobeynikov281cf242008-10-10 20:28:10 +000062 APInt &KnownZero,
Chris Lattner0a1762e2008-03-17 03:21:36 +000063 APInt &KnownOne,
64 const SelectionDAG &DAG,
65 unsigned Depth = 0) const;
Anton Korobeynikov281cf242008-10-10 20:28:10 +000066
Dan Gohman25c16532010-05-01 00:01:06 +000067 virtual MachineBasicBlock *
68 EmitInstrWithCustomInserter(MachineInstr *MI,
69 MachineBasicBlock *MBB) const;
Anton Korobeynikov281cf242008-10-10 20:28:10 +000070
Chris Lattner0a1762e2008-03-17 03:21:36 +000071 virtual const char *getTargetNodeName(unsigned Opcode) const;
Anton Korobeynikov281cf242008-10-10 20:28:10 +000072
73 ConstraintType getConstraintType(const std::string &Constraint) const;
74 std::pair<unsigned, const TargetRegisterClass*>
Chad Rosier295bd432013-06-22 18:37:38 +000075 getRegForInlineAsmConstraint(const std::string &Constraint, MVT VT) const;
Dan Gohman2fe6bee2008-10-18 02:06:02 +000076
77 virtual bool isOffsetFoldingLegal(const GlobalAddressSDNode *GA) const;
Jakob Stoklund Oleseneed10722013-04-14 05:48:50 +000078 virtual MVT getScalarShiftAmountTy(EVT LHSTy) const { return MVT::i32; }
Bill Wendling31ceb1b2009-06-30 22:38:32 +000079
Dan Gohmanf9bbcd12009-08-05 01:29:28 +000080 virtual SDValue
81 LowerFormalArguments(SDValue Chain,
Sandeep Patel68c5f472009-09-02 08:44:58 +000082 CallingConv::ID CallConv,
Dan Gohmanf9bbcd12009-08-05 01:29:28 +000083 bool isVarArg,
84 const SmallVectorImpl<ISD::InputArg> &Ins,
Andrew Trickef9de2a2013-05-25 02:42:55 +000085 SDLoc dl, SelectionDAG &DAG,
Dan Gohman21cea8a2010-04-17 15:26:15 +000086 SmallVectorImpl<SDValue> &InVals) const;
Jakob Stoklund Olesen0b21f352013-04-02 04:09:02 +000087 SDValue LowerFormalArguments_32(SDValue Chain,
88 CallingConv::ID CallConv,
89 bool isVarArg,
90 const SmallVectorImpl<ISD::InputArg> &Ins,
Andrew Trickef9de2a2013-05-25 02:42:55 +000091 SDLoc dl, SelectionDAG &DAG,
Jakob Stoklund Olesen0b21f352013-04-02 04:09:02 +000092 SmallVectorImpl<SDValue> &InVals) const;
93 SDValue LowerFormalArguments_64(SDValue Chain,
94 CallingConv::ID CallConv,
95 bool isVarArg,
96 const SmallVectorImpl<ISD::InputArg> &Ins,
Andrew Trickef9de2a2013-05-25 02:42:55 +000097 SDLoc dl, SelectionDAG &DAG,
Jakob Stoklund Olesen0b21f352013-04-02 04:09:02 +000098 SmallVectorImpl<SDValue> &InVals) const;
Dan Gohmanf9bbcd12009-08-05 01:29:28 +000099
100 virtual SDValue
Justin Holewinskiaa583972012-05-25 16:35:28 +0000101 LowerCall(TargetLowering::CallLoweringInfo &CLI,
Dan Gohman21cea8a2010-04-17 15:26:15 +0000102 SmallVectorImpl<SDValue> &InVals) const;
Jakob Stoklund Olesena30f4832013-04-07 19:10:57 +0000103 SDValue LowerCall_32(TargetLowering::CallLoweringInfo &CLI,
104 SmallVectorImpl<SDValue> &InVals) const;
105 SDValue LowerCall_64(TargetLowering::CallLoweringInfo &CLI,
106 SmallVectorImpl<SDValue> &InVals) const;
Dan Gohmanf9bbcd12009-08-05 01:29:28 +0000107
108 virtual SDValue
109 LowerReturn(SDValue Chain,
Sandeep Patel68c5f472009-09-02 08:44:58 +0000110 CallingConv::ID CallConv, bool isVarArg,
Dan Gohmanf9bbcd12009-08-05 01:29:28 +0000111 const SmallVectorImpl<ISD::OutputArg> &Outs,
Dan Gohmanfe7532a2010-07-07 15:54:55 +0000112 const SmallVectorImpl<SDValue> &OutVals,
Andrew Trickef9de2a2013-05-25 02:42:55 +0000113 SDLoc dl, SelectionDAG &DAG) const;
Jakob Stoklund Olesenedaf66b2013-04-06 23:57:33 +0000114 SDValue LowerReturn_32(SDValue Chain,
115 CallingConv::ID CallConv, bool IsVarArg,
116 const SmallVectorImpl<ISD::OutputArg> &Outs,
117 const SmallVectorImpl<SDValue> &OutVals,
Andrew Trickef9de2a2013-05-25 02:42:55 +0000118 SDLoc DL, SelectionDAG &DAG) const;
Jakob Stoklund Olesenedaf66b2013-04-06 23:57:33 +0000119 SDValue LowerReturn_64(SDValue Chain,
120 CallingConv::ID CallConv, bool IsVarArg,
121 const SmallVectorImpl<ISD::OutputArg> &Outs,
122 const SmallVectorImpl<SDValue> &OutVals,
Andrew Trickef9de2a2013-05-25 02:42:55 +0000123 SDLoc DL, SelectionDAG &DAG) const;
Chris Lattner840c7002009-09-15 17:46:24 +0000124
Dan Gohman21cea8a2010-04-17 15:26:15 +0000125 SDValue LowerGlobalAddress(SDValue Op, SelectionDAG &DAG) const;
Venkatraman Govindarajucb1dca62013-09-22 06:48:52 +0000126 SDValue LowerGlobalTLSAddress(SDValue Op, SelectionDAG &DAG) const;
Dan Gohman21cea8a2010-04-17 15:26:15 +0000127 SDValue LowerConstantPool(SDValue Op, SelectionDAG &DAG) const;
Venkatraman Govindarajuf80d72f2013-06-03 05:58:33 +0000128 SDValue LowerBlockAddress(SDValue Op, SelectionDAG &DAG) const;
Venkatraman Govindarajua82203f2011-02-21 03:42:44 +0000129
130 unsigned getSRetArgSize(SelectionDAG &DAG, SDValue Callee) const;
Jakob Stoklund Olesen1fb08a82013-04-14 01:33:32 +0000131 SDValue withTargetFlags(SDValue Op, unsigned TF, SelectionDAG &DAG) const;
132 SDValue makeHiLoPair(SDValue Op, unsigned HiTF, unsigned LoTF,
133 SelectionDAG &DAG) const;
Jakob Stoklund Olesene0fc8322013-04-14 04:35:16 +0000134 SDValue makeAddress(SDValue Op, SelectionDAG &DAG) const;
Venkatraman Govindaraju59039dc2013-09-03 04:11:59 +0000135
136 SDValue LowerF128_LibCallArg(SDValue Chain, ArgListTy &Args,
137 SDValue Arg, SDLoc DL,
138 SelectionDAG &DAG) const;
139 SDValue LowerF128Op(SDValue Op, SelectionDAG &DAG,
140 const char *LibFuncName,
141 unsigned numArgs) const;
142 SDValue LowerF128Compare(SDValue LHS, SDValue RHS,
143 unsigned &SPCC,
144 SDLoc DL,
145 SelectionDAG &DAG) const;
146
147 bool ShouldShrinkFPConstant(EVT VT) const {
148 // Do not shrink FP constpool if VT == MVT::f128.
149 // (ldd, call _Q_fdtoq) is more expensive than two ldds.
150 return VT != MVT::f128;
151 }
Chris Lattner0a1762e2008-03-17 03:21:36 +0000152 };
153} // end namespace llvm
154
155#endif // SPARC_ISELLOWERING_H