summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQuentin Colombet <qcolombet@apple.com>2016-04-05 23:34:59 +0000
committerQuentin Colombet <qcolombet@apple.com>2016-04-05 23:34:59 +0000
commit5300950f3a2043dede4511e3c311c35fbd387322 (patch)
tree7d927469ba33f2b6108589b26ab4971b1e36d273
parent29be7e10cacb1ee1a10e2e209ecc8b1ba879daf6 (diff)
downloadbcm5719-llvm-5300950f3a2043dede4511e3c311c35fbd387322.tar.gz
bcm5719-llvm-5300950f3a2043dede4511e3c311c35fbd387322.zip
[AArch64] Initial implementation of the targeting of the register bank information.
llvm-svn: 265489
-rw-r--r--llvm/lib/Target/AArch64/AArch64RegisterBankInfo.cpp73
-rw-r--r--llvm/lib/Target/AArch64/AArch64RegisterBankInfo.h41
-rw-r--r--llvm/lib/Target/AArch64/CMakeLists.txt1
3 files changed, 115 insertions, 0 deletions
diff --git a/llvm/lib/Target/AArch64/AArch64RegisterBankInfo.cpp b/llvm/lib/Target/AArch64/AArch64RegisterBankInfo.cpp
new file mode 100644
index 00000000000..277d4910e8d
--- /dev/null
+++ b/llvm/lib/Target/AArch64/AArch64RegisterBankInfo.cpp
@@ -0,0 +1,73 @@
+//===- AArch64RegisterBankInfo.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 targeting of the RegisterBankInfo class for
+/// AArch64.
+/// \todo This should be generated by TableGen.
+//===----------------------------------------------------------------------===//
+
+#include "AArch64RegisterBankInfo.h"
+#include "AArch64InstrInfo.h" // For XXXRegClassID.
+#include "llvm/CodeGen/GlobalISel/RegisterBank.h"
+#include "llvm/CodeGen/GlobalISel/RegisterBankInfo.h"
+#include "llvm/Target/TargetRegisterInfo.h"
+
+using namespace llvm;
+
+#ifndef LLVM_BUILD_GLOBAL_ISEL
+AArch64RegisterBankInfo::AArch64RegisterBankInfo(const TargetRegisterInfo &TRI)
+ : RegisterBankInfo(0) {
+ llvm_unreachable("This API shouldn't be useful outside of GlobalISel");
+}
+
+unsigned AArch64RegisterBankInfo::copyCost(const RegisterBank &A,
+ const RegisterBank &B) const {
+ return 0;
+}
+#else
+AArch64RegisterBankInfo::AArch64RegisterBankInfo(const TargetRegisterInfo &TRI)
+ : RegisterBankInfo(AArch64::NumRegisterBanks) {
+ // Initialize the GPR bank.
+ createRegisterBank(AArch64::GPRRegBankID, "GPR");
+ // The GPR register bank is fully defined by all the registers in
+ // GR64all + its subclasses.
+ addRegBankCoverage(AArch64::GPRRegBankID, AArch64::GPR64allRegClassID, TRI);
+ const RegisterBank &RBGPR = getRegBank(AArch64::GPRRegBankID);
+ (void)RBGPR;
+ assert(RBGPR.contains(*TRI.getRegClass(AArch64::GPR32RegClassID)) &&
+ "Subclass not added?");
+ assert(RBGPR.getSize() == 64 && "GPRs should hold up to 64-bit");
+
+ // Initialize the FPR bank.
+ createRegisterBank(AArch64::FPRRegBankID, "FPR");
+ // The FPR register bank is fully defined by all the registers in
+ // GR64all + its subclasses.
+ addRegBankCoverage(AArch64::FPRRegBankID, AArch64::QQQQRegClassID, TRI);
+ const RegisterBank &RBFPR = getRegBank(AArch64::FPRRegBankID);
+ (void)RBFPR;
+ assert(RBFPR.contains(*TRI.getRegClass(AArch64::QQRegClassID)) &&
+ "Subclass not added?");
+ assert(RBFPR.contains(*TRI.getRegClass(AArch64::FPR64RegClassID)) &&
+ "Subclass not added?");
+ assert(RBFPR.getSize() == 512 &&
+ "FPRs should hold up to 512-bit via QQQQ sequence");
+
+ verify(TRI);
+}
+
+unsigned AArch64RegisterBankInfo::copyCost(const RegisterBank &A,
+ const RegisterBank &B) const {
+ // What do we do with different size?
+ // copy are same size.
+ // Will introduce other hooks for different size:
+ // * extract cost.
+ // * build_sequence cost.
+ return 0;
+}
+#endif
diff --git a/llvm/lib/Target/AArch64/AArch64RegisterBankInfo.h b/llvm/lib/Target/AArch64/AArch64RegisterBankInfo.h
new file mode 100644
index 00000000000..c6019b51a8a
--- /dev/null
+++ b/llvm/lib/Target/AArch64/AArch64RegisterBankInfo.h
@@ -0,0 +1,41 @@
+//===- AArch64RegisterBankInfo -----------------------------------*- 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 targeting of the RegisterBankInfo class for AArch64.
+/// \todo This should be generated by TableGen.
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIB_TARGET_AARCH64_AARCH64REGISTERBANKINFO_H
+#define LLVM_LIB_TARGET_AARCH64_AARCH64REGISTERBANKINFO_H
+
+#include "llvm/CodeGen/GlobalISel/RegisterBankInfo.h"
+
+namespace llvm {
+
+class TargetRegisterInfo;
+
+namespace AArch64 {
+enum {
+ GPRRegBankID = 0, /// General Purpose Registers: W, X.
+ FPRRegBankID = 1, /// Floating Point/Vector Registers: B, H, S, D, Q.
+ NumRegisterBanks
+};
+} // End AArch64 namespace.
+
+/// This class provides the information for the target register banks.
+class AArch64RegisterBankInfo : public RegisterBankInfo {
+public:
+ AArch64RegisterBankInfo(const TargetRegisterInfo &TRI);
+ /// Get the cost of a copy from \p B to \p A, or put differently,
+ /// get the cost of A = COPY B.
+ unsigned copyCost(const RegisterBank &A,
+ const RegisterBank &B) const override;
+};
+} // End llvm namespace.
+#endif
diff --git a/llvm/lib/Target/AArch64/CMakeLists.txt b/llvm/lib/Target/AArch64/CMakeLists.txt
index 06c684da432..a88332b1feb 100644
--- a/llvm/lib/Target/AArch64/CMakeLists.txt
+++ b/llvm/lib/Target/AArch64/CMakeLists.txt
@@ -38,6 +38,7 @@ add_llvm_target(AArch64CodeGen
AArch64MCInstLower.cpp
AArch64PromoteConstant.cpp
AArch64PBQPRegAlloc.cpp
+ AArch64RegisterBankInfo.cpp
AArch64RegisterInfo.cpp
AArch64SelectionDAGInfo.cpp
AArch64StorePairSuppress.cpp
OpenPOWER on IntegriCloud