Position Independent Code (PIC) support [3]
[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 was developed by Bruno Cardoso Lopes and is distributed under the 
6 // University of Illinois Open Source 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       // Return 
41       Ret,
42
43       // Need to support addition with a input flag
44       Add,
45
46       // Used on PIC Code to load global addresses
47       LoadAddr
48     };
49   }
50
51   //===--------------------------------------------------------------------===//
52   // TargetLowering Implementation
53   //===--------------------------------------------------------------------===//
54   class MipsTargetLowering : public TargetLowering 
55   {
56     // FrameIndex for return slot.
57     int ReturnAddrIndex;
58
59     // const MipsSubtarget &MipsSubTarget;
60   public:
61
62     explicit MipsTargetLowering(MipsTargetMachine &TM);
63
64     /// LowerOperation - Provide custom lowering hooks for some operations.
65     virtual SDOperand LowerOperation(SDOperand Op, SelectionDAG &DAG);
66
67     /// getTargetNodeName - This method returns the name of a target specific 
68     //  DAG node.
69     virtual const char *getTargetNodeName(unsigned Opcode) const;
70
71   private:
72     // Lower Operand helpers
73     SDOperand LowerCCCArguments(SDOperand Op, SelectionDAG &DAG);
74     SDOperand LowerCCCCallTo(SDOperand Op, SelectionDAG &DAG, unsigned CC);
75     SDNode *LowerCallResult(SDOperand Chain, SDOperand InFlag, SDNode*TheCall,
76                             unsigned CallingConv, SelectionDAG &DAG);
77     SDOperand getReturnAddressFrameIndex(SelectionDAG &DAG);
78
79     // Lower Operand specifics
80     SDOperand LowerRET(SDOperand Op, SelectionDAG &DAG);
81     SDOperand LowerCALL(SDOperand Op, SelectionDAG &DAG);
82     SDOperand LowerFORMAL_ARGUMENTS(SDOperand Op, SelectionDAG &DAG);
83     SDOperand LowerGlobalAddress(SDOperand Op, SelectionDAG &DAG);
84     SDOperand LowerGlobalTLSAddress(SDOperand Op, SelectionDAG &DAG);
85
86     // Inline asm support
87     ConstraintType getConstraintType(const std::string &Constraint) const;
88
89     std::pair<unsigned, const TargetRegisterClass*> 
90               getRegForInlineAsmConstraint(const std::string &Constraint,
91               MVT::ValueType VT) const;
92
93     std::vector<unsigned>
94     getRegClassForInlineAsmConstraint(const std::string &Constraint,
95               MVT::ValueType VT) const;
96   };
97 }
98
99 #endif // MipsISELLOWERING_H