Add new helpers for registering targets.
[oota-llvm.git] / lib / Target / PIC16 / PIC16TargetMachine.cpp
1 //===-- PIC16TargetMachine.cpp - Define TargetMachine for PIC16 -----------===//
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 // Top-level implementation for the PIC16 target.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #include "PIC16.h"
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
22 using namespace llvm;
23
24 // PIC16TargetMachine - Traditional PIC16 Machine.
25 PIC16TargetMachine::PIC16TargetMachine(const Target &T, const Module &M, 
26                                        const std::string &FS, bool Cooper)
27 : LLVMTargetMachine(T),
28   Subtarget(M, FS, Cooper),
29   DataLayout("e-p:16:8:8-i8:8:8-i16:8:8-i32:8:8"), 
30   InstrInfo(*this), TLInfo(*this),
31   FrameInfo(TargetFrameInfo::StackGrowsUp, 8, 0) { }
32
33 // CooperTargetMachine - Uses the same PIC16TargetMachine, but makes IsCooper
34 // as true.
35 CooperTargetMachine::CooperTargetMachine(const Target &T, const Module &M, 
36                                          const std::string &FS)
37   : PIC16TargetMachine(T, M, FS, true) {}
38
39
40 const TargetAsmInfo *PIC16TargetMachine::createTargetAsmInfo() const {
41   return new PIC16TargetAsmInfo(*this);
42 }
43
44 bool PIC16TargetMachine::addInstSelector(PassManagerBase &PM,
45                                          CodeGenOpt::Level OptLevel) {
46   // Install an instruction selector.
47   PM.add(createPIC16ISelDag(*this));
48   return false;
49 }
50
51 bool PIC16TargetMachine::addPostRegAlloc(PassManagerBase &PM, 
52                                          CodeGenOpt::Level OptLevel) {
53   PM.add(createPIC16MemSelOptimizerPass());
54   return true;  // -print-machineinstr should print after this.
55 }
56
57