20 #define DEBUG_TYPE "mips-isel" 26 #define GET_GLOBALISEL_PREDICATE_BITSET 27 #include "MipsGenGlobalISel.inc" 28 #undef GET_GLOBALISEL_PREDICATE_BITSET 47 #define GET_GLOBALISEL_PREDICATES_DECL 48 #include "MipsGenGlobalISel.inc" 49 #undef GET_GLOBALISEL_PREDICATES_DECL 51 #define GET_GLOBALISEL_TEMPORARIES_DECL 52 #include "MipsGenGlobalISel.inc" 53 #undef GET_GLOBALISEL_TEMPORARIES_DECL 58 #define GET_GLOBALISEL_IMPL 59 #include "MipsGenGlobalISel.inc" 60 #undef GET_GLOBALISEL_IMPL 62 MipsInstructionSelector::MipsInstructionSelector(
66 TRI(*STI.getRegisterInfo()), RBI(RBI),
69 #include
"MipsGenGlobalISel.inc" 72 #include
"MipsGenGlobalISel.inc" 81 if (TargetRegisterInfo::isPhysicalRegister(DstReg))
113 using namespace TargetOpcode;
123 case G_FRAME_INDEX: {
133 const unsigned DestRegBank = RBI.
getRegBank(DestReg, MRI, TRI)->
getID();
136 if (DestRegBank != Mips::GPRBRegBankID || OpSize != 32)
139 const unsigned NewOpc = I.
getOpcode() == G_STORE ? Mips::SW : Mips::LW;
158 TII.
get(IsSigned ? Mips::PseudoSDIV : Mips::PseudoUDIV))
166 TII.
get(IsDiv ? Mips::PseudoMFLO : Mips::PseudoMFHI))
206 case G_GLOBAL_VALUE: {
235 unsigned Opcode,
Def, LHS, RHS;
236 Instr(
unsigned Opcode,
unsigned Def,
unsigned LHS,
unsigned RHS)
237 : Opcode(Opcode),
Def(Def), LHS(LHS), RHS(RHS){};
240 if (Opcode == Mips::SLTiu || Opcode == Mips::XORi)
255 case CmpInst::ICMP_EQ:
257 Instructions.
emplace_back(Mips::SLTiu, ICMPReg, Temp, 1);
259 case CmpInst::ICMP_NE:
261 Instructions.
emplace_back(Mips::SLTu, ICMPReg, Mips::ZERO, Temp);
263 case CmpInst::ICMP_UGT:
264 Instructions.
emplace_back(Mips::SLTu, ICMPReg, RHS, LHS);
266 case CmpInst::ICMP_UGE:
268 Instructions.
emplace_back(Mips::XORi, ICMPReg, Temp, 1);
270 case CmpInst::ICMP_ULT:
271 Instructions.
emplace_back(Mips::SLTu, ICMPReg, LHS, RHS);
273 case CmpInst::ICMP_ULE:
275 Instructions.
emplace_back(Mips::XORi, ICMPReg, Temp, 1);
277 case CmpInst::ICMP_SGT:
278 Instructions.
emplace_back(Mips::SLT, ICMPReg, RHS, LHS);
280 case CmpInst::ICMP_SGE:
282 Instructions.
emplace_back(Mips::XORi, ICMPReg, Temp, 1);
284 case CmpInst::ICMP_SLT:
285 Instructions.
emplace_back(Mips::SLT, ICMPReg, LHS, RHS);
287 case CmpInst::ICMP_SLE:
289 Instructions.
emplace_back(Mips::XORi, ICMPReg, Temp, 1);
296 for (
const struct Instr &
Instruction : Instructions) {
298 Instruction.Opcode, {Instruction.Def}, {Instruction.LHS});
324 return new MipsInstructionSelector(TM, Subtarget, RBI);
const MachineInstrBuilder & add(const MachineOperand &MO) const
This class represents lattice values for constants.
void setTargetFlags(unsigned F)
#define GET_GLOBALISEL_TEMPORARIES_INIT
const DebugLoc & getDebugLoc() const
Returns the debug location id of this MachineInstr.
unsigned getReg() const
getReg - Returns the register number.
static uint64_t selectImpl(uint64_t CandidateMask, uint64_t &NextInSequenceMask)
LLT getType(unsigned Reg) const
Get the low-level type of Reg or LLT{} if Reg is not a generic (target independent) virtual register...
unsigned const TargetRegisterInfo * TRI
const MachineInstrBuilder & addGlobalAddress(const GlobalValue *GV, int64_t Offset=0, unsigned char TargetFlags=0) const
Holds all the information related to register banks.
const HexagonInstrInfo * TII
const MachineInstrBuilder & addUse(unsigned RegNo, unsigned Flags=0, unsigned SubReg=0) const
Add a virtual register use operand.
void eraseFromParent()
Unlink 'this' from the containing basic block and delete it.
static StringRef getName(Value *V)
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
This file declares the targeting of the RegisterBankInfo class for Mips.
const APInt & getValue() const
Return the constant as an APInt value reference.
bool hasImm(uint64_t TSFlags)
InstructionSelector * createMipsInstructionSelector(const MipsTargetMachine &, MipsSubtarget &, MipsRegisterBankInfo &)
TargetInstrInfo - Interface to description of machine instruction set.
MachineInstrBuilder BuildMI(MachineFunction &MF, const DebugLoc &DL, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
unsigned const MachineRegisterInfo * MRI
MachineInstrBuilder buildInstr(unsigned Opcode)
Build and insert <empty> = Opcode <empty>.
const GlobalValue * getGlobal() const
Helper class to build MachineInstr.
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
StringRef getName(unsigned Opcode) const
Returns the name for the instructions with the given opcode.
mmo_iterator memoperands_begin() const
Access to memory operands of the instruction.
RegisterBank & getRegBank(unsigned ID)
Get the register bank identified by ID.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
unsigned getSizeInBits() const
Returns the total size of the type. Must only be called on sized types.
This class provides the information for the target register banks.
bool constrainSelectedInstRegOperands(MachineInstr &I, const TargetInstrInfo &TII, const TargetRegisterInfo &TRI, const RegisterBankInfo &RBI)
Mutate the newly-selected instruction I to constrain its (possibly generic) virtual register operands...
This file declares the MachineIRBuilder class.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
const MachineBasicBlock * getParent() const
MachineRegisterInfo - Keep track of information for virtual and physical registers, including vreg register classes, use/def chains for registers, etc.
Provides the logic to select generic machine instructions.
Representation of each machine instruction.
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
void emplace_back(ArgTypes &&... Args)
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
bool isPositionIndependent() const
uint64_t getLimitedValue(uint64_t Limit=UINT64_MAX) const
If this value is smaller than the specified limit, return it, otherwise return the limit value...
const MCInstrDesc & get(unsigned Opcode) const
Return the machine instruction descriptor that corresponds to the specified instruction opcode...
static const TargetRegisterClass * constrainGenericRegister(unsigned Reg, const TargetRegisterClass &RC, MachineRegisterInfo &MRI)
Constrain the (possibly generic) virtual register Reg to RC.
const LLVMTargetMachine & getTarget() const
getTarget - Return the target machine this machine code is compiled with
#define GET_GLOBALISEL_PREDICATES_INIT
bool isPreISelGenericOpcode(unsigned Opcode)
Check whether the given Opcode is a generic opcode that is not supposed to appear after ISel...
static bool selectCopy(MachineInstr &I, const TargetInstrInfo &TII, MachineRegisterInfo &MRI, const TargetRegisterInfo &TRI, const RegisterBankInfo &RBI)
const MachineOperand & getOperand(unsigned i) const
const ConstantInt * getCImm() const
unsigned createVirtualRegister(const TargetRegisterClass *RegClass, StringRef Name="")
createVirtualRegister - Create and return a new virtual register in the function with the specified r...
bool constrainAllUses(const TargetInstrInfo &TII, const TargetRegisterInfo &TRI, const RegisterBankInfo &RBI) const
unsigned getID() const
Get the identifier of this register bank.
unsigned getPredicate() const