blob: a85833ebc0c6b42f4cad203fa5ed6eec94b6277f [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
34// FrameInfo --> StackGrowsDown, 8 bytes aligned, LOA : -4 (Ra : 0)
35MipsTargetMachine::
36MipsTargetMachine(const Module &M, const std::string &FS):
37 Subtarget(*this, M, FS), DataLayout("E-p:32:32:32"),
38 InstrInfo(*this), FrameInfo(TargetFrameInfo::StackGrowsDown, 8, -4),
39 TLInfo(*this) {}
40
41// return 0 and must specify -march to gen MIPS code.
42unsigned MipsTargetMachine::
Chris Lattner87bdba62007-07-09 17:25:29 +000043getModuleMatchQuality(const Module &M) {
Bruno Cardoso Lopes972f5892007-06-06 07:42:06 +000044 // We strongly match "mips-*".
45 std::string TT = M.getTargetTriple();
46 if (TT.size() >= 5 && std::string(TT.begin(), TT.begin()+5) == "mips-")
47 return 20;
Chris Lattner87bdba62007-07-09 17:25:29 +000048 // If the target triple is something non-mips, we don't match.
49 if (!TT.empty()) return 0;
50
Bruno Cardoso Lopes972f5892007-06-06 07:42:06 +000051 return 0;
52}
53
54// Install an instruction selector pass using
55// the ISelDag to gen Mips code.
56bool MipsTargetMachine::
57addInstSelector(FunctionPassManager &PM, bool Fast)
58{
59 PM.add(createMipsISelDag(*this));
60 return false;
61}
62
63// Implemented by targets that want to run passes immediately before
64// machine code is emitted. return true if -print-machineinstrs should
65// print out the code after the passes.
66// TODO: Delay slot must be implemented here.
67bool MipsTargetMachine::
68addPreEmitPass(FunctionPassManager &PM, bool Fast)
69{
70 return false;
71}
72
73// Implements the AssemblyEmitter for the target. Must return
74// true if AssemblyEmitter is supported
75bool MipsTargetMachine::
76addAssemblyEmitter(FunctionPassManager &PM, bool Fast,
77 std::ostream &Out)
78{
79 // Output assembly language.
80 PM.add(createMipsCodePrinterPass(Out, *this));
81 return false;
82}