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" |
Sanjiv Gupta | 0e68771 | 2008-05-13 09:02:57 +0000 | [diff] [blame] | 19 | #include "llvm/Target/TargetAsmInfo.h" |
| 20 | |
| 21 | using namespace llvm; |
| 22 | |
Sanjiv Gupta | b1b5ffd | 2008-11-19 11:00:54 +0000 | [diff] [blame] | 23 | // PIC16TargetMachine - Traditional PIC16 Machine. |
Daniel Dunbar | e28039c | 2009-08-02 23:37:13 +0000 | [diff] [blame^] | 24 | PIC16TargetMachine::PIC16TargetMachine(const Target &T, const std::string &TT, |
Daniel Dunbar | 51b198a | 2009-07-15 20:24:03 +0000 | [diff] [blame] | 25 | const std::string &FS, bool Cooper) |
| 26 | : LLVMTargetMachine(T), |
Daniel Dunbar | e28039c | 2009-08-02 23:37:13 +0000 | [diff] [blame^] | 27 | Subtarget(TT, FS, Cooper), |
Sanjiv Gupta | b1b5ffd | 2008-11-19 11:00:54 +0000 | [diff] [blame] | 28 | 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] | 29 | InstrInfo(*this), TLInfo(*this), |
| 30 | FrameInfo(TargetFrameInfo::StackGrowsUp, 8, 0) { } |
| 31 | |
Sanjiv Gupta | b1b5ffd | 2008-11-19 11:00:54 +0000 | [diff] [blame] | 32 | // CooperTargetMachine - Uses the same PIC16TargetMachine, but makes IsCooper |
| 33 | // as true. |
Daniel Dunbar | e28039c | 2009-08-02 23:37:13 +0000 | [diff] [blame^] | 34 | CooperTargetMachine::CooperTargetMachine(const Target &T, const std::string &TT, |
Daniel Dunbar | 51b198a | 2009-07-15 20:24:03 +0000 | [diff] [blame] | 35 | const std::string &FS) |
Daniel Dunbar | e28039c | 2009-08-02 23:37:13 +0000 | [diff] [blame^] | 36 | : PIC16TargetMachine(T, TT, FS, true) {} |
Sanjiv Gupta | 0e68771 | 2008-05-13 09:02:57 +0000 | [diff] [blame] | 37 | |
Sanjiv Gupta | b1b5ffd | 2008-11-19 11:00:54 +0000 | [diff] [blame] | 38 | |
| 39 | const TargetAsmInfo *PIC16TargetMachine::createTargetAsmInfo() const { |
Chris Lattner | 3878bff | 2009-08-02 04:41:14 +0000 | [diff] [blame] | 40 | return new PIC16TargetAsmInfo(); |
Sanjiv Gupta | 0e68771 | 2008-05-13 09:02:57 +0000 | [diff] [blame] | 41 | } |
| 42 | |
Bill Wendling | be8cc2a | 2009-04-29 00:15:41 +0000 | [diff] [blame] | 43 | bool PIC16TargetMachine::addInstSelector(PassManagerBase &PM, |
Bill Wendling | 98a366d | 2009-04-29 23:29:43 +0000 | [diff] [blame] | 44 | CodeGenOpt::Level OptLevel) { |
Sanjiv Gupta | 0e68771 | 2008-05-13 09:02:57 +0000 | [diff] [blame] | 45 | // Install an instruction selector. |
| 46 | PM.add(createPIC16ISelDag(*this)); |
| 47 | return false; |
| 48 | } |
| 49 | |
Sanjiv Gupta | d8d27f4 | 2009-05-06 08:02:01 +0000 | [diff] [blame] | 50 | bool PIC16TargetMachine::addPostRegAlloc(PassManagerBase &PM, |
| 51 | CodeGenOpt::Level OptLevel) { |
| 52 | PM.add(createPIC16MemSelOptimizerPass()); |
| 53 | return true; // -print-machineinstr should print after this. |
| 54 | } |
| 55 | |
Sanjiv Gupta | b1b5ffd | 2008-11-19 11:00:54 +0000 | [diff] [blame] | 56 | |