2005-01-24 18:45:41 +00:00
|
|
|
//===-- AlphaTargetMachine.cpp - Define TargetMachine for Alpha -----------===//
|
2005-04-21 23:13:11 +00:00
|
|
|
//
|
2005-01-22 23:41:55 +00:00
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2007-12-29 20:36:04 +00:00
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
2005-04-21 23:13:11 +00:00
|
|
|
//
|
2005-01-22 23:41:55 +00:00
|
|
|
//===----------------------------------------------------------------------===//
|
2005-04-21 23:13:11 +00:00
|
|
|
//
|
2005-01-22 23:41:55 +00:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "Alpha.h"
|
2005-07-22 20:52:16 +00:00
|
|
|
#include "AlphaJITInfo.h"
|
2006-09-07 23:39:26 +00:00
|
|
|
#include "AlphaTargetAsmInfo.h"
|
2005-01-22 23:41:55 +00:00
|
|
|
#include "AlphaTargetMachine.h"
|
2005-02-01 20:35:11 +00:00
|
|
|
#include "llvm/Module.h"
|
2006-09-04 04:14:57 +00:00
|
|
|
#include "llvm/PassManager.h"
|
2005-01-22 23:41:55 +00:00
|
|
|
#include "llvm/Target/TargetMachineRegistry.h"
|
2008-08-21 00:14:44 +00:00
|
|
|
#include "llvm/Support/raw_ostream.h"
|
2005-02-01 20:35:11 +00:00
|
|
|
|
2005-01-22 23:41:55 +00:00
|
|
|
using namespace llvm;
|
|
|
|
|
2008-05-13 00:00:25 +00:00
|
|
|
// Register the targets
|
2008-10-16 06:16:50 +00:00
|
|
|
static RegisterTarget<AlphaTargetMachine> X("alpha", "Alpha [experimental]");
|
2005-01-22 23:41:55 +00:00
|
|
|
|
2009-06-19 19:36:55 +00:00
|
|
|
// No assembler printer by default
|
|
|
|
AlphaTargetMachine::AsmPrinterCtorFn AlphaTargetMachine::AsmPrinterCtor = 0;
|
|
|
|
|
2009-06-23 23:59:40 +00:00
|
|
|
// Force static initialization.
|
|
|
|
extern "C" void LLVMInitializeAlphaTarget() { }
|
2009-06-16 20:12:29 +00:00
|
|
|
|
2006-09-07 23:39:26 +00:00
|
|
|
const TargetAsmInfo *AlphaTargetMachine::createTargetAsmInfo() const {
|
|
|
|
return new AlphaTargetAsmInfo(*this);
|
|
|
|
}
|
|
|
|
|
2005-02-01 20:35:11 +00:00
|
|
|
unsigned AlphaTargetMachine::getModuleMatchQuality(const Module &M) {
|
|
|
|
// We strongly match "alpha*".
|
|
|
|
std::string TT = M.getTargetTriple();
|
|
|
|
if (TT.size() >= 5 && TT[0] == 'a' && TT[1] == 'l' && TT[2] == 'p' &&
|
|
|
|
TT[3] == 'h' && TT[4] == 'a')
|
|
|
|
return 20;
|
2007-07-09 17:25:29 +00:00
|
|
|
// If the target triple is something non-alpha, we don't match.
|
|
|
|
if (!TT.empty()) return 0;
|
2005-02-01 20:35:11 +00:00
|
|
|
|
|
|
|
if (M.getEndianness() == Module::LittleEndian &&
|
|
|
|
M.getPointerSize() == Module::Pointer64)
|
|
|
|
return 10; // Weak match
|
|
|
|
else if (M.getEndianness() != Module::AnyEndianness ||
|
|
|
|
M.getPointerSize() != Module::AnyPointerSize)
|
|
|
|
return 0; // Match for some other target
|
|
|
|
|
2005-10-30 16:44:01 +00:00
|
|
|
return getJITMatchQuality()/2;
|
2005-02-01 20:35:11 +00:00
|
|
|
}
|
|
|
|
|
2005-07-22 20:52:16 +00:00
|
|
|
unsigned AlphaTargetMachine::getJITMatchQuality() {
|
2005-07-22 21:00:30 +00:00
|
|
|
#ifdef __alpha
|
2005-07-22 20:52:16 +00:00
|
|
|
return 10;
|
|
|
|
#else
|
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2006-03-23 05:43:16 +00:00
|
|
|
AlphaTargetMachine::AlphaTargetMachine(const Module &M, const std::string &FS)
|
2007-08-03 20:20:50 +00:00
|
|
|
: DataLayout("e-f128:128:128"),
|
2005-08-03 22:33:21 +00:00
|
|
|
FrameInfo(TargetFrameInfo::StackGrowsDown, 16, 0),
|
2005-09-29 22:54:56 +00:00
|
|
|
JITInfo(*this),
|
2006-10-11 04:29:42 +00:00
|
|
|
Subtarget(M, FS),
|
|
|
|
TLInfo(*this) {
|
2006-09-24 19:46:56 +00:00
|
|
|
setRelocationModel(Reloc::PIC_);
|
2005-09-29 22:54:56 +00:00
|
|
|
}
|
2005-01-22 23:41:55 +00:00
|
|
|
|
2005-04-21 23:13:11 +00:00
|
|
|
|
2006-09-04 04:14:57 +00:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Pass Pipeline Configuration
|
|
|
|
//===----------------------------------------------------------------------===//
|
2005-01-22 23:41:55 +00:00
|
|
|
|
2009-04-29 00:15:41 +00:00
|
|
|
bool AlphaTargetMachine::addInstSelector(PassManagerBase &PM,
|
2009-04-29 23:29:43 +00:00
|
|
|
CodeGenOpt::Level OptLevel) {
|
2006-01-23 21:56:07 +00:00
|
|
|
PM.add(createAlphaISelDag(*this));
|
2005-01-22 23:41:55 +00:00
|
|
|
return false;
|
|
|
|
}
|
2009-04-29 00:15:41 +00:00
|
|
|
bool AlphaTargetMachine::addPreEmitPass(PassManagerBase &PM,
|
2009-04-29 23:29:43 +00:00
|
|
|
CodeGenOpt::Level OptLevel) {
|
2005-07-22 20:52:16 +00:00
|
|
|
// Must run branch selection immediately preceding the asm printer
|
2006-10-31 16:49:55 +00:00
|
|
|
PM.add(createAlphaBranchSelectionPass());
|
2006-09-04 04:14:57 +00:00
|
|
|
return false;
|
2005-07-22 20:52:16 +00:00
|
|
|
}
|
2009-04-29 00:15:41 +00:00
|
|
|
bool AlphaTargetMachine::addAssemblyEmitter(PassManagerBase &PM,
|
2009-04-29 23:29:43 +00:00
|
|
|
CodeGenOpt::Level OptLevel,
|
2009-03-25 01:47:28 +00:00
|
|
|
bool Verbose,
|
2008-08-21 00:14:44 +00:00
|
|
|
raw_ostream &Out) {
|
2006-09-18 19:44:29 +00:00
|
|
|
PM.add(createAlphaLLRPPass(*this));
|
2009-06-19 19:36:55 +00:00
|
|
|
// Output assembly language.
|
|
|
|
assert(AsmPrinterCtor && "AsmPrinter was not linked in");
|
|
|
|
if (AsmPrinterCtor)
|
2009-07-01 01:48:54 +00:00
|
|
|
PM.add(AsmPrinterCtor(Out, *this, Verbose));
|
2006-09-04 04:14:57 +00:00
|
|
|
return false;
|
|
|
|
}
|
2009-04-29 23:29:43 +00:00
|
|
|
bool AlphaTargetMachine::addCodeEmitter(PassManagerBase &PM,
|
|
|
|
CodeGenOpt::Level OptLevel,
|
2007-07-20 21:56:13 +00:00
|
|
|
bool DumpAsm, MachineCodeEmitter &MCE) {
|
2006-07-25 20:40:54 +00:00
|
|
|
PM.add(createAlphaCodeEmitterPass(*this, MCE));
|
2009-06-19 19:36:55 +00:00
|
|
|
if (DumpAsm) {
|
|
|
|
assert(AsmPrinterCtor && "AsmPrinter was not linked in");
|
|
|
|
if (AsmPrinterCtor)
|
2009-07-01 01:48:54 +00:00
|
|
|
PM.add(AsmPrinterCtor(errs(), *this, true));
|
2009-06-19 19:36:55 +00:00
|
|
|
}
|
2005-07-22 20:52:16 +00:00
|
|
|
return false;
|
|
|
|
}
|
2009-05-30 20:51:52 +00:00
|
|
|
bool AlphaTargetMachine::addCodeEmitter(PassManagerBase &PM,
|
|
|
|
CodeGenOpt::Level OptLevel,
|
|
|
|
bool DumpAsm, JITCodeEmitter &JCE) {
|
|
|
|
PM.add(createAlphaJITCodeEmitterPass(*this, JCE));
|
2009-06-19 19:36:55 +00:00
|
|
|
if (DumpAsm) {
|
|
|
|
assert(AsmPrinterCtor && "AsmPrinter was not linked in");
|
|
|
|
if (AsmPrinterCtor)
|
2009-07-01 01:48:54 +00:00
|
|
|
PM.add(AsmPrinterCtor(errs(), *this, true));
|
2009-06-19 19:36:55 +00:00
|
|
|
}
|
2009-05-30 20:51:52 +00:00
|
|
|
return false;
|
|
|
|
}
|
2008-03-11 22:29:46 +00:00
|
|
|
bool AlphaTargetMachine::addSimpleCodeEmitter(PassManagerBase &PM,
|
2009-04-29 23:29:43 +00:00
|
|
|
CodeGenOpt::Level OptLevel,
|
|
|
|
bool DumpAsm,
|
2007-02-08 01:38:33 +00:00
|
|
|
MachineCodeEmitter &MCE) {
|
2009-04-29 00:15:41 +00:00
|
|
|
return addCodeEmitter(PM, OptLevel, DumpAsm, MCE);
|
2007-02-08 01:38:33 +00:00
|
|
|
}
|
2009-05-30 20:51:52 +00:00
|
|
|
bool AlphaTargetMachine::addSimpleCodeEmitter(PassManagerBase &PM,
|
|
|
|
CodeGenOpt::Level OptLevel,
|
|
|
|
bool DumpAsm,
|
|
|
|
JITCodeEmitter &JCE) {
|
|
|
|
return addCodeEmitter(PM, OptLevel, DumpAsm, JCE);
|
|
|
|
}
|
|
|
|
|