Sanjiv Gupta | 0e68771 | 2008-05-13 09:02:57 +0000 | [diff] [blame] | 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" |
Sanjiv Gupta | 0e68771 | 2008-05-13 09:02:57 +0000 | [diff] [blame] | 15 | #include "PIC16TargetAsmInfo.h" |
Sanjiv Gupta | 2010b3e | 2008-05-14 11:31:39 +0000 | [diff] [blame] | 16 | #include "PIC16TargetMachine.h" |
Sanjiv Gupta | 0e68771 | 2008-05-13 09:02:57 +0000 | [diff] [blame] | 17 | #include "llvm/Module.h" |
| 18 | #include "llvm/PassManager.h" |
Sanjiv Gupta | 0e68771 | 2008-05-13 09:02:57 +0000 | [diff] [blame] | 19 | #include "llvm/Target/TargetAsmInfo.h" |
Sanjiv Gupta | 2010b3e | 2008-05-14 11:31:39 +0000 | [diff] [blame] | 20 | #include "llvm/Target/TargetMachineRegistry.h" |
Sanjiv Gupta | 0e68771 | 2008-05-13 09:02:57 +0000 | [diff] [blame] | 21 | |
| 22 | using namespace llvm; |
| 23 | |
Oscar Fuentes | 92adc19 | 2008-11-15 21:36:30 +0000 | [diff] [blame^] | 24 | /// PIC16TargetMachineModule - Note that this is used on hosts that |
| 25 | /// cannot link in a library unless there are references into the |
| 26 | /// library. In particular, it seems that it is not possible to get |
| 27 | /// things to work on Win32 without this. Though it is unused, do not |
| 28 | /// remove it. |
| 29 | extern "C" int PIC16TargetMachineModule; |
| 30 | int PIC16TargetMachineModule = 0; |
| 31 | |
Sanjiv Gupta | 0e68771 | 2008-05-13 09:02:57 +0000 | [diff] [blame] | 32 | namespace { |
| 33 | // Register the targets |
Chris Lattner | 0d5d05b | 2008-10-16 06:16:50 +0000 | [diff] [blame] | 34 | RegisterTarget<PIC16TargetMachine> X("pic16", "PIC16 14-bit [experimental]"); |
Sanjiv Gupta | 0e68771 | 2008-05-13 09:02:57 +0000 | [diff] [blame] | 35 | } |
| 36 | |
| 37 | PIC16TargetMachine:: |
| 38 | PIC16TargetMachine(const Module &M, const std::string &FS) : |
| 39 | Subtarget(*this, M, FS), DataLayout("e-p:16:8:8-i8:8:8-i16:8:8-i32:8:8"), |
| 40 | InstrInfo(*this), TLInfo(*this), |
| 41 | FrameInfo(TargetFrameInfo::StackGrowsUp, 8, 0) { } |
| 42 | |
| 43 | |
Sanjiv Gupta | 2010b3e | 2008-05-14 11:31:39 +0000 | [diff] [blame] | 44 | const TargetAsmInfo *PIC16TargetMachine::createTargetAsmInfo() const |
Sanjiv Gupta | 0e68771 | 2008-05-13 09:02:57 +0000 | [diff] [blame] | 45 | { |
| 46 | return new PIC16TargetAsmInfo(*this); |
| 47 | } |
| 48 | |
| 49 | //===----------------------------------------------------------------------===// |
| 50 | // Pass Pipeline Configuration |
| 51 | //===----------------------------------------------------------------------===// |
| 52 | |
Sanjiv Gupta | 2010b3e | 2008-05-14 11:31:39 +0000 | [diff] [blame] | 53 | bool PIC16TargetMachine::addInstSelector(PassManagerBase &PM, bool Fast) |
Sanjiv Gupta | 0e68771 | 2008-05-13 09:02:57 +0000 | [diff] [blame] | 54 | { |
| 55 | // Install an instruction selector. |
| 56 | PM.add(createPIC16ISelDag(*this)); |
| 57 | return false; |
| 58 | } |
| 59 | |
| 60 | bool PIC16TargetMachine:: |
| 61 | addPrologEpilogInserter(PassManagerBase &PM, bool Fast) |
| 62 | { |
| 63 | return false; |
| 64 | } |
| 65 | |
Sanjiv Gupta | 2010b3e | 2008-05-14 11:31:39 +0000 | [diff] [blame] | 66 | bool PIC16TargetMachine::addPreEmitPass(PassManagerBase &PM, bool Fast) |
Sanjiv Gupta | 0e68771 | 2008-05-13 09:02:57 +0000 | [diff] [blame] | 67 | { |
| 68 | return true; |
| 69 | } |
| 70 | |
| 71 | bool PIC16TargetMachine:: |
Owen Anderson | cb37188 | 2008-08-21 00:14:44 +0000 | [diff] [blame] | 72 | addAssemblyEmitter(PassManagerBase &PM, bool Fast, raw_ostream &Out) |
Sanjiv Gupta | 0e68771 | 2008-05-13 09:02:57 +0000 | [diff] [blame] | 73 | { |
| 74 | // Output assembly language. |
| 75 | PM.add(createPIC16CodePrinterPass(Out, *this)); |
| 76 | return false; |
| 77 | } |
| 78 | |