1 //===-- PIC16TargetMachine.cpp - Define TargetMachine for PIC16 -----------===//
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 // Top-level implementation for the PIC16 target.
12 //===----------------------------------------------------------------------===//
15 #include "PIC16TargetAsmInfo.h"
16 #include "PIC16TargetMachine.h"
17 #include "llvm/Module.h"
18 #include "llvm/PassManager.h"
19 #include "llvm/CodeGen/Passes.h"
20 #include "llvm/Target/TargetAsmInfo.h"
21 #include "llvm/Target/TargetMachineRegistry.h"
25 // Register the targets
26 extern Target ThePIC16Target;
27 static RegisterTarget<PIC16TargetMachine>
28 X(ThePIC16Target, "pic16", "PIC16 14-bit [experimental].");
30 extern Target TheCooperTarget;
31 static RegisterTarget<CooperTargetMachine>
32 Y(TheCooperTarget, "cooper", "PIC16 Cooper [experimental].");
34 // Force static initialization.
35 extern "C" void LLVMInitializePIC16Target() {
36 TargetRegistry::RegisterAsmPrinter(ThePIC16Target,
37 &createPIC16CodePrinterPass);
38 TargetRegistry::RegisterAsmPrinter(TheCooperTarget,
39 &createPIC16CodePrinterPass);
42 // PIC16TargetMachine - Traditional PIC16 Machine.
43 PIC16TargetMachine::PIC16TargetMachine(const Target &T, const Module &M,
44 const std::string &FS, bool Cooper)
45 : LLVMTargetMachine(T),
46 Subtarget(M, FS, Cooper),
47 DataLayout("e-p:16:8:8-i8:8:8-i16:8:8-i32:8:8"),
48 InstrInfo(*this), TLInfo(*this),
49 FrameInfo(TargetFrameInfo::StackGrowsUp, 8, 0) { }
51 // CooperTargetMachine - Uses the same PIC16TargetMachine, but makes IsCooper
53 CooperTargetMachine::CooperTargetMachine(const Target &T, const Module &M,
54 const std::string &FS)
55 : PIC16TargetMachine(T, M, FS, true) {}
58 const TargetAsmInfo *PIC16TargetMachine::createTargetAsmInfo() const {
59 return new PIC16TargetAsmInfo(*this);
62 bool PIC16TargetMachine::addInstSelector(PassManagerBase &PM,
63 CodeGenOpt::Level OptLevel) {
64 // Install an instruction selector.
65 PM.add(createPIC16ISelDag(*this));
69 bool PIC16TargetMachine::addPostRegAlloc(PassManagerBase &PM,
70 CodeGenOpt::Level OptLevel) {
71 PM.add(createPIC16MemSelOptimizerPass());
72 return true; // -print-machineinstr should print after this.