blob: 7cb610a04fb1b8b43cc88a4d3eb6d69e5682cbd7 [file] [log] [blame]
Rafael Espindola7bc59bc2006-05-14 22:18:28 +00001//===-- 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"
Evan Chenga8e29892007-01-19 07:51:42 +000015#include "ARMTargetAsmInfo.h"
Rafael Espindolaec46ea32006-08-16 14:43:33 +000016#include "ARMFrameInfo.h"
Rafael Espindola7bc59bc2006-05-14 22:18:28 +000017#include "ARM.h"
Rafael Espindola7bc59bc2006-05-14 22:18:28 +000018#include "llvm/Module.h"
19#include "llvm/PassManager.h"
Evan Chenga8e29892007-01-19 07:51:42 +000020#include "llvm/Support/CommandLine.h"
Rafael Espindola7bc59bc2006-05-14 22:18:28 +000021#include "llvm/Target/TargetMachineRegistry.h"
Evan Chenga8e29892007-01-19 07:51:42 +000022#include "llvm/Target/TargetOptions.h"
Rafael Espindola7bc59bc2006-05-14 22:18:28 +000023using namespace llvm;
24
Evan Chenga8e29892007-01-19 07:51:42 +000025static cl::opt<bool> DisableLdStOpti("disable-arm-loadstore-opti", cl::Hidden,
26 cl::desc("Disable load store optimization pass"));
27
Rafael Espindola7bc59bc2006-05-14 22:18:28 +000028namespace {
29 // Register the target.
30 RegisterTarget<ARMTargetMachine> X("arm", " ARM");
31}
32
33/// TargetMachine ctor - Create an ILP32 architecture model
34///
35ARMTargetMachine::ARMTargetMachine(const Module &M, const std::string &FS)
Evan Chenga8e29892007-01-19 07:51:42 +000036 : Subtarget(M, FS), DataLayout("e-p:32:32-d:32"), InstrInfo(Subtarget),
37 FrameInfo(Subtarget) {
Evan Cheng970a4192007-01-19 19:28:01 +000038 if (Subtarget.isTargetDarwin())
Evan Chenga8e29892007-01-19 07:51:42 +000039 NoFramePointerElim = true;
Rafael Espindola7bc59bc2006-05-14 22:18:28 +000040}
41
42unsigned ARMTargetMachine::getModuleMatchQuality(const Module &M) {
43 std::string TT = M.getTargetTriple();
44 if (TT.size() >= 4 && std::string(TT.begin(), TT.begin()+4) == "arm-")
45 return 20;
46
47 if (M.getPointerSize() == Module::Pointer32)
48 return 1;
49 else
50 return 0;
51}
52
Rafael Espindola7bc59bc2006-05-14 22:18:28 +000053
Evan Chenga8e29892007-01-19 07:51:42 +000054const TargetAsmInfo *ARMTargetMachine::createTargetAsmInfo() const {
55 return new ARMTargetAsmInfo(*this);
56}
57
58
Chris Lattner1911fd42006-09-04 04:14:57 +000059// Pass Pipeline Configuration
60bool ARMTargetMachine::addInstSelector(FunctionPassManager &PM, bool Fast) {
Rafael Espindola7bc59bc2006-05-14 22:18:28 +000061 PM.add(createARMISelDag(*this));
Chris Lattner1911fd42006-09-04 04:14:57 +000062 return false;
63}
Rafael Espindola71f3b942006-09-19 15:49:25 +000064
Evan Chenga8e29892007-01-19 07:51:42 +000065bool ARMTargetMachine::addPreEmitPass(FunctionPassManager &PM, bool Fast) {
66 // FIXME: temporarily disabling load / store optimization pass for Thumb mode.
67 if (!Fast && !DisableLdStOpti && !Subtarget.isThumb())
68 PM.add(createARMLoadStoreOptimizationPass());
69
70 PM.add(createARMConstantIslandPass());
Rafael Espindola71f3b942006-09-19 15:49:25 +000071 return true;
72}
73
Chris Lattner1911fd42006-09-04 04:14:57 +000074bool ARMTargetMachine::addAssemblyEmitter(FunctionPassManager &PM, bool Fast,
75 std::ostream &Out) {
Rafael Espindola7bc59bc2006-05-14 22:18:28 +000076 // Output assembly language.
77 PM.add(createARMCodePrinterPass(Out, *this));
Rafael Espindola7bc59bc2006-05-14 22:18:28 +000078 return false;
79}