blob: bf7f22145f51da2d6abb96bd9f25a4be5152589f [file] [log] [blame]
Andrew Lenharth3c127722005-01-24 18:45:41 +00001//===-- AlphaTargetMachine.cpp - Define TargetMachine for Alpha -----------===//
Misha Brukman89b8c8d2005-04-21 23:13:11 +00002//
Andrew Lenhartha1b5ca22005-01-22 23:41:55 +00003// The LLVM Compiler Infrastructure
4//
5// This file was developed by the LLVM research group and is distributed under
6// the University of Illinois Open Source License. See LICENSE.TXT for details.
Misha Brukman89b8c8d2005-04-21 23:13:11 +00007//
Andrew Lenhartha1b5ca22005-01-22 23:41:55 +00008//===----------------------------------------------------------------------===//
Misha Brukman89b8c8d2005-04-21 23:13:11 +00009//
Andrew Lenhartha1b5ca22005-01-22 23:41:55 +000010//
11//===----------------------------------------------------------------------===//
12
13#include "Alpha.h"
Andrew Lenharth55d04512005-07-22 20:52:16 +000014#include "AlphaJITInfo.h"
Jim Laskeyae92ce82006-09-07 23:39:26 +000015#include "AlphaTargetAsmInfo.h"
Andrew Lenhartha1b5ca22005-01-22 23:41:55 +000016#include "AlphaTargetMachine.h"
Andrew Lenharth8fb0d502005-02-01 20:35:11 +000017#include "llvm/Module.h"
Chris Lattner12e97302006-09-04 04:14:57 +000018#include "llvm/PassManager.h"
Andrew Lenhartha1b5ca22005-01-22 23:41:55 +000019#include "llvm/Target/TargetMachineRegistry.h"
Andrew Lenharth8fb0d502005-02-01 20:35:11 +000020
Andrew Lenhartha1b5ca22005-01-22 23:41:55 +000021using namespace llvm;
22
23namespace {
24 // Register the targets
25 RegisterTarget<AlphaTargetMachine> X("alpha", " Alpha (incomplete)");
26}
27
Jim Laskeyae92ce82006-09-07 23:39:26 +000028const TargetAsmInfo *AlphaTargetMachine::createTargetAsmInfo() const {
29 return new AlphaTargetAsmInfo(*this);
30}
31
Andrew Lenharth8fb0d502005-02-01 20:35:11 +000032unsigned AlphaTargetMachine::getModuleMatchQuality(const Module &M) {
33 // We strongly match "alpha*".
34 std::string TT = M.getTargetTriple();
35 if (TT.size() >= 5 && TT[0] == 'a' && TT[1] == 'l' && TT[2] == 'p' &&
36 TT[3] == 'h' && TT[4] == 'a')
37 return 20;
38
39 if (M.getEndianness() == Module::LittleEndian &&
40 M.getPointerSize() == Module::Pointer64)
41 return 10; // Weak match
42 else if (M.getEndianness() != Module::AnyEndianness ||
43 M.getPointerSize() != Module::AnyPointerSize)
44 return 0; // Match for some other target
45
Chris Lattner5c7d7312005-10-30 16:44:01 +000046 return getJITMatchQuality()/2;
Andrew Lenharth8fb0d502005-02-01 20:35:11 +000047}
48
Andrew Lenharth55d04512005-07-22 20:52:16 +000049unsigned AlphaTargetMachine::getJITMatchQuality() {
Andrew Lenharthc32843e2005-07-22 21:00:30 +000050#ifdef __alpha
Andrew Lenharth55d04512005-07-22 20:52:16 +000051 return 10;
52#else
53 return 0;
54#endif
55}
56
Chris Lattner6f95ab72006-03-23 05:43:16 +000057AlphaTargetMachine::AlphaTargetMachine(const Module &M, const std::string &FS)
Chris Lattner0fc45412006-09-03 18:44:02 +000058 : DataLayout("e"),
Andrew Lenharth3a18a392005-08-03 22:33:21 +000059 FrameInfo(TargetFrameInfo::StackGrowsDown, 16, 0),
Andrew Lenhartha7a83b92005-09-29 22:54:56 +000060 JITInfo(*this),
Andrew Lenhartha6bbf332006-10-11 04:29:42 +000061 Subtarget(M, FS),
62 TLInfo(*this) {
Andrew Lenharth5e2bacd2006-09-24 19:46:56 +000063 setRelocationModel(Reloc::PIC_);
Andrew Lenhartha7a83b92005-09-29 22:54:56 +000064}
Andrew Lenhartha1b5ca22005-01-22 23:41:55 +000065
Misha Brukman89b8c8d2005-04-21 23:13:11 +000066
Chris Lattner12e97302006-09-04 04:14:57 +000067//===----------------------------------------------------------------------===//
68// Pass Pipeline Configuration
69//===----------------------------------------------------------------------===//
Andrew Lenharthed4b6482005-03-02 17:21:38 +000070
Chris Lattner12e97302006-09-04 04:14:57 +000071bool AlphaTargetMachine::addInstSelector(FunctionPassManager &PM, bool Fast) {
Andrew Lenharthc0bf3772006-01-23 21:56:07 +000072 PM.add(createAlphaISelDag(*this));
Andrew Lenhartha1b5ca22005-01-22 23:41:55 +000073 return false;
74}
Chris Lattner12e97302006-09-04 04:14:57 +000075bool AlphaTargetMachine::addPreEmitPass(FunctionPassManager &PM, bool Fast) {
Andrew Lenharth55d04512005-07-22 20:52:16 +000076 // Must run branch selection immediately preceding the asm printer
Andrew Lenharth692e4152006-10-31 16:49:55 +000077 PM.add(createAlphaBranchSelectionPass());
Chris Lattner12e97302006-09-04 04:14:57 +000078 return false;
Andrew Lenharth55d04512005-07-22 20:52:16 +000079}
Chris Lattner12e97302006-09-04 04:14:57 +000080bool AlphaTargetMachine::addAssemblyEmitter(FunctionPassManager &PM, bool Fast,
81 std::ostream &Out) {
Andrew Lenharthf23e3bf2006-09-18 19:44:29 +000082 PM.add(createAlphaLLRPPass(*this));
Chris Lattner12e97302006-09-04 04:14:57 +000083 PM.add(createAlphaCodePrinterPass(Out, *this));
84 return false;
85}
86bool AlphaTargetMachine::addCodeEmitter(FunctionPassManager &PM, bool Fast,
87 MachineCodeEmitter &MCE) {
Evan Chengf6acb342006-07-25 20:40:54 +000088 PM.add(createAlphaCodeEmitterPass(*this, MCE));
Andrew Lenharth55d04512005-07-22 20:52:16 +000089 return false;
90}
Bill Wendling59889ae2007-02-08 01:38:33 +000091bool AlphaTargetMachine::addSimpleCodeEmitter(FunctionPassManager &PM,
92 bool Fast,
93 MachineCodeEmitter &MCE) {
94 return addCodeEmitter(PM, Fast, MCE);
95}