Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactoring of TR::ternary opcodes to TR::select #4578

Merged
merged 1 commit into from
Feb 26, 2020

Conversation

alvee-unb
Copy link
Contributor

Refactoring of TR::ternary opcodes to TR::select

Replacing of the ternary OpCodes such as TR::bternary etc. to
TR::bselect etc. and the associated items respectively.

The changes are made onto the followings:

  • Components of various data types such as- Int8, Float, Double
    (iternary, bternary etc) etc..
  • Corresponding evaluators such as- bselectEvaluator, iselectEvaluator
    etc. and other functions where the IL OpCodes are used.
  • Corresponding outputs of texts such as- "iselect" etc. and comments
    (//ternary).

Closes: GitHub issue #681

Signed-off-by: Md. Alvee Noor mnoor@unb.ca

@andrewcraik
Copy link
Contributor

Shouldn't the opCodeForTernarySelect also be renamed as part of this?

Copy link
Contributor

@0xdaryl 0xdaryl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your first contribution! I did an initial pass through this and found a few things that need to get fixed up. Once they are, on my next pass I will checkout your branch and sniff around the code for other "ternaries" that may have been missed (other than the one that @andrewcraik already mentioned).

TR::fternary, // Float
TR::dternary, // Double
TR::aternary, // Address
TR::bselect, // Int8. Formerly- TR::bternary
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are these ternary comments necessary? Please remove.

aternary, //
fternary, //
dternary, //
iselect, // Former Ternary Operator: Based on the result of the first child, take the value of the
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace "Former Ternary Operator" with "Select Operator"

dternary, //
iselect, // Former Ternary Operator: Based on the result of the first child, take the value of the
// second (first child evaluates to true) or third(first child evaluates to false) child
// Formerly iternary, lternary, bternary, sternary etc..
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the "Formerly..." comment.

@@ -574,7 +576,7 @@
vreturn, // return a vector
vcall, // direct call returning a vector
vcalli, // indirect call returning a vector
vternary, // vector ternary operator
vternary, // vector ternary operator
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename to vselect as well.

@@ -586,7 +586,7 @@ class IlBuilder : public TR::IlInjector
TR::IlBuilder **caseBuilder,
int32_t caseFallsThrough);

// ternary
// select (former ternary)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove former ternary

@@ -14424,7 +14424,7 @@ OMR::Z::TreeEvaluator::inlineVectorBinaryOp(TR::Node * node, TR::CodeGenerator *
}

TR::Register *
OMR::Z::TreeEvaluator::inlineVectorTernaryOp(TR::Node * node, TR::CodeGenerator *cg, TR::InstOpCode::Mnemonic op)
OMR::Z::TreeEvaluator::inlineVectorSelectOp(TR::Node * node, TR::CodeGenerator *cg, TR::InstOpCode::Mnemonic op)
{
TR_ASSERT(node->getNumChildren() >= 3,"Ternary Node must contain 3 or more children");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Select node"

@@ -546,7 +546,7 @@
TR::TreeEvaluator::vreturnEvaluator, // TR::vreturn
TR::TreeEvaluator::directCallEvaluator, // TR::vcall
TR::TreeEvaluator::indirectCallEvaluator,// TR::vcalli
TR::TreeEvaluator::ternaryEvaluator, // TR::vternary
TR::TreeEvaluator::selectEvaluator, // TR::vternary
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

vselect

static signatureCharIJJ_J_testMethodType *_lternary;
static signatureCharIFF_F_testMethodType *_fternary;
static signatureCharIDD_D_testMethodType *_dternary;
//Select (former- Ternary) operators
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove former ternary

@@ -133,7 +133,7 @@ class OpIlInjector : public TR::IlInjector

TR::ILOpCodes _opCode;
TR::DataType _dataType; // datatype of OpCode child/children
TR::DataType _conditionalDataType; // return type of Ternary opcodes
TR::DataType _conditionalDataType; // return type of Select (former- Ternary) opcodes
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove former ternary

*
* \tparam CompareType
* The type of the compare child of the ternary opcode.
* The type of the compare child of the select (former- ternary) opcode.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove former ternary

@alvee-unb alvee-unb force-pushed the Refactor-TernaryToSelect branch 2 times, most recently from c90236d to 9ca7659 Compare November 25, 2019 15:30
@@ -500,7 +500,7 @@
vicmpanyle, // vector integer any less equal

vnot, // vector boolean not
vselect, // vector select
vbitselect, // vector select
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps // vector bit select

{
return TR::TreeEvaluator::inlineVectorTernaryOp(node, cg, TR::InstOpCode::vsel);
return TR::TreeEvaluator::inlineVectorSelectOp(node, cg, TR::InstOpCode::vsel);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this function should be inlineVectorBitSelectOp since the opcode was renamed. This comment applies elsewhere to the other evaluators that call it too.

@@ -478,7 +478,7 @@
TR::TreeEvaluator::unImpOpEvaluator, // TR::vicmpanylt
TR::TreeEvaluator::unImpOpEvaluator, // TR::vicmpanyle
TR::TreeEvaluator::unImpOpEvaluator, // TR::vnot
TR::TreeEvaluator::vselEvaluator, // TR::vselect
TR::TreeEvaluator::vselEvaluator, // TR::vbitselect
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should now be TR::TreeEvaluator::unImpOpEvaluator as discussed in #4590.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe the issue #4590 refers to the new vselect opcode to be unimplemented in the Z tree evaluator table (which is done), not the vbitselect. Can you please re-confirm? Thanks.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, sorry.

@0xdaryl
Copy link
Contributor

0xdaryl commented Nov 26, 2019

Looking at what is left after this commit is applied there are a few things that stand out:

  • Rename rematerializeCmpUnderTernary
  • Rename:
il/OMRILProps.hpp:      Ternary                      = 0x00008000
il/OMRILOps.hpp:   bool isTernary()                  const { return properties2().testAny(ILProp2::Ternary); }
  • Rename:
il/OMRIL.hpp:   static TR::ILOpCodes opCodesForTernarySelect[];
il/OMRIL.hpp:   TR::ILOpCodes opCodeForTernarySelect(TR::DataType dt);
  • There are a number of comments that reference "ternary nodes" and such. These should probably be renamed to "select"

You have to be careful though because some of these have uses in downstream projects like OpenJ9. What I suggest you do is to eliminate downstream breakages as much as possible when renaming. For example, you can duplicate the isTernary function (as isSelect), when that change lands go and fix up the uses in OpenJ9, and then return to OMR and clean things up.

@alvee-unb alvee-unb changed the title Refactoring of TR::ternary opcodes to TR::select WIP: Refactoring of TR::ternary opcodes to TR::select Nov 27, 2019
@alvee-unb alvee-unb changed the title WIP: Refactoring of TR::ternary opcodes to TR::select Refactoring of TR::ternary opcodes to TR::select Dec 16, 2019
@0xdaryl
Copy link
Contributor

0xdaryl commented Dec 18, 2019

Be aware of #4681 as it is adding a new flag for "ternary" opcodes. Some of that new code will have to change if that PR lands first.

@alvee-unb
Copy link
Contributor Author

Be aware of #4681 as it is adding a new flag for "ternary" opcodes. Some of that new code will have to change if that PR lands first.

Hello @0xdaryl , as that PR landed first, I have updated the code accordingly and force-pushed again. Would appreciate a review, thank you.

@0xdaryl
Copy link
Contributor

0xdaryl commented Jan 15, 2020

@genie-omr build all

Copy link
Contributor

@0xdaryl 0xdaryl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The bulk of these changes look good to me. I just have a few minor points in the comments.

eclipse-openj9/openj9#8364 has introduced a new use of aternary in OpenJ9. In order for this PR in OMR to go in smoothly first, I suggest leaving the following in OMR for now:

  • keep aternary in the enum that shares the same enum value as aselect
  • keep the CodeGenerator functions getSupportsTernary()

These can be cleaned up (along with removing isTernaryHigh) once your corresponding OpenJ9 PR lands.

TR::ILOpCodes
OMR::IL::opCodeForSelect(TR::DataType dt)
{
TR_ASSERT(dt < TR::NumOMRTypes, "unexpcted opcode");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be "Unexpected data type". Also fix spelling of 'unexpected'.

Comment on lines 232 to 234
bool isSelect() const { return properties2().testAny(ILProp2::Select); }
bool isSelectAdd() const { return properties2().testAny(ILProp2::SelectAdd); }
bool isSelectSub() const { return properties2().testAny(ILProp2::SelectSub); }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a single space before const to maintain alignment.

Comment on lines 221 to 222
SelectAdd = 0x00010000,
SelectSub = 0x00020000,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a space before = to maintain alignment.

@@ -2084,6 +2084,25 @@ OMR::Node::isTernaryHigh()
return false;
}

bool
OMR::Node::isSelectHigh()
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If isTernaryHigh() is just a stub now (temporarily), I would rather it's body be gutted and simply return self()->isSelectHigh(); rather than identically duplicate this body.

Comment on lines 605 to 608
static TR::Register *iuselectEvaluator(TR::Node *node, TR::CodeGenerator *cg);
static TR::Register *luselectEvaluator(TR::Node *node, TR::CodeGenerator *cg);
static TR::Register *buselectEvaluator(TR::Node *node, TR::CodeGenerator *cg);
static TR::Register *suselectEvaluator(TR::Node *node, TR::CodeGenerator *cg);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these can just be deleted. There are no references and the opcode doesn't exist.

@alvee-unb
Copy link
Contributor Author

Hi @0xdaryl , @knn-k , I would appreciate a review on my most recent commit. Thank you.

@0xdaryl
Copy link
Contributor

0xdaryl commented Feb 19, 2020

Thanks for the changes. Please don't sprinkle the code with comment references to the OpenJ9 PR eclipse-openj9/openj9#7797. While it is true there is cleanup needed after that is merged, I'd rather you open an issue in OMR to track this removal (and all the other things you need to remove once downstream changes merge) than leave a comments in the code. I saw several comments in the code that referred to that downstream issue.

@0xdaryl
Copy link
Contributor

0xdaryl commented Feb 19, 2020

@genie-omr build all

@0xdaryl 0xdaryl self-assigned this Feb 20, 2020
@@ -533,6 +533,7 @@ class OMR_EXTENSIBLE Node
/// and the opcodes for highOp/adjunctOp are luaddc/luadd, or lusubb/lusub.
///
bool isTernaryHigh();
bool isSelectHigh();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The doxygen should be on isSelectHigh with a deprecated warning on isTernaryHigh.

Copy link
Contributor Author

@alvee-unb alvee-unb Feb 25, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your comment, I am updating this for other similar instances (on compiler/il/OMRNode.cpp).

Replacing of the ternary OpCodes such as TR::bternary etc. to
TR::bselect etc. and the associated items respectively.

The changes are made onto the followings:
- Components of various data types such as- Int8, Float, Double
  (iternary, bternary, vternary etc) etc..
- Corresponding evaluators such as- bselectEvaluator, iselectEvaluator
  etc. and other functions where the IL OpCodes are used.
- Corresponding outputs of texts such as- "iselect" etc. and comments
  (//ternary).
- The IL opcode (and its respective evaluator to- vbitselectEvaluator)-
vselect has been updated to vbitselect.
- The new vselect opcode has been marked- unimplemented in the Z tree
evaluator.
- File names which involved updating of the class names.
- There are some duplicated usages of the opcodes (`aternary`) and
their respective functions for their dependencies on OpenJ9, they will
need to be deleted once the eclipse/openj9 #7797 PR is accepted.

Partially Resolves: GitHub issues eclipse#681 and eclipse#4590

Signed-off-by: Md. Alvee Noor <mnoor@unb.ca>
alvee-unb added a commit to CAS-Atlantic/omr that referenced this pull request Feb 25, 2020
Removed deprecated functions (i.e. `getSupportsTernary` etc.)
which were introduced by the PR eclipse#4578.

Closes: GitHub issue eclipse#681

Signed-off-by: Md. Alvee Noor <mnoor@unb.ca>
alvee-unb added a commit to CAS-Atlantic/omr that referenced this pull request Feb 25, 2020
Removed deprecated functions (i.e. `getSupportsTernary` etc.)
which were introduced by the PR eclipse#4578.

Closes: GitHub issue eclipse#681 and eclipse#4847

Signed-off-by: Md. Alvee Noor <mnoor@unb.ca>
@0xdaryl
Copy link
Contributor

0xdaryl commented Feb 26, 2020

@genie-omr build all

@0xdaryl
Copy link
Contributor

0xdaryl commented Feb 26, 2020

macOS failure is a late infrastructure failure after the tests have succeeded. Merging.

@0xdaryl 0xdaryl merged commit a67e389 into eclipse:master Feb 26, 2020
alvee-unb added a commit to CAS-Atlantic/openj9 that referenced this pull request Mar 2, 2020
Replaced the ternary OpCodes such as TR::aternary etc. to
TR::aselect etc. respectively.

Related OMR PR: eclipse/omr#4578

Partially Resolves: Issue eclipse/omr#681 and eclipse/omr#4590

Signed-off-by: Md. Alvee Noor <mnoor@unb.ca>
alvee-unb added a commit to CAS-Atlantic/omr that referenced this pull request Mar 3, 2020
Removed deprecated functions (i.e. `getSupportsTernary` etc.)
which were introduced by the PR eclipse#4578.

Closes: GitHub issue eclipse#681 and eclipse#4847

Signed-off-by: Md. Alvee Noor <mnoor@unb.ca>
PushkarBettadpur pushed a commit to PushkarBettadpur/omr that referenced this pull request Mar 13, 2020
Removed deprecated functions (i.e. `getSupportsTernary` etc.)
which were introduced by the PR eclipse#4578.

Closes: GitHub issue eclipse#681 and eclipse#4847

Signed-off-by: Md. Alvee Noor <mnoor@unb.ca>
@aarongraham9 aarongraham9 deleted the Refactor-TernaryToSelect branch February 16, 2021 18:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants