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)");
30 cl::opt<bool> EnableAlphaLSR("enable-lsr-for-alpha",
31 cl::desc("Enable LSR for Alpha (beta option!)"),
35 unsigned AlphaTargetMachine::getModuleMatchQuality(const Module &M) {
36 // We strongly match "alpha*".
37 std::string TT = M.getTargetTriple();
38 if (TT.size() >= 5 && TT[0] == 'a' && TT[1] == 'l' && TT[2] == 'p' &&
39 TT[3] == 'h' && TT[4] == 'a')
42 if (M.getEndianness() == Module::LittleEndian &&
43 M.getPointerSize() == Module::Pointer64)
44 return 10; // Weak match
45 else if (M.getEndianness() != Module::AnyEndianness ||
46 M.getPointerSize() != Module::AnyPointerSize)
47 return 0; // Match for some other target
52 AlphaTargetMachine::AlphaTargetMachine( const Module &M, IntrinsicLowering *IL)
53 : TargetMachine("alpha", IL, true),
54 FrameInfo(TargetFrameInfo::StackGrowsDown, 8, 0) //TODO: check these
57 /// addPassesToEmitAssembly - Add passes to the specified pass manager
58 /// to implement a static compiler for this target.
60 bool AlphaTargetMachine::addPassesToEmitAssembly(PassManager &PM,
64 PM.add(createLoopStrengthReducePass());
65 PM.add(createCFGSimplificationPass());
68 // FIXME: Implement efficient support for garbage collection intrinsics.
69 PM.add(createLowerGCPass());
71 // FIXME: Implement the invoke/unwind instructions!
72 PM.add(createLowerInvokePass());
74 // FIXME: Implement the switch instruction in the instruction selector!
75 PM.add(createLowerSwitchPass());
77 // Make sure that no unreachable blocks are instruction selected.
78 PM.add(createUnreachableBlockEliminationPass());
80 PM.add(createAlphaPatternInstructionSelector(*this));
83 PM.add(createMachineFunctionPrinterPass(&std::cerr));
85 PM.add(createRegisterAllocator());
88 PM.add(createMachineFunctionPrinterPass(&std::cerr));
90 PM.add(createPrologEpilogCodeInserter());
92 // Must run branch selection immediately preceding the asm printer
93 //PM.add(createAlphaBranchSelectionPass());
95 PM.add(createAlphaCodePrinterPass(Out, *this));
97 PM.add(createMachineCodeDeleter());