LLVM API Documentation
00001 //===-- PIC16TargetMachine.cpp - Define TargetMachine for PIC16 -----------===// 00002 // 00003 // The LLVM Compiler Infrastructure 00004 // 00005 // This file is distributed under the University of Illinois Open Source 00006 // License. See LICENSE.TXT for details. 00007 // 00008 //===----------------------------------------------------------------------===// 00009 // 00010 // Top-level implementation for the PIC16 target. 00011 // 00012 //===----------------------------------------------------------------------===// 00013 00014 #include "PIC16.h" 00015 #include "PIC16TargetAsmInfo.h" 00016 #include "PIC16TargetMachine.h" 00017 #include "llvm/PassManager.h" 00018 #include "llvm/CodeGen/Passes.h" 00019 #include "llvm/Target/TargetRegistry.h" 00020 00021 using namespace llvm; 00022 00023 extern "C" void LLVMInitializePIC16Target() { 00024 // Register the target. Curretnly the codegen works for 00025 // enhanced pic16 mid-range. 00026 RegisterTargetMachine<PIC16TargetMachine> X(ThePIC16Target); 00027 RegisterAsmInfo<PIC16TargetAsmInfo> A(ThePIC16Target); 00028 } 00029 00030 00031 // PIC16TargetMachine - Enhanced PIC16 mid-range Machine. May also represent 00032 // a Traditional Machine if 'Trad' is true. 00033 PIC16TargetMachine::PIC16TargetMachine(const Target &T, const std::string &TT, 00034 const std::string &FS, bool Trad) 00035 : LLVMTargetMachine(T, TT), 00036 Subtarget(TT, FS, Trad), 00037 DataLayout("e-p:16:8:8-i8:8:8-i16:8:8-i32:8:8"), 00038 InstrInfo(*this), TLInfo(*this), 00039 FrameInfo(TargetFrameInfo::StackGrowsUp, 8, 0) { } 00040 00041 00042 bool PIC16TargetMachine::addInstSelector(PassManagerBase &PM, 00043 CodeGenOpt::Level OptLevel) { 00044 // Install an instruction selector. 00045 PM.add(createPIC16ISelDag(*this)); 00046 return false; 00047 } 00048 00049 bool PIC16TargetMachine::addPreEmitPass(PassManagerBase &PM, 00050 CodeGenOpt::Level OptLevel) { 00051 PM.add(createPIC16MemSelOptimizerPass()); 00052 return true; // -print-machineinstr should print after this. 00053 } 00054 00055