[llvm-commits] [llvm] r140305 - in /llvm/trunk/lib/Target/PTX: CMakeLists.txt PTX.h PTXRegAlloc.cpp
Justin Holewinski
justin.holewinski at gmail.com
Thu Sep 22 09:45:34 PDT 2011
Author: jholewinski
Date: Thu Sep 22 11:45:33 2011
New Revision: 140305
URL: http://llvm.org/viewvc/llvm-project?rev=140305&view=rev
Log:
PTX: Add new PTX-specific register allocator that keeps virtual registers
instead of allocating physical registers.
This is part of a work-in-progress overhaul of the PTX register allocation scheme.
Added:
llvm/trunk/lib/Target/PTX/PTXRegAlloc.cpp
Modified:
llvm/trunk/lib/Target/PTX/CMakeLists.txt
llvm/trunk/lib/Target/PTX/PTX.h
Modified: llvm/trunk/lib/Target/PTX/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/CMakeLists.txt?rev=140305&r1=140304&r2=140305&view=diff
==============================================================================
--- llvm/trunk/lib/Target/PTX/CMakeLists.txt (original)
+++ llvm/trunk/lib/Target/PTX/CMakeLists.txt Thu Sep 22 11:45:33 2011
@@ -16,6 +16,7 @@
PTXFrameLowering.cpp
PTXMCAsmStreamer.cpp
PTXMFInfoExtract.cpp
+ PTXRegAlloc.cpp
PTXRegisterInfo.cpp
PTXSubtarget.cpp
PTXTargetMachine.cpp
Modified: llvm/trunk/lib/Target/PTX/PTX.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/PTX.h?rev=140305&r1=140304&r2=140305&view=diff
==============================================================================
--- llvm/trunk/lib/Target/PTX/PTX.h (original)
+++ llvm/trunk/lib/Target/PTX/PTX.h Thu Sep 22 11:45:33 2011
@@ -43,6 +43,8 @@
FunctionPass *createPTXMFInfoExtract(PTXTargetMachine &TM,
CodeGenOpt::Level OptLevel);
+ FunctionPass *createPTXRegisterAllocator();
+
} // namespace llvm;
#endif // PTX_H
Added: llvm/trunk/lib/Target/PTX/PTXRegAlloc.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/PTXRegAlloc.cpp?rev=140305&view=auto
==============================================================================
--- llvm/trunk/lib/Target/PTX/PTXRegAlloc.cpp (added)
+++ llvm/trunk/lib/Target/PTX/PTXRegAlloc.cpp Thu Sep 22 11:45:33 2011
@@ -0,0 +1,58 @@
+//===-- PTXRegAlloc.cpp - PTX Register Allocator --------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file contains a register allocator for PTX code.
+//
+//===----------------------------------------------------------------------===//
+
+#define DEBUG_TYPE "ptx-reg-alloc"
+
+#include "PTX.h"
+#include "llvm/CodeGen/MachineFunctionPass.h"
+#include "llvm/CodeGen/RegAllocRegistry.h"
+
+using namespace llvm;
+
+namespace {
+ // Special register allocator for PTX.
+ class PTXRegAlloc : public MachineFunctionPass {
+ public:
+ static char ID;
+ PTXRegAlloc() : MachineFunctionPass(ID) {
+ initializePHIEliminationPass(*PassRegistry::getPassRegistry());
+ initializeTwoAddressInstructionPassPass(*PassRegistry::getPassRegistry());
+ }
+
+ virtual const char* getPassName() const {
+ return "PTX Register Allocator";
+ }
+
+ virtual void getAnalysisUsage(AnalysisUsage &AU) const {
+ AU.setPreservesCFG();
+ AU.addRequiredID(PHIEliminationID);
+ AU.addRequiredID(TwoAddressInstructionPassID);
+ MachineFunctionPass::getAnalysisUsage(AU);
+ }
+
+ virtual bool runOnMachineFunction(MachineFunction &MF) {
+ // We do not actually do anything (at least not yet).
+ return false;
+ }
+ };
+
+ char PTXRegAlloc::ID = 0;
+
+ static RegisterRegAlloc
+ ptxRegAlloc("ptx", "PTX register allocator", createPTXRegisterAllocator);
+}
+
+FunctionPass *llvm::createPTXRegisterAllocator() {
+ return new PTXRegAlloc();
+}
+
More information about the llvm-commits
mailing list