LLVM 20.0.0git
|
Go to the source code of this file.
Functions | |
static std::optional< uint64_t > | isConstantVal (DIExpression::ExprOperand Op) |
Returns true if the Op is a DW_OP_constu. | |
static bool | isNeutralElement (uint64_t Op, uint64_t Val) |
Returns true if an operation and operand result in a No Op. | |
static std::optional< uint64_t > | foldOperationIfPossible (uint64_t Const1, uint64_t Const2, dwarf::LocationAtom Operator) |
Try to fold Const1 and Const2 by applying Operator and returning the result, if there is an overflow, return a std::nullopt. | |
static bool | operationsAreFoldableAndCommutative (dwarf::LocationAtom Operator1, dwarf::LocationAtom Operator2) |
Returns true if the two operations Operator1 and Operator2 are commutative and can be folded. | |
static void | consumeOneOperator (DIExpressionCursor &Cursor, uint64_t &Loc, const DIExpression::ExprOperand &Op) |
Consume one operator and its operand(s). | |
void | startFromBeginning (uint64_t &Loc, DIExpressionCursor &Cursor, ArrayRef< uint64_t > WorkingOps) |
Reset the Cursor to the beginning of the WorkingOps. | |
static SmallVector< uint64_t > | canonicalizeDwarfOperations (ArrayRef< uint64_t > WorkingOps) |
This function will canonicalize: | |
static SmallVector< uint64_t > | optimizeDwarfOperations (ArrayRef< uint64_t > WorkingOps) |
This function will convert: | |
static bool | tryFoldNoOpMath (uint64_t Const1, ArrayRef< DIExpression::ExprOperand > Ops, uint64_t &Loc, DIExpressionCursor &Cursor, SmallVectorImpl< uint64_t > &WorkingOps) |
{DW_OP_constu, 0, DW_OP_[plus, minus, shl, shr]} -> {} {DW_OP_constu, 1, DW_OP_[mul, div]} -> {} | |
static bool | tryFoldConstants (uint64_t Const1, ArrayRef< DIExpression::ExprOperand > Ops, uint64_t &Loc, DIExpressionCursor &Cursor, SmallVectorImpl< uint64_t > &WorkingOps) |
{DW_OP_constu, Const1, DW_OP_constu, Const2, DW_OP_[plus, minus, mul, div, shl, shr] -> {DW_OP_constu, Const1 [+, -, *, /, <<, >>] Const2} | |
static bool | tryFoldCommutativeMath (uint64_t Const1, ArrayRef< DIExpression::ExprOperand > Ops, uint64_t &Loc, DIExpressionCursor &Cursor, SmallVectorImpl< uint64_t > &WorkingOps) |
{DW_OP_constu, Const1, DW_OP_[plus, mul], DW_OP_constu, Const2, DW_OP_[plus, mul]} -> {DW_OP_constu, Const1 [+, *] Const2, DW_OP_[plus, mul]} | |
static bool | tryFoldCommutativeMathWithArgInBetween (uint64_t Const1, ArrayRef< DIExpression::ExprOperand > Ops, uint64_t &Loc, DIExpressionCursor &Cursor, SmallVectorImpl< uint64_t > &WorkingOps) |
{DW_OP_constu, Const1, DW_OP_[plus, mul], DW_OP_LLVM_arg, Arg1, DW_OP_[plus, mul], DW_OP_constu, Const2, DW_OP_[plus, mul]} -> {DW_OP_constu, Const1 [+, *] Const2, DW_OP_[plus, mul], DW_OP_LLVM_arg, Arg1, DW_OP_[plus, mul]} | |
|
static |
This function will canonicalize:
Expression has no operations, break.
Definition at line 115 of file DIExpressionOptimizer.cpp.
References llvm::SmallVectorImpl< T >::append(), llvm::ArrayRef< T >::begin(), consumeOneOperator(), llvm::DIExpressionCursor::peek(), llvm::SmallVectorTemplateBase< T, bool >::push_back(), and llvm::ArrayRef< T >::size().
Referenced by llvm::DIExpression::foldConstantMath().
|
static |
Consume one operator and its operand(s).
Definition at line 98 of file DIExpressionOptimizer.cpp.
References llvm::DIExpressionCursor::consume().
Referenced by canonicalizeDwarfOperations(), llvm::DIExpression::foldConstantMath(), optimizeDwarfOperations(), tryFoldCommutativeMath(), tryFoldCommutativeMathWithArgInBetween(), and tryFoldConstants().
|
static |
Try to fold Const1
and Const2
by applying Operator
and returning the result, if there is an overflow, return a std::nullopt.
Definition at line 45 of file DIExpressionOptimizer.cpp.
References llvm::countl_zero(), llvm::countr_zero(), llvm::SaturatingAdd(), and llvm::SaturatingMultiply().
Referenced by tryFoldCommutativeMath(), tryFoldCommutativeMathWithArgInBetween(), and tryFoldConstants().
|
static |
Returns true if the Op is a DW_OP_constu.
Definition at line 20 of file DIExpressionOptimizer.cpp.
Referenced by llvm::DIExpression::foldConstantMath(), tryFoldCommutativeMath(), tryFoldCommutativeMathWithArgInBetween(), and tryFoldConstants().
Returns true if an operation and operand result in a No Op.
Definition at line 27 of file DIExpressionOptimizer.cpp.
Referenced by tryFoldNoOpMath().
|
static |
Returns true if the two operations Operator1
and Operator2
are commutative and can be folded.
Definition at line 91 of file DIExpressionOptimizer.cpp.
Referenced by tryFoldCommutativeMath(), and tryFoldCommutativeMathWithArgInBetween().
|
static |
This function will convert:
Expression has no operations, exit.
Expression has no more operations, copy into ResultOps and exit.
Definition at line 150 of file DIExpressionOptimizer.cpp.
References llvm::SmallVectorImpl< T >::append(), llvm::ArrayRef< T >::begin(), consumeOneOperator(), llvm::DIExpressionCursor::peek(), llvm::DIExpressionCursor::peekNext(), llvm::SmallVectorTemplateBase< T, bool >::push_back(), and llvm::ArrayRef< T >::size().
Referenced by llvm::DIExpression::foldConstantMath().
void startFromBeginning | ( | uint64_t & | Loc, |
DIExpressionCursor & | Cursor, | ||
ArrayRef< uint64_t > | WorkingOps | ||
) |
Reset the Cursor to the beginning of the WorkingOps.
Definition at line 105 of file DIExpressionOptimizer.cpp.
References llvm::DIExpressionCursor::assignNewExpr().
Referenced by tryFoldCommutativeMath(), tryFoldCommutativeMathWithArgInBetween(), tryFoldConstants(), and tryFoldNoOpMath().
|
static |
{DW_OP_constu, Const1, DW_OP_[plus, mul], DW_OP_constu, Const2, DW_OP_[plus, mul]} -> {DW_OP_constu, Const1 [+, *] Const2, DW_OP_[plus, mul]}
Definition at line 234 of file DIExpressionOptimizer.cpp.
References llvm::SmallVectorTemplateCommon< T, typename >::begin(), consumeOneOperator(), llvm::SmallVectorImpl< T >::erase(), foldOperationIfPossible(), isConstantVal(), operationsAreFoldableAndCommutative(), and startFromBeginning().
Referenced by llvm::DIExpression::foldConstantMath().
|
static |
{DW_OP_constu, Const1, DW_OP_[plus, mul], DW_OP_LLVM_arg, Arg1, DW_OP_[plus, mul], DW_OP_constu, Const2, DW_OP_[plus, mul]} -> {DW_OP_constu, Const1 [+, *] Const2, DW_OP_[plus, mul], DW_OP_LLVM_arg, Arg1, DW_OP_[plus, mul]}
Definition at line 262 of file DIExpressionOptimizer.cpp.
References llvm::SmallVectorTemplateCommon< T, typename >::begin(), consumeOneOperator(), llvm::dwarf::DW_OP_LLVM_arg, llvm::SmallVectorImpl< T >::erase(), foldOperationIfPossible(), isConstantVal(), operationsAreFoldableAndCommutative(), and startFromBeginning().
Referenced by llvm::DIExpression::foldConstantMath().
|
static |
{DW_OP_constu, Const1, DW_OP_constu, Const2, DW_OP_[plus, minus, mul, div, shl, shr] -> {DW_OP_constu, Const1 [+, -, *, /, <<, >>] Const2}
Definition at line 209 of file DIExpressionOptimizer.cpp.
References llvm::SmallVectorTemplateCommon< T, typename >::begin(), consumeOneOperator(), llvm::SmallVectorImpl< T >::erase(), foldOperationIfPossible(), isConstantVal(), and startFromBeginning().
Referenced by llvm::DIExpression::foldConstantMath().
|
static |
{DW_OP_constu, 0, DW_OP_[plus, minus, shl, shr]} -> {} {DW_OP_constu, 1, DW_OP_[mul, div]} -> {}
Definition at line 193 of file DIExpressionOptimizer.cpp.
References llvm::SmallVectorTemplateCommon< T, typename >::begin(), llvm::SmallVectorImpl< T >::erase(), isNeutralElement(), and startFromBeginning().
Referenced by llvm::DIExpression::foldConstantMath().