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

llvm-svn: 265449
This commit is contained in:
Quentin Colombet 2016-04-05 20:02:47 +00:00
parent b76e7253e9
commit b235d32e74
3 changed files with 81 additions and 0 deletions

View File

@ -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

View File

@ -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.

View File

@ -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 {}