2005-01-24 19:45:41 +01:00
|
|
|
//===-- AlphaTargetMachine.cpp - Define TargetMachine for Alpha -----------===//
|
2005-04-22 01:13:11 +02:00
|
|
|
//
|
2005-01-23 00:41:55 +01:00
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file was developed by the LLVM research group and is distributed under
|
|
|
|
// the University of Illinois Open Source License. See LICENSE.TXT for details.
|
2005-04-22 01:13:11 +02:00
|
|
|
//
|
2005-01-23 00:41:55 +01:00
|
|
|
//===----------------------------------------------------------------------===//
|
2005-04-22 01:13:11 +02:00
|
|
|
//
|
2005-01-23 00:41:55 +01:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "Alpha.h"
|
2005-07-22 22:52:16 +02:00
|
|
|
#include "AlphaJITInfo.h"
|
2006-09-08 01:39:26 +02:00
|
|
|
#include "AlphaTargetAsmInfo.h"
|
2005-01-23 00:41:55 +01:00
|
|
|
#include "AlphaTargetMachine.h"
|
2005-02-01 21:35:11 +01:00
|
|
|
#include "llvm/Module.h"
|
2006-09-04 06:14:57 +02:00
|
|
|
#include "llvm/PassManager.h"
|
2005-01-23 00:41:55 +01:00
|
|
|
#include "llvm/Target/TargetMachineRegistry.h"
|
2005-02-01 21:35:11 +01:00
|
|
|
|
2005-01-23 00:41:55 +01:00
|
|
|
using namespace llvm;
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
// Register the targets
|
|
|
|
RegisterTarget<AlphaTargetMachine> X("alpha", " Alpha (incomplete)");
|
|
|
|
}
|
|
|
|
|
2006-09-08 01:39:26 +02:00
|
|
|
const TargetAsmInfo *AlphaTargetMachine::createTargetAsmInfo() const {
|
|
|
|
return new AlphaTargetAsmInfo(*this);
|
|
|
|
}
|
|
|
|
|
2005-02-01 21:35:11 +01: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;
|
|
|
|
|
|
|
|
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 17:44:01 +01:00
|
|
|
return getJITMatchQuality()/2;
|
2005-02-01 21:35:11 +01:00
|
|
|
}
|
|
|
|
|
2005-07-22 22:52:16 +02:00
|
|
|
unsigned AlphaTargetMachine::getJITMatchQuality() {
|
2005-07-22 23:00:30 +02:00
|
|
|
#ifdef __alpha
|
2005-07-22 22:52:16 +02:00
|
|
|
return 10;
|
|
|
|
#else
|
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2006-03-23 06:43:16 +01:00
|
|
|
AlphaTargetMachine::AlphaTargetMachine(const Module &M, const std::string &FS)
|
2006-09-03 20:44:02 +02:00
|
|
|
: DataLayout("e"),
|
2005-08-04 00:33:21 +02:00
|
|
|
FrameInfo(TargetFrameInfo::StackGrowsDown, 16, 0),
|
2005-09-30 00:54:56 +02:00
|
|
|
JITInfo(*this),
|
2006-10-11 06:29:42 +02:00
|
|
|
Subtarget(M, FS),
|
|
|
|
TLInfo(*this) {
|
2006-09-24 21:46:56 +02:00
|
|
|
setRelocationModel(Reloc::PIC_);
|
2005-09-30 00:54:56 +02:00
|
|
|
}
|
2005-01-23 00:41:55 +01:00
|
|
|
|
2005-04-22 01:13:11 +02:00
|
|
|
|
2006-09-04 06:14:57 +02:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Pass Pipeline Configuration
|
|
|
|
//===----------------------------------------------------------------------===//
|
2005-01-23 00:41:55 +01:00
|
|
|
|
2006-09-04 06:14:57 +02:00
|
|
|
bool AlphaTargetMachine::addInstSelector(FunctionPassManager &PM, bool Fast) {
|
2006-01-23 22:56:07 +01:00
|
|
|
PM.add(createAlphaISelDag(*this));
|
2005-01-23 00:41:55 +01:00
|
|
|
return false;
|
|
|
|
}
|
2006-09-04 06:14:57 +02:00
|
|
|
bool AlphaTargetMachine::addPreEmitPass(FunctionPassManager &PM, bool Fast) {
|
2005-07-22 22:52:16 +02:00
|
|
|
// Must run branch selection immediately preceding the asm printer
|
2006-10-31 17:49:55 +01:00
|
|
|
PM.add(createAlphaBranchSelectionPass());
|
2006-09-04 06:14:57 +02:00
|
|
|
return false;
|
2005-07-22 22:52:16 +02:00
|
|
|
}
|
2006-09-04 06:14:57 +02:00
|
|
|
bool AlphaTargetMachine::addAssemblyEmitter(FunctionPassManager &PM, bool Fast,
|
|
|
|
std::ostream &Out) {
|
2006-09-18 21:44:29 +02:00
|
|
|
PM.add(createAlphaLLRPPass(*this));
|
2006-09-04 06:14:57 +02:00
|
|
|
PM.add(createAlphaCodePrinterPass(Out, *this));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool AlphaTargetMachine::addCodeEmitter(FunctionPassManager &PM, bool Fast,
|
|
|
|
MachineCodeEmitter &MCE) {
|
2006-07-25 22:40:54 +02:00
|
|
|
PM.add(createAlphaCodeEmitterPass(*this, MCE));
|
2005-07-22 22:52:16 +02:00
|
|
|
return false;
|
|
|
|
}
|