1 //===-- AVRTargetMachine.cpp - Define TargetMachine for AVR ---------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file defines the AVR specific subclass of TargetMachine.
12 //===----------------------------------------------------------------------===//
14 #include "AVRTargetMachine.h"
16 #include "llvm/CodeGen/Passes.h"
17 #include "llvm/IR/Module.h"
18 #include "llvm/IR/LegacyPassManager.h"
19 #include "llvm/Support/TargetRegistry.h"
21 #include "AVRTargetObjectFile.h"
23 #include "MCTargetDesc/AVRMCTargetDesc.h"
27 /// Processes a CPU name.
28 static StringRef getTargetCPU(StringRef CPU) {
29 if (CPU.empty() || CPU == "generic") {
36 AVRTargetMachine::AVRTargetMachine(const Target &T, const Triple &TT,
37 StringRef CPU, StringRef FS,
38 const TargetOptions &Options,
39 Reloc::Model RM, CodeModel::Model CM,
42 T, "e-p:16:8:8-i8:8:8-i16:8:8-i32:8:8-i64:8:8-f32:8:8-f64:8:8-n8", TT,
43 getTargetCPU(CPU), FS, Options, RM, CM, OL),
44 SubTarget(TT, GetTargetCPU(CPU), FS, *this) {
45 this->TLOF = make_unique<AVRTargetObjectFile>();
50 /// AVR Code Generator Pass Configuration Options.
51 class AVRPassConfig : public TargetPassConfig {
53 AVRPassConfig(AVRTargetMachine *TM, PassManagerBase &PM)
54 : TargetPassConfig(TM, PM) {}
56 AVRTargetMachine &getAVRTargetMachine() const {
57 return getTM<AVRTargetMachine>();
60 bool addInstSelector() override;
61 void addPreSched2() override;
62 void addPreRegAlloc() override;
63 void addPreEmitPass() override;
67 TargetPassConfig *AVRTargetMachine::createPassConfig(PassManagerBase &PM) {
68 return new AVRPassConfig(this, PM);
71 extern "C" void LLVMInitializeAVRTarget() {
72 // Register the target.
73 RegisterTargetMachine<AVRTargetMachine> X(TheAVRTarget);
76 const AVRSubtarget *AVRTargetMachine::getSubtargetImpl() const {
80 const AVRSubtarget *AVRTargetMachine::getSubtargetImpl(const Function &) const {
84 //===----------------------------------------------------------------------===//
85 // Pass Pipeline Configuration
86 //===----------------------------------------------------------------------===//
88 bool AVRPassConfig::addInstSelector() {
92 void AVRPassConfig::addPreRegAlloc() {
95 void AVRPassConfig::addPreSched2() { }
97 void AVRPassConfig::addPreEmitPass() {
100 } // end of namespace llvm