1 // Licensed to the .NET Foundation under one or more agreements.
2 // The .NET Foundation licenses this file to you under the MIT license.
3 // See the LICENSE file in the project root for more information.
5 //===============================================================================
8 class Rationalizer : public Phase
12 GenTreeStmt* m_statement;
15 Rationalizer(Compiler* comp);
18 static void ValidateStatement(GenTree* tree, BasicBlock* block);
20 // general purpose sanity checking of de facto standard GenTree
23 // sanity checking of rationalized IR
24 void SanityCheckRational();
28 virtual void DoPhase() override;
30 static void RewriteAssignmentIntoStoreLcl(GenTreeOp* assignment);
31 static void MorphAsgIntoStoreObj(Compiler::fgWalkData* data, GenTreeStmt* stmt, GenTree** ppTree);
34 inline LIR::Range& BlockRange() const
36 return LIR::AsRange(m_block);
40 void RewriteSIMDOperand(LIR::Use& use, bool keepBlk);
41 void FixupIfSIMDLocal(GenTreeLclVarCommon* node);
43 // Intrinsic related transformations
44 void RewriteNodeAsCall(GenTree** use,
45 ArrayStack<GenTree*>& parents,
46 CORINFO_METHOD_HANDLE callHnd,
47 #ifdef FEATURE_READYTORUN_COMPILER
48 CORINFO_CONST_LOOKUP entryPoint,
50 GenTreeArgList* args);
52 void RewriteIntrinsicAsUserCall(GenTree** use, ArrayStack<GenTree*>& parents);
54 // Other transformations
55 void RewriteAssignment(LIR::Use& use);
56 void RewriteAddress(LIR::Use& use);
59 Compiler::fgWalkResult RewriteNode(GenTree** useEdge, ArrayStack<GenTree*>& parents);
62 inline Rationalizer::Rationalizer(Compiler* _comp) : Phase(_comp, "IR Rationalize", PHASE_RATIONALIZE)
65 comp->compNumStatementLinksTraversed = 0;