Declare the callee saved regs
[oota-llvm.git] / lib / Target / ARM / ARMTargetMachine.cpp
1 //===-- ARMTargetMachine.cpp - Define TargetMachine for ARM ---------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file was developed by the "Instituto Nokia de Tecnologia" and
6 // is distributed under the University of Illinois Open Source
7 // License. See LICENSE.TXT for details.
8 //
9 //===----------------------------------------------------------------------===//
10 //
11 //
12 //===----------------------------------------------------------------------===//
13
14 #include "ARMTargetMachine.h"
15 #include "ARMFrameInfo.h"
16 #include "ARM.h"
17 #include "llvm/Assembly/PrintModulePass.h"
18 #include "llvm/Module.h"
19 #include "llvm/PassManager.h"
20 #include "llvm/CodeGen/MachineFunction.h"
21 #include "llvm/CodeGen/Passes.h"
22 #include "llvm/Target/TargetOptions.h"
23 #include "llvm/Target/TargetMachineRegistry.h"
24 #include "llvm/Transforms/Scalar.h"
25 #include <iostream>
26 using namespace llvm;
27
28 namespace {
29   // Register the target.
30   RegisterTarget<ARMTargetMachine> X("arm", "  ARM");
31 }
32
33 /// TargetMachine ctor - Create an ILP32 architecture model
34 ///
35 ARMTargetMachine::ARMTargetMachine(const Module &M, const std::string &FS)
36   : TargetMachine("ARM"), DataLayout("E-p:32:32"),
37     FrameInfo() {
38 }
39
40 unsigned ARMTargetMachine::getModuleMatchQuality(const Module &M) {
41   std::string TT = M.getTargetTriple();
42   if (TT.size() >= 4 && std::string(TT.begin(), TT.begin()+4) == "arm-")
43     return 20;
44
45   if (M.getPointerSize() == Module::Pointer32)
46     return 1;
47   else
48     return 0;
49 }
50
51 /// addPassesToEmitFile - Add passes to the specified pass manager
52 /// to implement a static compiler for this target.
53 ///
54 bool ARMTargetMachine::addPassesToEmitFile(PassManager &PM, std::ostream &Out,
55                                              CodeGenFileType FileType,
56                                              bool Fast) {
57   if (FileType != TargetMachine::AssemblyFile)
58     return true;
59
60   // Run loop strength reduction before anything else.
61   if (!Fast)
62     PM.add(createLoopStrengthReducePass());
63
64   // FIXME: Implement efficient support for garbage collection intrinsics.
65   PM.add(createLowerGCPass());
66
67   // FIXME: implement the invoke/unwind instructions!
68   PM.add(createLowerInvokePass());
69
70   // Print LLVM code input to instruction selector:
71   if (PrintMachineCode)
72     PM.add(new PrintFunctionPass());
73
74   // Make sure that no unreachable blocks are instruction selected.
75   PM.add(createUnreachableBlockEliminationPass());
76
77   PM.add(createARMISelDag(*this));
78
79   // Print machine instructions as they were initially generated.
80   if (PrintMachineCode)
81     PM.add(createMachineFunctionPrinterPass(&std::cerr));
82
83   PM.add(createRegisterAllocator());
84   PM.add(createPrologEpilogCodeInserter());
85
86   // Print machine instructions after register allocation and prolog/epilog
87   // insertion.
88   if (PrintMachineCode)
89     PM.add(createMachineFunctionPrinterPass(&std::cerr));
90
91   // Output assembly language.
92   PM.add(createARMCodePrinterPass(Out, *this));
93
94   // Delete the MachineInstrs we generated, since they're no longer needed.
95   PM.add(createMachineCodeDeleter());
96   return false;
97 }
98