blob: 7256617242fac84e362f1b62cc6ebd6c777f049f [file] [log] [blame]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001//===-- MipsISelLowering.h - Mips DAG Lowering Interface --------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner081ce942007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00007//
8//===----------------------------------------------------------------------===//
9//
10// This file defines the interfaces that Mips uses to lower LLVM code into a
11// selection DAG.
12//
13//===----------------------------------------------------------------------===//
14
15#ifndef MipsISELLOWERING_H
16#define MipsISELLOWERING_H
17
18#include "llvm/CodeGen/SelectionDAG.h"
19#include "llvm/Target/TargetLowering.h"
20#include "Mips.h"
21#include "MipsSubtarget.h"
22
23namespace llvm {
24 namespace MipsISD {
25 enum NodeType {
26 // Start the numbering from where ISD NodeType finishes.
Dan Gohman868636e2008-09-23 18:42:32 +000027 FIRST_NUMBER = ISD::BUILTIN_OP_END,
Dan Gohmanf17a25c2007-07-18 16:29:46 +000028
29 // Jump and link (call)
30 JmpLink,
31
32 // Get the Higher 16 bits from a 32-bit immediate
33 // No relation with Mips Hi register
34 Hi,
35
36 // Get the Lower 16 bits from a 32-bit immediate
37 // No relation with Mips Lo register
38 Lo,
39
Bruno Cardoso Lopes12355a82008-07-21 18:52:34 +000040 // Handle gp_rel (small data/bss sections) relocation.
41 GPRel,
42
Bruno Cardoso Lopes60f3e052008-08-13 07:13:40 +000043 // Conditional Move
44 CMov,
45
Bruno Cardoso Lopesed7723d2008-06-06 00:58:26 +000046 // Select CC Pseudo Instruction
47 SelectCC,
48
Bruno Cardoso Lopesda54c7d2008-07-29 19:05:28 +000049 // Floating Point Select CC Pseudo Instruction
50 FPSelectCC,
51
Bruno Cardoso Lopes68011702008-07-09 04:45:36 +000052 // Floating Point Branch Conditional
Bruno Cardoso Lopes4fb1f542008-07-05 19:05:21 +000053 FPBrcond,
54
Bruno Cardoso Lopes68011702008-07-09 04:45:36 +000055 // Floating Point Compare
Bruno Cardoso Lopes4fb1f542008-07-05 19:05:21 +000056 FPCmp,
57
Bruno Cardoso Lopes643c0402009-05-27 17:23:44 +000058 // Floating Point Rounding
59 FPRound,
60
Dan Gohmanf17a25c2007-07-18 16:29:46 +000061 // Return
Bruno Cardoso Lopes218d5822007-11-05 03:02:32 +000062 Ret
Dan Gohmanf17a25c2007-07-18 16:29:46 +000063 };
64 }
65
66 //===--------------------------------------------------------------------===//
67 // TargetLowering Implementation
68 //===--------------------------------------------------------------------===//
Chris Lattner653c9562009-08-13 05:41:27 +000069
70 class MipsTargetLowering : public TargetLowering {
Bruno Cardoso Lopes9125fde2010-02-06 21:00:02 +000071 int VarArgsFrameIndex; // FrameIndex for start of varargs area.
72
Dan Gohmanf17a25c2007-07-18 16:29:46 +000073 public:
74
Dan Gohman3a78bbf2007-08-02 21:21:54 +000075 explicit MipsTargetLowering(MipsTargetMachine &TM);
Dan Gohmanf17a25c2007-07-18 16:29:46 +000076
77 /// LowerOperation - Provide custom lowering hooks for some operations.
Dan Gohman8181bd12008-07-27 21:46:04 +000078 virtual SDValue LowerOperation(SDValue Op, SelectionDAG &DAG);
Dan Gohmanf17a25c2007-07-18 16:29:46 +000079
80 /// getTargetNodeName - This method returns the name of a target specific
81 // DAG node.
82 virtual const char *getTargetNodeName(unsigned Opcode) const;
83
Scott Michel502151f2008-03-10 15:42:14 +000084 /// getSetCCResultType - get the ISD::SETCC result ValueType
Owen Anderson36e3a6e2009-08-11 20:47:22 +000085 MVT::SimpleValueType getSetCCResultType(EVT VT) const;
Scott Michel502151f2008-03-10 15:42:14 +000086
Bill Wendling045f2632009-07-01 18:50:55 +000087 /// getFunctionAlignment - Return the Log2 alignment of this function.
Bill Wendling25a8ae32009-06-30 22:38:32 +000088 virtual unsigned getFunctionAlignment(const Function *F) const;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000089 private:
Bruno Cardoso Lopes4fb1f542008-07-05 19:05:21 +000090 // Subtarget Info
91 const MipsSubtarget *Subtarget;
92
Chris Lattner653c9562009-08-13 05:41:27 +000093
Dan Gohmanf17a25c2007-07-18 16:29:46 +000094 // Lower Operand helpers
Dan Gohman9178de12009-08-05 01:29:28 +000095 SDValue LowerCallResult(SDValue Chain, SDValue InFlag,
Sandeep Patel5838baa2009-09-02 08:44:58 +000096 CallingConv::ID CallConv, bool isVarArg,
Dan Gohman9178de12009-08-05 01:29:28 +000097 const SmallVectorImpl<ISD::InputArg> &Ins,
98 DebugLoc dl, SelectionDAG &DAG,
99 SmallVectorImpl<SDValue> &InVals);
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000100
101 // Lower Operand specifics
Bruno Cardoso Lopes25390a32008-08-02 19:37:33 +0000102 SDValue LowerANDOR(SDValue Op, SelectionDAG &DAG);
Bruno Cardoso Lopesdf8b4232008-07-31 18:31:28 +0000103 SDValue LowerBRCOND(SDValue Op, SelectionDAG &DAG);
Bruno Cardoso Lopesdf8b4232008-07-31 18:31:28 +0000104 SDValue LowerConstantPool(SDValue Op, SelectionDAG &DAG);
Bruno Cardoso Lopes44676cf2008-08-07 19:08:11 +0000105 SDValue LowerDYNAMIC_STACKALLOC(SDValue Op, SelectionDAG &DAG);
Bruno Cardoso Lopes643c0402009-05-27 17:23:44 +0000106 SDValue LowerFP_TO_SINT(SDValue Op, SelectionDAG &DAG);
Dan Gohman8181bd12008-07-27 21:46:04 +0000107 SDValue LowerGlobalAddress(SDValue Op, SelectionDAG &DAG);
108 SDValue LowerGlobalTLSAddress(SDValue Op, SelectionDAG &DAG);
109 SDValue LowerJumpTable(SDValue Op, SelectionDAG &DAG);
Bruno Cardoso Lopesdf8b4232008-07-31 18:31:28 +0000110 SDValue LowerSELECT(SDValue Op, SelectionDAG &DAG);
Bruno Cardoso Lopes8642dfd2008-07-28 19:11:24 +0000111 SDValue LowerSETCC(SDValue Op, SelectionDAG &DAG);
Bruno Cardoso Lopes9125fde2010-02-06 21:00:02 +0000112 SDValue LowerVASTART(SDValue Op, SelectionDAG &DAG);
Bruno Cardoso Lopesed7723d2008-06-06 00:58:26 +0000113
Dan Gohman9178de12009-08-05 01:29:28 +0000114 virtual SDValue
115 LowerFormalArguments(SDValue Chain,
Sandeep Patel5838baa2009-09-02 08:44:58 +0000116 CallingConv::ID CallConv, bool isVarArg,
Dan Gohman9178de12009-08-05 01:29:28 +0000117 const SmallVectorImpl<ISD::InputArg> &Ins,
118 DebugLoc dl, SelectionDAG &DAG,
119 SmallVectorImpl<SDValue> &InVals);
120
121 virtual SDValue
Evan Chengff116f92010-02-02 23:55:14 +0000122 LowerCall(SDValue Chain, SDValue Callee,
Sandeep Patel5838baa2009-09-02 08:44:58 +0000123 CallingConv::ID CallConv, bool isVarArg,
Evan Cheng6b6ed592010-01-27 00:07:07 +0000124 bool &isTailCall,
Dan Gohman9178de12009-08-05 01:29:28 +0000125 const SmallVectorImpl<ISD::OutputArg> &Outs,
126 const SmallVectorImpl<ISD::InputArg> &Ins,
127 DebugLoc dl, SelectionDAG &DAG,
128 SmallVectorImpl<SDValue> &InVals);
129
130 virtual SDValue
131 LowerReturn(SDValue Chain,
Sandeep Patel5838baa2009-09-02 08:44:58 +0000132 CallingConv::ID CallConv, bool isVarArg,
Dan Gohman9178de12009-08-05 01:29:28 +0000133 const SmallVectorImpl<ISD::OutputArg> &Outs,
134 DebugLoc dl, SelectionDAG &DAG);
135
Bruno Cardoso Lopesed7723d2008-06-06 00:58:26 +0000136 virtual MachineBasicBlock *EmitInstrWithCustomInserter(MachineInstr *MI,
Evan Chengd7dc9832009-09-18 21:02:19 +0000137 MachineBasicBlock *MBB,
138 DenseMap<MachineBasicBlock*, MachineBasicBlock*> *EM) const;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000139
Bruno Cardoso Lopes753b0552007-08-21 16:09:25 +0000140 // Inline asm support
141 ConstraintType getConstraintType(const std::string &Constraint) const;
142
143 std::pair<unsigned, const TargetRegisterClass*>
144 getRegForInlineAsmConstraint(const std::string &Constraint,
Owen Andersonac9de032009-08-10 22:56:29 +0000145 EVT VT) const;
Bruno Cardoso Lopes753b0552007-08-21 16:09:25 +0000146
147 std::vector<unsigned>
148 getRegClassForInlineAsmConstraint(const std::string &Constraint,
Owen Andersonac9de032009-08-10 22:56:29 +0000149 EVT VT) const;
Dan Gohman36322c72008-10-18 02:06:02 +0000150
151 virtual bool isOffsetFoldingLegal(const GlobalAddressSDNode *GA) const;
Evan Cheng6337b552009-10-27 19:56:55 +0000152
153 /// isFPImmLegal - Returns true if the target can instruction select the
154 /// specified FP immediate natively. If false, the legalizer will
155 /// materialize the FP immediate as a load from a constant pool.
Evan Chenga0e67782009-10-28 01:43:28 +0000156 virtual bool isFPImmLegal(const APFloat &Imm, EVT VT) const;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000157 };
158}
159
160#endif // MipsISELLOWERING_H