1 //===-- AlphaTargetMachine.cpp - Define TargetMachine for Alpha -----------===//
3 // The LLVM Compiler Infrastructure
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.
8 //===----------------------------------------------------------------------===//
11 //===----------------------------------------------------------------------===//
14 #include "AlphaJITInfo.h"
15 #include "AlphaTargetAsmInfo.h"
16 #include "AlphaTargetMachine.h"
17 #include "llvm/Module.h"
18 #include "llvm/PassManager.h"
19 #include "llvm/Target/TargetMachineRegistry.h"
24 // Register the targets
25 RegisterTarget<AlphaTargetMachine> X("alpha", " Alpha (incomplete)");
28 const TargetAsmInfo *AlphaTargetMachine::createTargetAsmInfo() const {
29 return new AlphaTargetAsmInfo(*this);
32 unsigned 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')
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
46 return getJITMatchQuality()/2;
49 unsigned AlphaTargetMachine::getJITMatchQuality() {
57 AlphaTargetMachine::AlphaTargetMachine(const Module &M, const std::string &FS)
59 FrameInfo(TargetFrameInfo::StackGrowsDown, 16, 0),
63 setRelocationModel(Reloc::PIC_);
67 //===----------------------------------------------------------------------===//
68 // Pass Pipeline Configuration
69 //===----------------------------------------------------------------------===//
71 bool AlphaTargetMachine::addInstSelector(FunctionPassManager &PM, bool Fast) {
72 PM.add(createAlphaISelDag(*this));
75 bool AlphaTargetMachine::addPreEmitPass(FunctionPassManager &PM, bool Fast) {
76 // Must run branch selection immediately preceding the asm printer
77 PM.add(createAlphaBranchSelectionPass());
80 bool AlphaTargetMachine::addAssemblyEmitter(FunctionPassManager &PM, bool Fast,
82 PM.add(createAlphaLLRPPass(*this));
83 PM.add(createAlphaCodePrinterPass(Out, *this));
86 bool AlphaTargetMachine::addCodeEmitter(FunctionPassManager &PM, bool Fast,
87 MachineCodeEmitter &MCE) {
88 PM.add(createAlphaCodeEmitterPass(*this, MCE));
91 bool AlphaTargetMachine::addSimpleCodeEmitter(FunctionPassManager &PM,
93 MachineCodeEmitter &MCE) {
94 return addCodeEmitter(PM, Fast, MCE);