2006-05-14 22:18:28 +00: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 07:51:42 +00:00
|
|
|
#include "ARMTargetAsmInfo.h"
|
2006-08-16 14:43:33 +00:00
|
|
|
#include "ARMFrameInfo.h"
|
2006-05-14 22:18:28 +00:00
|
|
|
#include "ARM.h"
|
|
|
|
#include "llvm/Module.h"
|
|
|
|
#include "llvm/PassManager.h"
|
2007-05-16 02:01:49 +00:00
|
|
|
#include "llvm/CodeGen/Passes.h"
|
2007-01-19 07:51:42 +00:00
|
|
|
#include "llvm/Support/CommandLine.h"
|
2006-05-14 22:18:28 +00:00
|
|
|
#include "llvm/Target/TargetMachineRegistry.h"
|
2007-01-19 07:51:42 +00:00
|
|
|
#include "llvm/Target/TargetOptions.h"
|
2006-05-14 22:18:28 +00:00
|
|
|
using namespace llvm;
|
|
|
|
|
2007-01-19 07:51:42 +00:00
|
|
|
static cl::opt<bool> DisableLdStOpti("disable-arm-loadstore-opti", cl::Hidden,
|
|
|
|
cl::desc("Disable load store optimization pass"));
|
2007-05-16 02:01:49 +00:00
|
|
|
static cl::opt<bool> EnableIfConversion("enable-arm-if-conversion", cl::Hidden,
|
|
|
|
cl::desc("Enable if-conversion pass"));
|
2007-01-19 07:51:42 +00:00
|
|
|
|
2006-05-14 22:18:28 +00:00
|
|
|
namespace {
|
|
|
|
// Register the target.
|
2007-02-23 03:14:31 +00:00
|
|
|
RegisterTarget<ARMTargetMachine> X("arm", " ARM");
|
|
|
|
RegisterTarget<ThumbTargetMachine> Y("thumb", " Thumb");
|
2006-05-14 22:18:28 +00:00
|
|
|
}
|
|
|
|
|
2007-02-23 03:14:31 +00:00
|
|
|
/// ThumbTargetMachine - Create an Thumb architecture model.
|
2006-05-14 22:18:28 +00:00
|
|
|
///
|
2007-02-23 03:14:31 +00:00
|
|
|
unsigned ThumbTargetMachine::getModuleMatchQuality(const Module &M) {
|
|
|
|
std::string TT = M.getTargetTriple();
|
|
|
|
if (TT.size() >= 6 && std::string(TT.begin(), TT.begin()+6) == "thumb-")
|
|
|
|
return 20;
|
|
|
|
|
|
|
|
return M.getPointerSize() == Module::Pointer32;
|
|
|
|
}
|
|
|
|
|
|
|
|
ThumbTargetMachine::ThumbTargetMachine(const Module &M, const std::string &FS)
|
|
|
|
: ARMTargetMachine(M, FS, true) {
|
|
|
|
}
|
|
|
|
|
|
|
|
/// TargetMachine ctor - Create an ARM architecture model.
|
|
|
|
///
|
|
|
|
ARMTargetMachine::ARMTargetMachine(const Module &M, const std::string &FS,
|
|
|
|
bool isThumb)
|
|
|
|
: Subtarget(M, FS, isThumb),
|
2007-02-13 19:52:28 +00:00
|
|
|
DataLayout(Subtarget.isAPCS_ABI() ?
|
2007-02-13 20:06:15 +00:00
|
|
|
// APCS ABI
|
2007-02-23 03:14:31 +00:00
|
|
|
(isThumb ?
|
2007-02-14 05:52:17 +00:00
|
|
|
std::string("e-p:32:32-f64:32:32-i64:32:32-"
|
|
|
|
"i16:16:32-i8:8:32-i1:8:32-a:0:32") :
|
|
|
|
std::string("e-p:32:32-f64:32:32-i64:32:32")) :
|
2007-02-13 20:06:15 +00:00
|
|
|
// AAPCS ABI
|
2007-02-23 03:14:31 +00:00
|
|
|
(isThumb ?
|
2007-02-14 05:52:17 +00:00
|
|
|
std::string("e-p:32:32-f64:64:64-i64:64:64-"
|
|
|
|
"i16:16:32-i8:8:32-i1:8:32-a:0:32") :
|
|
|
|
std::string("e-p:32:32-f64:64:64-i64:64:64"))),
|
2007-01-22 21:24:13 +00:00
|
|
|
InstrInfo(Subtarget),
|
2007-03-13 01:20:42 +00:00
|
|
|
FrameInfo(Subtarget),
|
|
|
|
TLInfo(*this) {}
|
2006-05-14 22:18:28 +00: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;
|
|
|
|
|
2007-02-23 03:14:31 +00:00
|
|
|
return M.getPointerSize() == Module::Pointer32;
|
2006-05-14 22:18:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-01-19 07:51:42 +00:00
|
|
|
const TargetAsmInfo *ARMTargetMachine::createTargetAsmInfo() const {
|
|
|
|
return new ARMTargetAsmInfo(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-09-04 04:14:57 +00:00
|
|
|
// Pass Pipeline Configuration
|
|
|
|
bool ARMTargetMachine::addInstSelector(FunctionPassManager &PM, bool Fast) {
|
2006-05-14 22:18:28 +00:00
|
|
|
PM.add(createARMISelDag(*this));
|
2006-09-04 04:14:57 +00:00
|
|
|
return false;
|
|
|
|
}
|
2006-09-19 15:49:25 +00:00
|
|
|
|
2007-01-19 07:51:42 +00: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());
|
|
|
|
|
2007-05-16 20:52:46 +00:00
|
|
|
if (!Fast && EnableIfConversion && !Subtarget.isThumb())
|
|
|
|
PM.add(createIfConverterPass());
|
|
|
|
|
2007-01-19 07:51:42 +00:00
|
|
|
PM.add(createARMConstantIslandPass());
|
2006-09-19 15:49:25 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2006-09-04 04:14:57 +00:00
|
|
|
bool ARMTargetMachine::addAssemblyEmitter(FunctionPassManager &PM, bool Fast,
|
|
|
|
std::ostream &Out) {
|
2006-05-14 22:18:28 +00:00
|
|
|
// Output assembly language.
|
|
|
|
PM.add(createARMCodePrinterPass(Out, *this));
|
|
|
|
return false;
|
|
|
|
}
|