blob: a1aab94d9a9a3e3561c89cff8ba72586b0ad9401 [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),
Jim Laskeyae92ce82006-09-07 23:39:26 +000061 Subtarget(M, FS) {
Andrew Lenharth5e2bacd2006-09-24 19:46:56 +000062 setRelocationModel(Reloc::PIC_);
Andrew Lenhartha7a83b92005-09-29 22:54:56 +000063}
Andrew Lenhartha1b5ca22005-01-22 23:41:55 +000064
Misha Brukman89b8c8d2005-04-21 23:13:11 +000065
Chris Lattner12e97302006-09-04 04:14:57 +000066//===----------------------------------------------------------------------===//
67// Pass Pipeline Configuration
68//===----------------------------------------------------------------------===//
Andrew Lenharthed4b6482005-03-02 17:21:38 +000069
Chris Lattner12e97302006-09-04 04:14:57 +000070bool AlphaTargetMachine::addInstSelector(FunctionPassManager &PM, bool Fast) {
Andrew Lenharthc0bf3772006-01-23 21:56:07 +000071 PM.add(createAlphaISelDag(*this));
Andrew Lenhartha1b5ca22005-01-22 23:41:55 +000072 return false;
73}
Chris Lattner12e97302006-09-04 04:14:57 +000074bool AlphaTargetMachine::addPreEmitPass(FunctionPassManager &PM, bool Fast) {
Andrew Lenharth55d04512005-07-22 20:52:16 +000075 // Must run branch selection immediately preceding the asm printer
76 //PM.add(createAlphaBranchSelectionPass());
Chris Lattner12e97302006-09-04 04:14:57 +000077 return false;
Andrew Lenharth55d04512005-07-22 20:52:16 +000078}
Chris Lattner12e97302006-09-04 04:14:57 +000079bool AlphaTargetMachine::addAssemblyEmitter(FunctionPassManager &PM, bool Fast,
80 std::ostream &Out) {
Andrew Lenharthf23e3bf2006-09-18 19:44:29 +000081 PM.add(createAlphaLLRPPass(*this));
Chris Lattner12e97302006-09-04 04:14:57 +000082 PM.add(createAlphaCodePrinterPass(Out, *this));
83 return false;
84}
85bool AlphaTargetMachine::addCodeEmitter(FunctionPassManager &PM, bool Fast,
86 MachineCodeEmitter &MCE) {
Evan Chengf6acb342006-07-25 20:40:54 +000087 PM.add(createAlphaCodeEmitterPass(*this, MCE));
Andrew Lenharth55d04512005-07-22 20:52:16 +000088 return false;
89}