#include "src/compiler/machine-operator-reducer.h"
#include <cmath>
#include <cstdint>
#include <limits>
#include <optional>
#include "src/base/bits.h"
#include "src/base/division-by-constant.h"
#include "src/base/ieee754.h"
#include "src/base/logging.h"
#include "src/base/overflowing-math.h"
#include "src/builtins/builtins.h"
#include "src/compiler/diamond.h"
#include "src/compiler/graph.h"
#include "src/compiler/js-operator.h"
#include "src/compiler/machine-graph.h"
#include "src/compiler/node-matchers.h"
#include "src/compiler/node-properties.h"
#include "src/compiler/opcodes.h"
#include "src/numbers/conversions-inl.h"
namespace v8 {
namespace internal {
namespace compiler {
class Word32Adapter { … };
class Word64Adapter { … };
namespace {
template <class T>
T SilenceNaN(T x) { … }
}
MachineOperatorReducer::MachineOperatorReducer(
Editor* editor, MachineGraph* mcgraph,
SignallingNanPropagation signalling_nan_propagation)
: … { … }
MachineOperatorReducer::~MachineOperatorReducer() = default;
Node* MachineOperatorReducer::Float32Constant(float value) { … }
Node* MachineOperatorReducer::Float64Constant(double value) { … }
Node* MachineOperatorReducer::Int32Constant(int32_t value) { … }
Node* MachineOperatorReducer::Int64Constant(int64_t value) { … }
Node* MachineOperatorReducer::Float64Mul(Node* lhs, Node* rhs) { … }
Node* MachineOperatorReducer::Float64PowHalf(Node* value) { … }
Node* MachineOperatorReducer::Word32And(Node* lhs, Node* rhs) { … }
Node* MachineOperatorReducer::Word32Sar(Node* lhs, uint32_t rhs) { … }
Node* MachineOperatorReducer::Word64Sar(Node* lhs, uint32_t rhs) { … }
Node* MachineOperatorReducer::Word32Shr(Node* lhs, uint32_t rhs) { … }
Node* MachineOperatorReducer::Word64Shr(Node* lhs, uint32_t rhs) { … }
Node* MachineOperatorReducer::Word32Equal(Node* lhs, Node* rhs) { … }
Node* MachineOperatorReducer::Word64Equal(Node* lhs, Node* rhs) { … }
Node* MachineOperatorReducer::Word64And(Node* lhs, Node* rhs) { … }
Node* MachineOperatorReducer::Int32Add(Node* lhs, Node* rhs) { … }
Node* MachineOperatorReducer::Int64Add(Node* lhs, Node* rhs) { … }
Node* MachineOperatorReducer::Int32Sub(Node* lhs, Node* rhs) { … }
Node* MachineOperatorReducer::Int64Sub(Node* lhs, Node* rhs) { … }
Node* MachineOperatorReducer::Int32Mul(Node* lhs, Node* rhs) { … }
Node* MachineOperatorReducer::Int64Mul(Node* lhs, Node* rhs) { … }
Node* MachineOperatorReducer::Int32Div(Node* dividend, int32_t divisor) { … }
Node* MachineOperatorReducer::Int64Div(Node* dividend, int64_t divisor) { … }
Node* MachineOperatorReducer::Uint32Div(Node* dividend, uint32_t divisor) { … }
Node* MachineOperatorReducer::Uint64Div(Node* dividend, uint64_t divisor) { … }
Node* MachineOperatorReducer::TruncateInt64ToInt32(Node* value) { … }
Node* MachineOperatorReducer::ChangeInt32ToInt64(Node* value) { … }
Reduction MachineOperatorReducer::Reduce(Node* node) { … }
Reduction MachineOperatorReducer::ReduceTruncateInt64ToInt32(Node* node) { … }
Reduction MachineOperatorReducer::ReduceInt32Add(Node* node) { … }
Reduction MachineOperatorReducer::ReduceInt64Add(Node* node) { … }
Reduction MachineOperatorReducer::ReduceInt32Sub(Node* node) { … }
Reduction MachineOperatorReducer::ReduceInt64Sub(Node* node) { … }
Reduction MachineOperatorReducer::ReduceInt64Mul(Node* node) { … }
Reduction MachineOperatorReducer::ReduceInt32Div(Node* node) { … }
Reduction MachineOperatorReducer::ReduceInt64Div(Node* node) { … }
Reduction MachineOperatorReducer::ReduceUint32Div(Node* node) { … }
Reduction MachineOperatorReducer::ReduceUint64Div(Node* node) { … }
Reduction MachineOperatorReducer::ReduceInt32Mod(Node* node) { … }
Reduction MachineOperatorReducer::ReduceInt64Mod(Node* node) { … }
Reduction MachineOperatorReducer::ReduceUint32Mod(Node* node) { … }
Reduction MachineOperatorReducer::ReduceUint64Mod(Node* node) { … }
Reduction MachineOperatorReducer::ReduceStore(Node* node) { … }
Reduction MachineOperatorReducer::ReduceProjection(size_t index, Node* node) { … }
namespace {
template <typename T>
bool CanRevertLeftShiftWithRightShift(T value, T shift) { … }
bool CanTruncate(int64_t value) { … }
}
Reduction MachineOperatorReducer::ReduceWord32Comparisons(Node* node) { … }
const Operator* MachineOperatorReducer::Map64To32Comparison(
const Operator* op, bool sign_extended) { … }
Reduction MachineOperatorReducer::ReduceWord64Comparisons(Node* node) { … }
Reduction MachineOperatorReducer::ReduceWord32Shifts(Node* node) { … }
Reduction MachineOperatorReducer::ReduceWord32Shl(Node* node) { … }
Reduction MachineOperatorReducer::ReduceWord64Shl(Node* node) { … }
Reduction MachineOperatorReducer::ReduceWord32Shr(Node* node) { … }
Reduction MachineOperatorReducer::ReduceWord64Shr(Node* node) { … }
Reduction MachineOperatorReducer::ReduceWord32Sar(Node* node) { … }
Reduction MachineOperatorReducer::ReduceWord64Sar(Node* node) { … }
template <typename WordNAdapter>
Reduction MachineOperatorReducer::ReduceWordNAnd(Node* node) { … }
template <typename WordNAdapter>
Reduction MachineOperatorReducer::ReduceUintNLessThanOrEqual(Node* node) { … }
namespace {
struct BitfieldCheck { … };
}
Reduction MachineOperatorReducer::ReduceWord32And(Node* node) { … }
Reduction MachineOperatorReducer::ReduceWord64And(Node* node) { … }
Reduction MachineOperatorReducer::TryMatchWord32Ror(Node* node) { … }
template <typename WordNAdapter>
Reduction MachineOperatorReducer::ReduceWordNOr(Node* node) { … }
Reduction MachineOperatorReducer::ReduceWord32Or(Node* node) { … }
Reduction MachineOperatorReducer::ReduceWord64Or(Node* node) { … }
template <typename WordNAdapter>
Reduction MachineOperatorReducer::ReduceWordNXor(Node* node) { … }
Reduction MachineOperatorReducer::ReduceWord32Xor(Node* node) { … }
Reduction MachineOperatorReducer::ReduceWord64Xor(Node* node) { … }
Reduction MachineOperatorReducer::ReduceWord32Equal(Node* node) { … }
Reduction MachineOperatorReducer::ReduceWord64Equal(Node* node) { … }
Reduction MachineOperatorReducer::ReduceFloat64InsertLowWord32(Node* node) { … }
Reduction MachineOperatorReducer::ReduceFloat64InsertHighWord32(Node* node) { … }
namespace {
bool IsFloat64RepresentableAsFloat32(const Float64Matcher& m) { … }
}
Reduction MachineOperatorReducer::ReduceFloat64Compare(Node* node) { … }
Reduction MachineOperatorReducer::ReduceFloat64RoundDown(Node* node) { … }
namespace {
bool IsZero(Node* node) { … }
std::optional<Node*> TryGetInvertedCondition(Node* cond) { … }
struct SimplifiedCondition { … };
std::optional<SimplifiedCondition> TrySimplifyCompareZero(Node* cond) { … }
Node* TrySimplifyCompareForTestBit(Node* cond) { … }
}
void MachineOperatorReducer::SwapBranches(Node* node) { … }
Reduction MachineOperatorReducer::SimplifyBranch(Node* node) { … }
Reduction MachineOperatorReducer::ReduceConditional(Node* node) { … }
template <typename WordNAdapter>
std::optional<Node*> MachineOperatorReducer::ReduceConditionalN(Node* node) { … }
template <typename WordNAdapter, typename uintN_t, typename intN_t>
std::optional<std::pair<Node*, uintN_t>>
MachineOperatorReducer::ReduceWordEqualForConstantRhs(Node* lhs, uintN_t rhs) { … }
CommonOperatorBuilder* MachineOperatorReducer::common() const { … }
MachineOperatorBuilder* MachineOperatorReducer::machine() const { … }
Graph* MachineOperatorReducer::graph() const { … }
}
}
}