Clean up the use of static and anonymous namespaces. This turned up
[oota-llvm.git] / lib / Target / Alpha / AlphaTargetMachine.cpp
1 //===-- AlphaTargetMachine.cpp - Define TargetMachine for Alpha -----------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 //
11 //===----------------------------------------------------------------------===//
12
13 #include "Alpha.h"
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"
20
21 using namespace llvm;
22
23 // Register the targets
24 static RegisterTarget<AlphaTargetMachine> X("alpha", "  Alpha (incomplete)");
25
26 const TargetAsmInfo *AlphaTargetMachine::createTargetAsmInfo() const {
27   return new AlphaTargetAsmInfo(*this);
28 }
29
30 unsigned AlphaTargetMachine::getModuleMatchQuality(const Module &M) {
31   // We strongly match "alpha*".
32   std::string TT = M.getTargetTriple();
33   if (TT.size() >= 5 && TT[0] == 'a' && TT[1] == 'l' && TT[2] == 'p' &&
34       TT[3] == 'h' && TT[4] == 'a')
35     return 20;
36   // If the target triple is something non-alpha, we don't match.
37   if (!TT.empty()) return 0;
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
46   return getJITMatchQuality()/2;
47 }
48
49 unsigned AlphaTargetMachine::getJITMatchQuality() {
50 #ifdef __alpha
51   return 10;
52 #else
53   return 0;
54 #endif
55 }
56
57 AlphaTargetMachine::AlphaTargetMachine(const Module &M, const std::string &FS)
58   : DataLayout("e-f128:128:128"),
59     FrameInfo(TargetFrameInfo::StackGrowsDown, 16, 0),
60     JITInfo(*this),
61     Subtarget(M, FS),
62     TLInfo(*this) {
63   setRelocationModel(Reloc::PIC_);
64 }
65
66
67 //===----------------------------------------------------------------------===//
68 // Pass Pipeline Configuration
69 //===----------------------------------------------------------------------===//
70
71 bool AlphaTargetMachine::addInstSelector(PassManagerBase &PM, bool Fast) {
72   PM.add(createAlphaISelDag(*this));
73   return false;
74 }
75 bool AlphaTargetMachine::addPreEmitPass(PassManagerBase &PM, bool Fast) {
76   // Must run branch selection immediately preceding the asm printer
77   PM.add(createAlphaBranchSelectionPass());
78   return false;
79 }
80 bool AlphaTargetMachine::addAssemblyEmitter(PassManagerBase &PM, bool Fast, 
81                                             std::ostream &Out) {
82   PM.add(createAlphaLLRPPass(*this));
83   PM.add(createAlphaCodePrinterPass(Out, *this));
84   return false;
85 }
86 bool AlphaTargetMachine::addCodeEmitter(PassManagerBase &PM, bool Fast,
87                                         bool DumpAsm, MachineCodeEmitter &MCE) {
88   PM.add(createAlphaCodeEmitterPass(*this, MCE));
89   if (DumpAsm)
90     PM.add(createAlphaCodePrinterPass(*cerr.stream(), *this));
91   return false;
92 }
93 bool AlphaTargetMachine::addSimpleCodeEmitter(PassManagerBase &PM,
94                                               bool Fast, bool DumpAsm,
95                                               MachineCodeEmitter &MCE) {
96   return addCodeEmitter(PM, Fast, DumpAsm, MCE);
97 }