1 //===-- MipsTargetMachine.cpp - Define TargetMachine for Mips -------------===//
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 // Implements the info about Mips target spec.
12 //===----------------------------------------------------------------------===//
15 #include "MipsTargetAsmInfo.h"
16 #include "MipsTargetMachine.h"
17 #include "llvm/Module.h"
18 #include "llvm/PassManager.h"
19 #include "llvm/Target/TargetMachineRegistry.h"
23 // Register the target.
24 RegisterTarget<MipsTargetMachine> X("mips", " Mips");
27 const TargetAsmInfo *MipsTargetMachine::
28 createTargetAsmInfo() const
30 return new MipsTargetAsmInfo(*this);
33 // DataLayout --> Big-endian, 32-bit pointer/ABI/alignment
34 // The stack is always 8 byte aligned
35 // On function prologue, the stack is created by decrementing
36 // its pointer. Once decremented, all references are done with positive
37 // offset from the stack/frame pointer, so StackGrowsUp is used.
38 // When using CodeModel::Large the behaviour
42 MipsTargetMachine(const Module &M, const std::string &FS):
43 Subtarget(*this, M, FS), DataLayout("E-p:32:32:32"),
44 InstrInfo(*this), FrameInfo(TargetFrameInfo::StackGrowsUp, 8, 0),
47 if (getRelocationModel() != Reloc::Static)
48 setRelocationModel(Reloc::PIC_);
49 if (getCodeModel() == CodeModel::Default)
50 setCodeModel(CodeModel::Small);
53 // return 0 and must specify -march to gen MIPS code.
54 unsigned MipsTargetMachine::
55 getModuleMatchQuality(const Module &M)
57 // We strongly match "mips-*".
58 std::string TT = M.getTargetTriple();
59 if (TT.size() >= 5 && std::string(TT.begin(), TT.begin()+5) == "mips-")
65 // Install an instruction selector pass using
66 // the ISelDag to gen Mips code.
67 bool MipsTargetMachine::
68 addInstSelector(FunctionPassManager &PM, bool Fast)
70 PM.add(createMipsISelDag(*this));
74 // Implemented by targets that want to run passes immediately before
75 // machine code is emitted. return true if -print-machineinstrs should
76 // print out the code after the passes.
77 bool MipsTargetMachine::
78 addPreEmitPass(FunctionPassManager &PM, bool Fast)
80 PM.add(createMipsDelaySlotFillerPass(*this));
84 // Implements the AssemblyEmitter for the target. Must return
85 // true if AssemblyEmitter is supported
86 bool MipsTargetMachine::
87 addAssemblyEmitter(FunctionPassManager &PM, bool Fast,
90 // Output assembly language.
91 PM.add(createMipsCodePrinterPass(Out, *this));