RegisterBankInfo::InstructionMappings
AArch64RegisterBankInfo::getInstrAlternativeMappings(
const MachineInstr &MI) const {
+ const MachineFunction &MF = *MI.getParent()->getParent();
+ const TargetSubtargetInfo &STI = MF.getSubtarget();
+ const TargetRegisterInfo &TRI = *STI.getRegisterInfo();
+ const MachineRegisterInfo &MRI = MF.getRegInfo();
+
switch (MI.getOpcode()) {
case TargetOpcode::G_OR: {
// 32 and 64-bit or can be mapped on either FPR or
// GPR for the same cost.
- const MachineFunction &MF = *MI.getParent()->getParent();
- const TargetSubtargetInfo &STI = MF.getSubtarget();
- const TargetRegisterInfo &TRI = *STI.getRegisterInfo();
- const MachineRegisterInfo &MRI = MF.getRegInfo();
-
unsigned Size = getSizeInBits(MI.getOperand(0).getReg(), MRI, TRI);
if (Size != 32 && Size != 64)
break;
AltMappings.emplace_back(std::move(FPRMapping));
return AltMappings;
}
+ case TargetOpcode::G_BITCAST: {
+ unsigned Size = getSizeInBits(MI.getOperand(0).getReg(), MRI, TRI);
+ if (Size != 32 && Size != 64)
+ break;
+
+ // If the instruction has any implicit-defs or uses,
+ // do not mess with it.
+ if (MI.getNumOperands() != 2)
+ break;
+
+ InstructionMappings AltMappings;
+ InstructionMapping GPRMapping(
+ /*ID*/ 1, /*Cost*/ 1,
+ AArch64::getCopyMapping(/*DstIsGPR*/ true, /*SrcIsGPR*/ true, Size),
+ /*NumOperands*/ 2);
+ InstructionMapping FPRMapping(
+ /*ID*/ 2, /*Cost*/ 1,
+ AArch64::getCopyMapping(/*DstIsFPR*/ false, /*SrcIsFPR*/ false, Size),
+ /*NumOperands*/ 2);
+ InstructionMapping GPRToFPRMapping(
+ /*ID*/ 3,
+ /*Cost*/ copyCost(AArch64::GPRRegBank, AArch64::FPRRegBank, Size),
+ AArch64::getCopyMapping(/*DstIsFPR*/ false, /*SrcIsFPR*/ true, Size),
+ /*NumOperands*/ 2);
+ InstructionMapping FPRToGPRMapping(
+ /*ID*/ 3,
+ /*Cost*/ copyCost(AArch64::GPRRegBank, AArch64::FPRRegBank, Size),
+ AArch64::getCopyMapping(/*DstIsFPR*/ true, /*SrcIsFPR*/ false, Size),
+ /*NumOperands*/ 2);
+
+ AltMappings.emplace_back(std::move(GPRMapping));
+ AltMappings.emplace_back(std::move(FPRMapping));
+ AltMappings.emplace_back(std::move(GPRToFPRMapping));
+ AltMappings.emplace_back(std::move(FPRToGPRMapping));
+ return AltMappings;
+ }
default:
break;
}
void AArch64RegisterBankInfo::applyMappingImpl(
const OperandsMapper &OpdMapper) const {
switch (OpdMapper.getMI().getOpcode()) {
- case TargetOpcode::G_OR: {
+ case TargetOpcode::G_OR:
+ case TargetOpcode::G_BITCAST: {
// Those ID must match getInstrAlternativeMappings.
- assert((OpdMapper.getInstrMapping().getID() == 1 ||
- OpdMapper.getInstrMapping().getID() == 2) &&
+ assert((OpdMapper.getInstrMapping().getID() >= 1 ||
+ OpdMapper.getInstrMapping().getID() <= 4) &&
"Don't know how to handle that ID");
return applyDefaultMapping(OpdMapper);
}
# CHECK: registers:
# CHECK-NEXT: - { id: 0, class: gpr }
-# CHECK-NEXT: - { id: 1, class: fpr }
+# FAST-NEXT: - { id: 1, class: fpr }
+# GREEDY-NEXT: - { id: 1, class: gpr }
registers:
- { id: 0, class: _ }
- { id: 1, class: _ }
# CHECK: registers:
# CHECK-NEXT: - { id: 0, class: fpr }
-# CHECK-NEXT: - { id: 1, class: gpr }
+# FAST-NEXT: - { id: 1, class: gpr }
+# GREEDY-NEXT: - { id: 1, class: fpr }
registers:
- { id: 0, class: _ }
- { id: 1, class: _ }
# CHECK: registers:
# CHECK-NEXT: - { id: 0, class: gpr }
-# CHECK-NEXT: - { id: 1, class: fpr }
+# FAST-NEXT: - { id: 1, class: fpr }
+# GREEDY-NEXT: - { id: 1, class: gpr }
registers:
- { id: 0, class: _ }
- { id: 1, class: _ }
# CHECK: registers:
# CHECK-NEXT: - { id: 0, class: fpr }
-# CHECK-NEXT: - { id: 1, class: gpr }
+# FAST-NEXT: - { id: 1, class: gpr }
+# GREEDY-NEXT: - { id: 1, class: fpr }
registers:
- { id: 0, class: _ }
- { id: 1, class: _ }