Skip to content

Commit

Permalink
Merge pull request #3059 from 0dvictor/rct
Browse files Browse the repository at this point in the history
RecognizedCallTransformer to provide a default action
  • Loading branch information
0xdaryl authored Dec 20, 2018
2 parents f81a866 + 491dd1b commit dd0d82d
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 3 deletions.
16 changes: 16 additions & 0 deletions compiler/optimizer/OMRRecognizedCallTransformer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
#include "il/TreeTop_inlines.hpp"
#include "infra/Checklist.hpp" // for NodeChecklist, etc
#include "codegen/CodeGenerator.hpp" // for CodeGenerator
#include "codegen/CodeGenerator_inlines.hpp"
#include "optimizer/TransformUtil.hpp"

TR::Optimization* OMR::RecognizedCallTransformer::create(TR::OptimizationManager *manager)
{
Expand Down Expand Up @@ -55,6 +57,20 @@ int32_t OMR::RecognizedCallTransformer::perform()
return 0;
}

bool OMR::RecognizedCallTransformer::isInlineable(TR::TreeTop* treetop)
{
return cg()->isIntrinsicMethodSupported(treetop->getNode()->getFirstChild()->getSymbol()->castToMethodSymbol()->getMandatoryRecognizedMethod());
}

void OMR::RecognizedCallTransformer::transform(TR::TreeTop* treetop)
{
auto node = treetop->getNode()->getFirstChild();
auto rm = node->getSymbol()->castToMethodSymbol()->getMandatoryRecognizedMethod();
TR_ASSERT(cg()->isIntrinsicMethodSupported(rm), "Only supported intrinsic method should reach here.");
TR::Node::recreate(node, cg()->ilOpCodeForIntrinsicMethod(rm));
TR::TransformUtil::removeTree(comp(), treetop);
}

const char* OMR::RecognizedCallTransformer::optDetailString() const throw()
{
return "O^O RECOGNIZED CALL TRANSFORMER:";
Expand Down
21 changes: 18 additions & 3 deletions compiler/optimizer/OMRRecognizedCallTransformer.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2017, 2017 IBM Corp. and others
* Copyright (c) 2017, 2018 IBM Corp. and others
*
* This program and the accompanying materials are made available under
* the terms of the Eclipse Public License 2.0 which accompanies this
Expand Down Expand Up @@ -43,8 +43,23 @@ class RecognizedCallTransformer : public TR::Optimization

protected:

virtual bool isInlineable(TR::TreeTop* treetop) { return false; }
virtual void transform(TR::TreeTop* treetop) {}
/** \brief
* Check if a treetop is inlineable. The treetop must have one sole child TR::call
*
* \param treetop
* The treetop which anchors the call node.
*
*/
virtual bool isInlineable(TR::TreeTop* treetop);

/** \brief
* Perform transformation on the treetop. The treetop must have one sole child TR::call
*
* \param treetop
* The treetop which anchors the call node.
*
*/
virtual void transform(TR::TreeTop* treetop);
};

}
Expand Down

0 comments on commit dd0d82d

Please sign in to comment.