Introduce new headers whose inclusion forces linking and
[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 #include "llvm/Target/TargetMachineRegistry.h"
22
23 using namespace llvm;
24
25 /// PIC16TargetMachineModule - Note that this is used on hosts that
26 /// cannot link in a library unless there are references into the
27 /// library.  In particular, it seems that it is not possible to get
28 /// things to work on Win32 without this.  Though it is unused, do not
29 /// remove it.
30 extern "C" int PIC16TargetMachineModule;
31 int PIC16TargetMachineModule = 0;
32
33
34 // Register the targets
35 static RegisterTarget<PIC16TargetMachine> 
36 X("pic16", "PIC16 14-bit [experimental].");
37 static RegisterTarget<CooperTargetMachine> 
38 Y("cooper", "PIC16 Cooper [experimental].");
39
40 // Force static initialization when called from llvm/InitializeAllTargets.h
41 namespace llvm {
42   void InitializePIC16Target() { }
43 }
44
45 // PIC16TargetMachine - Traditional PIC16 Machine.
46 PIC16TargetMachine::PIC16TargetMachine(const Module &M, const std::string &FS,
47                                        bool Cooper)
48 : Subtarget(M, FS, Cooper),
49   DataLayout("e-p:16:8:8-i8:8:8-i16:8:8-i32:8:8"), 
50   InstrInfo(*this), TLInfo(*this),
51   FrameInfo(TargetFrameInfo::StackGrowsUp, 8, 0) { }
52
53 // CooperTargetMachine - Uses the same PIC16TargetMachine, but makes IsCooper
54 // as true.
55 CooperTargetMachine::CooperTargetMachine(const Module &M, const std::string &FS)
56   : PIC16TargetMachine(M, FS, true) {}
57
58
59 const TargetAsmInfo *PIC16TargetMachine::createTargetAsmInfo() const {
60   return new PIC16TargetAsmInfo(*this);
61 }
62
63 bool PIC16TargetMachine::addInstSelector(PassManagerBase &PM,
64                                          CodeGenOpt::Level OptLevel) {
65   // Install an instruction selector.
66   PM.add(createPIC16ISelDag(*this));
67   return false;
68 }
69
70 bool PIC16TargetMachine::
71 addAssemblyEmitter(PassManagerBase &PM, CodeGenOpt::Level OptLevel,
72                    bool Verbose, raw_ostream &Out) {
73   // Output assembly language.
74   PM.add(createPIC16CodePrinterPass(Out, *this, OptLevel, Verbose));
75   return false;
76 }
77
78 bool PIC16TargetMachine::addPostRegAlloc(PassManagerBase &PM, 
79                                          CodeGenOpt::Level OptLevel) {
80   PM.add(createPIC16MemSelOptimizerPass());
81   return true;  // -print-machineinstr should print after this.
82 }
83
84