Skip to content

Commit

Permalink
Refactor the code
Browse files Browse the repository at this point in the history
The code is refactored based on the following
GitHub pull request review:
#6945 (review).

Closes: #4550.
Author: Amarpreet Singh amarpreet1997@gmail.com.
  • Loading branch information
singh264 committed May 15, 2023
1 parent 16b4052 commit 8ce9e53
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 23 deletions.
8 changes: 3 additions & 5 deletions compiler/codegen/CodeGenRA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,7 @@
#include "optimizer/Structure.hpp"
#include "ras/Debug.hpp"

#define OPT_DETAILS "O^O CODE GENERATION: "
#define OPT_DETAILS_SPILL_TEMPS "O^O SPILL TEMPS: "
#define OPT_DETAILS_HALF_SLOT_SPILLS "O^O HALF-SLOT SPILLS: "
#define OPT_DETAILS "O^O CODE GENERATION REGISTER ALLOCATION: "
#define OPT_DETAILS_GLOBAL_REGISTER_ALLOCATION "O^O GLOBAL REGISTER ALLOCATION: "

#define NUM_REGS_USED_BY_COMPLEX_OPCODES 3
Expand Down Expand Up @@ -493,7 +491,7 @@ OMR::CodeGenerator::allocateSpill(int32_t dataSize, bool containsCollectedRefere
}

if (
(spill && self()->comp()->getOption(TR_TraceRA) && !performTransformation(self()->comp(), "%sReuse spill temp %s\n", OPT_DETAILS_SPILL_TEMPS, self()->getDebug()->getName(spill->getSymbolReference()))))
(spill && self()->comp()->getOption(TR_TraceRA) && !performTransformation(self()->comp(), "%sReuse spill temp %s\n", OPT_DETAILS, self()->getDebug()->getName(spill->getSymbolReference()))))
{
// Discard the spill temp we popped and never use it again; allocate a
// new one instead, and later, where we would have returned this spill
Expand Down Expand Up @@ -538,7 +536,7 @@ OMR::CodeGenerator::allocateSpill(int32_t dataSize, bool containsCollectedRefere
//
if ( offset == NULL
|| spill->secondHalfIsOccupied()
|| !performTransformation(self()->comp(), "%sUse second half of %s\n", OPT_DETAILS_HALF_SLOT_SPILLS, self()->getDebug()->getName(spill->getSymbolReference())))
|| !performTransformation(self()->comp(), "%sUse second half of %s\n", OPT_DETAILS, self()->getDebug()->getName(spill->getSymbolReference())))
{
spill->setFirstHalfIsOccupied();
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/il/Aliases.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
#include "runtime/RuntimeAssumptions.hpp"
#endif

#define OPT_DETAILS "O^O REFINING ALIASES: "
#define OPT_DETAILS "O^O IL ALIASES: "

class TR_OpaqueClassBlock;
namespace TR { class Register; }
Expand Down
2 changes: 1 addition & 1 deletion compiler/il/OMRNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6476,7 +6476,7 @@ OMR::Node::setArrayChkPrimitiveArray2(bool v)
{
TR::Compilation * c = TR::comp();
TR_ASSERT(self()->getOpCodeValue() == TR::ArrayCHK, "Opcode must be ArrayCHK");
if (performNodeTransformation3(c, "%s Setting arrayChkPrimitiveArray2 flag on node %p to %d\n", OPT_DETAILS, self(), v))
if (performNodeTransformation3(c, "%sSetting arrayChkPrimitiveArray2 flag on node %p to %d\n", OPT_DETAILS, self(), v))
_flags.set(arrayChkPrimitiveArray2, v);
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/il/OMRResolvedMethodSymbol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
#include "runtime/Runtime.hpp"
#include "infra/SimpleRegex.hpp"

#define OPT_DETAILS "O^O OSR: "
#define OPT_DETAILS "O^O IL Resolved Method Symbol: "

TR::ResolvedMethodSymbol *
OMR::ResolvedMethodSymbol::self()
Expand Down
5 changes: 2 additions & 3 deletions compiler/optimizer/Inliner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ int32_t *NumInlinedMethods = NULL;
int32_t *InlinedSizes = NULL;

#define OPT_DETAILS "O^O INLINER: "
#define OPT_DETAILS_GUARDED_CALL_REMAT "O^O GUARDED CALL REMAT: "

// == Hack markers ==

Expand Down Expand Up @@ -1684,7 +1683,7 @@ void TR_InlinerBase::rematerializeCallArguments(TR_TransformInlinedFunction & ti
if (rematTree == argStoreTree)
{
TR::Node *duplicateStore = argStore->duplicateTree();
if (performTransformation(comp(), "%sRematerialize [%p] as [%p]\n", OPT_DETAILS_GUARDED_CALL_REMAT, argStore, duplicateStore))
if (performTransformation(comp(), "%sGuarded call rematerialize [%p] as [%p]\n", OPT_DETAILS, argStore, duplicateStore))
{
rematPoint = TR::TreeTop::create(comp(), rematPoint, duplicateStore);
}
Expand All @@ -1694,7 +1693,7 @@ void TR_InlinerBase::rematerializeCallArguments(TR_TransformInlinedFunction & ti
{
TR::Node *duplicateStore = TR::Node::createStore(argStore->getSymbolReference(), TR::Node::createLoad(argStore, rematTree->getNode()->getSymbolReference()));
duplicateStore->setByteCodeInfo(argStore->getByteCodeInfo());
if (performTransformation(comp(), "%sPartial rematerialize of [%p] as [%p] - load of [%d]\n", OPT_DETAILS_GUARDED_CALL_REMAT, argStore, duplicateStore, rematTree->getNode()->getSymbolReference()->getReferenceNumber()))
if (performTransformation(comp(), "%sGuarded call partial rematerialize of [%p] as [%p] - load of [%d]\n", OPT_DETAILS, argStore, duplicateStore, rematTree->getNode()->getSymbolReference()->getReferenceNumber()))
{
rematPoint = TR::TreeTop::create(comp(), rematPoint, duplicateStore);
}
Expand Down
11 changes: 4 additions & 7 deletions compiler/z/codegen/OMRCodeGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,6 @@ namespace TR { class DebugCounterBase; }
namespace TR { class SimpleRegex; }

#define OPT_DETAILS "O^O CODE GENERATION: "
#define OPT_DETAILS_IS_ACTIVE_COMPARE_CC "O^O isActiveCompareCC: "
#define OPT_DETAILS_ARITHMETIC_CC "O^O Arithmetic CC: "
#define OPT_DETAILS_LOGICAL_CC_INFO "O^O Logical CC Info: "

void
OMR::Z::CodeGenerator::preLowerTrees()
Expand Down Expand Up @@ -4034,7 +4031,7 @@ bool OMR::Z::CodeGenerator::isActiveCompareCC(TR::InstOpCode::Mnemonic opcd, TR:

if (opcd == ccInst->getOpCodeValue() && tReg == ccTgtReg && sReg == ccSrcReg &&
performTransformation(self()->comp(), "%sRR Compare Op [%s\t %s, %s] can reuse CC from ccInstr [%p]\n",
OPT_DETAILS_IS_ACTIVE_COMPARE_CC, ccInst->getOpCode().getMnemonicName(), self()->getDebug()->getName(tReg),self()->getDebug()->getName(sReg), ccInst))
OPT_DETAILS, ccInst->getOpCode().getMnemonicName(), self()->getDebug()->getName(tReg),self()->getDebug()->getName(sReg), ccInst))
{
return true;
}
Expand All @@ -4048,8 +4045,8 @@ bool OMR::Z::CodeGenerator::isActiveCompareCC(TR::InstOpCode::Mnemonic opcd, TR:
bool OMR::Z::CodeGenerator::isActiveArithmeticCC(TR::Register* tstReg)
{
if (self()->hasCCInfo() && self()->hasCCSigned() && !self()->hasCCOverflow() && !self()->hasCCCarry() &&
performTransformation(self()->comp(), "%sCCInfo(%d) CCSigned(%d) CCOverflow(%d) CCCarry(%d)\n",
OPT_DETAILS_ARITHMETIC_CC, self()->hasCCInfo(), self()->hasCCSigned(), self()->hasCCOverflow(), self()->hasCCCarry())
performTransformation(self()->comp(), "%sArithemtic op CC result matches CC of a compare immediate op\n",
OPT_DETAILS)
)
{
TR::Instruction* inst = self()->ccInstruction();
Expand All @@ -4068,7 +4065,7 @@ bool OMR::Z::CodeGenerator::isActiveLogicalCC(TR::Node* ccNode, TR::Register* ts

if (self()->hasCCInfo() && self()->hasCCZero() && !self()->hasCCOverflow() &&
(TR::ILOpCode::isEqualCmp(op) || TR::ILOpCode::isNotEqualCmp(op)) &&
performTransformation(self()->comp(), "%sCCInfo(%d) CCZero(%d) CCOverflow(%d)\n", OPT_DETAILS_LOGICAL_CC_INFO, self()->hasCCInfo(), self()->hasCCZero(), self()->hasCCOverflow())
performTransformation(self()->comp(), "%sCC (CCInfo(%d) CCZero(%d) CCOverflow(%d)) can be reused from logical instruction [%p]\n", OPT_DETAILS, self()->hasCCInfo(), self()->hasCCZero(), self()->hasCCOverflow(), self()->ccInstruction())
)
{
TR::Instruction* inst = self()->ccInstruction();
Expand Down
2 changes: 1 addition & 1 deletion compiler/z/codegen/OMRMachine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
#define S390_REGISTER_PRESERVED_WEIGHT 0x00000002
#define S390_REGISTER_PAIR_SIBLING 0x00008000

#define OPT_DETAILS_RANDOM_CODEGEN "O^O Random Codegen: "
#define OPT_DETAILS_RANDOM_CODEGEN "0^0 S390 Machine Codegen: "

////////////////////////////////////////////////////////////////////////////////
// OMR::Z::Machine memeber functions
Expand Down
8 changes: 4 additions & 4 deletions compiler/z/codegen/OMRPeephole.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1580,7 +1580,7 @@ OMR::Z::Peephole::tryToRemoveDuplicateNILF()
{
if (currInst->getSourceImmediate() == nextInst->getSourceImmediate())
{
if (performTransformation(self()->comp(), "%sdeleting duplicate NILF from pair %p %p*\n", OPT_DETAILS_S390_PEEPHOLE, currInst, nextInst))
if (performTransformation(self()->comp(), "%sDeleting duplicate NILF from pair %p %p*\n", OPT_DETAILS_S390_PEEPHOLE, currInst, nextInst))
{
nextInst->remove();

Expand All @@ -1604,7 +1604,7 @@ OMR::Z::Peephole::tryToRemoveDuplicateNILF()
else if (((currInst->getSourceImmediate() & nextInst->getSourceImmediate()) == currInst->getSourceImmediate()) &&
((nextInst->getSourceImmediate() & currInst->getSourceImmediate()) != nextInst->getSourceImmediate()))
{
if (performTransformation(self()->comp(), "%sdeleting unnecessary NILF from pair %p %p*\n", OPT_DETAILS_S390_PEEPHOLE, currInst, nextInst))
if (performTransformation(self()->comp(), "%sDeleting unnecessary NILF from pair %p %p*\n", OPT_DETAILS_S390_PEEPHOLE, currInst, nextInst))
{
nextInst->remove();

Expand Down Expand Up @@ -1635,7 +1635,7 @@ OMR::Z::Peephole::tryToRemoveDuplicateNILH()
if (currInst->matchesTargetRegister(nextInst->getRegisterOperand(1)) &&
nextInst->matchesTargetRegister(currInst->getRegisterOperand(1)))
{
if (performTransformation(self()->comp(), "%sdeleting duplicate NILH from pair %p %p*\n", OPT_DETAILS_S390_PEEPHOLE, currInst, nextInst))
if (performTransformation(self()->comp(), "%sDeleting duplicate NILH from pair %p %p*\n", OPT_DETAILS_S390_PEEPHOLE, currInst, nextInst))
{
nextInst->remove();

Expand Down Expand Up @@ -1773,7 +1773,7 @@ OMR::Z::Peephole::tryToRemoveRedundantShift()
uint32_t newShift = currRSInst->getSourceImmediate() + nextRSInst->getSourceImmediate();
if (newShift < 64)
{
if (performTransformation(self()->comp(), "%smerging SRL/SLL pair [%p] [%p]\n", OPT_DETAILS_S390_PEEPHOLE, cursor, cursor->getNext()))
if (performTransformation(self()->comp(), "%sMerging SRL/SLL pair [%p] [%p]\n", OPT_DETAILS_S390_PEEPHOLE, cursor, cursor->getNext()))
{
currRSInst->setSourceImmediate(newShift);
nextInst->remove();
Expand Down

0 comments on commit 8ce9e53

Please sign in to comment.