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/PassManager.h" |
Sanjiv Gupta | b1b5ffd | 2008-11-19 11:00:54 +0000 | [diff] [blame] | 18 | #include "llvm/CodeGen/Passes.h" |
Daniel Dunbar | a8c58d5 | 2009-08-13 17:08:54 +0000 | [diff] [blame] | 19 | #include "llvm/Target/TargetRegistry.h" |
Sanjiv Gupta | 0e68771 | 2008-05-13 09:02:57 +0000 | [diff] [blame] | 20 | |
| 21 | using namespace llvm; |
| 22 | |
Daniel Dunbar | a8c58d5 | 2009-08-13 17:08:54 +0000 | [diff] [blame] | 23 | extern "C" void LLVMInitializePIC16Target() { |
| 24 | // Register the target. Curretnly the codegen works for |
| 25 | // enhanced pic16 mid-range. |
| 26 | RegisterTargetMachine<PIC16TargetMachine> X(ThePIC16Target); |
| 27 | RegisterAsmInfo<PIC16TargetAsmInfo> A(ThePIC16Target); |
| 28 | } |
| 29 | |
| 30 | |
| 31 | // PIC16TargetMachine - Enhanced PIC16 mid-range Machine. May also represent |
| 32 | // a Traditional Machine if 'Trad' is true. |
Daniel Dunbar | e28039c | 2009-08-02 23:37:13 +0000 | [diff] [blame] | 33 | PIC16TargetMachine::PIC16TargetMachine(const Target &T, const std::string &TT, |
Daniel Dunbar | a8c58d5 | 2009-08-13 17:08:54 +0000 | [diff] [blame] | 34 | const std::string &FS, bool Trad) |
Chris Lattner | 0a31d2f | 2009-08-11 20:42:37 +0000 | [diff] [blame] | 35 | : LLVMTargetMachine(T, TT), |
Daniel Dunbar | a8c58d5 | 2009-08-13 17:08:54 +0000 | [diff] [blame] | 36 | Subtarget(TT, FS, Trad), |
Sanjiv Gupta | b1b5ffd | 2008-11-19 11:00:54 +0000 | [diff] [blame] | 37 | DataLayout("e-p:16:8:8-i8:8:8-i16:8:8-i32:8:8"), |
Sanjiv Gupta | 0e68771 | 2008-05-13 09:02:57 +0000 | [diff] [blame] | 38 | InstrInfo(*this), TLInfo(*this), |
| 39 | FrameInfo(TargetFrameInfo::StackGrowsUp, 8, 0) { } |
| 40 | |
Sanjiv Gupta | b1b5ffd | 2008-11-19 11:00:54 +0000 | [diff] [blame] | 41 | |
Bill Wendling | be8cc2a | 2009-04-29 00:15:41 +0000 | [diff] [blame] | 42 | bool PIC16TargetMachine::addInstSelector(PassManagerBase &PM, |
Bill Wendling | 98a366d | 2009-04-29 23:29:43 +0000 | [diff] [blame] | 43 | CodeGenOpt::Level OptLevel) { |
Sanjiv Gupta | 0e68771 | 2008-05-13 09:02:57 +0000 | [diff] [blame] | 44 | // Install an instruction selector. |
| 45 | PM.add(createPIC16ISelDag(*this)); |
| 46 | return false; |
| 47 | } |
| 48 | |
Sanjiv Gupta | 85019e1 | 2009-08-07 05:44:27 +0000 | [diff] [blame] | 49 | bool PIC16TargetMachine::addPreEmitPass(PassManagerBase &PM, |
Sanjiv Gupta | d8d27f4 | 2009-05-06 08:02:01 +0000 | [diff] [blame] | 50 | CodeGenOpt::Level OptLevel) { |
| 51 | PM.add(createPIC16MemSelOptimizerPass()); |
| 52 | return true; // -print-machineinstr should print after this. |
| 53 | } |
| 54 | |
Sanjiv Gupta | b1b5ffd | 2008-11-19 11:00:54 +0000 | [diff] [blame] | 55 | |