blob: 7d02df8adcca151befafac35e06dd41aa9bba001 [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
18#include "llvm/Target/TargetLowering.h"
19#include "Sparc.h"
20
21namespace llvm {
22 namespace SPISD {
23 enum {
Dan Gohmaned1cf1a2008-09-23 18:42:32 +000024 FIRST_NUMBER = ISD::BUILTIN_OP_END,
Chris Lattner0a1762e2008-03-17 03:21:36 +000025 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 Korobeynikov281cf242008-10-10 20:28:10 +000031
Chris Lattner0a1762e2008-03-17 03:21:36 +000032 Hi, Lo, // Hi/Lo operations, typically on a global address.
Anton Korobeynikov281cf242008-10-10 20:28:10 +000033
Chris Lattner0a1762e2008-03-17 03:21:36 +000034 FTOI, // FP to Int within a FP register.
35 ITOF, // Int to FP within a FP register.
Anton Korobeynikov281cf242008-10-10 20:28:10 +000036
Chris Lattner0a1762e2008-03-17 03:21:36 +000037 CALL, // A call instruction.
Chris Lattner840c7002009-09-15 17:46:24 +000038 RET_FLAG, // Return with a flag operand.
Venkatraman Govindarajud9645802011-01-12 05:08:36 +000039 GLOBAL_BASE_REG, // Global base reg for PIC
Venkatraman Govindarajuef8cf452011-01-21 22:00:00 +000040 FLUSHW // FLUSH register windows to stack
Chris Lattner0a1762e2008-03-17 03:21:36 +000041 };
42 }
Anton Korobeynikov281cf242008-10-10 20:28:10 +000043
Chris Lattner0a1762e2008-03-17 03:21:36 +000044 class SparcTargetLowering : public TargetLowering {
Chris Lattner0a1762e2008-03-17 03:21:36 +000045 public:
46 SparcTargetLowering(TargetMachine &TM);
Dan Gohman21cea8a2010-04-17 15:26:15 +000047 virtual SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const;
Anton Korobeynikov281cf242008-10-10 20:28:10 +000048
Anton Korobeynikov281cf242008-10-10 20:28:10 +000049 /// computeMaskedBitsForTargetNode - Determine which of the bits specified
50 /// in Mask are known to be either zero or one and return them in the
Chris Lattner0a1762e2008-03-17 03:21:36 +000051 /// KnownZero/KnownOne bitsets.
Dan Gohman2ce6f2a2008-07-27 21:46:04 +000052 virtual void computeMaskedBitsForTargetNode(const SDValue Op,
Chris Lattner0a1762e2008-03-17 03:21:36 +000053 const APInt &Mask,
Anton Korobeynikov281cf242008-10-10 20:28:10 +000054 APInt &KnownZero,
Chris Lattner0a1762e2008-03-17 03:21:36 +000055 APInt &KnownOne,
56 const SelectionDAG &DAG,
57 unsigned Depth = 0) const;
Anton Korobeynikov281cf242008-10-10 20:28:10 +000058
Dan Gohman25c16532010-05-01 00:01:06 +000059 virtual MachineBasicBlock *
60 EmitInstrWithCustomInserter(MachineInstr *MI,
61 MachineBasicBlock *MBB) const;
Anton Korobeynikov281cf242008-10-10 20:28:10 +000062
Chris Lattner0a1762e2008-03-17 03:21:36 +000063 virtual const char *getTargetNodeName(unsigned Opcode) const;
Anton Korobeynikov281cf242008-10-10 20:28:10 +000064
65 ConstraintType getConstraintType(const std::string &Constraint) const;
66 std::pair<unsigned, const TargetRegisterClass*>
Owen Anderson53aa7a92009-08-10 22:56:29 +000067 getRegForInlineAsmConstraint(const std::string &Constraint, EVT VT) const;
Anton Korobeynikov281cf242008-10-10 20:28:10 +000068 std::vector<unsigned>
69 getRegClassForInlineAsmConstraint(const std::string &Constraint,
Owen Anderson53aa7a92009-08-10 22:56:29 +000070 EVT VT) const;
Dan Gohman2fe6bee2008-10-18 02:06:02 +000071
72 virtual bool isOffsetFoldingLegal(const GlobalAddressSDNode *GA) const;
Bill Wendling31ceb1b2009-06-30 22:38:32 +000073
Bill Wendling512ff732009-07-01 18:50:55 +000074 /// getFunctionAlignment - Return the Log2 alignment of this function.
Bill Wendling31ceb1b2009-06-30 22:38:32 +000075 virtual unsigned getFunctionAlignment(const Function *F) const;
Dan Gohmanf9bbcd12009-08-05 01:29:28 +000076
77 virtual SDValue
78 LowerFormalArguments(SDValue Chain,
Sandeep Patel68c5f472009-09-02 08:44:58 +000079 CallingConv::ID CallConv,
Dan Gohmanf9bbcd12009-08-05 01:29:28 +000080 bool isVarArg,
81 const SmallVectorImpl<ISD::InputArg> &Ins,
82 DebugLoc dl, SelectionDAG &DAG,
Dan Gohman21cea8a2010-04-17 15:26:15 +000083 SmallVectorImpl<SDValue> &InVals) const;
Dan Gohmanf9bbcd12009-08-05 01:29:28 +000084
85 virtual SDValue
Evan Cheng6f36a082010-02-02 23:55:14 +000086 LowerCall(SDValue Chain, SDValue Callee,
Sandeep Patel68c5f472009-09-02 08:44:58 +000087 CallingConv::ID CallConv, bool isVarArg,
Evan Cheng67a69dd2010-01-27 00:07:07 +000088 bool &isTailCall,
Dan Gohmanf9bbcd12009-08-05 01:29:28 +000089 const SmallVectorImpl<ISD::OutputArg> &Outs,
Dan Gohmanfe7532a2010-07-07 15:54:55 +000090 const SmallVectorImpl<SDValue> &OutVals,
Dan Gohmanf9bbcd12009-08-05 01:29:28 +000091 const SmallVectorImpl<ISD::InputArg> &Ins,
92 DebugLoc dl, SelectionDAG &DAG,
Dan Gohman21cea8a2010-04-17 15:26:15 +000093 SmallVectorImpl<SDValue> &InVals) const;
Dan Gohmanf9bbcd12009-08-05 01:29:28 +000094
95 virtual SDValue
96 LowerReturn(SDValue Chain,
Sandeep Patel68c5f472009-09-02 08:44:58 +000097 CallingConv::ID CallConv, bool isVarArg,
Dan Gohmanf9bbcd12009-08-05 01:29:28 +000098 const SmallVectorImpl<ISD::OutputArg> &Outs,
Dan Gohmanfe7532a2010-07-07 15:54:55 +000099 const SmallVectorImpl<SDValue> &OutVals,
Dan Gohman21cea8a2010-04-17 15:26:15 +0000100 DebugLoc dl, SelectionDAG &DAG) const;
Chris Lattner840c7002009-09-15 17:46:24 +0000101
Dan Gohman21cea8a2010-04-17 15:26:15 +0000102 SDValue LowerGlobalAddress(SDValue Op, SelectionDAG &DAG) const;
103 SDValue LowerConstantPool(SDValue Op, SelectionDAG &DAG) const;
Venkatraman Govindarajua82203f2011-02-21 03:42:44 +0000104
105 unsigned getSRetArgSize(SelectionDAG &DAG, SDValue Callee) const;
Chris Lattner0a1762e2008-03-17 03:21:36 +0000106 };
107} // end namespace llvm
108
109#endif // SPARC_ISELLOWERING_H