blob: 9a3b1858b80200d1e4f0ede3410a46da2b2ef177 [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/Module.h"
18#include "llvm/PassManager.h"
Sanjiv Guptab1b5ffd2008-11-19 11:00:54 +000019#include "llvm/CodeGen/Passes.h"
Sanjiv Gupta0e687712008-05-13 09:02:57 +000020#include "llvm/Target/TargetAsmInfo.h"
21
22using namespace llvm;
23
Sanjiv Guptab1b5ffd2008-11-19 11:00:54 +000024// PIC16TargetMachine - Traditional PIC16 Machine.
Daniel Dunbar51b198a2009-07-15 20:24:03 +000025PIC16TargetMachine::PIC16TargetMachine(const Target &T, const Module &M,
26 const std::string &FS, bool Cooper)
27: LLVMTargetMachine(T),
Daniel Dunbar3be03402009-08-02 22:11:08 +000028 Subtarget(M.getTargetTriple(), FS, Cooper),
Sanjiv Guptab1b5ffd2008-11-19 11:00:54 +000029 DataLayout("e-p:16:8:8-i8:8:8-i16:8:8-i32:8:8"),
Sanjiv Gupta0e687712008-05-13 09:02:57 +000030 InstrInfo(*this), TLInfo(*this),
31 FrameInfo(TargetFrameInfo::StackGrowsUp, 8, 0) { }
32
Sanjiv Guptab1b5ffd2008-11-19 11:00:54 +000033// CooperTargetMachine - Uses the same PIC16TargetMachine, but makes IsCooper
34// as true.
Daniel Dunbar51b198a2009-07-15 20:24:03 +000035CooperTargetMachine::CooperTargetMachine(const Target &T, const Module &M,
36 const std::string &FS)
37 : PIC16TargetMachine(T, M, FS, true) {}
Sanjiv Gupta0e687712008-05-13 09:02:57 +000038
Sanjiv Guptab1b5ffd2008-11-19 11:00:54 +000039
40const TargetAsmInfo *PIC16TargetMachine::createTargetAsmInfo() const {
Chris Lattner3878bff2009-08-02 04:41:14 +000041 return new PIC16TargetAsmInfo();
Sanjiv Gupta0e687712008-05-13 09:02:57 +000042}
43
Bill Wendlingbe8cc2a2009-04-29 00:15:41 +000044bool PIC16TargetMachine::addInstSelector(PassManagerBase &PM,
Bill Wendling98a366d2009-04-29 23:29:43 +000045 CodeGenOpt::Level OptLevel) {
Sanjiv Gupta0e687712008-05-13 09:02:57 +000046 // Install an instruction selector.
47 PM.add(createPIC16ISelDag(*this));
48 return false;
49}
50
Sanjiv Guptad8d27f42009-05-06 08:02:01 +000051bool PIC16TargetMachine::addPostRegAlloc(PassManagerBase &PM,
52 CodeGenOpt::Level OptLevel) {
53 PM.add(createPIC16MemSelOptimizerPass());
54 return true; // -print-machineinstr should print after this.
55}
56
Sanjiv Guptab1b5ffd2008-11-19 11:00:54 +000057