Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openj9
Path: blob/master/runtime/compiler/optimizer/IdiomRecognitionUtils.hpp
6000 views
1
/*******************************************************************************
2
* Copyright (c) 2000, 2019 IBM Corp. and others
3
*
4
* This program and the accompanying materials are made available under
5
* the terms of the Eclipse Public License 2.0 which accompanies this
6
* distribution and is available at https://www.eclipse.org/legal/epl-2.0/
7
* or the Apache License, Version 2.0 which accompanies this distribution and
8
* is available at https://www.apache.org/licenses/LICENSE-2.0.
9
*
10
* This Source Code may also be made available under the following
11
* Secondary Licenses when the conditions for such availability set
12
* forth in the Eclipse Public License, v. 2.0 are satisfied: GNU
13
* General Public License, version 2 with the GNU Classpath
14
* Exception [1] and GNU General Public License, version 2 with the
15
* OpenJDK Assembly Exception [2].
16
*
17
* [1] https://www.gnu.org/software/classpath/license.html
18
* [2] http://openjdk.java.net/legal/assembly-exception.html
19
*
20
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 OR LicenseRef-GPL-2.0 WITH Assembly-exception
21
*******************************************************************************/
22
23
#ifndef IDIOM_RECOGNITION_UTILS_INCL
24
#define IDIOM_RECOGNITION_UTILS_INCL
25
26
#include <stddef.h>
27
#include <stdint.h>
28
#include "il/DataTypes.hpp"
29
#include "il/ILOpCodes.hpp"
30
31
class TR_BitVector;
32
class TR_CISCNode;
33
class TR_CISCTransformer;
34
class TR_PCISCGraph;
35
class TR_PCISCNode;
36
namespace TR { class SymbolReference; }
37
namespace TR { class Block; }
38
namespace TR { class Compilation; }
39
namespace TR { class Node; }
40
template <class T> class List;
41
42
enum
43
{
44
CISCUtilCtl_64Bit = 1,
45
CISCUtilCtl_NoI2L = 2,
46
CISCUtilCtl_ChildDirectConnected = 4,
47
CISCUtilCtl_BigEndian = 8,
48
CISCUtilCtl_NoConversion = 16,
49
CISCUtilCtl_AllConversion = 32
50
};
51
TR_PCISCGraph *makeStrlen16Graph(TR::Compilation *c, int32_t ctrl);
52
TR_PCISCGraph *makePtrArraySetGraph(TR::Compilation *c, int32_t ctrl);
53
TR_PCISCGraph *makeMemSetGraph(TR::Compilation *c, int32_t ctrl);
54
TR_PCISCGraph *makeMixedMemSetGraph(TR::Compilation *c, int32_t ctrl);
55
56
TR_PCISCGraph *makeTRTGraph(TR::Compilation *c, int32_t ctrl);
57
TR_PCISCGraph *makeTRTGraph2(TR::Compilation *c, int32_t ctrl);
58
TR_PCISCGraph *makeTRT4NestedArrayGraph(TR::Compilation *c, int32_t ctrl);
59
TR_PCISCGraph *makeTRT4NestedArrayIfGraph(TR::Compilation *c, int32_t ctrl);
60
61
TR_PCISCGraph *makeTROTArrayGraph(TR::Compilation *c, int32_t ctrl);
62
TR_PCISCGraph *makeTRTOArrayGraph(TR::Compilation *c, int32_t ctrl);
63
TR_PCISCGraph *makeTRTOArrayGraphSpecial(TR::Compilation *c, int32_t ctrl);
64
TR_PCISCGraph *makeCopyingTROOSpecialGraph(TR::Compilation *c, int32_t ctrl);
65
TR_PCISCGraph *makeCopyingTROxGraph(TR::Compilation *c, int32_t ctrl, int pattern);
66
TR_PCISCGraph *makeCopyingTROTInduction1Graph(TR::Compilation *c, int32_t ctrl, int32_t pattern);
67
TR_PCISCGraph *makeCopyingTRTxGraph(TR::Compilation *c, int32_t ctrl, int pattern);
68
TR_PCISCGraph *makeCopyingTRTxThreeIfsGraph(TR::Compilation *c, int32_t ctrl);
69
TR_PCISCGraph *makeCopyingTRTOGraphSpecial(TR::Compilation *c, int32_t ctrl);
70
TR_PCISCGraph *makeCopyingTRTOInduction1Graph(TR::Compilation *c, int32_t ctrl, int32_t pattern);
71
TR_PCISCGraph *makeCopyingTRTTSpecialGraph(TR::Compilation *c, int32_t ctrl);
72
73
TR_PCISCGraph *makeMemCmpGraph(TR::Compilation *c, int32_t ctrl);
74
TR_PCISCGraph *makeMemCmpSpecialGraph(TR::Compilation *c, int32_t ctrl);
75
TR_PCISCGraph *makeMemCmpIndexOfGraph(TR::Compilation *c, int32_t ctrl);
76
77
TR_PCISCGraph *makeMemCpySpecialGraph(TR::Compilation *c, int32_t ctrl);
78
TR_PCISCGraph *makeMemCpyGraph(TR::Compilation *c, int32_t ctrl);
79
TR_PCISCGraph *makeMemCpyDecGraph(TR::Compilation *c, int32_t ctrl);
80
TR_PCISCGraph *makeMemCpyByteToCharGraph(TR::Compilation *c, int32_t ctrl);
81
TR_PCISCGraph *makeMemCpyByteToCharBndchkGraph(TR::Compilation *c, int32_t ctrl);
82
TR_PCISCGraph *makeMemCpyCharToByteGraph(TR::Compilation *c, int32_t ctrl);
83
TR_PCISCGraph *makeMEMCPYChar2ByteGraph2(TR::Compilation *c, int32_t ctrl);
84
TR_PCISCGraph *makeMEMCPYChar2ByteMixedGraph(TR::Compilation *c, int32_t ctrl);
85
// not active idioms
86
TR_PCISCGraph *makeMEMCPYByte2IntGraph(TR::Compilation *c, int32_t ctrl);
87
TR_PCISCGraph *makeMEMCPYInt2ByteGraph(TR::Compilation *c, int32_t ctrl);
88
89
TR_PCISCGraph *makeBitOpMemGraph(TR::Compilation *c, int32_t ctrl);
90
TR_PCISCGraph *makeCountDecimalDigitLongGraph(TR::Compilation *c, int32_t ctrl, bool isDiv2Mul);
91
TR_PCISCGraph *makeCountDecimalDigitIntGraph(TR::Compilation *c, int32_t ctrl, bool isDiv2Mul);
92
TR_PCISCGraph *makeLongToStringGraph(TR::Compilation *c, int32_t ctrl);
93
TR_PCISCGraph *makeIntToStringGraph(TR::Compilation *c, int32_t ctrl, bool isDiv2Mul);
94
TR_PCISCNode *createIdiomIOP2VarInLoop(TR_PCISCGraph *tgt, int32_t ctrl, int dagId, TR_PCISCNode *pred, int opcode, TR_PCISCNode *v, TR_PCISCNode *subval);
95
TR_PCISCNode *createIdiomIOP2VarInLoop(TR_PCISCGraph *tgt, int32_t ctrl, int dagId, TR_PCISCNode *pred, int opcode, TR_PCISCNode *v, TR_PCISCNode *src1, TR_PCISCNode *subval);
96
TR_PCISCNode *createIdiomDecVarInLoop(TR_PCISCGraph *tgt, int32_t ctrl, int dagId, TR_PCISCNode *pred, TR_PCISCNode *v, TR_PCISCNode *src1, TR_PCISCNode *subval);
97
TR_PCISCNode *createIdiomIncVarInLoop(TR_PCISCGraph *tgt, int32_t ctrl, int dagId, TR_PCISCNode *pred, TR_PCISCNode *v, TR_PCISCNode *src1, TR_PCISCNode *subval);
98
TR_PCISCNode *createIdiomDecVarInLoop(TR_PCISCGraph *tgt, int32_t ctrl, int dagId, TR_PCISCNode *pred, TR_PCISCNode *v, TR_PCISCNode *subval);
99
TR_PCISCNode *createIdiomIncVarInLoop(TR_PCISCGraph *tgt, int32_t ctrl, int dagId, TR_PCISCNode *pred, TR_PCISCNode *v, TR_PCISCNode *subval);
100
TR_PCISCNode *createIdiomArrayRelatedConst(TR_PCISCGraph *tgt, int32_t ctrl, uint16_t id, int dagId, int32_t val);
101
TR_PCISCNode *createIdiomArrayHeaderConst(TR_PCISCGraph *tgt, int32_t ctrl, uint16_t id, int dagId, TR::Compilation *c);
102
TR_PCISCNode *createIdiomArrayAddressInLoop(TR_PCISCGraph *tgt, int32_t ctrl, int dagId, TR_PCISCNode *pred, TR_PCISCNode *base, TR_PCISCNode *indexTree);
103
TR_PCISCNode *createIdiomI2LIfNecessary(TR_PCISCGraph *tgt, int32_t ctrl, int dagId, TR_PCISCNode **pred, TR_PCISCNode *node);
104
TR_PCISCNode *createIdiomArrayAddressIndexTreeInLoop(TR_PCISCGraph *tgt, int32_t ctrl, int dagId, TR_PCISCNode *pred, TR_PCISCNode *index, TR_PCISCNode *cmah, TR_PCISCNode *const2);
105
TR_PCISCNode *createIdiomArrayAddressInLoop(TR_PCISCGraph *tgt, int32_t ctrl, int dagId, TR_PCISCNode *pred, TR_PCISCNode *base, TR_PCISCNode *index, TR_PCISCNode *cmah, TR_PCISCNode *const2);
106
TR_PCISCNode *createIdiomCharArrayLoadInLoop(TR_PCISCGraph *tgt, int32_t ctrl, int dagId, TR_PCISCNode *pred, TR_PCISCNode *base, TR_PCISCNode *index, TR_PCISCNode *cmah, TR_PCISCNode *const2);
107
TR_PCISCNode *createIdiomArrayLoadInLoop(TR_PCISCGraph *tgt, int32_t ctrl, int dagId, TR_PCISCNode *pred, int opcode, TR::DataType, TR_PCISCNode *base, TR_PCISCNode *index, TR_PCISCNode *cmah, TR_PCISCNode *mulconst);
108
TR_PCISCNode *createIdiomArrayStoreBodyInLoop(TR_PCISCGraph *tgt, int32_t ctrl, int dagId, TR_PCISCNode *pred, int opcode, TR_PCISCNode *addr, TR_PCISCNode *storeval);
109
TR_PCISCNode *createIdiomCharArrayStoreBodyInLoop(TR_PCISCGraph *tgt, int32_t ctrl, int dagId, TR_PCISCNode *pred, TR_PCISCNode *addr, TR_PCISCNode *storeval);
110
TR_PCISCNode *createIdiomCharArrayStoreInLoop(TR_PCISCGraph *tgt, int32_t ctrl, int dagId, TR_PCISCNode *pred, TR_PCISCNode *base, TR_PCISCNode *index, TR_PCISCNode *cmah, TR_PCISCNode *const2, TR_PCISCNode *storeval);
111
TR_PCISCNode *createIdiomArrayStoreInLoop(TR_PCISCGraph *tgt, int32_t ctrl, int dagId, TR_PCISCNode *pred, int opcode, TR::DataType, TR_PCISCNode *base, TR_PCISCNode *index, TR_PCISCNode *cmah, TR_PCISCNode *const2, TR_PCISCNode *storeval);
112
TR_PCISCNode *createIdiomByteDirectArrayLoadInLoop(TR_PCISCGraph *tgt, int32_t ctrl, int dagId, TR_PCISCNode *pred, TR_PCISCNode *base, TR_PCISCNode *index);
113
TR_PCISCNode *createIdiomIDiv10InLoop(TR_PCISCGraph *tgt, int32_t ctrl, bool isDiv2Mul, int dagId, TR_PCISCNode *pred, TR_PCISCNode *src1, TR_PCISCNode *src2, TR_PCISCNode *c2, TR_PCISCNode *c31);
114
bool searchNodeInBlock(TR_CISCNode *start, TR_CISCNode *target);
115
bool checkSuccsSet(TR_CISCTransformer *const trans, TR_CISCNode *t, TR_BitVector *const pBV);
116
bool getThreeNodesForArray(TR_CISCNode *top, TR_CISCNode **ixload, TR_CISCNode **aload, TR_CISCNode **iload, bool allowArrayIndex = false);
117
bool testExitIF(int opcode, bool *isDecrement = NULL, int32_t *modLength = NULL, int32_t *modStartIdx = NULL);
118
bool testIConst(TR_CISCNode *n, int idx, int32_t value);
119
TR::Node* createI2LIfNecessary(TR::Compilation *comp, bool is64bit, TR::Node *child);
120
TR::Node* createLoadWithI2LIfNecessary(TR::Compilation *comp, bool is64bit, TR::Node *indexNode);
121
TR::Node* createBytesFromElement(TR::Compilation *comp, bool is64bit, TR::Node *indexNode, int multiply);
122
TR::Node* createIndexOffsetTree(TR::Compilation *comp, bool is64bit, TR::Node *indexNode, int multiply);
123
TR::Node* createLoad(TR::Node *baseNode);
124
TR::Node* createArrayHeaderConst(TR::Compilation *comp, bool is64bit, TR::Node *baseNode);
125
TR::Node* createArrayTopAddressTree(TR::Compilation *comp, bool is64bit, TR::Node *baseNode);
126
TR::Node* createArrayAddressTree(TR::Compilation *comp, bool is64bit, TR::Node *baseNode, TR::Node *indexNode, int multiply = 1);
127
TR::Node* createArrayLoad(TR::Compilation *comp, bool is64bit, TR::Node *ixload, TR::Node *baseNode, TR::Node *indexNode, int multiply = 1);
128
TR::Node* replaceIndexInAddressTree(TR::Compilation *comp, TR::Node *tree, TR::SymbolReference *symRef, TR::Node *newNode);
129
TR::Node* createTableLoad(TR::Compilation *comp, TR::Node* repNode, uint8_t inputSize, uint8_t outputSize, void *array, bool dispTrace);
130
TR::Node* createOP2(TR::Compilation *comp, TR::ILOpCodes op2, TR::Node* ch1, TR::Node* ch2);
131
TR::Node* createStoreOP2(TR::Compilation *comp, TR::Node* storeNode, TR::ILOpCodes op2, TR::Node* ch1, TR::Node* ch2);
132
TR::Node* createStoreOP2(TR::Compilation *comp, TR::SymbolReference* store, TR::ILOpCodes op2, TR::SymbolReference* ch1, TR::Node* ch2, TR::Node *rep);
133
TR::Node* createStoreOP2(TR::Compilation *comp, TR::SymbolReference* store, TR::ILOpCodes op2, TR::SymbolReference* ch1, TR::SymbolReference* ch2, TR::Node *rep);
134
TR::Node* createStoreOP2(TR::Compilation *comp, TR::SymbolReference* store, TR::ILOpCodes op2, TR::SymbolReference* ch1, int ch2Const, TR::Node *rep);
135
TR::Node* createMin(TR::Compilation *comp, TR::Node* x, TR::Node* y);
136
TR::Node* createMax(TR::Compilation *comp, TR::Node* x, TR::Node* y);
137
TR::Node* convertStoreToLoadWithI2LIfNecessary(TR::Compilation *comp, bool is64bit, TR::Node *indexNode);
138
TR::Node* convertStoreToLoad(TR::Compilation *comp, TR::Node *indexNode);
139
TR::Node* modifyArrayHeaderConst(TR::Compilation *comp, TR::Node *tree, int32_t offset);
140
bool getMultiplier(TR_CISCTransformer *trans, TR_CISCNode *mulConst, TR::Node **multiplier, int *elementSize, TR::DataType srcNodeType);
141
void getP2TTrRepNodes(TR_CISCTransformer *trans, TR::Node** array, int count);
142
void getP2TTrRepNodes(TR_CISCTransformer *trans, TR::Node** n1, TR::Node** n2);
143
void getP2TTrRepNodes(TR_CISCTransformer *trans, TR::Node** n1, TR::Node** n2, TR::Node** n3);
144
void getP2TTrRepNodes(TR_CISCTransformer *trans, TR::Node** n1, TR::Node** n2, TR::Node** n3, TR::Node** n4);
145
void getP2TTrRepNodes(TR_CISCTransformer *trans, TR::Node** n1, TR::Node** n2, TR::Node** n3, TR::Node** n4, TR::Node** n5);
146
void getP2TTrRepNodes(TR_CISCTransformer *trans, TR::Node** n1, TR::Node** n2, TR::Node** n3, TR::Node** n4, TR::Node** n5, TR::Node** n6);
147
void getP2TTrRepNodes(TR_CISCTransformer *trans, TR::Node** n1, TR::Node** n2, TR::Node** n3, TR::Node** n4, TR::Node** n5, TR::Node** n6, TR::Node** n7);
148
bool isFitTRTFunctionTable(uint8_t *table);
149
TR::Node* createTableAlignmentCheck(TR::Compilation *comp, TR::Node *tableNode, bool isByteSource, bool isByteTarget, bool tableBackedByRawStorage);
150
List<TR_CISCNode>* sortList(List<TR_CISCNode>* input, List<TR_CISCNode>* output, List<TR_CISCNode>* order, bool reverse = false);
151
152
void dump256Bytes(uint8_t *t, TR::Compilation * comp);
153
154
bool isLoopPreheaderLastBlockInMethod(TR::Compilation *comp, TR::Block *block, TR::Block **predBlock = NULL);
155
bool findAndOrReplaceNodesWithMatchingSymRefNumber(TR::Node *curNode, TR::Node *targetNode, int32_t symRefNumberToBeMatched);
156
TR::Node *findLoadWithMatchingSymRefNumber(TR::Node *curNode, int32_t symRefNumberToBeMatched);
157
158
#endif
159
160