#include "MCTargetDesc/RISCVMatInt.h"
#include "RISCVRegisterBankInfo.h"
#include "RISCVSubtarget.h"
#include "RISCVTargetMachine.h"
#include "llvm/CodeGen/GlobalISel/GIMatchTableExecutorImpl.h"
#include "llvm/CodeGen/GlobalISel/GISelKnownBits.h"
#include "llvm/CodeGen/GlobalISel/GenericMachineInstrs.h"
#include "llvm/CodeGen/GlobalISel/InstructionSelector.h"
#include "llvm/CodeGen/GlobalISel/MIPatternMatch.h"
#include "llvm/CodeGen/GlobalISel/MachineIRBuilder.h"
#include "llvm/CodeGen/MachineJumpTableInfo.h"
#include "llvm/IR/IntrinsicsRISCV.h"
#include "llvm/Support/Debug.h"
#define DEBUG_TYPE …
usingnamespacellvm;
usingnamespaceMIPatternMatch;
#define GET_GLOBALISEL_PREDICATE_BITSET
#include "RISCVGenGlobalISel.inc"
#undef GET_GLOBALISEL_PREDICATE_BITSET
namespace {
class RISCVInstructionSelector : public InstructionSelector { … };
}
#define GET_GLOBALISEL_IMPL
#include "RISCVGenGlobalISel.inc"
#undef GET_GLOBALISEL_IMPL
RISCVInstructionSelector::RISCVInstructionSelector(
const RISCVTargetMachine &TM, const RISCVSubtarget &STI,
const RISCVRegisterBankInfo &RBI)
: … { … }
InstructionSelector::ComplexRendererFns
RISCVInstructionSelector::selectShiftMask(MachineOperand &Root) const { … }
InstructionSelector::ComplexRendererFns
RISCVInstructionSelector::selectSHXADDOp(MachineOperand &Root,
unsigned ShAmt) const { … }
InstructionSelector::ComplexRendererFns
RISCVInstructionSelector::selectSHXADD_UWOp(MachineOperand &Root,
unsigned ShAmt) const { … }
InstructionSelector::ComplexRendererFns
RISCVInstructionSelector::selectAddrRegImm(MachineOperand &Root) const { … }
static RISCVCC::CondCode getRISCVCCFromICmp(CmpInst::Predicate CC) { … }
static void getOperandsForBranch(Register CondReg, MachineRegisterInfo &MRI,
RISCVCC::CondCode &CC, Register &LHS,
Register &RHS) { … }
bool RISCVInstructionSelector::select(MachineInstr &MI) { … }
bool RISCVInstructionSelector::selectMergeValues(
MachineInstr &MI, MachineIRBuilder &MIB, MachineRegisterInfo &MRI) const { … }
bool RISCVInstructionSelector::selectUnmergeValues(
MachineInstr &MI, MachineIRBuilder &MIB, MachineRegisterInfo &MRI) const { … }
bool RISCVInstructionSelector::replacePtrWithInt(MachineOperand &Op,
MachineIRBuilder &MIB,
MachineRegisterInfo &MRI) { … }
void RISCVInstructionSelector::preISelLower(MachineInstr &MI,
MachineIRBuilder &MIB,
MachineRegisterInfo &MRI) { … }
void RISCVInstructionSelector::renderNegImm(MachineInstrBuilder &MIB,
const MachineInstr &MI,
int OpIdx) const { … }
void RISCVInstructionSelector::renderImmSubFromXLen(MachineInstrBuilder &MIB,
const MachineInstr &MI,
int OpIdx) const { … }
void RISCVInstructionSelector::renderImmSubFrom32(MachineInstrBuilder &MIB,
const MachineInstr &MI,
int OpIdx) const { … }
void RISCVInstructionSelector::renderImmPlus1(MachineInstrBuilder &MIB,
const MachineInstr &MI,
int OpIdx) const { … }
void RISCVInstructionSelector::renderImm(MachineInstrBuilder &MIB,
const MachineInstr &MI,
int OpIdx) const { … }
void RISCVInstructionSelector::renderTrailingZeros(MachineInstrBuilder &MIB,
const MachineInstr &MI,
int OpIdx) const { … }
const TargetRegisterClass *RISCVInstructionSelector::getRegClassForTypeOnBank(
LLT Ty, const RegisterBank &RB) const { … }
bool RISCVInstructionSelector::isRegInGprb(Register Reg,
MachineRegisterInfo &MRI) const { … }
bool RISCVInstructionSelector::isRegInFprb(Register Reg,
MachineRegisterInfo &MRI) const { … }
bool RISCVInstructionSelector::selectCopy(MachineInstr &MI,
MachineRegisterInfo &MRI) const { … }
bool RISCVInstructionSelector::selectImplicitDef(
MachineInstr &MI, MachineIRBuilder &MIB, MachineRegisterInfo &MRI) const { … }
bool RISCVInstructionSelector::materializeImm(Register DstReg, int64_t Imm,
MachineIRBuilder &MIB) const { … }
bool RISCVInstructionSelector::selectAddr(MachineInstr &MI,
MachineIRBuilder &MIB,
MachineRegisterInfo &MRI,
bool IsLocal,
bool IsExternWeak) const { … }
bool RISCVInstructionSelector::selectSExtInreg(MachineInstr &MI,
MachineIRBuilder &MIB) const { … }
bool RISCVInstructionSelector::selectSelect(MachineInstr &MI,
MachineIRBuilder &MIB,
MachineRegisterInfo &MRI) const { … }
static unsigned getFCmpOpcode(CmpInst::Predicate Pred, unsigned Size) { … }
static bool legalizeFCmpPredicate(Register &LHS, Register &RHS,
CmpInst::Predicate &Pred, bool &NeedInvert) { … }
bool RISCVInstructionSelector::selectFPCompare(MachineInstr &MI,
MachineIRBuilder &MIB,
MachineRegisterInfo &MRI) const { … }
void RISCVInstructionSelector::emitFence(AtomicOrdering FenceOrdering,
SyncScope::ID FenceSSID,
MachineIRBuilder &MIB) const { … }
namespace llvm {
InstructionSelector *
createRISCVInstructionSelector(const RISCVTargetMachine &TM,
const RISCVSubtarget &Subtarget,
const RISCVRegisterBankInfo &RBI) { … }
}