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 "AlphaTargetMachine.h"
15 #include "llvm/Module.h"
16 #include "llvm/CodeGen/Passes.h"
17 #include "llvm/Target/TargetOptions.h"
18 #include "llvm/Target/TargetMachineRegistry.h"
19 #include "llvm/Transforms/Scalar.h"
25 // Register the targets
26 RegisterTarget<AlphaTargetMachine> X("alpha", " Alpha (incomplete)");
29 unsigned 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')
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
46 AlphaTargetMachine::AlphaTargetMachine( const Module &M, IntrinsicLowering *IL)
47 : TargetMachine("alpha", IL, true),
48 FrameInfo(TargetFrameInfo::StackGrowsDown, 8, 0) //TODO: check these
51 /// addPassesToEmitAssembly - Add passes to the specified pass manager
52 /// to implement a static compiler for this target.
54 bool AlphaTargetMachine::addPassesToEmitAssembly(PassManager &PM,
57 // FIXME: Implement efficient support for garbage collection intrinsics.
58 PM.add(createLowerGCPass());
60 // FIXME: Implement the invoke/unwind instructions!
61 PM.add(createLowerInvokePass());
63 // FIXME: Implement the switch instruction in the instruction selector!
64 PM.add(createLowerSwitchPass());
66 // Make sure that no unreachable blocks are instruction selected.
67 PM.add(createUnreachableBlockEliminationPass());
69 PM.add(createAlphaPatternInstructionSelector(*this));
72 PM.add(createMachineFunctionPrinterPass(&std::cerr));
74 PM.add(createRegisterAllocator());
77 PM.add(createMachineFunctionPrinterPass(&std::cerr));
79 PM.add(createPrologEpilogCodeInserter());
81 // Must run branch selection immediately preceding the asm printer
82 //PM.add(createAlphaBranchSelectionPass());
84 PM.add(createAlphaCodePrinterPass(Out, *this));
86 PM.add(createMachineCodeDeleter());