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"
|
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
|
|
|
|
static RegisterTarget<AlphaTargetMachine> X("alpha", " Alpha (incomplete)");
|
2005-01-22 23:41:55 +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
|
|
|
|
2008-03-11 22:29:46 +00:00
|
|
|
bool AlphaTargetMachine::addInstSelector(PassManagerBase &PM, bool Fast) {
|
2006-01-23 21:56:07 +00:00
|
|
|
PM.add(createAlphaISelDag(*this));
|
2005-01-22 23:41:55 +00:00
|
|
|
return false;
|
|
|
|
}
|
2008-03-11 22:29:46 +00:00
|
|
|
bool AlphaTargetMachine::addPreEmitPass(PassManagerBase &PM, bool Fast) {
|
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
|
|
|
}
|
2008-03-11 22:29:46 +00:00
|
|
|
bool AlphaTargetMachine::addAssemblyEmitter(PassManagerBase &PM, bool Fast,
|
2006-09-04 04:14:57 +00:00
|
|
|
std::ostream &Out) {
|
2006-09-18 19:44:29 +00:00
|
|
|
PM.add(createAlphaLLRPPass(*this));
|
2006-09-04 04:14:57 +00:00
|
|
|
PM.add(createAlphaCodePrinterPass(Out, *this));
|
|
|
|
return false;
|
|
|
|
}
|
2008-03-11 22:29:46 +00:00
|
|
|
bool AlphaTargetMachine::addCodeEmitter(PassManagerBase &PM, bool Fast,
|
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));
|
2007-07-20 21:56:13 +00:00
|
|
|
if (DumpAsm)
|
|
|
|
PM.add(createAlphaCodePrinterPass(*cerr.stream(), *this));
|
2005-07-22 20:52:16 +00:00
|
|
|
return false;
|
|
|
|
}
|
2008-03-11 22:29:46 +00:00
|
|
|
bool AlphaTargetMachine::addSimpleCodeEmitter(PassManagerBase &PM,
|
2007-07-20 21:56:13 +00:00
|
|
|
bool Fast, bool DumpAsm,
|
2007-02-08 01:38:33 +00:00
|
|
|
MachineCodeEmitter &MCE) {
|
2007-07-20 21:56:13 +00:00
|
|
|
return addCodeEmitter(PM, Fast, DumpAsm, MCE);
|
2007-02-08 01:38:33 +00:00
|
|
|
}
|