LLVM 20.0.0git
M68kRegisterBankInfo.cpp
Go to the documentation of this file.
1//===-- M68kRegisterBankInfo.cpp --------------------------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8/// \file
9/// This file implements the targeting of the RegisterBankInfo class for M68k.
10/// \todo This should be generated by TableGen.
11//===----------------------------------------------------------------------===//
12
14#include "M68kInstrInfo.h" // For the register classes
15#include "M68kSubtarget.h"
20
21#define GET_TARGET_REGBANK_IMPL
22#include "M68kGenRegisterBank.inc"
23
24using namespace llvm;
25
26// FIXME: TableGen this.
27// If it grows too much and TableGen still isn't ready to do the job, extract it
28// into an M68kGenRegisterBankInfo.def (similar to AArch64).
29namespace llvm {
30namespace M68k {
34};
35
37 // GPR Partial Mapping
38 {0, 32, GPRRegBank},
39};
40
44};
45
47 // invalid
48 {nullptr, 0},
49 // 3 operands in GPRs
53
54};
55} // end namespace M68k
56} // end namespace llvm
57
60
63 auto Opc = MI.getOpcode();
64
65 if (!isPreISelGenericOpcode(Opc)) {
67 if (Mapping.isValid())
68 return Mapping;
69 }
70
71 using namespace TargetOpcode;
72
73 unsigned NumOperands = MI.getNumOperands();
74 const ValueMapping *OperandsMapping = &M68k::ValueMappings[M68k::GPR3OpsIdx];
75
76 switch (Opc) {
77 case G_ADD:
78 case G_SUB:
79 case G_MUL:
80 case G_SDIV:
81 case G_UDIV:
82 case G_LOAD:
83 case G_STORE: {
84 OperandsMapping = &M68k::ValueMappings[M68k::GPR3OpsIdx];
85 break;
86 }
87
88 case G_CONSTANT:
89 case G_FRAME_INDEX:
90 OperandsMapping =
92 break;
93 default:
95 }
96
97 return getInstructionMapping(DefaultMappingID, /*Cost=*/1, OperandsMapping,
98 NumOperands);
99}
IRTranslator LLVM IR MI
This file contains the M68k implementation of the TargetInstrInfo class.
This file declares the targeting of the RegisterBankInfo class for M68k.
This file declares the M68k specific subclass of TargetSubtargetInfo.
unsigned const TargetRegisterInfo * TRI
M68kRegisterBankInfo(const TargetRegisterInfo &TRI)
const InstructionMapping & getInstrMapping(const MachineInstr &MI) const override
Get the mapping of the different operands of MI on the register bank.
Representation of each machine instruction.
Definition: MachineInstr.h:69
Helper class that represents how the value of an instruction may be mapped and what is the related co...
bool isValid() const
Check whether this object is valid.
const InstructionMapping & getInstructionMapping(unsigned ID, unsigned Cost, const ValueMapping *OperandsMapping, unsigned NumOperands) const
Method to get a uniquely generated InstructionMapping.
const InstructionMapping & getInvalidInstructionMapping() const
Method to get a uniquely generated invalid InstructionMapping.
const ValueMapping * getOperandsMapping(Iterator Begin, Iterator End) const
Get the uniquely generated array of ValueMapping for the elements of between Begin and End.
static const unsigned DefaultMappingID
Identifier used when the related instruction mapping instance is generated by target independent code...
const InstructionMapping & getInstrMappingImpl(const MachineInstr &MI) const
Try to get the mapping of MI.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
const RegisterBankInfo::PartialMapping PartMappings[]
const RegisterBankInfo::ValueMapping ValueMappings[]
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
bool isPreISelGenericOpcode(unsigned Opcode)
Check whether the given Opcode is a generic opcode that is not supposed to appear after ISel.
Definition: TargetOpcodes.h:30
Helper struct that represents how a value is partially mapped into a register.
Helper struct that represents how a value is mapped through different register banks.