summaryrefslogtreecommitdiff
path: root/src/jit/rationalize.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/jit/rationalize.h')
-rw-r--r--src/jit/rationalize.h67
1 files changed, 67 insertions, 0 deletions
diff --git a/src/jit/rationalize.h b/src/jit/rationalize.h
new file mode 100644
index 0000000000..9b15fe4871
--- /dev/null
+++ b/src/jit/rationalize.h
@@ -0,0 +1,67 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+//===============================================================================
+#include "phase.h"
+
+class Rationalizer : public Phase
+{
+private:
+ BasicBlock* m_block;
+ GenTreeStmt* m_statement;
+
+public:
+ Rationalizer(Compiler* comp);
+
+#ifdef DEBUG
+ static void ValidateStatement(GenTree* tree, BasicBlock* block);
+
+ // general purpose sanity checking of de facto standard GenTree
+ void SanityCheck();
+
+ // sanity checking of rationalized IR
+ void SanityCheckRational();
+
+#endif // DEBUG
+
+ virtual void DoPhase() override;
+
+ static void RewriteAssignmentIntoStoreLcl(GenTreeOp* assignment);
+ static void MorphAsgIntoStoreObj(Compiler::fgWalkData* data, GenTreeStmt* stmt, GenTree** ppTree);
+
+private:
+ inline LIR::Range& BlockRange() const
+ {
+ return LIR::AsRange(m_block);
+ }
+
+ // SIMD related
+ void RewriteSIMDOperand(LIR::Use& use, bool keepBlk);
+ void FixupIfSIMDLocal(GenTreeLclVarCommon* node);
+
+ // Intrinsic related transformations
+ static void RewriteNodeAsCall(GenTreePtr* ppTree,
+ Compiler::fgWalkData* data,
+ CORINFO_METHOD_HANDLE callHnd,
+#ifdef FEATURE_READYTORUN_COMPILER
+ CORINFO_CONST_LOOKUP entryPoint,
+#endif
+ GenTreeArgList* args);
+
+ static void RewriteIntrinsicAsUserCall(GenTreePtr* ppTree, Compiler::fgWalkData* data);
+
+ // Other transformations
+ void RewriteAssignment(LIR::Use& use);
+ void RewriteAddress(LIR::Use& use);
+
+ // Root visitor
+ Compiler::fgWalkResult RewriteNode(GenTree** useEdge, ArrayStack<GenTree*>& parents);
+};
+
+inline Rationalizer::Rationalizer(Compiler* _comp) : Phase(_comp, "IR Rationalize", PHASE_RATIONALIZE)
+{
+#ifdef DEBUG
+ comp->compNumStatementLinksTraversed = 0;
+#endif
+}