[llvm] r265449 - [GlobalISel] Add the RegisterBankInfo class for the handling of register banks.

Quentin Colombet via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 5 13:02:48 PDT 2016


Author: qcolombet
Date: Tue Apr  5 15:02:47 2016
New Revision: 265449

URL: http://llvm.org/viewvc/llvm-project?rev=265449&view=rev
Log:
[GlobalISel] Add the RegisterBankInfo class for the handling of register banks.

Added:
    llvm/trunk/include/llvm/CodeGen/GlobalISel/RegisterBankInfo.h
    llvm/trunk/lib/CodeGen/GlobalISel/RegisterBankInfo.cpp
Modified:
    llvm/trunk/lib/CodeGen/GlobalISel/CMakeLists.txt

Added: llvm/trunk/include/llvm/CodeGen/GlobalISel/RegisterBankInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/GlobalISel/RegisterBankInfo.h?rev=265449&view=auto
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/GlobalISel/RegisterBankInfo.h (added)
+++ llvm/trunk/include/llvm/CodeGen/GlobalISel/RegisterBankInfo.h Tue Apr  5 15:02:47 2016
@@ -0,0 +1,52 @@
+//==-- llvm/CodeGen/GlobalISel/RegisterBankInfo.h ----------------*- C++ -*-==//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+/// \file This file declares the API for the register bank info.
+/// This API is responsible for handling the register banks.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_CODEGEN_GLOBALISEL_REGBANKINFO_H
+#define LLVM_CODEGEN_GLOBALISEL_REGBANKINFO_H
+
+#include <memory>
+
+namespace llvm {
+class RegisterBank;
+class TargetRegisterInfo;
+
+/// Holds all the information related to register banks.
+class RegisterBankInfo {
+protected:
+  std::unique_ptr<RegisterBank[]> RegBanks;
+  unsigned NbOfRegBanks;
+
+  RegisterBankInfo(unsigned NbOfRegBanks);
+
+  virtual ~RegisterBankInfo();
+
+public:
+  /// Get the register bank identified by \p ID.
+  const RegisterBank &getRegBank(unsigned ID) const {
+    assert(ID < NbOfRegBanks && "Accessing an unknown register bank");
+    return RegBanks[ID];
+  }
+
+  /// Get the cost of a copy from \p B to \p A, or put differently,
+  /// get the cost of A = COPY B.
+  virtual unsigned copyCost(const RegisterBank &A,
+                            const RegisterBank &B) const {
+    return 0;
+  }
+
+  void verify(const TargetRegisterInfo &TRI) const;
+};
+} // End namespace llvm.
+
+#endif

Modified: llvm/trunk/lib/CodeGen/GlobalISel/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/GlobalISel/CMakeLists.txt?rev=265449&r1=265448&r2=265449&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/GlobalISel/CMakeLists.txt (original)
+++ llvm/trunk/lib/CodeGen/GlobalISel/CMakeLists.txt Tue Apr  5 15:02:47 2016
@@ -4,6 +4,7 @@ set(GLOBAL_ISEL_FILES
       MachineIRBuilder.cpp
       RegBankSelect.cpp
       RegisterBank.cpp
+      RegisterBankInfo.cpp
       )
 
 # Add GlobalISel files to the dependencies if the user wants to build it.

Added: llvm/trunk/lib/CodeGen/GlobalISel/RegisterBankInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/GlobalISel/RegisterBankInfo.cpp?rev=265449&view=auto
==============================================================================
--- llvm/trunk/lib/CodeGen/GlobalISel/RegisterBankInfo.cpp (added)
+++ llvm/trunk/lib/CodeGen/GlobalISel/RegisterBankInfo.cpp Tue Apr  5 15:02:47 2016
@@ -0,0 +1,28 @@
+//===- llvm/CodeGen/GlobalISel/RegisterBankInfo.cpp --------------*- C++ -*-==//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+/// \file
+/// This file implements the RegisterBankInfo class.
+//===----------------------------------------------------------------------===//
+
+#include "llvm/CodeGen/GlobalISel/RegisterBank.h"
+#include "llvm/CodeGen/GlobalISel/RegisterBankInfo.h"
+#include "llvm/Target/TargetRegisterInfo.h"
+
+#define DEBUG_TYPE "registerbankinfo"
+
+using namespace llvm;
+
+RegisterBankInfo::RegisterBankInfo(unsigned NbOfRegBanks)
+    : NbOfRegBanks(NbOfRegBanks) {
+  RegBanks.reset(new RegisterBank[NbOfRegBanks]);
+}
+
+RegisterBankInfo::~RegisterBankInfo() {}
+
+void RegisterBankInfo::verify(const TargetRegisterInfo &TRI) const {}




More information about the llvm-commits mailing list