From b235d32e7419cb8d5c95852fae58476fbf788873 Mon Sep 17 00:00:00 2001 From: Quentin Colombet Date: Tue, 5 Apr 2016 20:02:47 +0000 Subject: [PATCH] [GlobalISel] Add the RegisterBankInfo class for the handling of register banks. llvm-svn: 265449 --- .../CodeGen/GlobalISel/RegisterBankInfo.h | 52 +++++++++++++++++++ llvm/lib/CodeGen/GlobalISel/CMakeLists.txt | 1 + .../CodeGen/GlobalISel/RegisterBankInfo.cpp | 28 ++++++++++ 3 files changed, 81 insertions(+) create mode 100644 llvm/include/llvm/CodeGen/GlobalISel/RegisterBankInfo.h create mode 100644 llvm/lib/CodeGen/GlobalISel/RegisterBankInfo.cpp diff --git a/llvm/include/llvm/CodeGen/GlobalISel/RegisterBankInfo.h b/llvm/include/llvm/CodeGen/GlobalISel/RegisterBankInfo.h new file mode 100644 index 000000000000..8eaf2fa73847 --- /dev/null +++ b/llvm/include/llvm/CodeGen/GlobalISel/RegisterBankInfo.h @@ -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 + +namespace llvm { +class RegisterBank; +class TargetRegisterInfo; + +/// Holds all the information related to register banks. +class RegisterBankInfo { +protected: + std::unique_ptr 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 diff --git a/llvm/lib/CodeGen/GlobalISel/CMakeLists.txt b/llvm/lib/CodeGen/GlobalISel/CMakeLists.txt index 162c8197e950..e3e81ae5c4b1 100644 --- a/llvm/lib/CodeGen/GlobalISel/CMakeLists.txt +++ b/llvm/lib/CodeGen/GlobalISel/CMakeLists.txt @@ -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. diff --git a/llvm/lib/CodeGen/GlobalISel/RegisterBankInfo.cpp b/llvm/lib/CodeGen/GlobalISel/RegisterBankInfo.cpp new file mode 100644 index 000000000000..1d98c993c81f --- /dev/null +++ b/llvm/lib/CodeGen/GlobalISel/RegisterBankInfo.cpp @@ -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 {}