blob: 2ee73c1ac9095bc60fc80251fa6db08dc25ebef8 [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
18#include "llvm/Target/TargetLowering.h"
19#include "Sparc.h"
20
21namespace llvm {
22 namespace SPISD {
23 enum {
Dan Gohman0ba2bcf2008-09-23 18:42:32 +000024 FIRST_NUMBER = ISD::BUILTIN_OP_END,
Chris Lattnerd23405e2008-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 Korobeynikov0eefda12008-10-10 20:28:10 +000031
Chris Lattnerd23405e2008-03-17 03:21:36 +000032 Hi, Lo, // Hi/Lo operations, typically on a global address.
Anton Korobeynikov0eefda12008-10-10 20:28:10 +000033
Chris Lattnerd23405e2008-03-17 03:21:36 +000034 FTOI, // FP to Int within a FP register.
35 ITOF, // Int to FP within a FP register.
Anton Korobeynikov0eefda12008-10-10 20:28:10 +000036
Chris Lattnerd23405e2008-03-17 03:21:36 +000037 CALL, // A call instruction.
Chris Lattnerdb486a62009-09-15 17:46:24 +000038 RET_FLAG, // Return with a flag operand.
39 GLOBAL_BASE_REG // Global base reg for PIC
Chris Lattnerd23405e2008-03-17 03:21:36 +000040 };
41 }
Anton Korobeynikov0eefda12008-10-10 20:28:10 +000042
Chris Lattnerd23405e2008-03-17 03:21:36 +000043 class SparcTargetLowering : public TargetLowering {
44 int VarArgsFrameOffset; // Frame offset to start of varargs area.
45 public:
46 SparcTargetLowering(TargetMachine &TM);
Dan Gohman475871a2008-07-27 21:46:04 +000047 virtual SDValue LowerOperation(SDValue Op, SelectionDAG &DAG);
Anton Korobeynikov0eefda12008-10-10 20:28:10 +000048
Chris Lattnerd23405e2008-03-17 03:21:36 +000049 int getVarArgsFrameOffset() const { return VarArgsFrameOffset; }
Anton Korobeynikov0eefda12008-10-10 20:28:10 +000050
51 /// computeMaskedBitsForTargetNode - Determine which of the bits specified
52 /// in Mask are known to be either zero or one and return them in the
Chris Lattnerd23405e2008-03-17 03:21:36 +000053 /// KnownZero/KnownOne bitsets.
Dan Gohman475871a2008-07-27 21:46:04 +000054 virtual void computeMaskedBitsForTargetNode(const SDValue Op,
Chris Lattnerd23405e2008-03-17 03:21:36 +000055 const APInt &Mask,
Anton Korobeynikov0eefda12008-10-10 20:28:10 +000056 APInt &KnownZero,
Chris Lattnerd23405e2008-03-17 03:21:36 +000057 APInt &KnownOne,
58 const SelectionDAG &DAG,
59 unsigned Depth = 0) const;
Anton Korobeynikov0eefda12008-10-10 20:28:10 +000060
Chris Lattnerd23405e2008-03-17 03:21:36 +000061 virtual MachineBasicBlock *EmitInstrWithCustomInserter(MachineInstr *MI,
Evan Chengfb2e7522009-09-18 21:02:19 +000062 MachineBasicBlock *MBB,
63 DenseMap<MachineBasicBlock*, MachineBasicBlock*> *EM) const;
Anton Korobeynikov0eefda12008-10-10 20:28:10 +000064
Chris Lattnerd23405e2008-03-17 03:21:36 +000065 virtual const char *getTargetNodeName(unsigned Opcode) const;
Anton Korobeynikov0eefda12008-10-10 20:28:10 +000066
67 ConstraintType getConstraintType(const std::string &Constraint) const;
68 std::pair<unsigned, const TargetRegisterClass*>
Owen Andersone50ed302009-08-10 22:56:29 +000069 getRegForInlineAsmConstraint(const std::string &Constraint, EVT VT) const;
Anton Korobeynikov0eefda12008-10-10 20:28:10 +000070 std::vector<unsigned>
71 getRegClassForInlineAsmConstraint(const std::string &Constraint,
Owen Andersone50ed302009-08-10 22:56:29 +000072 EVT VT) const;
Dan Gohman6520e202008-10-18 02:06:02 +000073
74 virtual bool isOffsetFoldingLegal(const GlobalAddressSDNode *GA) const;
Bill Wendling20c568f2009-06-30 22:38:32 +000075
Bill Wendlingb4202b82009-07-01 18:50:55 +000076 /// getFunctionAlignment - Return the Log2 alignment of this function.
Bill Wendling20c568f2009-06-30 22:38:32 +000077 virtual unsigned getFunctionAlignment(const Function *F) const;
Dan Gohman98ca4f22009-08-05 01:29:28 +000078
79 virtual SDValue
80 LowerFormalArguments(SDValue Chain,
Sandeep Patel65c3c8f2009-09-02 08:44:58 +000081 CallingConv::ID CallConv,
Dan Gohman98ca4f22009-08-05 01:29:28 +000082 bool isVarArg,
83 const SmallVectorImpl<ISD::InputArg> &Ins,
84 DebugLoc dl, SelectionDAG &DAG,
85 SmallVectorImpl<SDValue> &InVals);
86
87 virtual SDValue
88 LowerCall(SDValue Chain, SDValue Callee,
Sandeep Patel65c3c8f2009-09-02 08:44:58 +000089 CallingConv::ID CallConv, bool isVarArg,
Evan Cheng0c439eb2010-01-27 00:07:07 +000090 bool &isTailCall,
Dan Gohman98ca4f22009-08-05 01:29:28 +000091 const SmallVectorImpl<ISD::OutputArg> &Outs,
92 const SmallVectorImpl<ISD::InputArg> &Ins,
93 DebugLoc dl, SelectionDAG &DAG,
94 SmallVectorImpl<SDValue> &InVals);
95
96 virtual SDValue
97 LowerReturn(SDValue Chain,
Sandeep Patel65c3c8f2009-09-02 08:44:58 +000098 CallingConv::ID CallConv, bool isVarArg,
Dan Gohman98ca4f22009-08-05 01:29:28 +000099 const SmallVectorImpl<ISD::OutputArg> &Outs,
100 DebugLoc dl, SelectionDAG &DAG);
Chris Lattnerdb486a62009-09-15 17:46:24 +0000101
102 SDValue LowerGlobalAddress(SDValue Op, SelectionDAG &DAG);
103 SDValue LowerConstantPool(SDValue Op, SelectionDAG &DAG);
Chris Lattnerd23405e2008-03-17 03:21:36 +0000104 };
105} // end namespace llvm
106
107#endif // SPARC_ISELLOWERING_H