RegAllocGreedy comment.
[oota-llvm.git] / lib / Target / MBlaze / MBlazeTargetMachine.cpp
1 //===-- MBlazeTargetMachine.cpp - Define TargetMachine for MBlaze ---------===//
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 // Implements the info about MBlaze target spec.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #include "MBlazeTargetMachine.h"
15 #include "MBlaze.h"
16 #include "llvm/CodeGen/Passes.h"
17 #include "llvm/PassManager.h"
18 #include "llvm/Support/FormattedStream.h"
19 #include "llvm/Support/TargetRegistry.h"
20 #include "llvm/Target/TargetOptions.h"
21 using namespace llvm;
22
23 extern "C" void LLVMInitializeMBlazeTarget() {
24   // Register the target.
25   RegisterTargetMachine<MBlazeTargetMachine> X(TheMBlazeTarget);
26 }
27
28 // DataLayout --> Big-endian, 32-bit pointer/ABI/alignment
29 // The stack is always 8 byte aligned
30 // On function prologue, the stack is created by decrementing
31 // its pointer. Once decremented, all references are done with positive
32 // offset from the stack/frame pointer, using StackGrowsUp enables
33 // an easier handling.
34 MBlazeTargetMachine::
35 MBlazeTargetMachine(const Target &T, StringRef TT,
36                     StringRef CPU, StringRef FS, const TargetOptions &Options,
37                     Reloc::Model RM, CodeModel::Model CM,
38                     CodeGenOpt::Level OL)
39   : LLVMTargetMachine(T, TT, CPU, FS, Options, RM, CM, OL),
40     Subtarget(TT, CPU, FS),
41     DL("E-p:32:32:32-i8:8:8-i16:16:16"),
42     InstrInfo(*this),
43     FrameLowering(Subtarget),
44     TLInfo(*this), TSInfo(*this),
45     InstrItins(Subtarget.getInstrItineraryData()) {
46   initAsmInfo();
47 }
48
49 namespace {
50 /// MBlaze Code Generator Pass Configuration Options.
51 class MBlazePassConfig : public TargetPassConfig {
52 public:
53   MBlazePassConfig(MBlazeTargetMachine *TM, PassManagerBase &PM)
54     : TargetPassConfig(TM, PM) {}
55
56   MBlazeTargetMachine &getMBlazeTargetMachine() const {
57     return getTM<MBlazeTargetMachine>();
58   }
59
60   virtual bool addInstSelector();
61   virtual bool addPreEmitPass();
62 };
63 } // namespace
64
65 TargetPassConfig *MBlazeTargetMachine::createPassConfig(PassManagerBase &PM) {
66   return new MBlazePassConfig(this, PM);
67 }
68
69 // Install an instruction selector pass using
70 // the ISelDag to gen MBlaze code.
71 bool MBlazePassConfig::addInstSelector() {
72   addPass(createMBlazeISelDag(getMBlazeTargetMachine()));
73   return false;
74 }
75
76 // Implemented by targets that want to run passes immediately before
77 // machine code is emitted. return true if -print-machineinstrs should
78 // print out the code after the passes.
79 bool MBlazePassConfig::addPreEmitPass() {
80   addPass(createMBlazeDelaySlotFillerPass(getMBlazeTargetMachine()));
81   return true;
82 }