blob: 7fdba30bd21322b49b80d4a7b1ec4a94fde8a149 [file] [log] [blame]
Bruno Cardoso Lopes972f5892007-06-06 07:42:06 +00001//===-- MipsTargetMachine.cpp - Define TargetMachine for Mips -------------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file was developed by Bruno Cardoso Lopes and is distributed under the
6// University of Illinois Open Source License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// Implements the info about Mips target spec.
11//
12//===----------------------------------------------------------------------===//
13
14#include "Mips.h"
15#include "MipsTargetAsmInfo.h"
16#include "MipsTargetMachine.h"
17#include "llvm/Module.h"
18#include "llvm/PassManager.h"
19#include "llvm/Target/TargetMachineRegistry.h"
20using namespace llvm;
21
22namespace {
23 // Register the target.
24 RegisterTarget<MipsTargetMachine> X("mips", " Mips");
25}
26
27const TargetAsmInfo *MipsTargetMachine::
28createTargetAsmInfo() const
29{
30 return new MipsTargetAsmInfo(*this);
31}
32
33// DataLayout --> Big-endian, 32-bit pointer/ABI/alignment
Bruno Cardoso Lopes758dcca2007-07-11 23:17:41 +000034//
35// FrameInfo --> StackGrowsDown, 8 bytes aligned,
36// LOA : 0
Bruno Cardoso Lopes972f5892007-06-06 07:42:06 +000037MipsTargetMachine::
38MipsTargetMachine(const Module &M, const std::string &FS):
39 Subtarget(*this, M, FS), DataLayout("E-p:32:32:32"),
Bruno Cardoso Lopes758dcca2007-07-11 23:17:41 +000040 InstrInfo(*this), FrameInfo(TargetFrameInfo::StackGrowsDown, 8, 0),
Bruno Cardoso Lopes972f5892007-06-06 07:42:06 +000041 TLInfo(*this) {}
42
43// return 0 and must specify -march to gen MIPS code.
44unsigned MipsTargetMachine::
Bruno Cardoso Lopes758dcca2007-07-11 23:17:41 +000045getModuleMatchQuality(const Module &M)
46{
Bruno Cardoso Lopes972f5892007-06-06 07:42:06 +000047 // We strongly match "mips-*".
48 std::string TT = M.getTargetTriple();
49 if (TT.size() >= 5 && std::string(TT.begin(), TT.begin()+5) == "mips-")
50 return 20;
Bruno Cardoso Lopes758dcca2007-07-11 23:17:41 +000051
Bruno Cardoso Lopes972f5892007-06-06 07:42:06 +000052 return 0;
53}
54
55// Install an instruction selector pass using
56// the ISelDag to gen Mips code.
57bool MipsTargetMachine::
58addInstSelector(FunctionPassManager &PM, bool Fast)
59{
60 PM.add(createMipsISelDag(*this));
61 return false;
62}
63
64// Implemented by targets that want to run passes immediately before
65// machine code is emitted. return true if -print-machineinstrs should
66// print out the code after the passes.
67// TODO: Delay slot must be implemented here.
68bool MipsTargetMachine::
69addPreEmitPass(FunctionPassManager &PM, bool Fast)
70{
71 return false;
72}
73
74// Implements the AssemblyEmitter for the target. Must return
75// true if AssemblyEmitter is supported
76bool MipsTargetMachine::
77addAssemblyEmitter(FunctionPassManager &PM, bool Fast,
78 std::ostream &Out)
79{
80 // Output assembly language.
81 PM.add(createMipsCodePrinterPass(Out, *this));
82 return false;
83}