1 //===-- ARMTargetMachine.cpp - Define TargetMachine for ARM ---------------===//
3 // The LLVM Compiler Infrastructure
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.
9 //===----------------------------------------------------------------------===//
12 //===----------------------------------------------------------------------===//
14 #include "ARMTargetMachine.h"
15 #include "ARMFrameInfo.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"
29 // Register the target.
30 RegisterTarget<ARMTargetMachine> X("arm", " ARM");
33 /// TargetMachine ctor - Create an ILP32 architecture model
35 ARMTargetMachine::ARMTargetMachine(const Module &M, const std::string &FS)
36 : TargetMachine("ARM"), DataLayout("E-p:32:32"),
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-")
45 if (M.getPointerSize() == Module::Pointer32)
51 /// addPassesToEmitFile - Add passes to the specified pass manager
52 /// to implement a static compiler for this target.
54 bool ARMTargetMachine::addPassesToEmitFile(PassManager &PM, std::ostream &Out,
55 CodeGenFileType FileType,
57 if (FileType != TargetMachine::AssemblyFile)
60 // Run loop strength reduction before anything else.
62 PM.add(createLoopStrengthReducePass());
64 // FIXME: Implement efficient support for garbage collection intrinsics.
65 PM.add(createLowerGCPass());
67 // FIXME: implement the invoke/unwind instructions!
68 PM.add(createLowerInvokePass());
70 // Print LLVM code input to instruction selector:
72 PM.add(new PrintFunctionPass());
74 // Make sure that no unreachable blocks are instruction selected.
75 PM.add(createUnreachableBlockEliminationPass());
77 PM.add(createARMISelDag(*this));
79 // Print machine instructions as they were initially generated.
81 PM.add(createMachineFunctionPrinterPass(&std::cerr));
83 PM.add(createRegisterAllocator());
84 PM.add(createPrologEpilogCodeInserter());
86 // Print machine instructions after register allocation and prolog/epilog
89 PM.add(createMachineFunctionPrinterPass(&std::cerr));
91 // Output assembly language.
92 PM.add(createARMCodePrinterPass(Out, *this));
94 // Delete the MachineInstrs we generated, since they're no longer needed.
95 PM.add(createMachineCodeDeleter());