blob: b077f0744811a35b4c2fe7eb64df1c84f223d931 [file] [log] [blame]
Andrew Lenharth886470e2005-01-24 18:45:41 +00001//===-- AlphaTargetMachine.cpp - Define TargetMachine for Alpha -----------===//
Andrew Lenharth304d0f32005-01-22 23:41:55 +00002//
3// 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.
7//
8//===----------------------------------------------------------------------===//
9//
10//
11//===----------------------------------------------------------------------===//
12
13#include "Alpha.h"
14#include "AlphaTargetMachine.h"
Andrew Lenharth2f401632005-02-01 20:35:11 +000015#include "llvm/Module.h"
Andrew Lenharth304d0f32005-01-22 23:41:55 +000016#include "llvm/CodeGen/Passes.h"
17#include "llvm/Target/TargetOptions.h"
18#include "llvm/Target/TargetMachineRegistry.h"
19#include "llvm/Transforms/Scalar.h"
Andrew Lenharth304d0f32005-01-22 23:41:55 +000020#include <iostream>
Andrew Lenharth2f401632005-02-01 20:35:11 +000021
Andrew Lenharth304d0f32005-01-22 23:41:55 +000022using namespace llvm;
23
24namespace {
25 // Register the targets
26 RegisterTarget<AlphaTargetMachine> X("alpha", " Alpha (incomplete)");
27}
28
Andrew Lenharth2f401632005-02-01 20:35:11 +000029unsigned AlphaTargetMachine::getModuleMatchQuality(const Module &M) {
30 // We strongly match "alpha*".
31 std::string TT = M.getTargetTriple();
32 if (TT.size() >= 5 && TT[0] == 'a' && TT[1] == 'l' && TT[2] == 'p' &&
33 TT[3] == 'h' && TT[4] == 'a')
34 return 20;
35
36 if (M.getEndianness() == Module::LittleEndian &&
37 M.getPointerSize() == Module::Pointer64)
38 return 10; // Weak match
39 else if (M.getEndianness() != Module::AnyEndianness ||
40 M.getPointerSize() != Module::AnyPointerSize)
41 return 0; // Match for some other target
42
43 return 0;
44}
45
Andrew Lenharth304d0f32005-01-22 23:41:55 +000046AlphaTargetMachine::AlphaTargetMachine( const Module &M, IntrinsicLowering *IL)
47 : TargetMachine("alpha", IL, true),
48 FrameInfo(TargetFrameInfo::StackGrowsDown, 8, 0) //TODO: check these
Andrew Lenharth304d0f32005-01-22 23:41:55 +000049{}
50
Andrew Lenharth304d0f32005-01-22 23:41:55 +000051/// addPassesToEmitAssembly - Add passes to the specified pass manager
52/// to implement a static compiler for this target.
53///
54bool AlphaTargetMachine::addPassesToEmitAssembly(PassManager &PM,
55 std::ostream &Out) {
56
57 // FIXME: Implement efficient support for garbage collection intrinsics.
58 PM.add(createLowerGCPass());
59
60 // FIXME: Implement the invoke/unwind instructions!
61 PM.add(createLowerInvokePass());
62
63 // FIXME: Implement the switch instruction in the instruction selector!
64 PM.add(createLowerSwitchPass());
65
Andrew Lenharth304d0f32005-01-22 23:41:55 +000066 // Make sure that no unreachable blocks are instruction selected.
67 PM.add(createUnreachableBlockEliminationPass());
68
69 PM.add(createAlphaPatternInstructionSelector(*this));
70
71 if (PrintMachineCode)
72 PM.add(createMachineFunctionPrinterPass(&std::cerr));
73
74 PM.add(createRegisterAllocator());
75
76 if (PrintMachineCode)
77 PM.add(createMachineFunctionPrinterPass(&std::cerr));
78
79 PM.add(createPrologEpilogCodeInserter());
80
81 // Must run branch selection immediately preceding the asm printer
82 //PM.add(createAlphaBranchSelectionPass());
83
84 PM.add(createAlphaCodePrinterPass(Out, *this));
85
86 PM.add(createMachineCodeDeleter());
87 return false;
88}