20#include "llvm/IR/IntrinsicsHexagon.h"
30 HexagonOptimizeSZextends() : FunctionPass(ID) {}
33 StringRef getPassName()
const override {
return "Remove sign extends"; }
35 void getAnalysisUsage(AnalysisUsage &AU)
const override {
37 FunctionPass::getAnalysisUsage(AU);
44char HexagonOptimizeSZextends::ID = 0;
47 "Remove Sign and Zero Extends for Args",
false,
false)
49bool HexagonOptimizeSZextends::intrinsicAlreadySextended(
Intrinsic::
ID IntID) {
51 case llvm::Intrinsic::hexagon_A2_addh_l16_sat_ll:
59bool HexagonOptimizeSZextends::runOnFunction(
Function &
F) {
67 for (
auto &Arg :
F.args()) {
68 if (
F.getAttributes().hasParamAttr(Idx, Attribute::SExt)) {
73 SExtInst*
SI =
new SExtInst(&Arg,
Use->getType());
76 Use->replaceAllUsesWith(SI);
79 Use->eraseFromParent();
97 if (!(Ashr && Ashr->
getOpcode() == Instruction::AShr))
102 if (!(
C &&
C->getSExtValue() == 16))
107 if (!(Shl && Shl->
getOpcode() == Instruction::Shl))
113 if (!(
C &&
C->getSExtValue() == 16))
118 if (!intrinsicAlreadySextended(
I->getIntrinsicID()))
123 const Use &TheUse = UI.getUse();
125 J->replaceUsesOfWith(Ashr,
I);
137 return new HexagonOptimizeSZextends();
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static bool runOnFunction(Function &F, bool PostInlining)
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
AnalysisUsage & addPreserved()
Add the specified Pass class to the set of analyses preserved by this pass.
InstListType::iterator iterator
Instruction iterators...
BinaryOps getOpcode() const
FunctionPass class - This class is used to implement most global optimizations.
unsigned getOpcode() const
Returns a member of one of the enums like Instruction::Add.
User * getUser() const
Returns the User that contains this Use.
Value * getOperand(unsigned i) const
user_iterator user_begin()
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
@ C
The default llvm calling convention, compatible with C.
This namespace contains an enum with a value for every intrinsic/builtin function known by LLVM.
NodeAddr< UseNode * > Use
friend class Instruction
Iterator for Instructions in a `BasicBlock.
This is an optimization pass for GlobalISel generic memory operations.
FunctionAddr VTableAddr Value
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
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...
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
FunctionPass * createHexagonOptimizeSZextends()
@ First
Helpers to iterate all locations in the MemoryEffectsBase class.
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
static LLVM_ABI EVT getEVT(Type *Ty, bool HandleUnknown=false)
Return the value type corresponding to the specified type.