1 //===-- PIC16TargetMachine.cpp - Define TargetMachine for PIC16 -----------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // Top-level implementation for the PIC16 target.
12 //===----------------------------------------------------------------------===//
15 #include "PIC16MCAsmInfo.h"
16 #include "PIC16TargetMachine.h"
17 #include "llvm/PassManager.h"
18 #include "llvm/CodeGen/Passes.h"
19 #include "llvm/Target/TargetRegistry.h"
23 extern "C" void LLVMInitializePIC16Target() {
24 // Register the target. Curretnly the codegen works for
25 // enhanced pic16 mid-range.
26 RegisterTargetMachine
<PIC16TargetMachine
> X(ThePIC16Target
);
27 RegisterAsmInfo
<PIC16MCAsmInfo
> A(ThePIC16Target
);
31 // PIC16TargetMachine - Enhanced PIC16 mid-range Machine. May also represent
32 // a Traditional Machine if 'Trad' is true.
33 PIC16TargetMachine::PIC16TargetMachine(const Target
&T
, const std::string
&TT
,
34 const std::string
&FS
, bool Trad
)
35 : LLVMTargetMachine(T
, TT
),
36 Subtarget(TT
, FS
, Trad
),
37 DataLayout("e-p:16:8:8-i8:8:8-i16:8:8-i32:8:8"),
38 InstrInfo(*this), TLInfo(*this),
39 FrameInfo(TargetFrameInfo::StackGrowsUp
, 8, 0) { }
42 bool PIC16TargetMachine::addInstSelector(PassManagerBase
&PM
,
43 CodeGenOpt::Level OptLevel
) {
44 // Install an instruction selector.
45 PM
.add(createPIC16ISelDag(*this));
49 bool PIC16TargetMachine::addPreEmitPass(PassManagerBase
&PM
,
50 CodeGenOpt::Level OptLevel
) {
51 PM
.add(createPIC16MemSelOptimizerPass());
52 return true; // -print-machineinstr should print after this.