2016-04-06 01:34:59 +02:00
|
|
|
//===- 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.
|
2016-04-07 02:39:29 +02:00
|
|
|
CCRRegBankID = 2, /// Conditional register: NZCV.
|
2016-04-06 01:34:59 +02:00
|
|
|
NumRegisterBanks
|
|
|
|
};
|
|
|
|
} // End AArch64 namespace.
|
|
|
|
|
2017-01-13 11:53:57 +01:00
|
|
|
class AArch64GenRegisterBankInfo : public RegisterBankInfo {
|
|
|
|
private:
|
|
|
|
static RegisterBank *RegBanks[];
|
|
|
|
|
|
|
|
protected:
|
|
|
|
AArch64GenRegisterBankInfo();
|
|
|
|
|
|
|
|
public:
|
|
|
|
static RegisterBankInfo::PartialMapping PartMappings[];
|
|
|
|
static RegisterBankInfo::ValueMapping ValMappings[];
|
|
|
|
static bool checkPartialMap(unsigned Idx, unsigned ValStartIdx,
|
|
|
|
unsigned ValLength, const RegisterBank &RB);
|
|
|
|
static bool checkValueMapImpl(unsigned Idx, unsigned FirstInBank,
|
|
|
|
unsigned Size, unsigned Offset);
|
|
|
|
enum PartialMappingIdx {
|
|
|
|
PMI_None = -1,
|
|
|
|
PMI_GPR32 = 1,
|
|
|
|
PMI_GPR64,
|
|
|
|
PMI_FPR32,
|
|
|
|
PMI_FPR64,
|
|
|
|
PMI_FPR128,
|
|
|
|
PMI_FPR256,
|
|
|
|
PMI_FPR512,
|
|
|
|
PMI_FirstGPR = PMI_GPR32,
|
|
|
|
PMI_LastGPR = PMI_GPR64,
|
|
|
|
PMI_FirstFPR = PMI_FPR32,
|
|
|
|
PMI_LastFPR = PMI_FPR512,
|
|
|
|
PMI_Min = PMI_FirstGPR,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum ValueMappingIdx {
|
|
|
|
First3OpsIdx = 0,
|
|
|
|
Last3OpsIdx = 18,
|
|
|
|
DistanceBetweenRegBanks = 3,
|
|
|
|
FirstCrossRegCpyIdx = 21,
|
|
|
|
LastCrossRegCpyIdx = 27,
|
|
|
|
DistanceBetweenCrossRegCpy = 2
|
|
|
|
};
|
|
|
|
|
|
|
|
static bool checkPartialMappingIdx(PartialMappingIdx FirstAlias,
|
|
|
|
PartialMappingIdx LastAlias,
|
2017-01-13 12:50:34 +01:00
|
|
|
ArrayRef<PartialMappingIdx> Order);
|
2017-01-13 11:53:57 +01:00
|
|
|
|
2017-01-13 12:50:34 +01:00
|
|
|
static unsigned getRegBankBaseIdxOffset(unsigned RBIdx, unsigned Size);
|
2017-01-13 11:53:57 +01:00
|
|
|
|
2017-01-13 12:50:34 +01:00
|
|
|
/// Get the pointer to the ValueMapping representing the RegisterBank
|
|
|
|
/// at \p RBIdx with a size of \p Size.
|
|
|
|
///
|
|
|
|
/// The returned mapping works for instructions with the same kind of
|
|
|
|
/// operands for up to 3 operands.
|
|
|
|
///
|
|
|
|
/// \pre \p RBIdx != PartialMappingIdx::None
|
|
|
|
static const RegisterBankInfo::ValueMapping *
|
|
|
|
getValueMapping(PartialMappingIdx RBIdx, unsigned Size);
|
|
|
|
|
|
|
|
/// Get the pointer to the ValueMapping of the operands of a copy
|
|
|
|
/// instruction from a GPR or FPR register to a GPR or FPR register
|
|
|
|
/// with a size of \p Size.
|
|
|
|
///
|
|
|
|
/// If \p DstIsGPR is true, the destination of the copy is on GPR,
|
|
|
|
/// otherwise it is on FPR. Same thing for \p SrcIsGPR.
|
|
|
|
static const RegisterBankInfo::ValueMapping *
|
|
|
|
getCopyMapping(bool DstIsGPR, bool SrcIsGPR, unsigned Size);
|
2017-01-13 11:53:57 +01:00
|
|
|
};
|
|
|
|
|
2016-04-06 01:34:59 +02:00
|
|
|
/// This class provides the information for the target register banks.
|
2017-01-13 11:53:57 +01:00
|
|
|
class AArch64RegisterBankInfo final : public AArch64GenRegisterBankInfo {
|
2016-06-08 18:53:32 +02:00
|
|
|
/// See RegisterBankInfo::applyMapping.
|
|
|
|
void applyMappingImpl(const OperandsMapper &OpdMapper) const override;
|
|
|
|
|
2016-10-03 22:20:13 +02:00
|
|
|
/// Get an instruction mapping where all the operands map to
|
|
|
|
/// the same register bank and have similar size.
|
|
|
|
///
|
|
|
|
/// \pre MI.getNumOperands() <= 3
|
|
|
|
///
|
|
|
|
/// \return An InstructionMappings with a statically allocated
|
|
|
|
/// OperandsMapping.
|
|
|
|
static InstructionMapping
|
|
|
|
getSameKindOfOperandsMapping(const MachineInstr &MI);
|
|
|
|
|
2016-04-06 01:34:59 +02:00
|
|
|
public:
|
|
|
|
AArch64RegisterBankInfo(const TargetRegisterInfo &TRI);
|
2016-12-15 19:22:15 +01:00
|
|
|
|
2016-06-08 03:11:03 +02:00
|
|
|
unsigned copyCost(const RegisterBank &A, const RegisterBank &B,
|
|
|
|
unsigned Size) const override;
|
2016-04-07 02:14:30 +02:00
|
|
|
|
|
|
|
const RegisterBank &
|
|
|
|
getRegBankFromRegClass(const TargetRegisterClass &RC) const override;
|
2016-06-08 18:53:32 +02:00
|
|
|
|
|
|
|
InstructionMappings
|
|
|
|
getInstrAlternativeMappings(const MachineInstr &MI) const override;
|
2016-07-20 21:09:30 +02:00
|
|
|
|
|
|
|
InstructionMapping getInstrMapping(const MachineInstr &MI) const override;
|
2016-04-06 01:34:59 +02:00
|
|
|
};
|
|
|
|
} // End llvm namespace.
|
|
|
|
#endif
|