blob: 52846cf68cccb43ea4cfd3b6c88f288b7dad1306 [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"
Sanjiv Gupta0e687712008-05-13 09:02:57 +000019#include "llvm/Target/TargetAsmInfo.h"
20
21using namespace llvm;
22
Sanjiv Guptab1b5ffd2008-11-19 11:00:54 +000023// PIC16TargetMachine - Traditional PIC16 Machine.
Daniel Dunbare28039c2009-08-02 23:37:13 +000024PIC16TargetMachine::PIC16TargetMachine(const Target &T, const std::string &TT,
Daniel Dunbar51b198a2009-07-15 20:24:03 +000025 const std::string &FS, bool Cooper)
26: LLVMTargetMachine(T),
Daniel Dunbare28039c2009-08-02 23:37:13 +000027 Subtarget(TT, FS, Cooper),
Sanjiv Guptab1b5ffd2008-11-19 11:00:54 +000028 DataLayout("e-p:16:8:8-i8:8:8-i16:8:8-i32:8:8"),
Sanjiv Gupta0e687712008-05-13 09:02:57 +000029 InstrInfo(*this), TLInfo(*this),
30 FrameInfo(TargetFrameInfo::StackGrowsUp, 8, 0) { }
31
Sanjiv Guptab1b5ffd2008-11-19 11:00:54 +000032// CooperTargetMachine - Uses the same PIC16TargetMachine, but makes IsCooper
33// as true.
Daniel Dunbare28039c2009-08-02 23:37:13 +000034CooperTargetMachine::CooperTargetMachine(const Target &T, const std::string &TT,
Daniel Dunbar51b198a2009-07-15 20:24:03 +000035 const std::string &FS)
Daniel Dunbare28039c2009-08-02 23:37:13 +000036 : PIC16TargetMachine(T, TT, FS, true) {}
Sanjiv Gupta0e687712008-05-13 09:02:57 +000037
Sanjiv Guptab1b5ffd2008-11-19 11:00:54 +000038
39const TargetAsmInfo *PIC16TargetMachine::createTargetAsmInfo() const {
Chris Lattner3878bff2009-08-02 04:41:14 +000040 return new PIC16TargetAsmInfo();
Sanjiv Gupta0e687712008-05-13 09:02:57 +000041}
42
Bill Wendlingbe8cc2a2009-04-29 00:15:41 +000043bool PIC16TargetMachine::addInstSelector(PassManagerBase &PM,
Bill Wendling98a366d2009-04-29 23:29:43 +000044 CodeGenOpt::Level OptLevel) {
Sanjiv Gupta0e687712008-05-13 09:02:57 +000045 // Install an instruction selector.
46 PM.add(createPIC16ISelDag(*this));
47 return false;
48}
49
Sanjiv Guptad8d27f42009-05-06 08:02:01 +000050bool PIC16TargetMachine::addPostRegAlloc(PassManagerBase &PM,
51 CodeGenOpt::Level OptLevel) {
52 PM.add(createPIC16MemSelOptimizerPass());
53 return true; // -print-machineinstr should print after this.
54}
55
Sanjiv Guptab1b5ffd2008-11-19 11:00:54 +000056