40char AVRShiftExpand::ID = 0;
47bool AVRShiftExpand::runOnFunction(
Function &
F) {
49 auto &Ctx =
F.getContext();
57 if (isa<ConstantInt>(
I.getOperand(1)))
61 ShiftInsts.
push_back(cast<BinaryOperator>(&
I));
67 for (
auto *
I : ShiftInsts) {
72 return ShiftInsts.size() > 0;
96 Value *Cmp1 =
Builder.CreateICmpEQ(ShiftAmount, Int8Zero);
97 Builder.CreateCondBr(Cmp1, EndBB, LoopBB);
101 Builder.SetInsertPoint(LoopBB);
109 Value *ShiftAmountSub =
111 ShiftAmountPHI->
addIncoming(ShiftAmountSub, LoopBB);
118 case Instruction::Shl:
121 case Instruction::LShr:
124 case Instruction::AShr:
134 Value *Cmp2 =
Builder.CreateICmpEQ(ShiftAmountSub, Int8Zero);
135 Builder.CreateCondBr(Cmp2, EndBB, LoopBB);
142 Result->addIncoming(ValueShifted, LoopBB);
static Expected< BitVector > expand(StringRef S, StringRef Original)
print must be executed print the must be executed context for all instructions
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
LLVM Basic Block Representation.
static BasicBlock * Create(LLVMContext &Context, const Twine &Name="", Function *Parent=nullptr, BasicBlock *InsertBefore=nullptr)
Creates a new BasicBlock.
BasicBlock * splitBasicBlock(iterator I, const Twine &BBName="", bool Before=false)
Split the basic block into two basic blocks at the specified instruction.
const Function * getParent() const
Return the enclosing method, or null if none.
const Instruction & back() const
BinaryOps getOpcode() const
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.
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...
const BasicBlock * getParent() const
SymbolTableList< Instruction >::iterator eraseFromParent()
This method unlinks 'this' from the containing basic block and deletes it.
void addIncoming(Value *V, BasicBlock *BB)
Add an incoming value to the end of the PHI list.
Pass interface - Implemented by all 'passes'.
virtual StringRef getPassName() const
getPassName - Return a nice clean name for a pass.
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringRef - Represent a constant reference to a string, i.e.
The instances of the Type class are immutable: once they are created, they are never changed.
static IntegerType * getInt8Ty(LLVMContext &C)
static IntegerType * getInt32Ty(LLVMContext &C)
Value * getOperand(unsigned i) const
LLVM Value Representation.
void replaceAllUsesWith(Value *V)
Change all uses of this to point to a new Value.
LLVMContext & getContext() const
All values hold a context through their type.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
This is an optimization pass for GlobalISel generic memory operations.
Pass * createAVRShiftExpandPass()