1//===-- PTXRegAlloc.cpp - PTX Register Allocator --------------------------===//
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// This file contains a register allocator for PTX code.
11//
12//===----------------------------------------------------------------------===//
13
14#define DEBUG_TYPE "ptx-reg-alloc"
15
16#include "PTX.h"
17#include "llvm/CodeGen/MachineFunctionPass.h"
18#include "llvm/CodeGen/RegAllocRegistry.h"
19
20using namespace llvm;
21
22namespace {
23  // Special register allocator for PTX.
24  class PTXRegAlloc : public MachineFunctionPass {
25  public:
26    static char ID;
27    PTXRegAlloc() : MachineFunctionPass(ID) {
28      initializePHIEliminationPass(*PassRegistry::getPassRegistry());
29      initializeTwoAddressInstructionPassPass(*PassRegistry::getPassRegistry());
30    }
31
32    virtual const char* getPassName() const {
33      return "PTX Register Allocator";
34    }
35
36    virtual void getAnalysisUsage(AnalysisUsage &AU) const {
37      AU.setPreservesCFG();
38      AU.addRequiredID(PHIEliminationID);
39      AU.addRequiredID(TwoAddressInstructionPassID);
40      MachineFunctionPass::getAnalysisUsage(AU);
41    }
42
43    virtual bool runOnMachineFunction(MachineFunction &MF) {
44      // We do not actually do anything (at least not yet).
45      return false;
46    }
47  };
48
49  char PTXRegAlloc::ID = 0;
50
51  static RegisterRegAlloc
52    ptxRegAlloc("ptx", "PTX register allocator", createPTXRegisterAllocator);
53}
54
55FunctionPass *llvm::createPTXRegisterAllocator() {
56  return new PTXRegAlloc();
57}
58
59