blob: 21c183113bfe10b7b5b72b5cd5b32ee318f38540 [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;
Bill Wendling20c568f2009-06-30 22:38:32 +000074
Dan Gohman98ca4f22009-08-05 01:29:28 +000075 virtual SDValue
76 LowerFormalArguments(SDValue Chain,
Sandeep Patel65c3c8f2009-09-02 08:44:58 +000077 CallingConv::ID CallConv,
Dan Gohman98ca4f22009-08-05 01:29:28 +000078 bool isVarArg,
79 const SmallVectorImpl<ISD::InputArg> &Ins,
80 DebugLoc dl, SelectionDAG &DAG,
Dan Gohmand858e902010-04-17 15:26:15 +000081 SmallVectorImpl<SDValue> &InVals) const;
Jakob Stoklund Olesenf37812e2013-04-02 04:09:02 +000082 SDValue LowerFormalArguments_32(SDValue Chain,
83 CallingConv::ID CallConv,
84 bool isVarArg,
85 const SmallVectorImpl<ISD::InputArg> &Ins,
86 DebugLoc dl, SelectionDAG &DAG,
87 SmallVectorImpl<SDValue> &InVals) const;
88 SDValue LowerFormalArguments_64(SDValue Chain,
89 CallingConv::ID CallConv,
90 bool isVarArg,
91 const SmallVectorImpl<ISD::InputArg> &Ins,
92 DebugLoc dl, SelectionDAG &DAG,
93 SmallVectorImpl<SDValue> &InVals) const;
Dan Gohman98ca4f22009-08-05 01:29:28 +000094
95 virtual SDValue
Justin Holewinskid2ea0e12012-05-25 16:35:28 +000096 LowerCall(TargetLowering::CallLoweringInfo &CLI,
Dan Gohmand858e902010-04-17 15:26:15 +000097 SmallVectorImpl<SDValue> &InVals) const;
Jakob Stoklund Olesen18fdb392013-04-07 19:10:57 +000098 SDValue LowerCall_32(TargetLowering::CallLoweringInfo &CLI,
99 SmallVectorImpl<SDValue> &InVals) const;
100 SDValue LowerCall_64(TargetLowering::CallLoweringInfo &CLI,
101 SmallVectorImpl<SDValue> &InVals) const;
Dan Gohman98ca4f22009-08-05 01:29:28 +0000102
103 virtual SDValue
104 LowerReturn(SDValue Chain,
Sandeep Patel65c3c8f2009-09-02 08:44:58 +0000105 CallingConv::ID CallConv, bool isVarArg,
Dan Gohman98ca4f22009-08-05 01:29:28 +0000106 const SmallVectorImpl<ISD::OutputArg> &Outs,
Dan Gohmanc9403652010-07-07 15:54:55 +0000107 const SmallVectorImpl<SDValue> &OutVals,
Dan Gohmand858e902010-04-17 15:26:15 +0000108 DebugLoc dl, SelectionDAG &DAG) const;
Jakob Stoklund Olesen53d4bcf2013-04-06 23:57:33 +0000109 SDValue LowerReturn_32(SDValue Chain,
110 CallingConv::ID CallConv, bool IsVarArg,
111 const SmallVectorImpl<ISD::OutputArg> &Outs,
112 const SmallVectorImpl<SDValue> &OutVals,
113 DebugLoc DL, SelectionDAG &DAG) const;
114 SDValue LowerReturn_64(SDValue Chain,
115 CallingConv::ID CallConv, bool IsVarArg,
116 const SmallVectorImpl<ISD::OutputArg> &Outs,
117 const SmallVectorImpl<SDValue> &OutVals,
118 DebugLoc DL, SelectionDAG &DAG) const;
Chris Lattnerdb486a62009-09-15 17:46:24 +0000119
Dan Gohmand858e902010-04-17 15:26:15 +0000120 SDValue LowerGlobalAddress(SDValue Op, SelectionDAG &DAG) const;
121 SDValue LowerConstantPool(SDValue Op, SelectionDAG &DAG) const;
Venkatraman Govindaraju58269b92011-02-21 03:42:44 +0000122
123 unsigned getSRetArgSize(SelectionDAG &DAG, SDValue Callee) const;
Jakob Stoklund Olesen0ec587e2013-04-14 01:33:32 +0000124 SDValue withTargetFlags(SDValue Op, unsigned TF, SelectionDAG &DAG) const;
125 SDValue makeHiLoPair(SDValue Op, unsigned HiTF, unsigned LoTF,
126 SelectionDAG &DAG) const;
Jakob Stoklund Olesen26932102013-04-14 04:35:16 +0000127 SDValue makeAddress(SDValue Op, SelectionDAG &DAG) const;
Chris Lattnerd23405e2008-03-17 03:21:36 +0000128 };
129} // end namespace llvm
130
131#endif // SPARC_ISELLOWERING_H