30#define DEBUG_TYPE "riscv-codegenprepare"
31#define PASS_NAME "RISC-V CodeGenPrepare"
71 using namespace PatternMatch;
84 auto *CI = dyn_cast<ConstantInt>(RHS);
92 if (!isUInt<32>(
C) || isInt<12>(
C) || !isInt<12>(SignExtend64<32>(
C)))
96 C = SignExtend64<32>(
C);
131 if (
I.getIntrinsicID() != Intrinsic::vector_reduce_fadd)
134 auto *
PHI = dyn_cast<PHINode>(
I.getOperand(0));
135 if (!
PHI || !
PHI->hasOneUse() ||
139 Type *VecTy =
I.getOperand(1)->getType();
141 auto *VecPHI = Builder.CreatePHI(VecTy,
PHI->getNumIncomingValues());
143 for (
auto *BB :
PHI->blocks()) {
144 Builder.SetInsertPoint(BB->getTerminator());
145 Value *InsertElt = Builder.CreateInsertElement(
146 VecTy,
PHI->getIncomingValueForBlock(BB), (
uint64_t)0);
147 VecPHI->addIncoming(InsertElt, BB);
150 Builder.SetInsertPoint(&
I);
151 I.setOperand(0, Builder.CreateExtractElement(VecPHI, (
uint64_t)0));
153 PHI->eraseFromParent();
158bool RISCVCodeGenPrepare::runOnFunction(
Function &
F) {
162 auto &TPC = getAnalysis<TargetPassConfig>();
166 DL = &
F.getParent()->getDataLayout();
168 bool MadeChange =
false;
171 MadeChange |= visit(
I);
180char RISCVCodeGenPrepare::
ID = 0;
183 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...
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:
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.
This provides a uniform API for creating instructions and inserting them into a basic block: either a...
Base class for instruction visitors.
RetTy visitIntrinsicInst(IntrinsicInst &I)
void visitInstruction(Instruction &I)
A wrapper class for inspecting calls to intrinsic functions.
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.
StringRef - Represent a constant reference to a string, i.e.
Target-Independent Code Generator Pass Configuration Options.
The instances of the Type class are immutable: once they are created, they are never changed.
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.
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)
NNegZExt_match< OpTy > m_NNegZExt(const OpTy &Op)
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()
bool is_contained(R &&Range, const E &Element)
Returns true if Element is found in Range.