blob: 85a84228718861635ea9d02c254e7cbdb45aa541 [file] [log] [blame]
Bruno Cardoso Lopes972f5892007-06-06 07:42:06 +00001//===-- MipsISelLowering.h - Mips DAG Lowering Interface --------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner4ee451d2007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Bruno Cardoso Lopes972f5892007-06-06 07:42:06 +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.
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
Bruno Cardoso Lopes07cec752008-06-06 00:58:26 +000040 // Select CC Pseudo Instruction
41 SelectCC,
42
Bruno Cardoso Lopes225ca9c2008-07-05 19:05:21 +000043 // Float Point Branch Conditional
44 FPBrcond,
45
46 // Float Point Compare
47 FPCmp,
48
Bruno Cardoso Lopes972f5892007-06-06 07:42:06 +000049 // Return
Bruno Cardoso Lopesc7db5612007-11-05 03:02:32 +000050 Ret
Bruno Cardoso Lopes972f5892007-06-06 07:42:06 +000051 };
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
Dan Gohman61e729e2007-08-02 21:21:54 +000065 explicit MipsTargetLowering(MipsTargetMachine &TM);
Bruno Cardoso Lopes972f5892007-06-06 07:42:06 +000066
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
Scott Michel5b8f82e2008-03-10 15:42:14 +000074 /// getSetCCResultType - get the ISD::SETCC result ValueType
Duncan Sands83ec4b62008-06-06 12:08:01 +000075 MVT getSetCCResultType(const SDOperand &) const;
Scott Michel5b8f82e2008-03-10 15:42:14 +000076
Bruno Cardoso Lopes972f5892007-06-06 07:42:06 +000077 private:
Bruno Cardoso Lopes225ca9c2008-07-05 19:05:21 +000078 // Subtarget Info
79 const MipsSubtarget *Subtarget;
80
Bruno Cardoso Lopes972f5892007-06-06 07:42:06 +000081 // 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);
Lauro Ramos Venancio75ce0102007-07-11 17:19:51 +000093 SDOperand LowerGlobalTLSAddress(SDOperand Op, SelectionDAG &DAG);
Bruno Cardoso Lopes753a9872007-11-12 19:49:57 +000094 SDOperand LowerJumpTable(SDOperand Op, SelectionDAG &DAG);
Bruno Cardoso Lopes97c25372008-07-09 04:15:08 +000095 SDOperand LowerConstantPool(SDOperand Op, SelectionDAG &DAG);
Bruno Cardoso Lopes07cec752008-06-06 00:58:26 +000096 SDOperand LowerSELECT_CC(SDOperand Op, SelectionDAG &DAG);
97
98 virtual MachineBasicBlock *EmitInstrWithCustomInserter(MachineInstr *MI,
99 MachineBasicBlock *MBB);
Bruno Cardoso Lopes972f5892007-06-06 07:42:06 +0000100
Bruno Cardoso Lopes84f47c52007-08-21 16:09:25 +0000101 // Inline asm support
102 ConstraintType getConstraintType(const std::string &Constraint) const;
103
104 std::pair<unsigned, const TargetRegisterClass*>
105 getRegForInlineAsmConstraint(const std::string &Constraint,
Duncan Sands83ec4b62008-06-06 12:08:01 +0000106 MVT VT) const;
Bruno Cardoso Lopes84f47c52007-08-21 16:09:25 +0000107
108 std::vector<unsigned>
109 getRegClassForInlineAsmConstraint(const std::string &Constraint,
Duncan Sands83ec4b62008-06-06 12:08:01 +0000110 MVT VT) const;
Bruno Cardoso Lopes972f5892007-06-06 07:42:06 +0000111 };
112}
113
114#endif // MipsISELLOWERING_H