blob: 274673cd4da0ad7c460f083ddd9a53cd825b47dc [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.
33 SELECT_FCC, // Select between two values using the current FCC flags.
Anton Korobeynikov0eefda12008-10-10 20:28:10 +000034
Chris Lattnerd23405e2008-03-17 03:21:36 +000035 Hi, Lo, // Hi/Lo operations, typically on a global address.
Anton Korobeynikov0eefda12008-10-10 20:28:10 +000036
Chris Lattnerd23405e2008-03-17 03:21:36 +000037 FTOI, // FP to Int within a FP register.
38 ITOF, // Int to FP within a FP register.
Anton Korobeynikov0eefda12008-10-10 20:28:10 +000039
Chris Lattnerd23405e2008-03-17 03:21:36 +000040 CALL, // A call instruction.
Chris Lattnerdb486a62009-09-15 17:46:24 +000041 RET_FLAG, // Return with a flag operand.
Venkatraman Govindaraju860b64c2011-01-12 05:08:36 +000042 GLOBAL_BASE_REG, // Global base reg for PIC
Venkatraman Govindarajufc3faa72011-01-21 22:00:00 +000043 FLUSHW // FLUSH register windows to stack
Chris Lattnerd23405e2008-03-17 03:21:36 +000044 };
45 }
Anton Korobeynikov0eefda12008-10-10 20:28:10 +000046
Chris Lattnerd23405e2008-03-17 03:21:36 +000047 class SparcTargetLowering : public TargetLowering {
Jakob Stoklund Olesenfcb25e62013-04-02 04:08:54 +000048 const SparcSubtarget *Subtarget;
Chris Lattnerd23405e2008-03-17 03:21:36 +000049 public:
50 SparcTargetLowering(TargetMachine &TM);
Dan Gohmand858e902010-04-17 15:26:15 +000051 virtual SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const;
Anton Korobeynikov0eefda12008-10-10 20:28:10 +000052
Anton Korobeynikov0eefda12008-10-10 20:28:10 +000053 /// computeMaskedBitsForTargetNode - Determine which of the bits specified
54 /// in Mask are known to be either zero or one and return them in the
Chris Lattnerd23405e2008-03-17 03:21:36 +000055 /// KnownZero/KnownOne bitsets.
Dan Gohman475871a2008-07-27 21:46:04 +000056 virtual void computeMaskedBitsForTargetNode(const SDValue Op,
Anton Korobeynikov0eefda12008-10-10 20:28:10 +000057 APInt &KnownZero,
Chris Lattnerd23405e2008-03-17 03:21:36 +000058 APInt &KnownOne,
59 const SelectionDAG &DAG,
60 unsigned Depth = 0) const;
Anton Korobeynikov0eefda12008-10-10 20:28:10 +000061
Dan Gohmanaf1d8ca2010-05-01 00:01:06 +000062 virtual MachineBasicBlock *
63 EmitInstrWithCustomInserter(MachineInstr *MI,
64 MachineBasicBlock *MBB) const;
Anton Korobeynikov0eefda12008-10-10 20:28:10 +000065
Chris Lattnerd23405e2008-03-17 03:21:36 +000066 virtual const char *getTargetNodeName(unsigned Opcode) const;
Anton Korobeynikov0eefda12008-10-10 20:28:10 +000067
68 ConstraintType getConstraintType(const std::string &Constraint) const;
69 std::pair<unsigned, const TargetRegisterClass*>
Owen Andersone50ed302009-08-10 22:56:29 +000070 getRegForInlineAsmConstraint(const std::string &Constraint, EVT VT) const;
Dan Gohman6520e202008-10-18 02:06:02 +000071
72 virtual bool isOffsetFoldingLegal(const GlobalAddressSDNode *GA) const;
Bill Wendling20c568f2009-06-30 22:38:32 +000073
Dan Gohman98ca4f22009-08-05 01:29:28 +000074 virtual SDValue
75 LowerFormalArguments(SDValue Chain,
Sandeep Patel65c3c8f2009-09-02 08:44:58 +000076 CallingConv::ID CallConv,
Dan Gohman98ca4f22009-08-05 01:29:28 +000077 bool isVarArg,
78 const SmallVectorImpl<ISD::InputArg> &Ins,
79 DebugLoc dl, SelectionDAG &DAG,
Dan Gohmand858e902010-04-17 15:26:15 +000080 SmallVectorImpl<SDValue> &InVals) const;
Jakob Stoklund Olesenf37812e2013-04-02 04:09:02 +000081 SDValue LowerFormalArguments_32(SDValue Chain,
82 CallingConv::ID CallConv,
83 bool isVarArg,
84 const SmallVectorImpl<ISD::InputArg> &Ins,
85 DebugLoc dl, SelectionDAG &DAG,
86 SmallVectorImpl<SDValue> &InVals) const;
87 SDValue LowerFormalArguments_64(SDValue Chain,
88 CallingConv::ID CallConv,
89 bool isVarArg,
90 const SmallVectorImpl<ISD::InputArg> &Ins,
91 DebugLoc dl, SelectionDAG &DAG,
92 SmallVectorImpl<SDValue> &InVals) const;
Dan Gohman98ca4f22009-08-05 01:29:28 +000093
94 virtual SDValue
Justin Holewinskid2ea0e12012-05-25 16:35:28 +000095 LowerCall(TargetLowering::CallLoweringInfo &CLI,
Dan Gohmand858e902010-04-17 15:26:15 +000096 SmallVectorImpl<SDValue> &InVals) const;
Dan Gohman98ca4f22009-08-05 01:29:28 +000097
98 virtual SDValue
99 LowerReturn(SDValue Chain,
Sandeep Patel65c3c8f2009-09-02 08:44:58 +0000100 CallingConv::ID CallConv, bool isVarArg,
Dan Gohman98ca4f22009-08-05 01:29:28 +0000101 const SmallVectorImpl<ISD::OutputArg> &Outs,
Dan Gohmanc9403652010-07-07 15:54:55 +0000102 const SmallVectorImpl<SDValue> &OutVals,
Dan Gohmand858e902010-04-17 15:26:15 +0000103 DebugLoc dl, SelectionDAG &DAG) const;
Chris Lattnerdb486a62009-09-15 17:46:24 +0000104
Dan Gohmand858e902010-04-17 15:26:15 +0000105 SDValue LowerGlobalAddress(SDValue Op, SelectionDAG &DAG) const;
106 SDValue LowerConstantPool(SDValue Op, SelectionDAG &DAG) const;
Venkatraman Govindaraju58269b92011-02-21 03:42:44 +0000107
108 unsigned getSRetArgSize(SelectionDAG &DAG, SDValue Callee) const;
Chris Lattnerd23405e2008-03-17 03:21:36 +0000109 };
110} // end namespace llvm
111
112#endif // SPARC_ISELLOWERING_H