2006-05-15 06:18:28 +08:00
|
|
|
//===-- ARMTargetMachine.cpp - Define TargetMachine for ARM ---------------===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file was developed by the "Instituto Nokia de Tecnologia" and
|
|
|
|
// is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "ARMTargetMachine.h"
|
2007-01-19 15:51:42 +08:00
|
|
|
#include "ARMTargetAsmInfo.h"
|
2006-08-16 22:43:33 +08:00
|
|
|
#include "ARMFrameInfo.h"
|
2006-05-15 06:18:28 +08:00
|
|
|
#include "ARM.h"
|
|
|
|
#include "llvm/Module.h"
|
|
|
|
#include "llvm/PassManager.h"
|
2007-01-19 15:51:42 +08:00
|
|
|
#include "llvm/Support/CommandLine.h"
|
2006-05-15 06:18:28 +08:00
|
|
|
#include "llvm/Target/TargetMachineRegistry.h"
|
2007-01-19 15:51:42 +08:00
|
|
|
#include "llvm/Target/TargetOptions.h"
|
2006-05-15 06:18:28 +08:00
|
|
|
using namespace llvm;
|
|
|
|
|
2007-01-19 15:51:42 +08:00
|
|
|
static cl::opt<bool> DisableLdStOpti("disable-arm-loadstore-opti", cl::Hidden,
|
|
|
|
cl::desc("Disable load store optimization pass"));
|
|
|
|
|
2006-05-15 06:18:28 +08:00
|
|
|
namespace {
|
|
|
|
// Register the target.
|
|
|
|
RegisterTarget<ARMTargetMachine> X("arm", " ARM");
|
|
|
|
}
|
|
|
|
|
|
|
|
/// TargetMachine ctor - Create an ILP32 architecture model
|
|
|
|
///
|
|
|
|
ARMTargetMachine::ARMTargetMachine(const Module &M, const std::string &FS)
|
2007-01-23 05:24:13 +08:00
|
|
|
: Subtarget(M, FS),
|
2007-02-14 03:52:28 +08:00
|
|
|
DataLayout(Subtarget.isAPCS_ABI() ?
|
|
|
|
//APCS ABI
|
2007-02-01 10:18:36 +08:00
|
|
|
(Subtarget.isThumb() ?
|
|
|
|
std::string("e-p:32:32-d:32:32-l:32:32-s:16:32-b:8:32-B:8:32-A:32") :
|
|
|
|
std::string("e-p:32:32-d:32:32-l:32:32")) :
|
2007-02-14 03:52:28 +08:00
|
|
|
//AAPCS ABI
|
2007-02-01 10:18:36 +08:00
|
|
|
(Subtarget.isThumb() ?
|
2007-02-14 03:52:28 +08:00
|
|
|
std::string("e-p:32:32-d:64:64-l:64:64-s:16:32-b:8:32-B:8:32-A:32") :
|
|
|
|
std::string("e-p:32:32-d:64:64-l:64:64"))),
|
2007-01-23 05:24:13 +08:00
|
|
|
InstrInfo(Subtarget),
|
2007-01-20 10:09:25 +08:00
|
|
|
FrameInfo(Subtarget) {}
|
2006-05-15 06:18:28 +08:00
|
|
|
|
|
|
|
unsigned ARMTargetMachine::getModuleMatchQuality(const Module &M) {
|
|
|
|
std::string TT = M.getTargetTriple();
|
|
|
|
if (TT.size() >= 4 && std::string(TT.begin(), TT.begin()+4) == "arm-")
|
|
|
|
return 20;
|
|
|
|
|
|
|
|
if (M.getPointerSize() == Module::Pointer32)
|
|
|
|
return 1;
|
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-01-19 15:51:42 +08:00
|
|
|
const TargetAsmInfo *ARMTargetMachine::createTargetAsmInfo() const {
|
|
|
|
return new ARMTargetAsmInfo(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-09-04 12:14:57 +08:00
|
|
|
// Pass Pipeline Configuration
|
|
|
|
bool ARMTargetMachine::addInstSelector(FunctionPassManager &PM, bool Fast) {
|
2006-05-15 06:18:28 +08:00
|
|
|
PM.add(createARMISelDag(*this));
|
2006-09-04 12:14:57 +08:00
|
|
|
return false;
|
|
|
|
}
|
2006-09-19 23:49:25 +08:00
|
|
|
|
2007-01-19 15:51:42 +08:00
|
|
|
bool ARMTargetMachine::addPreEmitPass(FunctionPassManager &PM, bool Fast) {
|
|
|
|
// FIXME: temporarily disabling load / store optimization pass for Thumb mode.
|
|
|
|
if (!Fast && !DisableLdStOpti && !Subtarget.isThumb())
|
|
|
|
PM.add(createARMLoadStoreOptimizationPass());
|
|
|
|
|
|
|
|
PM.add(createARMConstantIslandPass());
|
2006-09-19 23:49:25 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2006-09-04 12:14:57 +08:00
|
|
|
bool ARMTargetMachine::addAssemblyEmitter(FunctionPassManager &PM, bool Fast,
|
|
|
|
std::ostream &Out) {
|
2006-05-15 06:18:28 +08:00
|
|
|
// Output assembly language.
|
|
|
|
PM.add(createARMCodePrinterPass(Out, *this));
|
|
|
|
return false;
|
|
|
|
}
|