forked from Hoernchen/Epiphany
-
Notifications
You must be signed in to change notification settings - Fork 2
/
EpiphanyISelDAGToDAG.h
86 lines (66 loc) · 2.85 KB
/
EpiphanyISelDAGToDAG.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
//===---- EpiphanyISelDAGToDAG.h - A Dag to Dag Inst Selector for E16 -----===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file defines an instruction selector for the Epiphany target.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_LIB_TARGET_EPIPHANY_EPIPHANYISELDAGTODAG_H
#define LLVM_LIB_TARGET_EPIPHANY_EPIPHANYISELDAGTODAG_H
#include "EpiphanyConfig.h"
#include "MCTargetDesc/EpiphanyAddressingModes.h"
#include "Epiphany.h"
#include "EpiphanySubtarget.h"
#include "EpiphanyTargetMachine.h"
#include "llvm/CodeGen/SelectionDAGISel.h"
#include "llvm/IR/Type.h"
#include "llvm/Support/Debug.h"
//===----------------------------------------------------------------------===//
// Instruction Selector Implementation
//===----------------------------------------------------------------------===//
//===----------------------------------------------------------------------===//
// EpiphanyDAGToDAGISel - Epiphany specific code to select E16 CPU
// instructions for SelectionDAG operations.
//===----------------------------------------------------------------------===//
namespace llvm {
class EpiphanyDAGToDAGISel : public SelectionDAGISel {
public:
explicit EpiphanyDAGToDAGISel(EpiphanyTargetMachine &TM, CodeGenOpt::Level OL)
: SelectionDAGISel(TM, OL), Subtarget(nullptr) {}
// Pass Name
StringRef getPassName() const override {
return "Epiphany DAG->DAG Pattern Instruction Selection";
}
bool runOnMachineFunction(MachineFunction &MF) override;
protected:
/// Keep a pointer to the Subtarget around so that we can make the right
/// decision when generating code for different targets.
const EpiphanySubtarget *Subtarget;
private:
// Include the pieces autogenerated from the target description.
#include "EpiphanyGenDAGISel.inc"
/// getTargetMachine - Return a reference to the TargetMachine, casted
/// to the target-specific type.
const EpiphanyTargetMachine &getTargetMachine() {
return static_cast<const EpiphanyTargetMachine &>(TM);
}
void Select(SDNode *N) override;
bool trySelect(SDNode *Node);
void processFunctionAfterISel(MachineFunction &MF);
// Complex Pattern.
template<bool is16bit> bool SelectAddr(SDNode *Parent, SDValue Addr, SDValue &Base, SDValue &Offset) {
return SelectAddr(Parent, Addr, Base, Offset, is16bit);
}
bool SelectAddr(SDNode *Parent, SDValue N, SDValue &Base, SDValue &Offset, bool is16bit);
// getImm - Return a target constant with the specified value.
inline SDValue getImm(const SDNode *Node, unsigned Imm) {
return CurDAG->getTargetConstant(Imm, SDLoc(Node), Node->getValueType(0));
}
};
}
#endif