blob: bb140dca9232fbca7ac709c0da60ad6c855e9ebf [file] [log] [blame]
Andrew Lenharth886470e2005-01-24 18:45:41 +00001//===-- AlphaTargetMachine.cpp - Define TargetMachine for Alpha -----------===//
Misha Brukman4633f1c2005-04-21 23:13:11 +00002//
Andrew Lenharth304d0f32005-01-22 23:41:55 +00003// The LLVM Compiler Infrastructure
4//
Chris Lattner4ee451d2007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Misha Brukman4633f1c2005-04-21 23:13:11 +00007//
Andrew Lenharth304d0f32005-01-22 23:41:55 +00008//===----------------------------------------------------------------------===//
Misha Brukman4633f1c2005-04-21 23:13:11 +00009//
Andrew Lenharth304d0f32005-01-22 23:41:55 +000010//
11//===----------------------------------------------------------------------===//
12
13#include "Alpha.h"
Andrew Lenharth0934ae02005-07-22 20:52:16 +000014#include "AlphaJITInfo.h"
Jim Laskeyfde1b3b2006-09-07 23:39:26 +000015#include "AlphaTargetAsmInfo.h"
Andrew Lenharth304d0f32005-01-22 23:41:55 +000016#include "AlphaTargetMachine.h"
Chris Lattner1911fd42006-09-04 04:14:57 +000017#include "llvm/PassManager.h"
David Greene71847812009-07-14 20:18:05 +000018#include "llvm/Support/FormattedStream.h"
Daniel Dunbar0c795d62009-07-25 06:49:55 +000019#include "llvm/Target/TargetRegistry.h"
Andrew Lenharth2f401632005-02-01 20:35:11 +000020
Andrew Lenharth304d0f32005-01-22 23:41:55 +000021using namespace llvm;
22
Daniel Dunbar0c795d62009-07-25 06:49:55 +000023extern "C" void LLVMInitializeAlphaTarget() {
24 // Register the target.
25 RegisterTargetMachine<AlphaTargetMachine> X(TheAlphaTarget);
26}
Douglas Gregor1555a232009-06-16 20:12:29 +000027
Jim Laskeyfde1b3b2006-09-07 23:39:26 +000028const TargetAsmInfo *AlphaTargetMachine::createTargetAsmInfo() const {
Chris Lattnerf67de7a2009-08-02 04:46:05 +000029 return new AlphaTargetAsmInfo();
Jim Laskeyfde1b3b2006-09-07 23:39:26 +000030}
31
Daniel Dunbare28039c2009-08-02 23:37:13 +000032AlphaTargetMachine::AlphaTargetMachine(const Target &T, const std::string &TT,
Daniel Dunbar51b198a2009-07-15 20:24:03 +000033 const std::string &FS)
Chris Lattner0a31d2f2009-08-11 20:42:37 +000034 : LLVMTargetMachine(T, TT),
Daniel Dunbar51b198a2009-07-15 20:24:03 +000035 DataLayout("e-f128:128:128"),
Andrew Lenharthdc7c0b82005-08-03 22:33:21 +000036 FrameInfo(TargetFrameInfo::StackGrowsDown, 16, 0),
Andrew Lenharth120ab482005-09-29 22:54:56 +000037 JITInfo(*this),
Daniel Dunbare28039c2009-08-02 23:37:13 +000038 Subtarget(TT, FS),
Andrew Lenharth82c3d8f2006-10-11 04:29:42 +000039 TLInfo(*this) {
Andrew Lenharth0607a2f2006-09-24 19:46:56 +000040 setRelocationModel(Reloc::PIC_);
Andrew Lenharth120ab482005-09-29 22:54:56 +000041}
Andrew Lenharth304d0f32005-01-22 23:41:55 +000042
Misha Brukman4633f1c2005-04-21 23:13:11 +000043
Chris Lattner1911fd42006-09-04 04:14:57 +000044//===----------------------------------------------------------------------===//
45// Pass Pipeline Configuration
46//===----------------------------------------------------------------------===//
Andrew Lenharthe4f161c2005-03-02 17:21:38 +000047
Bill Wendlingbe8cc2a2009-04-29 00:15:41 +000048bool AlphaTargetMachine::addInstSelector(PassManagerBase &PM,
Bill Wendling98a366d2009-04-29 23:29:43 +000049 CodeGenOpt::Level OptLevel) {
Andrew Lenharthfabd5ba2006-01-23 21:56:07 +000050 PM.add(createAlphaISelDag(*this));
Andrew Lenharth304d0f32005-01-22 23:41:55 +000051 return false;
52}
Bill Wendlingbe8cc2a2009-04-29 00:15:41 +000053bool AlphaTargetMachine::addPreEmitPass(PassManagerBase &PM,
Bill Wendling98a366d2009-04-29 23:29:43 +000054 CodeGenOpt::Level OptLevel) {
Andrew Lenharth0934ae02005-07-22 20:52:16 +000055 // Must run branch selection immediately preceding the asm printer
Andrew Lenharthf81173f2006-10-31 16:49:55 +000056 PM.add(createAlphaBranchSelectionPass());
Chris Lattner7add5ff2009-07-15 21:40:24 +000057 PM.add(createAlphaLLRPPass(*this));
Chris Lattner1911fd42006-09-04 04:14:57 +000058 return false;
Andrew Lenharth0934ae02005-07-22 20:52:16 +000059}
Bill Wendling98a366d2009-04-29 23:29:43 +000060bool AlphaTargetMachine::addCodeEmitter(PassManagerBase &PM,
61 CodeGenOpt::Level OptLevel,
Daniel Dunbarcfe9a602009-07-15 22:33:19 +000062 MachineCodeEmitter &MCE) {
Evan Cheng55fc2802006-07-25 20:40:54 +000063 PM.add(createAlphaCodeEmitterPass(*this, MCE));
Andrew Lenharth0934ae02005-07-22 20:52:16 +000064 return false;
65}
Bruno Cardoso Lopesa3f99f92009-05-30 20:51:52 +000066bool AlphaTargetMachine::addCodeEmitter(PassManagerBase &PM,
67 CodeGenOpt::Level OptLevel,
Daniel Dunbarcfe9a602009-07-15 22:33:19 +000068 JITCodeEmitter &JCE) {
Bruno Cardoso Lopesa3f99f92009-05-30 20:51:52 +000069 PM.add(createAlphaJITCodeEmitterPass(*this, JCE));
Bruno Cardoso Lopesa3f99f92009-05-30 20:51:52 +000070 return false;
71}
Bruno Cardoso Lopesac57e6e2009-07-06 05:09:34 +000072bool AlphaTargetMachine::addCodeEmitter(PassManagerBase &PM,
73 CodeGenOpt::Level OptLevel,
Daniel Dunbarcfe9a602009-07-15 22:33:19 +000074 ObjectCodeEmitter &OCE) {
Bruno Cardoso Lopesac57e6e2009-07-06 05:09:34 +000075 PM.add(createAlphaObjectCodeEmitterPass(*this, OCE));
Bruno Cardoso Lopesac57e6e2009-07-06 05:09:34 +000076 return false;
77}
Dan Gohmanbfae8312008-03-11 22:29:46 +000078bool AlphaTargetMachine::addSimpleCodeEmitter(PassManagerBase &PM,
Bill Wendling98a366d2009-04-29 23:29:43 +000079 CodeGenOpt::Level OptLevel,
Bill Wendling50e4e882007-02-08 01:38:33 +000080 MachineCodeEmitter &MCE) {
Daniel Dunbarcfe9a602009-07-15 22:33:19 +000081 return addCodeEmitter(PM, OptLevel, MCE);
Bill Wendling50e4e882007-02-08 01:38:33 +000082}
Bruno Cardoso Lopesa3f99f92009-05-30 20:51:52 +000083bool AlphaTargetMachine::addSimpleCodeEmitter(PassManagerBase &PM,
84 CodeGenOpt::Level OptLevel,
Bruno Cardoso Lopesa3f99f92009-05-30 20:51:52 +000085 JITCodeEmitter &JCE) {
Daniel Dunbarcfe9a602009-07-15 22:33:19 +000086 return addCodeEmitter(PM, OptLevel, JCE);
Bruno Cardoso Lopesa3f99f92009-05-30 20:51:52 +000087}
Bruno Cardoso Lopesac57e6e2009-07-06 05:09:34 +000088bool AlphaTargetMachine::addSimpleCodeEmitter(PassManagerBase &PM,
89 CodeGenOpt::Level OptLevel,
Bruno Cardoso Lopesac57e6e2009-07-06 05:09:34 +000090 ObjectCodeEmitter &OCE) {
Daniel Dunbarcfe9a602009-07-15 22:33:19 +000091 return addCodeEmitter(PM, OptLevel, OCE);
Bruno Cardoso Lopesac57e6e2009-07-06 05:09:34 +000092}
Bruno Cardoso Lopesa3f99f92009-05-30 20:51:52 +000093