#include "RISCV.h"
#include "RISCVMachineFunctionInfo.h"
#include "RISCVSubtarget.h"
#include "llvm/ADT/SmallSet.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/CodeGen/MachineFunctionPass.h"
#include "llvm/CodeGen/TargetInstrInfo.h"
usingnamespacellvm;
#define DEBUG_TYPE …
#define RISCV_OPT_W_INSTRS_NAME …
STATISTIC(NumRemovedSExtW, "Number of removed sign-extensions");
STATISTIC(NumTransformedToWInstrs,
"Number of instructions transformed to W-ops");
static cl::opt<bool> DisableSExtWRemoval("riscv-disable-sextw-removal",
cl::desc("Disable removal of sext.w"),
cl::init(false), cl::Hidden);
static cl::opt<bool> DisableStripWSuffix("riscv-disable-strip-w-suffix",
cl::desc("Disable strip W suffix"),
cl::init(false), cl::Hidden);
namespace {
class RISCVOptWInstrs : public MachineFunctionPass { … };
}
char RISCVOptWInstrs::ID = …;
INITIALIZE_PASS(…)
FunctionPass *llvm::createRISCVOptWInstrsPass() { … }
static bool vectorPseudoHasAllNBitUsers(const MachineOperand &UserOp,
unsigned Bits) { … }
static bool hasAllNBitUsers(const MachineInstr &OrigMI,
const RISCVSubtarget &ST,
const MachineRegisterInfo &MRI, unsigned OrigBits) { … }
static bool hasAllWUsers(const MachineInstr &OrigMI, const RISCVSubtarget &ST,
const MachineRegisterInfo &MRI) { … }
static bool isSignExtendingOpW(const MachineInstr &MI, unsigned OpNo) { … }
static bool isSignExtendedW(Register SrcReg, const RISCVSubtarget &ST,
const MachineRegisterInfo &MRI,
SmallPtrSetImpl<MachineInstr *> &FixableDef) { … }
static unsigned getWOp(unsigned Opcode) { … }
bool RISCVOptWInstrs::removeSExtWInstrs(MachineFunction &MF,
const RISCVInstrInfo &TII,
const RISCVSubtarget &ST,
MachineRegisterInfo &MRI) { … }
bool RISCVOptWInstrs::stripWSuffixes(MachineFunction &MF,
const RISCVInstrInfo &TII,
const RISCVSubtarget &ST,
MachineRegisterInfo &MRI) { … }
bool RISCVOptWInstrs::appendWSuffixes(MachineFunction &MF,
const RISCVInstrInfo &TII,
const RISCVSubtarget &ST,
MachineRegisterInfo &MRI) { … }
bool RISCVOptWInstrs::runOnMachineFunction(MachineFunction &MF) { … }