blob: 2cdaff344fefce759ce575f34ff9ae4d41528126 [file] [log] [blame]
Sanjiv Gupta0e687712008-05-13 09:02:57 +00001//===-- 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 Gupta0e687712008-05-13 09:02:57 +000015#include "PIC16TargetAsmInfo.h"
Sanjiv Gupta2010b3e2008-05-14 11:31:39 +000016#include "PIC16TargetMachine.h"
Sanjiv Gupta0e687712008-05-13 09:02:57 +000017#include "llvm/PassManager.h"
Sanjiv Guptab1b5ffd2008-11-19 11:00:54 +000018#include "llvm/CodeGen/Passes.h"
Daniel Dunbara8c58d52009-08-13 17:08:54 +000019#include "llvm/Target/TargetRegistry.h"
Sanjiv Gupta0e687712008-05-13 09:02:57 +000020
21using namespace llvm;
22
Daniel Dunbara8c58d52009-08-13 17:08:54 +000023extern "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 Dunbare28039c2009-08-02 23:37:13 +000033PIC16TargetMachine::PIC16TargetMachine(const Target &T, const std::string &TT,
Daniel Dunbara8c58d52009-08-13 17:08:54 +000034 const std::string &FS, bool Trad)
Chris Lattner0a31d2f2009-08-11 20:42:37 +000035: LLVMTargetMachine(T, TT),
Daniel Dunbara8c58d52009-08-13 17:08:54 +000036 Subtarget(TT, FS, Trad),
Sanjiv Guptab1b5ffd2008-11-19 11:00:54 +000037 DataLayout("e-p:16:8:8-i8:8:8-i16:8:8-i32:8:8"),
Sanjiv Gupta0e687712008-05-13 09:02:57 +000038 InstrInfo(*this), TLInfo(*this),
39 FrameInfo(TargetFrameInfo::StackGrowsUp, 8, 0) { }
40
Sanjiv Guptab1b5ffd2008-11-19 11:00:54 +000041
Bill Wendlingbe8cc2a2009-04-29 00:15:41 +000042bool PIC16TargetMachine::addInstSelector(PassManagerBase &PM,
Bill Wendling98a366d2009-04-29 23:29:43 +000043 CodeGenOpt::Level OptLevel) {
Sanjiv Gupta0e687712008-05-13 09:02:57 +000044 // Install an instruction selector.
45 PM.add(createPIC16ISelDag(*this));
46 return false;
47}
48
Sanjiv Gupta85019e12009-08-07 05:44:27 +000049bool PIC16TargetMachine::addPreEmitPass(PassManagerBase &PM,
Sanjiv Guptad8d27f42009-05-06 08:02:01 +000050 CodeGenOpt::Level OptLevel) {
51 PM.add(createPIC16MemSelOptimizerPass());
52 return true; // -print-machineinstr should print after this.
53}
54
Sanjiv Guptab1b5ffd2008-11-19 11:00:54 +000055