38 cl::desc(
"No extract instruction with offset 0"));
41 cl::desc(
"Require & in extract patterns"));
56 virtual const char *getPassName()
const override {
57 return "Hexagon generate \"extract\" instructions";
59 virtual bool runOnFunction(
Function &
F)
override;
60 virtual void getAnalysisUsage(
AnalysisUsage &AU)
const override {
70 unsigned ExtractCount;
78 "\"extract\" instructions",
false,
false)
85 using namespace PatternMatch;
145 Type *Ty = BF->getType();
146 if (!Ty->isIntegerTy())
149 if (BW != 32 && BW != 64)
152 uint32_t SR = CSR->getZExtValue();
153 uint32_t SL = CSL->getZExtValue();
159 if (!LogicalSR && (SR > SL))
168 uint32_t
T = M.countTrailingOnes();
172 uint32_t U = BW - std::max(SL, SR);
199 Intrinsic::ID IntId = (BW == 32) ? Intrinsic::hexagon_S2_extractu
200 : Intrinsic::hexagon_S2_extractup;
201 Module *Mod = BB->getParent()->getParent();
205 NewIn = IRB.
CreateShl(NewIn, SL, CSL->getName());
211 bool HexagonGenExtract::visitBlock(
BasicBlock *B) {
215 typedef GTN::ChildIteratorType Iter;
216 for (Iter
I = GTN::child_begin(DTN), E = GTN::child_end(DTN);
I != E; ++
I)
217 visitBlock((*I)->getBlock());
223 bool Changed =
false;
226 if (HasCutoff && (ExtractCount >= Cutoff))
228 bool Last = (I == Begin);
230 NextI = std::prev(I);
232 bool Done = convert(In);
233 if (HasCutoff && Done)
244 bool HexagonGenExtract::runOnFunction(
Function &
F) {
245 DT = &getAnalysis<DominatorTreeWrapperPass>().getDomTree();
251 Changed = visitBlock(Entry);
258 return new HexagonGenExtract();
BinaryOp_match< LHS, RHS, Instruction::And > m_And(const LHS &L, const RHS &R)
class_match< Value > m_Value()
Match an arbitrary value and ignore it.
AnalysisUsage & addPreserved()
Add the specified Pass class to the set of analyses preserved by this pass.
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
A Module instance is used to store all the information related to an LLVM module. ...
DominatorTree GraphTraits specialization so the DominatorTree can be iterable by generic graph iterat...
virtual void getAnalysisUsage(AnalysisUsage &) const
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
BinaryOp_match< LHS, RHS, Instruction::AShr > m_AShr(const LHS &L, const RHS &R)
bool isMask(unsigned numBits, const APInt &APIVal)
const Function * getParent() const
Return the enclosing method, or null if none.
void initializeHexagonGenExtractPass(PassRegistry &)
MachineFunctionAnalysis - This class is a Pass that manages a MachineFunction object.
iterator begin()
Instruction iterator methods.
bool match(Val *V, const Pattern &P)
AnalysisUsage & addRequired()
#define INITIALIZE_PASS_DEPENDENCY(depName)
APInt LLVM_ATTRIBUTE_UNUSED_RESULT lshr(unsigned shiftAmt) const
Logical right-shift function.
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
This provides a uniform API for creating instructions and inserting them into a basic block: either a...
Number of individual test Apply this number of consecutive mutations to each input exit after the first new interesting input is found the minimized corpus is saved into the first input directory Number of jobs to run If min(jobs, NumberOfCpuCores()/2)\" is used.") FUZZER_FLAG_INT(reload
Base class for the actual dominator tree node.
class_match< ConstantInt > m_ConstantInt()
Match an arbitrary ConstantInt and ignore it.
Function * getDeclaration(Module *M, ID id, ArrayRef< Type * > Tys=None)
Create or insert an LLVM Function declaration for an intrinsic, and return it.
APInt LLVM_ATTRIBUTE_UNUSED_RESULT shl(unsigned shiftAmt) const
Left-shift function.
void replaceAllUsesWith(Value *V)
Change all uses of this to point to a new Value.
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree...
static APInt getHighBitsSet(unsigned numBits, unsigned hiBitsSet)
Get a value with high bits set.
initializer< Ty > init(const Ty &Val)
BinaryOp_match< LHS, RHS, Instruction::LShr > m_LShr(const LHS &L, const RHS &R)
LLVM Basic Block Representation.
The instances of the Type class are immutable: once they are created, they are never changed...
This is an important class for using LLVM in a threaded context.
This file contains the declarations for the subclasses of Constant, which represent the different fla...
Represent the analysis usage information of a pass.
BinaryOp_match< LHS, RHS, Instruction::Shl > m_Shl(const LHS &L, const RHS &R)
FunctionPass class - This class is used to implement most global optimizations.
CallInst * CreateCall(Value *Callee, ArrayRef< Value * > Args=None, const Twine &Name="")
This is the shared class of boolean and integer constants.
ConstantInt * getInt32(uint32_t C)
Get a constant 32-bit value.
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.
Class for arbitrary precision integers.
Value * CreateShl(Value *LHS, Value *RHS, const Twine &Name="", bool HasNUW=false, bool HasNSW=false)
static IntegerType * getInt32Ty(LLVMContext &C)
unsigned getPrimitiveSizeInBits() const LLVM_READONLY
getPrimitiveSizeInBits - Return the basic size of this type if it is a primitive type.
LLVM Value Representation.
FunctionPass * createHexagonGenExtract()
PassRegistry - This class manages the registration and intitialization of the pass subsystem as appli...
Legacy analysis pass which computes a DominatorTree.