Fix part 1 of pr4682. PICADD is a 16-bit instruction even in thumb2 mode.
[llvm/avr.git] / lib / Target / PIC16 / PIC16TargetMachine.cpp
blob52846cf68cccb43ea4cfd3b6c88f288b7dad1306
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.
12 //===----------------------------------------------------------------------===//
14 #include "PIC16.h"
15 #include "PIC16TargetAsmInfo.h"
16 #include "PIC16TargetMachine.h"
17 #include "llvm/PassManager.h"
18 #include "llvm/CodeGen/Passes.h"
19 #include "llvm/Target/TargetAsmInfo.h"
21 using namespace llvm;
23 // PIC16TargetMachine - Traditional PIC16 Machine.
24 PIC16TargetMachine::PIC16TargetMachine(const Target &T, const std::string &TT,
25 const std::string &FS, bool Cooper)
26 : LLVMTargetMachine(T),
27 Subtarget(TT, FS, Cooper),
28 DataLayout("e-p:16:8:8-i8:8:8-i16:8:8-i32:8:8"),
29 InstrInfo(*this), TLInfo(*this),
30 FrameInfo(TargetFrameInfo::StackGrowsUp, 8, 0) { }
32 // CooperTargetMachine - Uses the same PIC16TargetMachine, but makes IsCooper
33 // as true.
34 CooperTargetMachine::CooperTargetMachine(const Target &T, const std::string &TT,
35 const std::string &FS)
36 : PIC16TargetMachine(T, TT, FS, true) {}
39 const TargetAsmInfo *PIC16TargetMachine::createTargetAsmInfo() const {
40 return new PIC16TargetAsmInfo();
43 bool PIC16TargetMachine::addInstSelector(PassManagerBase &PM,
44 CodeGenOpt::Level OptLevel) {
45 // Install an instruction selector.
46 PM.add(createPIC16ISelDag(*this));
47 return false;
50 bool PIC16TargetMachine::addPostRegAlloc(PassManagerBase &PM,
51 CodeGenOpt::Level OptLevel) {
52 PM.add(createPIC16MemSelOptimizerPass());
53 return true; // -print-machineinstr should print after this.