Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b0d762d

Browse files
authored
Merge pull request eclipse-openj9#5458 from liqunl/PRE
Add opCodeForCorresponding APIs for load/store
2 parents c5d1e78 + 295982f commit b0d762d

File tree

2 files changed

+116
-0
lines changed

2 files changed

+116
-0
lines changed

compiler/il/OMRIL.cpp

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
*******************************************************************************/
2121

2222
#include "il/IL.hpp"
23+
#include "il/ILOps.hpp"
2324
#include "il/ILOpCodes.hpp"
2425
#include "infra/Assert.hpp"
2526

@@ -652,6 +653,102 @@ OMR::IL::opCodeForCorrespondingIndirectStore(TR::ILOpCodes storeOpCode)
652653
return TR::BadILOp;
653654
}
654655

656+
TR::IL*
657+
OMR::IL::self()
658+
{
659+
return static_cast<TR::IL*>(this);
660+
}
661+
662+
TR::ILOpCodes
663+
OMR::IL::opCodeForCorrespondingLoadOrStore(TR::ILOpCodes opCodes)
664+
{
665+
TR::ILOpCode opCode(opCodes);
666+
667+
if (opCode.isLoadIndirect())
668+
return self()->opCodeForCorrespondingIndirectLoad(opCodes);
669+
else if (opCode.isLoadDirect())
670+
return self()->opCodeForCorrespondingDirectLoad(opCodes);
671+
else if (opCode.isStoreIndirect())
672+
return self()->opCodeForCorrespondingIndirectStore(opCodes);
673+
else if (opCode.isStoreDirect())
674+
return self()->opCodeForCorrespondingDirectStore(opCodes);
675+
676+
TR_ASSERT_FATAL(0, "opCode is not load or store");
677+
return TR::BadILOp;
678+
}
679+
680+
TR::ILOpCodes
681+
OMR::IL::opCodeForCorrespondingDirectLoad(TR::ILOpCodes loadOpCode)
682+
{
683+
switch (loadOpCode)
684+
{
685+
case TR::bload: return TR::bstore;
686+
case TR::sload: return TR::sstore;
687+
case TR::iload: return TR::istore;
688+
case TR::lload: return TR::lstore;
689+
case TR::fload: return TR::fstore;
690+
case TR::dload: return TR::dstore;
691+
case TR::aload: return TR::astore;
692+
case TR::vload: return TR::vstore;
693+
case TR::cload: return TR::cstore;
694+
case TR::buload: return TR::bstore;
695+
case TR::iuload: return TR::istore;
696+
case TR::luload: return TR::lstore;
697+
case TR::brdbar:
698+
case TR::srdbar:
699+
case TR::irdbar:
700+
case TR::lrdbar:
701+
case TR::frdbar:
702+
case TR::drdbar:
703+
case TR::ardbar:
704+
//There is not necessarily a guaranteed symmetry about whether an direct rdbar should be mapped to
705+
//an direct wrtbar or a normal direct store. The mapping of rdbar/ wrtbar totally depends on the
706+
//actual use in subprojects and should be undefined in OMR level.
707+
TR_ASSERT_FATAL(0, "xrdbar can't be used with global opcode mapping API at OMR level\n");
708+
default: break;
709+
}
710+
711+
TR_ASSERT_FATAL(0, "no corresponding store opcode for specified load opcode");
712+
return TR::BadILOp;
713+
}
714+
715+
716+
TR::ILOpCodes
717+
OMR::IL::opCodeForCorrespondingDirectStore(TR::ILOpCodes storeOpCode)
718+
{
719+
switch (storeOpCode)
720+
{
721+
case TR::bstore: return TR::bload;
722+
case TR::sstore: return TR::sload;
723+
case TR::istore: return TR::iload;
724+
case TR::lstore: return TR::lload;
725+
case TR::fstore: return TR::fload;
726+
case TR::dstore: return TR::dload;
727+
case TR::astore: return TR::aload;
728+
case TR::awrtbar: return TR::aload;
729+
case TR::vstore: return TR::vload;
730+
case TR::cstore: return TR::sload;
731+
case TR::bustore: return TR::bload;
732+
case TR::iustore: return TR::iload;
733+
case TR::lustore: return TR::lload;
734+
case TR::bwrtbar:
735+
case TR::swrtbar:
736+
case TR::iwrtbar:
737+
case TR::lwrtbar:
738+
case TR::fwrtbar:
739+
case TR::dwrtbar:
740+
//There is not necessarily a guaranteed symmetry about whether an direct wrtbar should be mapped to
741+
//an direct rdbar or a normal direct load. The mapping of rdbar/wrtbar totally depends on the
742+
//actual use in subprojects and should be undefined in OMR level.
743+
TR_ASSERT_FATAL(0, "xwrtbar can't be used with global opcode mapping API at OMR level\n");
744+
745+
default: break;
746+
}
747+
748+
TR_ASSERT_FATAL(0, "no corresponding load opcode for specified store opcode");
749+
return TR::BadILOp;
750+
}
751+
655752
TR::ILOpCodes
656753
OMR::IL::opCodeForSelect(TR::DataType dt)
657754
{

compiler/il/OMRIL.hpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ namespace OMR { typedef OMR::IL ILConnector; }
3535
#include "il/ILOpCodes.hpp"
3636
#include "il/DataTypes.hpp"
3737

38+
namespace TR { class IL; }
39+
3840
namespace OMR
3941
{
4042

@@ -43,6 +45,8 @@ class OMR_EXTENSIBLE IL
4345

4446
public:
4547

48+
TR::IL* self();
49+
4650
static TR::ILOpCodes opCodesForConst[];
4751
static TR::ILOpCodes opCodesForDirectLoad[];
4852
static TR::ILOpCodes opCodesForDirectReadBarrier[];
@@ -72,6 +76,21 @@ class OMR_EXTENSIBLE IL
7276

7377
TR::ILOpCodes opCodeForCorrespondingIndirectLoad(TR::ILOpCodes loadOpCode);
7478
TR::ILOpCodes opCodeForCorrespondingIndirectStore(TR::ILOpCodes storeOpCode);
79+
/**
80+
* \brief
81+
* Given a direct load opcode, return its corresponding direct store opcode
82+
*/
83+
TR::ILOpCodes opCodeForCorrespondingDirectLoad(TR::ILOpCodes loadOpCode);
84+
/**
85+
* \brief
86+
* Given a direct store opcode, return its corresponding direct load opcode
87+
*/
88+
TR::ILOpCodes opCodeForCorrespondingDirectStore(TR::ILOpCodes storeOpCode);
89+
/**
90+
* \brief
91+
* Given a load/store opcode, return its corresponding store/load opcode
92+
*/
93+
TR::ILOpCodes opCodeForCorrespondingLoadOrStore(TR::ILOpCodes opCodes);
7594

7695
TR::ILOpCodes opCodeForSelect(TR::DataType dt);
7796
TR::ILOpCodes opCodeForConst(TR::DataType dt);

0 commit comments

Comments
 (0)