28#define DEBUG_TYPE "riscv-codegenprepare"
29#define PASS_NAME "RISC-V CodeGenPrepare"
31STATISTIC(NumZExtToSExt,
"Number of SExt instructions converted to ZExt");
61bool RISCVCodeGenPrepare::visitZExtInst(
ZExtInst &ZExt) {
76 *
DL).value_or(
false)) {
78 SExt->takeName(&ZExt);
89 using namespace PatternMatch;
92 SExt->takeName(&ZExt);
117 if (!LHS || (!isa<SExtInst>(LHS) && !isa<ZExtInst>(LHS)))
127 auto *CI = dyn_cast<ConstantInt>(RHS);
135 if (!isUInt<32>(
C) || isInt<12>(
C) || !isInt<12>(SignExtend64<32>(
C)))
142 LHS, *
DL).value_or(
false))
146 C = SignExtend64<32>(
C);
152bool RISCVCodeGenPrepare::runOnFunction(
Function &
F) {
156 auto &TPC = getAnalysis<TargetPassConfig>();
160 DL = &
F.getParent()->getDataLayout();
162 bool MadeChange =
false;
165 MadeChange |= visit(
I);
174char RISCVCodeGenPrepare::
ID = 0;
177 return new RISCVCodeGenPrepare();
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
const char LLVMTargetMachineRef TM
#define INITIALIZE_PASS_DEPENDENCY(depName)
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
#define INITIALIZE_PASS_BEGIN(passName, arg, name, cfg, analysis)
This file defines the 'Statistic' class, which is designed to be an easy way to expose various metric...
#define STATISTIC(VARNAME, DESC)
Target-Independent Code Generator Pass Configuration Options pass.
Represent the analysis usage information of a pass.
AnalysisUsage & addRequired()
void setPreservesCFG()
This function should be called by the pass, iff they do not:
static Constant * get(Type *Ty, uint64_t V, bool IsSigned=false)
If Ty is a vector type, return a Constant with a splat of the given value.
static Constant * getNullValue(Type *Ty)
Constructor to create a '0' constant of arbitrary type.
A parsed version of the target data layout string in and methods for querying it.
FunctionPass class - This class is used to implement most global optimizations.
virtual bool runOnFunction(Function &F)=0
runOnFunction - Virtual method overriden by subclasses to do the per-function processing of the pass.
Base class for instruction visitors.
void visitInstruction(Instruction &I)
RetTy visitZExtInst(ZExtInst &I)
const DebugLoc & getDebugLoc() const
Return the debug location for this node as a DebugLoc.
SymbolTableList< Instruction >::iterator eraseFromParent()
This method unlinks 'this' from the containing basic block and deletes it.
virtual void getAnalysisUsage(AnalysisUsage &) const
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
virtual StringRef getPassName() const
getPassName - Return a nice clean name for a pass.
This class represents a sign extension of integer types.
StringRef - Represent a constant reference to a string, i.e.
Target-Independent Code Generator Pass Configuration Options.
bool isIntegerTy() const
True if this is an instance of IntegerType.
void setOperand(unsigned i, Value *Val)
Value * getOperand(unsigned i) const
LLVM Value Representation.
Type * getType() const
All values are typed, get the type of this value.
void replaceAllUsesWith(Value *V)
Change all uses of this to point to a new Value.
This class represents zero extension of integer types.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
@ C
The default llvm calling convention, compatible with C.
bool match(Val *V, const Pattern &P)
cst_pred_ty< is_one > m_One()
Match an integer 1 or a vector with all elements equal to 1.
class_match< Value > m_Value()
Match an arbitrary value and ignore it.
This is an optimization pass for GlobalISel generic memory operations.
iterator_range< early_inc_iterator_impl< detail::IterOfRange< RangeT > > > make_early_inc_range(RangeT &&Range)
Make a range that does early increment to allow mutation of the underlying range without disrupting i...
FunctionPass * createRISCVCodeGenPreparePass()
std::optional< bool > isImpliedByDomCondition(const Value *Cond, const Instruction *ContextI, const DataLayout &DL)
Return the boolean condition value in the context of the given instruction if it is known based on do...