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 "ARMTargetAsmInfo.h"
16 #include "ARMFrameInfo.h"
18 #include "llvm/Module.h"
19 #include "llvm/PassManager.h"
20 #include "llvm/Support/CommandLine.h"
21 #include "llvm/Target/TargetMachineRegistry.h"
22 #include "llvm/Target/TargetOptions.h"
25 static cl::opt<bool> DisableLdStOpti("disable-arm-loadstore-opti", cl::Hidden,
26 cl::desc("Disable load store optimization pass"));
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)
37 DataLayout(Subtarget.isAPCS_ABI() ?
39 (Subtarget.isThumb() ?
40 std::string("e-p:32:32-d:32:32-l:32:32-s:16:32-b:8:32-B:8:32-A:32") :
41 std::string("e-p:32:32-d:32:32-l:32:32")) :
43 (Subtarget.isThumb() ?
44 std::string("e-p:32:32-d:64:64-l:64:64-s:16:32-b:8:32-B:8:32-A:32") :
45 std::string("e-p:32:32-d:64:64-l:64:64"))),
47 FrameInfo(Subtarget) {}
49 unsigned ARMTargetMachine::getModuleMatchQuality(const Module &M) {
50 std::string TT = M.getTargetTriple();
51 if (TT.size() >= 4 && std::string(TT.begin(), TT.begin()+4) == "arm-")
54 if (M.getPointerSize() == Module::Pointer32)
61 const TargetAsmInfo *ARMTargetMachine::createTargetAsmInfo() const {
62 return new ARMTargetAsmInfo(*this);
66 // Pass Pipeline Configuration
67 bool ARMTargetMachine::addInstSelector(FunctionPassManager &PM, bool Fast) {
68 PM.add(createARMISelDag(*this));
72 bool ARMTargetMachine::addPreEmitPass(FunctionPassManager &PM, bool Fast) {
73 // FIXME: temporarily disabling load / store optimization pass for Thumb mode.
74 if (!Fast && !DisableLdStOpti && !Subtarget.isThumb())
75 PM.add(createARMLoadStoreOptimizationPass());
77 PM.add(createARMConstantIslandPass());
81 bool ARMTargetMachine::addAssemblyEmitter(FunctionPassManager &PM, bool Fast,
83 // Output assembly language.
84 PM.add(createARMCodePrinterPass(Out, *this));