-
Notifications
You must be signed in to change notification settings - Fork 8
/
EpiphanyTargetMachine.cpp
96 lines (81 loc) · 2.99 KB
/
EpiphanyTargetMachine.cpp
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
87
88
89
90
91
92
93
94
95
96
//===-- EpiphanyTargetMachine.cpp - Define TargetMachine for Epiphany -------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file contains the implementation of the EpiphanyTargetMachine
// methods. Principally just setting up the passes needed to generate correct
// code on this architecture.
//
//===----------------------------------------------------------------------===//
#include "Epiphany.h"
#include "EpiphanyTargetMachine.h"
#include "MCTargetDesc/EpiphanyMCTargetDesc.h"
#include "llvm/PassManager.h"
#include "llvm/CodeGen/Passes.h"
#include "llvm/Support/TargetRegistry.h"
#include "llvm/Support/CommandLine.h"
using namespace llvm;
static cl::opt<bool>
EnableLSD("double-ls", cl::Hidden,
cl::desc("Enable double loads and stores"),
cl::init(false));
extern "C" void LLVMInitializeEpiphanyTarget() {
RegisterTargetMachine<EpiphanyTargetMachine> X(TheEpiphanyTarget);
}
EpiphanyTargetMachine::EpiphanyTargetMachine(const Target &T, StringRef TT,
StringRef CPU, StringRef FS,
const TargetOptions &Options,
Reloc::Model RM, CodeModel::Model CM,
CodeGenOpt::Level OL)
: LLVMTargetMachine(T, TT, CPU, FS, Options, RM, CM, OL),
Subtarget(TT, CPU, FS),
InstrInfo(Subtarget),
DL("e-p:32:32-i8:8:8-i16:16:16-i32:32:32-f32:32:32-i64:64:64-f64:64:64-s64:64:64-S64:64:64-a0:32:32"),
TLInfo(*this),
TSInfo(*this),
FrameLowering(Subtarget) {
initAsmInfo();
}
namespace {
/// Epiphany Code Generator Pass Configuration Options.
class EpiphanyPassConfig : public TargetPassConfig {
public:
EpiphanyPassConfig(EpiphanyTargetMachine *TM, PassManagerBase &PM)
: TargetPassConfig(TM, PM) {}
EpiphanyTargetMachine &getEpiphanyTargetMachine() const {
return getTM<EpiphanyTargetMachine>();
}
const EpiphanySubtarget &getEpiphanySubtarget() const {
return *getEpiphanyTargetMachine().getSubtargetImpl();
}
virtual bool addInstSelector();
virtual bool addPreEmitPass();
virtual bool addPreRegAlloc();
virtual bool addPostRegAlloc();
};
} // namespace
TargetPassConfig *EpiphanyTargetMachine::createPassConfig(PassManagerBase &PM) {
return new EpiphanyPassConfig(this, PM);
}
bool EpiphanyPassConfig::addPreEmitPass() {
addPass(&UnpackMachineBundlesID);
return true;
}
bool EpiphanyPassConfig::addInstSelector() {
addPass(createEpiphanyISelDAG(getEpiphanyTargetMachine(), getOptLevel()));
return false;
}
bool EpiphanyPassConfig::addPreRegAlloc() {
if (EnableLSD)
addPass(createEpiphanyLSOptPass());
return true;
}
bool EpiphanyPassConfig::addPostRegAlloc() {
addPass(createEpiphanyCondMovPass(getEpiphanyTargetMachine()));
return true;
}