1 | /* |
2 | * Copyright (c) 2015-2018, Intel Corporation |
3 | * |
4 | * Redistribution and use in source and binary forms, with or without |
5 | * modification, are permitted provided that the following conditions are met: |
6 | * |
7 | * * Redistributions of source code must retain the above copyright notice, |
8 | * this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of Intel Corporation nor the names of its contributors |
13 | * may be used to endorse or promote products derived from this software |
14 | * without specific prior written permission. |
15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
26 | * POSSIBILITY OF SUCH DAMAGE. |
27 | */ |
28 | |
29 | #ifndef GREY_H |
30 | #define GREY_H |
31 | |
32 | #include <vector> |
33 | #include <string> |
34 | |
35 | #include "ue2common.h" |
36 | |
37 | namespace ue2 { |
38 | |
39 | struct Grey { |
40 | Grey(void); |
41 | |
42 | bool optimiseComponentTree; |
43 | |
44 | bool calcComponents; |
45 | bool performGraphSimplification; |
46 | bool prefilterReductions; |
47 | bool removeEdgeRedundancy; |
48 | |
49 | bool allowGough; |
50 | bool allowHaigLit; |
51 | bool allowLitHaig; |
52 | bool allowLbr; |
53 | bool allowMcClellan; |
54 | bool allowSheng; |
55 | bool allowMcSheng; |
56 | bool allowPuff; |
57 | bool allowLiteral; |
58 | bool allowViolet; |
59 | bool allowExtendedNFA; |
60 | bool allowLimExNFA; |
61 | bool allowAnchoredAcyclic; |
62 | bool allowSmallLiteralSet; |
63 | bool allowCastle; |
64 | bool allowDecoratedLiteral; |
65 | bool allowApproximateMatching; |
66 | |
67 | bool allowNoodle; |
68 | bool fdrAllowTeddy; |
69 | bool fdrAllowFlood; |
70 | |
71 | u32 violetAvoidSuffixes; /* 0=never, 1=sometimes, 2=always */ |
72 | bool violetAvoidWeakInfixes; |
73 | bool violetDoubleCut; |
74 | bool ; |
75 | bool violetLiteralChains; |
76 | u32 violetDoubleCutLiteralLen; |
77 | u32 violetEarlyCleanLiteralLen; |
78 | |
79 | bool puffImproveHead; |
80 | bool castleExclusive; // enable castle mutual exclusion analysis |
81 | |
82 | bool mergeSEP; |
83 | bool mergeRose; |
84 | bool mergeSuffixes; |
85 | bool mergeOutfixes; |
86 | bool onlyOneOutfix; // if > 1 outfix, fail compile |
87 | |
88 | bool allowShermanStates; |
89 | bool allowMcClellan8; |
90 | bool allowWideStates; // enable wide state for McClellan8 |
91 | bool highlanderPruneDFA; |
92 | bool minimizeDFA; |
93 | |
94 | bool accelerateDFA; |
95 | bool accelerateNFA; |
96 | bool reverseAccelerate; |
97 | |
98 | bool squashNFA; |
99 | bool compressNFAState; |
100 | bool numberNFAStatesWrong; |
101 | bool highlanderSquash; |
102 | bool allowZombies; |
103 | bool floodAsPuffette; |
104 | |
105 | u32 nfaForceSize; |
106 | |
107 | u32 maxHistoryAvailable; |
108 | u32 minHistoryAvailable; |
109 | u32 maxAnchoredRegion; |
110 | u32 minRoseLiteralLength; |
111 | u32 minRoseNetflowLiteralLength; |
112 | u32 maxRoseNetflowEdges; |
113 | u32 maxEditDistance; |
114 | |
115 | u32 minExtBoundedRepeatSize; /* to be considered for ng_repeat */ |
116 | |
117 | bool goughCopyPropagate; |
118 | bool goughRegisterAllocate; |
119 | |
120 | bool shortcutLiterals; |
121 | |
122 | bool roseGraphReduction; |
123 | bool roseRoleAliasing; |
124 | bool roseMasks; |
125 | bool roseConvertFloodProneSuffixes; |
126 | bool roseMergeRosesDuringAliasing; |
127 | bool roseMultiTopRoses; |
128 | bool roseHamsterMasks; |
129 | bool roseLookaroundMasks; |
130 | u32 roseMcClellanPrefix; /* 0 = off, 1 = only if large nfa, 2 = always */ |
131 | u32 roseMcClellanSuffix; /* 0 = off, 1 = only if very large nfa, 2 = |
132 | * always */ |
133 | u32 roseMcClellanOutfix; /* 0 = off, 1 = sometimes, 2 = almost always */ |
134 | bool roseTransformDelay; |
135 | |
136 | bool earlyMcClellanPrefix; |
137 | bool earlyMcClellanInfix; |
138 | bool earlyMcClellanSuffix; |
139 | |
140 | bool allowCountingMiracles; |
141 | |
142 | bool allowSomChain; |
143 | u32 somMaxRevNfaLength; |
144 | |
145 | bool hamsterAccelForward; |
146 | bool hamsterAccelReverse; // currently not implemented |
147 | |
148 | u32 miracleHistoryBonus; /* cheap hack to make miracles better, TODO |
149 | * something dignified */ |
150 | |
151 | bool equivalenceEnable; |
152 | |
153 | // SmallWrite engine |
154 | bool allowSmallWrite; |
155 | bool allowSmallWriteSheng; |
156 | u32 smallWriteLargestBuffer; // largest buffer that can be small write |
157 | u32 smallWriteLargestBufferBad;// largest buffer that can be small write |
158 | u32 limitSmallWriteOutfixSize; //!< max total size of outfix DFAs |
159 | u32 smallWriteMaxPatterns; // only try small writes if fewer patterns |
160 | u32 smallWriteMaxLiterals; // only try small writes if fewer literals |
161 | u32 smallWriteMergeBatchSize; // number of DFAs to merge in a batch |
162 | |
163 | // Tamarama engine |
164 | bool allowTamarama; |
165 | u32 tamaChunkSize; //!< max chunk size for exclusivity analysis in Tamarama |
166 | |
167 | enum DumpFlags { |
168 | DUMP_NONE = 0, |
169 | DUMP_BASICS = 1 << 0, // Dump basic textual data |
170 | DUMP_PARSE = 1 << 1, // Dump component tree to .txt |
171 | DUMP_INT_GRAPH = 1 << 2, // Dump non-implementation graphs |
172 | DUMP_IMPL = 1 << 3 // Dump implementation graphs |
173 | }; |
174 | |
175 | u32 dumpFlags; |
176 | std::string dumpPath; |
177 | |
178 | /* Resource limits. These are somewhat arbitrary, but are intended to bound |
179 | * the input to many of our internal structures. Exceeding one of these |
180 | * limits will cause an error to be returned to the user. |
181 | * |
182 | * NOTE: Raising these limitations make cause smoke to come out of parts of |
183 | * the runtime. */ |
184 | |
185 | u32 limitPatternCount; //!< max number of patterns |
186 | u32 limitPatternLength; //!< max number of characters in a regex |
187 | u32 limitGraphVertices; //!< max number of states in built NFA graph |
188 | u32 limitGraphEdges; //!< max number of edges in build NFA graph |
189 | u32 limitReportCount; //!< max number of ReportIDs allocated internally |
190 | |
191 | // HWLM literal matcher limits. |
192 | u32 limitLiteralCount; //!< max number of literals in an HWLM table |
193 | u32 limitLiteralLength; //!< max number of characters in a literal |
194 | u32 limitLiteralMatcherChars; //!< max characters in an HWLM literal matcher |
195 | u32 limitLiteralMatcherSize; //!< max size of an HWLM matcher (in bytes) |
196 | |
197 | // Rose limits. |
198 | u32 limitRoseRoleCount; //!< max number of Rose roles |
199 | u32 limitRoseEngineCount; //!< max prefix/infix/suffix/outfix engines |
200 | u32 limitRoseAnchoredSize; //!< max total size of anchored DFAs (bytes) |
201 | |
202 | // Engine (DFA/NFA/etc) limits. |
203 | u32 limitEngineSize; //!< max size of an engine (in bytes) |
204 | u32 limitDFASize; //!< max size of a DFA (in bytes) |
205 | u32 limitNFASize; //!< max size of an NFA (in bytes) |
206 | u32 limitLBRSize; //!< max size of an LBR engine (in bytes) |
207 | |
208 | // Approximate matching limits. |
209 | u32 limitApproxMatchingVertices; //!< max number of vertices per graph |
210 | }; |
211 | |
212 | #ifndef RELEASE_BUILD |
213 | #include <string> |
214 | void applyGreyOverrides(Grey *g, const std::string &overrides); |
215 | #endif |
216 | |
217 | } // namespace ue2 |
218 | |
219 | #endif |
220 | |