blob: cf0f9c58aa9ceece22bbe83574ec4ffc5b965df2 [file] [log] [blame]
Akira Hatanaka1d905662013-03-14 18:28:19 +00001//===---- MipsISelDAGToDAG.h - A Dag to Dag Inst Selector for Mips --------===//
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 an instruction selector for the MIPS target.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef MIPSISELDAGTODAG_H
15#define MIPSISELDAGTODAG_H
16
17#include "Mips.h"
18#include "MipsSubtarget.h"
19#include "MipsTargetMachine.h"
20#include "llvm/CodeGen/SelectionDAGISel.h"
21
22//===----------------------------------------------------------------------===//
23// Instruction Selector Implementation
24//===----------------------------------------------------------------------===//
25
26//===----------------------------------------------------------------------===//
27// MipsDAGToDAGISel - MIPS specific code to select MIPS machine
28// instructions for SelectionDAG operations.
29//===----------------------------------------------------------------------===//
30namespace llvm {
31
32class MipsDAGToDAGISel : public SelectionDAGISel {
33public:
34 explicit MipsDAGToDAGISel(MipsTargetMachine &TM)
35 : SelectionDAGISel(TM), Subtarget(TM.getSubtarget<MipsSubtarget>()) {}
36
37 // Pass Name
38 virtual const char *getPassName() const {
39 return "MIPS DAG->DAG Pattern Instruction Selection";
40 }
41
42 virtual bool runOnMachineFunction(MachineFunction &MF);
43
44protected:
45 SDNode *getGlobalBaseReg();
46
47 /// Keep a pointer to the MipsSubtarget around so that we can make the right
48 /// decision when generating code for different targets.
49 const MipsSubtarget &Subtarget;
50
51private:
52 // Include the pieces autogenerated from the target description.
53 #include "MipsGenDAGISel.inc"
54
55 // Complex Pattern.
56 /// (reg + imm).
57 virtual bool selectAddrRegImm(SDValue Addr, SDValue &Base,
58 SDValue &Offset) const;
59
60 /// Fall back on this function if all else fails.
61 virtual bool selectAddrDefault(SDValue Addr, SDValue &Base,
62 SDValue &Offset) const;
63
64 /// Match integer address pattern.
65 virtual bool selectIntAddr(SDValue Addr, SDValue &Base,
66 SDValue &Offset) const;
67
Akira Hatanakaf2835122013-03-14 18:33:23 +000068 virtual bool selectAddr16(SDNode *Parent, SDValue N, SDValue &Base,
Akira Hatanaka1d905662013-03-14 18:28:19 +000069 SDValue &Offset, SDValue &Alias);
70
71 virtual SDNode *Select(SDNode *N);
72
Akira Hatanakaf2835122013-03-14 18:33:23 +000073 virtual std::pair<bool, SDNode*> selectNode(SDNode *Node) = 0;
Akira Hatanaka1d905662013-03-14 18:28:19 +000074
75 // getImm - Return a target constant with the specified value.
76 inline SDValue getImm(const SDNode *Node, uint64_t Imm) {
77 return CurDAG->getTargetConstant(Imm, Node->getValueType(0));
78 }
79
Akira Hatanakaf2835122013-03-14 18:33:23 +000080 virtual void processFunctionAfterISel(MachineFunction &MF) = 0;
Akira Hatanaka1d905662013-03-14 18:28:19 +000081
82 virtual bool SelectInlineAsmMemoryOperand(const SDValue &Op,
83 char ConstraintCode,
84 std::vector<SDValue> &OutOps);
85};
86
87/// createMipsISelDag - This pass converts a legalized DAG into a
88/// MIPS-specific DAG, ready for instruction scheduling.
89FunctionPass *createMipsISelDag(MipsTargetMachine &TM);
90
91}
92
93#endif