Flutter Engine
The Flutter Engine
Public Member Functions | Static Public Member Functions | List of all members
dart::BinaryIntegerOpInstr Class Reference

#include <il.h>

Inheritance diagram for dart::BinaryIntegerOpInstr:
dart::TemplateDefinition< 2, NoThrow, Pure > dart::PureDefinition dart::Definition dart::Instruction dart::ZoneAllocated dart::BinaryInt32OpInstr dart::BinaryInt64OpInstr dart::BinarySmiOpInstr dart::BinaryUint32OpInstr dart::ShiftIntegerOpInstr dart::ShiftInt64OpInstr dart::ShiftUint32OpInstr dart::SpeculativeShiftInt64OpInstr dart::SpeculativeShiftUint32OpInstr

Public Member Functions

 BinaryIntegerOpInstr (Token::Kind op_kind, Value *left, Value *right, intptr_t deopt_id)
 
Token::Kind op_kind () const
 
Valueleft () const
 
Valueright () const
 
bool can_overflow () const
 
void set_can_overflow (bool overflow)
 
bool is_truncating () const
 
void mark_truncating ()
 
bool RightIsNonZero () const
 
bool RightIsPowerOfTwoConstant () const
 
virtual DefinitionCanonicalize (FlowGraph *flow_graph)
 
virtual bool AttributesEqual (const Instruction &other) const
 
virtual intptr_t DeoptimizationTarget () const
 
virtual void InferRange (RangeAnalysis *analysis, Range *range)
 
- Public Member Functions inherited from dart::TemplateDefinition< 2, NoThrow, Pure >
 TemplateDefinition (intptr_t deopt_id=DeoptId::kNone)
 
 TemplateDefinition (const InstructionSource &source, intptr_t deopt_id=DeoptId::kNone)
 
virtual intptr_t InputCount () const
 
virtual ValueInputAt (intptr_t i) const
 
virtual bool MayThrow () const
 
- Public Member Functions inherited from dart::PureDefinition
 PureDefinition (intptr_t deopt_id)
 
 PureDefinition (const InstructionSource &source, intptr_t deopt_id)
 
virtual bool AllowsCSE () const
 
virtual bool HasUnknownSideEffects () const
 
- Public Member Functions inherited from dart::Definition
 Definition (intptr_t deopt_id=DeoptId::kNone)
 
 Definition (const InstructionSource &source, intptr_t deopt_id=DeoptId::kNone)
 
virtual intptr_t CallCount () const
 
intptr_t temp_index () const
 
void set_temp_index (intptr_t index)
 
void ClearTempIndex ()
 
bool HasTemp () const
 
intptr_t ssa_temp_index () const
 
void set_ssa_temp_index (intptr_t index)
 
bool HasSSATemp () const
 
void ClearSSATempIndex ()
 
intptr_t vreg (intptr_t index) const
 
intptr_t location_count () const
 
bool HasPairRepresentation () const
 
CompileTypeType ()
 
bool HasType () const
 
bool IsInt64Definition ()
 
bool IsInt32Definition ()
 
virtual CompileType ComputeType () const
 
virtual bool RecomputeType ()
 
PRINT_OPERANDS_TO_SUPPORT PRINT_TO_SUPPORT bool UpdateType (CompileType new_type)
 
bool HasUses () const
 
bool HasOnlyUse (Value *use) const
 
bool HasOnlyInputUse (Value *use) const
 
Valueinput_use_list () const
 
void set_input_use_list (Value *head)
 
Valueenv_use_list () const
 
void set_env_use_list (Value *head)
 
ValueListIterable input_uses () const
 
void AddInputUse (Value *value)
 
void AddEnvUse (Value *value)
 
virtual bool MayCreateUnsafeUntaggedPointer () const
 
virtual bool CanReplaceWithConstant () const
 
virtual bool CanEliminate (const BlockEntryInstr *block) const
 
void ReplaceUsesWith (Definition *other)
 
void ReplaceWithResult (Instruction *replacement, Definition *replacement_for_uses, ForwardInstructionIterator *iterator)
 
void ReplaceWith (Definition *other, ForwardInstructionIterator *iterator)
 
Objectconstant_value ()
 
virtual void InferRange (RangeAnalysis *analysis, Range *range)
 
Rangerange () const
 
void set_range (const Range &)
 
virtual DefinitionCanonicalize (FlowGraph *flow_graph)
 
DefinitionReplacement ()
 
void SetReplacement (Definition *other)
 
virtual AliasIdentity Identity () const
 
virtual void SetIdentity (AliasIdentity identity)
 
DefinitionOriginalDefinition ()
 
virtual ValueRedefinedValue () const
 
DefinitionOriginalDefinitionIgnoreBoxingAndConstraints ()
 
virtual DefinitionAsDefinition ()
 
virtual const DefinitionAsDefinition () const
 
- Public Member Functions inherited from dart::Instruction
 Instruction (const InstructionSource &source, intptr_t deopt_id=DeoptId::kNone)
 
 Instruction (intptr_t deopt_id=DeoptId::kNone)
 
virtual ~Instruction ()
 
virtual Tag tag () const =0
 
virtual intptr_t statistics_tag () const
 
intptr_t deopt_id () const
 
virtual TokenPosition token_pos () const
 
InstructionSource source () const
 
virtual intptr_t InputCount () const =0
 
virtual ValueInputAt (intptr_t i) const =0
 
void SetInputAt (intptr_t i, Value *value)
 
InputsIterable inputs ()
 
void UnuseAllInputs ()
 
virtual intptr_t ArgumentCount () const
 
ValueArgumentValueAt (intptr_t index) const
 
DefinitionArgumentAt (intptr_t index) const
 
virtual void SetMoveArguments (MoveArgumentsArray *move_arguments)
 
virtual MoveArgumentsArrayGetMoveArguments () const
 
virtual void ReplaceInputsWithMoveArguments (MoveArgumentsArray *move_arguments)
 
bool HasMoveArguments () const
 
void RepairArgumentUsesInEnvironment () const
 
virtual bool ComputeCanDeoptimize () const =0
 
virtual bool ComputeCanDeoptimizeAfterCall () const
 
bool CanDeoptimize () const
 
virtual void Accept (InstructionVisitor *visitor)=0
 
Instructionprevious () const
 
void set_previous (Instruction *instr)
 
Instructionnext () const
 
void set_next (Instruction *instr)
 
void LinkTo (Instruction *next)
 
InstructionRemoveFromGraph (bool return_previous=true)
 
virtual intptr_t SuccessorCount () const
 
virtual BlockEntryInstrSuccessorAt (intptr_t index) const
 
SuccessorsIterable successors () const
 
void Goto (JoinEntryInstr *entry)
 
virtual const char * DebugName () const =0
 
void CheckField (const Field &field) const
 
const char * ToCString () const
 
 DECLARE_INSTRUCTION_TYPE_CHECK (BlockEntryWithInitialDefs, BlockEntryWithInitialDefs) template< typename T > T *Cast()
 
template<typename T >
const TCast () const
 
LocationSummarylocs ()
 
bool HasLocs () const
 
virtual LocationSummaryMakeLocationSummary (Zone *zone, bool is_optimizing) const =0
 
void InitializeLocationSummary (Zone *zone, bool optimizing)
 
virtual void EmitNativeCode (FlowGraphCompiler *compiler)
 
Environmentenv () const
 
void SetEnvironment (Environment *deopt_env)
 
void RemoveEnvironment ()
 
void ReplaceInEnvironment (Definition *current, Definition *replacement)
 
virtual intptr_t NumberOfInputsConsumedBeforeCall () const
 
intptr_t GetPassSpecificId (CompilerPass::Id pass) const
 
void SetPassSpecificId (CompilerPass::Id pass, intptr_t id)
 
bool HasPassSpecificId (CompilerPass::Id pass) const
 
bool HasUnmatchedInputRepresentations () const
 
virtual Representation RequiredInputRepresentation (intptr_t idx) const
 
SpeculativeMode SpeculativeModeOfInputs () const
 
virtual SpeculativeMode SpeculativeModeOfInput (intptr_t index) const
 
virtual Representation representation () const
 
bool WasEliminated () const
 
virtual intptr_t DeoptimizationTarget () const
 
virtual InstructionCanonicalize (FlowGraph *flow_graph)
 
void InsertBefore (Instruction *next)
 
void InsertAfter (Instruction *prev)
 
InstructionAppendInstruction (Instruction *tail)
 
virtual bool AllowsCSE () const
 
virtual bool HasUnknownSideEffects () const =0
 
virtual bool CanCallDart () const
 
virtual bool CanTriggerGC () const
 
virtual BlockEntryInstrGetBlock ()
 
virtual intptr_t inlining_id () const
 
virtual void set_inlining_id (intptr_t value)
 
virtual bool has_inlining_id () const
 
virtual uword Hash () const
 
bool Equals (const Instruction &other) const
 
virtual bool AttributesEqual (const Instruction &other) const
 
void InheritDeoptTarget (Zone *zone, Instruction *other)
 
bool NeedsEnvironment () const
 
virtual bool CanBecomeDeoptimizationTarget () const
 
void InheritDeoptTargetAfter (FlowGraph *flow_graph, Definition *call, Definition *result)
 
virtual bool MayThrow () const =0
 
virtual bool MayHaveVisibleEffect () const
 
virtual bool CanEliminate (const BlockEntryInstr *block) const
 
bool CanEliminate ()
 
bool IsDominatedBy (Instruction *dom)
 
void ClearEnv ()
 
void Unsupported (FlowGraphCompiler *compiler)
 
virtual bool UseSharedSlowPathStub (bool is_optimizing) const
 
Location::Kind RegisterKindForResult () const
 
- Public Member Functions inherited from dart::ZoneAllocated
 ZoneAllocated ()
 
void * operator new (size_t size)
 
void * operator new (size_t size, Zone *zone)
 
void operator delete (void *pointer)
 

Static Public Member Functions

static BinaryIntegerOpInstrMake (Representation representation, Token::Kind op_kind, Value *left, Value *right, intptr_t deopt_id, SpeculativeMode speculative_mode=kGuardInputs)
 
static BinaryIntegerOpInstrMake (Representation representation, Token::Kind op_kind, Value *left, Value *right, intptr_t deopt_id, bool can_overflow, bool is_truncating, Range *range, SpeculativeMode speculative_mode=kGuardInputs)
 
- Static Public Member Functions inherited from dart::Definition
static bool IsArrayLength (Definition *def)
 
- Static Public Member Functions inherited from dart::Instruction
static const ICDataGetICData (const ZoneGrowableArray< const ICData * > &ic_data_array, intptr_t deopt_id, bool is_static_call)
 
static LocationSummaryMakeCallSummary (Zone *zone, const Instruction *instr, LocationSummary *locs=nullptr)
 
static bool SlowPathSharingSupported (bool is_optimizing)
 

Additional Inherited Members

- Public Types inherited from dart::TemplateDefinition< 2, NoThrow, Pure >
using BaseClass = typename Pure< Definition, PureDefinition >::Base
 
- Public Types inherited from dart::Instruction
enum  Tag { FOR_EACH_INSTRUCTION =(DECLARE_TAG) kNumInstructions }
 
enum  SpeculativeMode { kGuardInputs , kNotSpeculative }
 
using InputsIterable = InstructionIndexedPropertyIterable< InputsTrait >
 
using SuccessorsIterable = InstructionIndexedPropertyIterable< SuccessorsTrait >
 
- Static Public Attributes inherited from dart::Definition
static constexpr intptr_t kReplacementMarker = -2
 
- Static Public Attributes inherited from dart::Instruction
static const intptr_t kInstructionAttrs [kNumInstructions]
 
- Protected Member Functions inherited from dart::Definition
void set_type (CompileType *type)
 
- Protected Member Functions inherited from dart::Instruction
intptr_t GetDeoptId () const
 
virtual void CopyDeoptIdFrom (const Instruction &instr)
 
void WriteExtraWithoutInputs (FlowGraphSerializer *s)
 
void ReadExtraWithoutInputs (FlowGraphDeserializer *d)
 
- Protected Attributes inherited from dart::TemplateDefinition< 2, NoThrow, Pure >
EmbeddedArray< Value *, Ninputs_
 
- Protected Attributes inherited from dart::Definition
Rangerange_ = nullptr
 

Detailed Description

Definition at line 9363 of file il.h.

Constructor & Destructor Documentation

◆ BinaryIntegerOpInstr()

dart::BinaryIntegerOpInstr::BinaryIntegerOpInstr ( Token::Kind  op_kind,
Value left,
Value right,
intptr_t  deopt_id 
)
inline

Definition at line 9365 of file il.h.

9370 op_kind_(op_kind),
9371 can_overflow_(true),
9372 is_truncating_(false) {
9373 SetInputAt(0, left);
9374 SetInputAt(1, right);
9375 }
Value * right() const
Definition: il.h:9398
Token::Kind op_kind() const
Definition: il.h:9396
Value * left() const
Definition: il.h:9397
void SetInputAt(intptr_t i, Value *value)
Definition: il.h:1014
intptr_t deopt_id() const
Definition: il.h:993
TemplateDefinition(intptr_t deopt_id=DeoptId::kNone)
Definition: il.h:2749

Member Function Documentation

◆ AttributesEqual()

bool dart::BinaryIntegerOpInstr::AttributesEqual ( const Instruction other) const
virtual

Reimplemented from dart::Instruction.

Reimplemented in dart::BinaryInt64OpInstr.

Definition at line 1113 of file il.cc.

1113 {
1114 ASSERT(other.tag() == tag());
1115 auto const other_op = other.AsBinaryIntegerOp();
1116 return (op_kind() == other_op->op_kind()) &&
1117 (can_overflow() == other_op->can_overflow()) &&
1118 (is_truncating() == other_op->is_truncating());
1119}
bool can_overflow() const
Definition: il.h:9400
bool is_truncating() const
Definition: il.h:9406
virtual Tag tag() const =0
#define ASSERT(E)

◆ can_overflow()

bool dart::BinaryIntegerOpInstr::can_overflow ( ) const
inline

Definition at line 9400 of file il.h.

9400{ return can_overflow_; }

◆ Canonicalize()

Definition * dart::BinaryIntegerOpInstr::Canonicalize ( FlowGraph flow_graph)
virtual

Reimplemented from dart::Definition.

Definition at line 2409 of file il.cc.

2409 {
2410 // If range analysis has already determined a single possible value for
2411 // this operation, then replace it if possible.
2413 const auto& value =
2415 auto* const replacement =
2416 flow_graph->TryCreateConstantReplacementFor(this, value);
2417 if (replacement != this) {
2418 return replacement;
2419 }
2420 }
2421
2422 // If both operands are constants evaluate this expression. Might
2423 // occur due to load forwarding after constant propagation pass
2424 // have already been run.
2425
2426 if (left()->BindsToConstant() && right()->BindsToConstant()) {
2428 left()->BoundConstant(), right()->BoundConstant(), op_kind(),
2430
2431 if (!result.IsNull()) {
2432 return flow_graph->TryCreateConstantReplacementFor(this, result);
2433 }
2434 }
2435
2436 if (left()->BindsToConstant() && !right()->BindsToConstant() &&
2438 Value* l = left();
2439 Value* r = right();
2440 SetInputAt(0, r);
2441 SetInputAt(1, l);
2442 }
2443
2444 int64_t rhs;
2445 if (!Evaluator::ToIntegerConstant(right(), &rhs)) {
2446 return this;
2447 }
2448
2449 if (is_truncating()) {
2450 switch (op_kind()) {
2451 case Token::kMUL:
2452 case Token::kSUB:
2453 case Token::kADD:
2454 case Token::kBIT_AND:
2455 case Token::kBIT_OR:
2456 case Token::kBIT_XOR:
2458 break;
2459 default:
2460 break;
2461 }
2462 }
2463
2464 if (IsBinaryUint32Op() && HasUnmatchedInputRepresentations()) {
2465 // Canonicalization may eliminate instruction and loose truncation,
2466 // so it is illegal to canonicalize truncating uint32 instruction
2467 // until all conversions for its inputs are inserted.
2468 return this;
2469 }
2470
2471 switch (op_kind()) {
2472 case Token::kMUL:
2473 if (rhs == 1) {
2474 return left()->definition();
2475 } else if (rhs == 0) {
2476 return right()->definition();
2477 } else if ((rhs > 0) && Utils::IsPowerOfTwo(rhs)) {
2478 const int64_t shift_amount = Utils::ShiftForPowerOfTwo(rhs);
2479 const Representation shift_amount_rep =
2480 (SpeculativeModeOfInputs() == kNotSpeculative) ? kUnboxedInt64
2481 : kTagged;
2482 ConstantInstr* constant_shift_amount = flow_graph->GetConstant(
2483 Smi::Handle(Smi::New(shift_amount)), shift_amount_rep);
2485 representation(), Token::kSHL, left()->CopyWithType(),
2486 new Value(constant_shift_amount), GetDeoptId(), can_overflow(),
2488 if (shift != nullptr) {
2489 // Assign a range to the shift factor, just in case range
2490 // analysis no longer runs after this rewriting.
2491 if (auto shift_with_range = shift->AsShiftIntegerOp()) {
2492 shift_with_range->set_shift_range(
2493 new Range(RangeBoundary::FromConstant(shift_amount),
2494 RangeBoundary::FromConstant(shift_amount)));
2495 }
2496 if (!MayThrow()) {
2497 ASSERT(!shift->MayThrow());
2498 }
2499 if (!CanDeoptimize()) {
2500 ASSERT(!shift->CanDeoptimize());
2501 }
2502 flow_graph->InsertBefore(this, shift, env(), FlowGraph::kValue);
2503 return shift;
2504 }
2505 }
2506
2507 break;
2508 case Token::kADD:
2509 if (rhs == 0) {
2510 return left()->definition();
2511 }
2512 break;
2513 case Token::kBIT_AND:
2514 if (rhs == 0) {
2515 return right()->definition();
2516 } else if (rhs == RepresentationMask(representation())) {
2517 return left()->definition();
2518 }
2519 break;
2520 case Token::kBIT_OR:
2521 if (rhs == 0) {
2522 return left()->definition();
2523 } else if (rhs == RepresentationMask(representation())) {
2524 return right()->definition();
2525 }
2526 break;
2527 case Token::kBIT_XOR:
2528 if (rhs == 0) {
2529 return left()->definition();
2530 } else if (rhs == RepresentationMask(representation())) {
2531 UnaryIntegerOpInstr* bit_not = UnaryIntegerOpInstr::Make(
2532 representation(), Token::kBIT_NOT, left()->CopyWithType(),
2534 if (bit_not != nullptr) {
2535 flow_graph->InsertBefore(this, bit_not, env(), FlowGraph::kValue);
2536 return bit_not;
2537 }
2538 }
2539 break;
2540
2541 case Token::kSUB:
2542 if (rhs == 0) {
2543 return left()->definition();
2544 }
2545 break;
2546
2547 case Token::kTRUNCDIV:
2548 if (rhs == 1) {
2549 return left()->definition();
2550 } else if (rhs == -1) {
2551 UnaryIntegerOpInstr* negation = UnaryIntegerOpInstr::Make(
2552 representation(), Token::kNEGATE, left()->CopyWithType(),
2554 if (negation != nullptr) {
2555 flow_graph->InsertBefore(this, negation, env(), FlowGraph::kValue);
2556 return negation;
2557 }
2558 }
2559 break;
2560
2561 case Token::kMOD:
2562 if ((rhs == -1) || (rhs == 1)) {
2563 return flow_graph->TryCreateConstantReplacementFor(this,
2564 Object::smi_zero());
2565 }
2566 break;
2567
2568 case Token::kUSHR:
2569 if (rhs >= kBitsPerInt64) {
2570 return flow_graph->TryCreateConstantReplacementFor(this,
2571 Object::smi_zero());
2572 }
2574 case Token::kSHR:
2575 if (rhs == 0) {
2576 return left()->definition();
2577 } else if (rhs < 0) {
2578 // Instruction will always throw on negative rhs operand.
2579 if (!CanDeoptimize()) {
2580 // For non-speculative operations (no deopt), let
2581 // the code generator deal with throw on slowpath.
2582 break;
2583 }
2585 DeoptimizeInstr* deopt =
2586 new DeoptimizeInstr(ICData::kDeoptBinarySmiOp, GetDeoptId());
2587 flow_graph->InsertBefore(this, deopt, env(), FlowGraph::kEffect);
2588 // Replace with zero since it always throws.
2589 return flow_graph->TryCreateConstantReplacementFor(this,
2590 Object::smi_zero());
2591 }
2592 break;
2593
2594 case Token::kSHL: {
2595 const intptr_t result_bits = RepresentationBits(representation());
2596 if (rhs == 0) {
2597 return left()->definition();
2598 } else if ((rhs >= kBitsPerInt64) ||
2599 ((rhs >= result_bits) && is_truncating())) {
2600 return flow_graph->TryCreateConstantReplacementFor(this,
2601 Object::smi_zero());
2602 } else if ((rhs < 0) || ((rhs >= result_bits) && !is_truncating())) {
2603 // Instruction will always throw on negative rhs operand or
2604 // deoptimize on large rhs operand.
2605 if (!CanDeoptimize()) {
2606 // For non-speculative operations (no deopt), let
2607 // the code generator deal with throw on slowpath.
2608 break;
2609 }
2611 DeoptimizeInstr* deopt =
2612 new DeoptimizeInstr(ICData::kDeoptBinarySmiOp, GetDeoptId());
2613 flow_graph->InsertBefore(this, deopt, env(), FlowGraph::kEffect);
2614 // Replace with zero since it overshifted or always throws.
2615 return flow_graph->TryCreateConstantReplacementFor(this,
2616 Object::smi_zero());
2617 }
2618 break;
2619 }
2620
2621 default:
2622 break;
2623 }
2624
2625 return this;
2626}
static BinaryIntegerOpInstr * Make(Representation representation, Token::Kind op_kind, Value *left, Value *right, intptr_t deopt_id, SpeculativeMode speculative_mode=kGuardInputs)
Definition: il.cc:2293
BinaryIntegerOpInstr(Token::Kind op_kind, Value *left, Value *right, intptr_t deopt_id)
Definition: il.h:9365
Range * range() const
Definition: il.h:2636
virtual bool CanReplaceWithConstant() const
Definition: il.h:2599
friend class Value
Definition: il.h:2690
static constexpr intptr_t kNone
Definition: deopt_id.h:27
static int64_t TruncateTo(int64_t v, Representation r)
Definition: evaluator.cc:81
static IntegerPtr BinaryIntegerEvaluate(const Object &left, const Object &right, Token::Kind token_kind, bool is_truncating, Representation representation, Thread *thread)
Definition: evaluator.cc:99
static bool ToIntegerConstant(Value *value, int64_t *result)
Definition: evaluator.cc:281
intptr_t GetDeoptId() const
Definition: il.h:1409
Environment * env() const
Definition: il.h:1215
@ kNotSpeculative
Definition: il.h:975
bool HasUnmatchedInputRepresentations() const
Definition: il.cc:1609
virtual Representation representation() const
Definition: il.h:1260
bool CanDeoptimize() const
Definition: il.h:1079
SpeculativeMode SpeculativeModeOfInputs() const
Definition: il.h:1245
static IntegerPtr NewCanonical(const String &str)
Definition: object.cc:22999
static Object & Handle()
Definition: object.h:407
static RangeBoundary FromConstant(int64_t val)
static bool IsSingleton(Range *range)
static SmiPtr New(intptr_t value)
Definition: object.h:10006
static Thread * Current()
Definition: thread.h:362
static UnaryIntegerOpInstr * Make(Representation representation, Token::Kind op_kind, Value *value, intptr_t deopt_id, SpeculativeMode speculative_mode, Range *range)
Definition: il.cc:2257
static constexpr int ShiftForPowerOfTwo(T x)
Definition: utils.h:81
static constexpr bool IsPowerOfTwo(T x)
Definition: utils.h:76
Definition * definition() const
Definition: il.h:103
uint8_t value
GAsyncResult * result
static int64_t RepresentationMask(Representation r)
Definition: il.cc:2149
Representation
Definition: locations.h:66
static intptr_t RepresentationBits(Representation r)
Definition: il.cc:2134
static bool IsCommutative(Token::Kind op)
Definition: il.cc:2240
constexpr intptr_t kBitsPerInt64
Definition: globals.h:467
#define FALL_THROUGH
Definition: globals.h:15

◆ DeoptimizationTarget()

virtual intptr_t dart::BinaryIntegerOpInstr::DeoptimizationTarget ( ) const
inlinevirtual

Reimplemented from dart::Instruction.

Definition at line 9424 of file il.h.

9424{ return GetDeoptId(); }

◆ InferRange()

void dart::BinaryIntegerOpInstr::InferRange ( RangeAnalysis analysis,
Range range 
)
virtual

Reimplemented from dart::Definition.

Reimplemented in dart::BinarySmiOpInstr, and dart::ShiftIntegerOpInstr.

Definition at line 3039 of file range_analysis.cc.

3039 {
3040 auto const left_size =
3042 auto const right_size =
3044 InferRangeHelper(GetInputRange(analysis, left_size, left()),
3045 GetInputRange(analysis, right_size, right()), range);
3046}
virtual Representation RequiredInputRepresentation(intptr_t idx) const
Definition: il.h:1241
static const Range * GetInputRange(RangeAnalysis *analysis, RangeBoundary::RangeSize size, Value *input)
static RangeBoundary::RangeSize RepresentationToRangeSize(Representation r)

◆ is_truncating()

bool dart::BinaryIntegerOpInstr::is_truncating ( ) const
inline

Definition at line 9406 of file il.h.

9406{ return is_truncating_; }

◆ left()

Value * dart::BinaryIntegerOpInstr::left ( ) const
inline

Definition at line 9397 of file il.h.

9397{ return inputs_[0]; }
EmbeddedArray< Value *, N > inputs_
Definition: il.h:2762

◆ Make() [1/2]

BinaryIntegerOpInstr * dart::BinaryIntegerOpInstr::Make ( Representation  representation,
Token::Kind  op_kind,
Value left,
Value right,
intptr_t  deopt_id,
bool  can_overflow,
bool  is_truncating,
Range range,
SpeculativeMode  speculative_mode = kGuardInputs 
)
static

Definition at line 2366 of file il.cc.

2375 {
2377 representation, op_kind, left, right, deopt_id, speculative_mode);
2378 if (op == nullptr) {
2379 return nullptr;
2380 }
2381 if (!Range::IsUnknown(range)) {
2382 op->set_range(*range);
2383 }
2384
2385 op->set_can_overflow(can_overflow);
2386 if (is_truncating) {
2387 op->mark_truncating();
2388 }
2389
2390 return op;
2391}
static bool IsUnknown(const Range *other)

◆ Make() [2/2]

BinaryIntegerOpInstr * dart::BinaryIntegerOpInstr::Make ( Representation  representation,
Token::Kind  op_kind,
Value left,
Value right,
intptr_t  deopt_id,
SpeculativeMode  speculative_mode = kGuardInputs 
)
static

Definition at line 2293 of file il.cc.

2299 {
2300 BinaryIntegerOpInstr* op = nullptr;
2301 Range* right_range = nullptr;
2302 switch (op_kind) {
2303 case Token::kMOD:
2304 case Token::kTRUNCDIV:
2305 if (representation != kTagged) break;
2307 case Token::kSHL:
2308 case Token::kSHR:
2309 case Token::kUSHR:
2310 if (auto const const_def = right->definition()->AsConstant()) {
2311 right_range = new Range();
2312 const_def->InferRange(nullptr, right_range);
2313 }
2314 break;
2315 default:
2316 break;
2317 }
2318 switch (representation) {
2319 case kTagged:
2320 op = new BinarySmiOpInstr(op_kind, left, right, deopt_id, right_range);
2321 break;
2322 case kUnboxedInt32:
2324 return nullptr;
2325 }
2326 op = new BinaryInt32OpInstr(op_kind, left, right, deopt_id);
2327 break;
2328 case kUnboxedUint32:
2329 if ((op_kind == Token::kSHL) || (op_kind == Token::kSHR) ||
2330 (op_kind == Token::kUSHR)) {
2331 if (speculative_mode == kNotSpeculative) {
2332 op = new ShiftUint32OpInstr(op_kind, left, right, deopt_id,
2333 right_range);
2334 } else {
2335 op = new SpeculativeShiftUint32OpInstr(op_kind, left, right, deopt_id,
2336 right_range);
2337 }
2338 } else {
2339 op = new BinaryUint32OpInstr(op_kind, left, right, deopt_id);
2340 }
2341 break;
2342 case kUnboxedInt64:
2343 if ((op_kind == Token::kSHL) || (op_kind == Token::kSHR) ||
2344 (op_kind == Token::kUSHR)) {
2345 if (speculative_mode == kNotSpeculative) {
2346 op = new ShiftInt64OpInstr(op_kind, left, right, deopt_id,
2347 right_range);
2348 } else {
2349 op = new SpeculativeShiftInt64OpInstr(op_kind, left, right, deopt_id,
2350 right_range);
2351 }
2352 } else {
2353 op = new BinaryInt64OpInstr(op_kind, left, right, deopt_id,
2354 speculative_mode);
2355 }
2356 break;
2357 default:
2358 UNREACHABLE();
2359 return nullptr;
2360 }
2361
2362 ASSERT(op->representation() == representation);
2363 return op;
2364}
#define UNREACHABLE()
Definition: assert.h:248
static bool IsSupported(Token::Kind op_kind, Value *left, Value *right)
Definition: il.h:9497

◆ mark_truncating()

void dart::BinaryIntegerOpInstr::mark_truncating ( )
inline

Definition at line 9407 of file il.h.

9407 {
9408 is_truncating_ = true;
9409 set_can_overflow(false);
9410 }
void set_can_overflow(bool overflow)
Definition: il.h:9401

◆ op_kind()

Token::Kind dart::BinaryIntegerOpInstr::op_kind ( ) const
inline

Definition at line 9396 of file il.h.

9396{ return op_kind_; }

◆ right()

Value * dart::BinaryIntegerOpInstr::right ( ) const
inline

Definition at line 9398 of file il.h.

9398{ return inputs_[1]; }

◆ RightIsNonZero()

bool dart::BinaryIntegerOpInstr::RightIsNonZero ( ) const

Definition at line 2116 of file il.cc.

2116 {
2117 if (right()->BindsToConstant()) {
2118 const auto& constant = right()->BoundConstant();
2119 if (!constant.IsInteger()) return false;
2120 return Integer::Cast(constant).AsInt64Value() != 0;
2121 }
2122 return !RangeUtils::CanBeZero(right()->definition()->range());
2123}
static bool CanBeZero(Range *range)
const Object & BoundConstant() const
Definition: il.cc:1201

◆ RightIsPowerOfTwoConstant()

bool dart::BinaryIntegerOpInstr::RightIsPowerOfTwoConstant ( ) const

Definition at line 2125 of file il.cc.

2125 {
2126 if (!right()->BindsToConstant()) return false;
2127 const Object& constant = right()->BoundConstant();
2128 if (!constant.IsSmi()) return false;
2129 const intptr_t int_value = Smi::Cast(constant).Value();
2130 ASSERT(int_value != kIntptrMin);
2131 return Utils::IsPowerOfTwo(Utils::Abs(int_value));
2132}
static T Abs(T x)
Definition: utils.h:49
constexpr intptr_t kIntptrMin
Definition: globals.h:556

◆ set_can_overflow()

void dart::BinaryIntegerOpInstr::set_can_overflow ( bool  overflow)
inline

Definition at line 9401 of file il.h.

9401 {
9402 ASSERT(!is_truncating_ || !overflow);
9403 can_overflow_ = overflow;
9404 }

The documentation for this class was generated from the following files: