From bdc3b4d5230fcaace4101e6f4a664cd01828a46a Mon Sep 17 00:00:00 2001 From: Quentin Colombet Date: Tue, 5 Apr 2016 19:54:44 +0000 Subject: [GlobalISel] Add a class, RegisterBank, to represent register banks. llvm-svn: 265445 --- llvm/lib/CodeGen/GlobalISel/CMakeLists.txt | 1 + llvm/lib/CodeGen/GlobalISel/RegisterBank.cpp | 39 ++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 llvm/lib/CodeGen/GlobalISel/RegisterBank.cpp (limited to 'llvm/lib/CodeGen') diff --git a/llvm/lib/CodeGen/GlobalISel/CMakeLists.txt b/llvm/lib/CodeGen/GlobalISel/CMakeLists.txt index bb6225f031a..162c8197e95 100644 --- a/llvm/lib/CodeGen/GlobalISel/CMakeLists.txt +++ b/llvm/lib/CodeGen/GlobalISel/CMakeLists.txt @@ -3,6 +3,7 @@ set(GLOBAL_ISEL_FILES IRTranslator.cpp MachineIRBuilder.cpp RegBankSelect.cpp + RegisterBank.cpp ) # Add GlobalISel files to the dependencies if the user wants to build it. diff --git a/llvm/lib/CodeGen/GlobalISel/RegisterBank.cpp b/llvm/lib/CodeGen/GlobalISel/RegisterBank.cpp new file mode 100644 index 00000000000..5c86e426e1b --- /dev/null +++ b/llvm/lib/CodeGen/GlobalISel/RegisterBank.cpp @@ -0,0 +1,39 @@ +//===- llvm/CodeGen/GlobalISel/RegisterBank.cpp - Register Bank --*- 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 RegisterBank class. +//===----------------------------------------------------------------------===// + +#include "llvm/CodeGen/GlobalISel/RegisterBank.h" + +#include "llvm/Target/TargetRegisterInfo.h" + +#define DEBUG_TYPE "registerbank" + +using namespace llvm; + +void RegisterBank::verify(const TargetRegisterInfo &TRI) const { + // Verify that the Size of the register bank is big enough to cover all the + // register classes it covers. + // Verify that the register bank covers all the sub and super classes of the + // classes it covers. +} + +bool RegisterBank::contains(const TargetRegisterClass &RC) const { + return ContainedRegClass.test(RC.getID()); +} + +bool RegisterBank::operator==(const RegisterBank &OtherRB) const { + // There must be only one instance of a given register bank alive + // for the whole compilation. + // The RegisterBankInfo is supposed to enforce that. + assert((OtherRB.getID() != getID() || &OtherRB == this) && + "ID does not uniquely identify a RegisterBank"); + return &OtherRB == this; +} -- cgit v1.2.3