blob: 7506ea8c29ab3daf6ca1e0c9330d00bb1173554e [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
Jim Laskeyfde1b3b2006-09-07 23:39:26 +000014#include "ARMTargetAsmInfo.h"
Rafael Espindola7bc59bc2006-05-14 22:18:28 +000015#include "ARMTargetMachine.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"
Rafael Espindola7bc59bc2006-05-14 22:18:28 +000020#include "llvm/Target/TargetMachineRegistry.h"
Rafael Espindola7bc59bc2006-05-14 22:18:28 +000021using namespace llvm;
22
23namespace {
24 // Register the target.
25 RegisterTarget<ARMTargetMachine> X("arm", " ARM");
26}
27
Jim Laskeyfde1b3b2006-09-07 23:39:26 +000028
29const TargetAsmInfo *ARMTargetMachine::createTargetAsmInfo() const {
30 return new ARMTargetAsmInfo(*this);
31}
32
33
Rafael Espindola7bc59bc2006-05-14 22:18:28 +000034/// TargetMachine ctor - Create an ILP32 architecture model
35///
36ARMTargetMachine::ARMTargetMachine(const Module &M, const std::string &FS)
Chris Lattnerc4fa3862006-09-03 18:44:02 +000037 : DataLayout("E-p:32:32") {
Rafael Espindola7bc59bc2006-05-14 22:18:28 +000038}
39
40unsigned 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
Rafael Espindola7bc59bc2006-05-14 22:18:28 +000051
Chris Lattner1911fd42006-09-04 04:14:57 +000052// Pass Pipeline Configuration
53bool ARMTargetMachine::addInstSelector(FunctionPassManager &PM, bool Fast) {
Rafael Espindola7bc59bc2006-05-14 22:18:28 +000054 PM.add(createARMISelDag(*this));
Chris Lattner1911fd42006-09-04 04:14:57 +000055 return false;
56}
Rafael Espindola71f3b942006-09-19 15:49:25 +000057
58bool ARMTargetMachine::addPostRegAlloc(FunctionPassManager &PM, bool Fast) {
59 PM.add(createARMFixMulPass());
60 return true;
61}
62
Chris Lattner1911fd42006-09-04 04:14:57 +000063bool ARMTargetMachine::addAssemblyEmitter(FunctionPassManager &PM, bool Fast,
64 std::ostream &Out) {
Rafael Espindola7bc59bc2006-05-14 22:18:28 +000065 // Output assembly language.
66 PM.add(createARMCodePrinterPass(Out, *this));
Rafael Espindola7bc59bc2006-05-14 22:18:28 +000067 return false;
68}