Several changes to Mips backend, experimental fp support being the most
[oota-llvm.git] / lib / Target / Mips / MipsISelLowering.h
1 //===-- MipsISelLowering.h - Mips 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 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
23 namespace llvm {
24   namespace MipsISD {
25     enum NodeType {
26       // Start the numbering from where ISD NodeType finishes.
27       FIRST_NUMBER = ISD::BUILTIN_OP_END+Mips::INSTRUCTION_LIST_END,
28
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
40       // Select CC Pseudo Instruction
41       SelectCC,
42
43       // Float Point Branch Conditional
44       FPBrcond,
45
46       // Float Point Compare
47       FPCmp,
48
49       // Return 
50       Ret
51     };
52   }
53
54   //===--------------------------------------------------------------------===//
55   // TargetLowering Implementation
56   //===--------------------------------------------------------------------===//
57   class MipsTargetLowering : public TargetLowering 
58   {
59     // FrameIndex for return slot.
60     int ReturnAddrIndex;
61
62     // const MipsSubtarget &MipsSubTarget;
63   public:
64
65     explicit MipsTargetLowering(MipsTargetMachine &TM);
66
67     /// LowerOperation - Provide custom lowering hooks for some operations.
68     virtual SDOperand LowerOperation(SDOperand Op, SelectionDAG &DAG);
69
70     /// getTargetNodeName - This method returns the name of a target specific 
71     //  DAG node.
72     virtual const char *getTargetNodeName(unsigned Opcode) const;
73
74     /// getSetCCResultType - get the ISD::SETCC result ValueType
75     MVT getSetCCResultType(const SDOperand &) const;
76
77   private:
78     // Subtarget Info
79     const MipsSubtarget *Subtarget;
80
81     // Lower Operand helpers
82     SDOperand LowerCCCArguments(SDOperand Op, SelectionDAG &DAG);
83     SDOperand LowerCCCCallTo(SDOperand Op, SelectionDAG &DAG, unsigned CC);
84     SDNode *LowerCallResult(SDOperand Chain, SDOperand InFlag, SDNode*TheCall,
85                             unsigned CallingConv, SelectionDAG &DAG);
86     SDOperand getReturnAddressFrameIndex(SelectionDAG &DAG);
87
88     // Lower Operand specifics
89     SDOperand LowerRET(SDOperand Op, SelectionDAG &DAG);
90     SDOperand LowerCALL(SDOperand Op, SelectionDAG &DAG);
91     SDOperand LowerFORMAL_ARGUMENTS(SDOperand Op, SelectionDAG &DAG);
92     SDOperand LowerGlobalAddress(SDOperand Op, SelectionDAG &DAG);
93     SDOperand LowerGlobalTLSAddress(SDOperand Op, SelectionDAG &DAG);
94     SDOperand LowerJumpTable(SDOperand Op, SelectionDAG &DAG);
95     SDOperand LowerSELECT_CC(SDOperand Op, SelectionDAG &DAG);
96
97     virtual MachineBasicBlock *EmitInstrWithCustomInserter(MachineInstr *MI,
98                                                         MachineBasicBlock *MBB);
99
100     // Inline asm support
101     ConstraintType getConstraintType(const std::string &Constraint) const;
102
103     std::pair<unsigned, const TargetRegisterClass*> 
104               getRegForInlineAsmConstraint(const std::string &Constraint,
105               MVT VT) const;
106
107     std::vector<unsigned>
108     getRegClassForInlineAsmConstraint(const std::string &Constraint,
109               MVT VT) const;
110   };
111 }
112
113 #endif // MipsISELLOWERING_H