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"
16 #include "llvm/Assembly/PrintModulePass.h"
17 #include "llvm/Module.h"
18 #include "llvm/PassManager.h"
19 #include "llvm/CodeGen/MachineFunction.h"
20 #include "llvm/CodeGen/Passes.h"
21 #include "llvm/Target/TargetOptions.h"
22 #include "llvm/Target/TargetMachineRegistry.h"
23 #include "llvm/Transforms/Scalar.h"
28 // Register the target.
29 RegisterTarget<ARMTargetMachine> X("arm", " ARM");
32 /// TargetMachine ctor - Create an ILP32 architecture model
34 ARMTargetMachine::ARMTargetMachine(const Module &M, const std::string &FS)
35 : TargetMachine("ARM"), DataLayout("E-p:32:32"),
36 FrameInfo(TargetFrameInfo::StackGrowsDown, 8, 0) {
39 unsigned ARMTargetMachine::getModuleMatchQuality(const Module &M) {
40 std::string TT = M.getTargetTriple();
41 if (TT.size() >= 4 && std::string(TT.begin(), TT.begin()+4) == "arm-")
44 if (M.getPointerSize() == Module::Pointer32)
50 /// addPassesToEmitFile - Add passes to the specified pass manager
51 /// to implement a static compiler for this target.
53 bool ARMTargetMachine::addPassesToEmitFile(PassManager &PM, std::ostream &Out,
54 CodeGenFileType FileType,
56 if (FileType != TargetMachine::AssemblyFile)
59 // Run loop strength reduction before anything else.
61 PM.add(createLoopStrengthReducePass());
63 // FIXME: Implement efficient support for garbage collection intrinsics.
64 PM.add(createLowerGCPass());
66 // FIXME: implement the invoke/unwind instructions!
67 PM.add(createLowerInvokePass());
69 // Print LLVM code input to instruction selector:
71 PM.add(new PrintFunctionPass());
73 // Make sure that no unreachable blocks are instruction selected.
74 PM.add(createUnreachableBlockEliminationPass());
76 PM.add(createARMISelDag(*this));
78 // Print machine instructions as they were initially generated.
80 PM.add(createMachineFunctionPrinterPass(&std::cerr));
82 PM.add(createRegisterAllocator());
83 PM.add(createPrologEpilogCodeInserter());
85 // Print machine instructions after register allocation and prolog/epilog
88 PM.add(createMachineFunctionPrinterPass(&std::cerr));
90 // Output assembly language.
91 PM.add(createARMCodePrinterPass(Out, *this));
93 // Delete the MachineInstrs we generated, since they're no longer needed.
94 PM.add(createMachineCodeDeleter());