#define nfaExecMcSheng64_16_testEOD NFA_API_NO_IMPL
#define nfaExecMcSheng64_16_reportCurrent NFA_API_NO_IMPL
-#endif //end of HAVE_AVX512VBM
+#endif //end of HAVE_AVX512VBMI
#endif
}
}
-#if defined(HAVE_AVX512VBMI)
static
mstate_aux *getAux64(NFA *n, dstate_id_t i) {
mcsheng64 *m = (mcsheng64 *)getMutableImplNfa(n);
m->flags |= MCSHENG_FLAG_SINGLE;
}
}
-#endif
static
size_t calcShermanRegionSize(const dfa_info &info) {
}
}
-#if defined(HAVE_AVX512VBMI)
static
void fill_in_aux_info64(NFA *nfa, const dfa_info &info,
const map<dstate_id_t, AccelScheme> &accel_escape_info,
}
}
}
-#endif
#define MAX_SHERMAN_LIST_LEN 8
}
}
-#if defined(HAVE_AVX512VBMI)
static
void fill_in_sherman64(NFA *nfa, dfa_info &info, UNUSED u16 sherman_limit) {
char *nfa_base = (char *)nfa;
}
}
}
-#endif
static
void allocateImplId8(dfa_info &info, dstate_id_t sheng_end,
return nfa;
}
-#if defined(HAVE_AVX512VBMI)
static
bytecode_ptr<NFA> mcsheng64Compile8(dfa_info &info, dstate_id_t sheng_end,
const map<dstate_id_t, AccelScheme> &accel_escape_info) {
return nfa;
}
-#endif
bytecode_ptr<NFA> mcshengCompile(raw_dfa &raw, const CompileContext &cc,
const ReportManager &rm) {
return nfa;
}
-#if defined(HAVE_AVX512VBMI)
bytecode_ptr<NFA> mcshengCompile64(raw_dfa &raw, const CompileContext &cc,
const ReportManager &rm) {
if (!cc.grey.allowMcSheng) {
return nullptr;
}
+ if (!cc.target_info.has_avx512vbmi()) {
+ DEBUG_PRINTF("McSheng64 failed, no HS_CPU_FEATURES_AVX512VBMI!\n");
+ return nullptr;
+ }
+
mcclellan_build_strat mbs(raw, rm, false);
dfa_info info(mbs);
bool using8bit = cc.grey.allowMcClellan8 && info.size() <= 256;
DEBUG_PRINTF("compile done\n");
return nfa;
}
-#endif
bool has_accel_mcsheng(const NFA *) {
return true; /* consider the sheng region as accelerated */
0xff0000000000003f,
};
#endif
-
}
}
-#if defined(HAVE_AVX512VBMI)
static
const mstate_aux *getAux64(const NFA *n, dstate_id_t i) {
auto *m = (const mcsheng64 *)getImplNfa(n);
fprintf(f, "\" ];\n");
}
}
-#endif
static
void dumpAccelDot(FILE *f, u16 i, const union AccelAux *accel) {
}
-#if defined(HAVE_AVX512VBMI)
static
void describeNode64(const NFA *n, const mcsheng64 *m, u16 i, FILE *f) {
const mstate_aux *aux = getAux64(n, i);
}
}
-#endif
static
void dumpDotPreambleDfa(FILE *f) {
dumpTextReverse(nfa, f);
}
-#if defined(HAVE_AVX512VBMI)
static
void dump64_dot_16(const NFA *nfa, FILE *f) {
auto *m = (const mcsheng64 *)getImplNfa(nfa);
fprintf(f, "\n");
dumpTextReverse(nfa, f);
}
-#endif
void nfaExecMcSheng16_dump(const NFA *nfa, const string &base) {
assert(nfa->type == MCSHENG_NFA_16);
}
void nfaExecMcSheng64_16_dump(UNUSED const NFA *nfa, UNUSED const string &base) {
-#if defined(HAVE_AVX512VBMI)
assert(nfa->type == MCSHENG_64_NFA_16);
dump64_text_16(nfa, StdioFile(base + ".txt", "w"));
dump64_dot_16(nfa, StdioFile(base + ".dot", "w"));
-#endif
}
void nfaExecMcSheng64_8_dump(UNUSED const NFA *nfa, UNUSED const string &base) {
-#if defined(HAVE_AVX512VBMI)
assert(nfa->type == MCSHENG_64_NFA_8);
dump64_text_8(nfa, StdioFile(base + ".txt", "w"));
dump64_dot_8(nfa, StdioFile(base + ".dot", "w"));
-#endif
}
} // namespace ue2
* representing the data from a u64a. */
extern const u64a mcsheng_pext_mask[8];
-#if defined(HAVE_AVX512VBMI)
struct mcsheng64 {
u16 state_count; /**< total number of states */
u32 length; /**< length of dfa in bytes */
};
extern const u64a mcsheng64_pext_mask[8];
-#endif
#endif
/** \brief True if the given type (from NFA::type) is a Sheng-McClellan hybrid
* DFA. */
static really_inline int isShengMcClellanType(u8 t) {
-#if defined(HAVE_AVX512VBMI)
- return t == MCSHENG_64_NFA_8 || t == MCSHENG_64_NFA_16 || t == MCSHENG_NFA_8 ||
- t == MCSHENG_NFA_16;
-#else
- return t == MCSHENG_NFA_8 || t == MCSHENG_NFA_16;
-#endif
+ return t == MCSHENG_NFA_8 || t == MCSHENG_NFA_16 ||
+ t == MCSHENG_64_NFA_8 || t == MCSHENG_64_NFA_16;
}
/** \brief True if the given type (from NFA::type) is a Gough DFA. */
return t == SHENG_NFA;
}
-#if defined(HAVE_AVX512VBMI)
/** \brief True if the given type (from NFA::type) is a Sheng32 DFA. */
static really_inline int isSheng32Type(u8 t) {
return t == SHENG_NFA_32;
static really_inline int isSheng64Type(u8 t) {
return t == SHENG_NFA_64;
}
-#endif
/** \brief True if the given type (from NFA::type) is a Sheng16/32/64 DFA. */
static really_inline int isShengType(u8 t) {
-#if defined(HAVE_AVX512VBMI)
return t == SHENG_NFA || t == SHENG_NFA_32 || t == SHENG_NFA_64;
-#else
- return t == SHENG_NFA;
-#endif
}
/**
#define SHENG_STATE_MASK 0xF
#define SHENG_STATE_FLAG_MASK 0x70
-#if defined (HAVE_AVX512VBMI)
#define SHENG32_STATE_ACCEPT 0x20
#define SHENG32_STATE_DEAD 0x40
#define SHENG32_STATE_ACCEL 0x80
#define SHENG64_STATE_DEAD 0x80
#define SHENG64_STATE_MASK 0x3F
#define SHENG64_STATE_FLAG_MASK 0xC0
-#endif
#define SHENG_FLAG_SINGLE_REPORT 0x1
#define SHENG_FLAG_CAN_DIE 0x2
ReportID report;
};
-#if defined (HAVE_AVX512VBMI)
struct sheng32 {
m512 succ_masks[256];
u32 length;
u8 flags;
ReportID report;
};
-#endif
#endif /* SHENG_INTERNAL_H_ */
DEBUG_PRINTF("chr %3u: %s\n", chr, o.str().c_str());
}
-#if defined (HAVE_AVX512VBMI)
static really_inline
void dumpShuffleMask32(const u8 chr, const u8 *buf, unsigned sz) {
stringstream o;
DEBUG_PRINTF("chr %3u: %s\n", chr, o.str().c_str());
}
#endif
-#endif
static
void fillAccelOut(const map<dstate_id_t, AccelScheme> &accel_escape_info,
return s;
}
-#if defined(HAVE_AVX512VBMI)
template <>
u8 getShengState<sheng32>(dstate &state, dfa_info &info,
map<dstate_id_t, AccelScheme> &accelInfo) {
}
return s;
}
-#endif
template <typename T>
static
s->floating = getShengState<sheng>(info.floating, info, accelInfo);
}
-#if defined(HAVE_AVX512VBMI)
template <>
void populateBasicInfo<sheng32>(struct NFA *n, dfa_info &info,
map<dstate_id_t, AccelScheme> &accelInfo,
s->anchored = getShengState<sheng64>(info.anchored, info, accelInfo);
s->floating = getShengState<sheng64>(info.floating, info, accelInfo);
}
-#endif
template <typename T>
static
return true;
}
-#if defined(HAVE_AVX512VBMI)
template <>
bool createShuffleMasks<sheng32>(sheng32 *s, dfa_info &info,
map<dstate_id_t, AccelScheme> &accelInfo) {
}
return true;
}
-#endif
bool has_accel_sheng(const NFA *) {
return true; /* consider the sheng region as accelerated */
return shengCompile_int<sheng>(raw, cc, accel_states, strat, info);
}
-#if defined(HAVE_AVX512VBMI)
bytecode_ptr<NFA> sheng32Compile(raw_dfa &raw, const CompileContext &cc,
const ReportManager &rm, bool only_accel_init,
set<dstate_id_t> *accel_states) {
return nullptr;
}
+ if (!cc.target_info.has_avx512vbmi()) {
+ DEBUG_PRINTF("Sheng32 failed, no HS_CPU_FEATURES_AVX512VBMI!\n");
+ return nullptr;
+ }
+
sheng_build_strat strat(raw, rm, only_accel_init);
dfa_info info(strat);
return nullptr;
}
+ if (!cc.target_info.has_avx512vbmi()) {
+ DEBUG_PRINTF("Sheng64 failed, no HS_CPU_FEATURES_AVX512VBMI!\n");
+ return nullptr;
+ }
+
sheng_build_strat strat(raw, rm, only_accel_init);
dfa_info info(strat);
}
return nfa;
}
-#endif
} // namespace ue2
const ReportManager &rm, bool only_accel_init,
std::set<dstate_id_t> *accel_states = nullptr);
-#if defined(HAVE_AVX512VBMI)
bytecode_ptr<NFA> sheng32Compile(raw_dfa &raw, const CompileContext &cc,
const ReportManager &rm, bool only_accel_init,
std::set<dstate_id_t> *accel_states = nullptr);
bytecode_ptr<NFA> sheng64Compile(raw_dfa &raw, const CompileContext &cc,
const ReportManager &rm, bool only_accel_init,
std::set<dstate_id_t> *accel_states = nullptr);
-#endif
struct sheng_escape_info {
CharReach outs;
return aux;
}
-#if defined(HAVE_AVX512VBMI)
static
const sstate_aux *get_aux32(const NFA *n, dstate_id_t i) {
assert(n && isSheng32Type(n->type));
return aux;
}
-#endif
static
void dumpHeader(FILE *f, const sheng *s) {
!!(s->flags & SHENG_FLAG_SINGLE_REPORT));
}
-#if defined(HAVE_AVX512VBMI)
static
void dumpHeader32(FILE *f, const sheng32 *s) {
fprintf(f, "number of states: %u, DFA engine size: %u\n", s->n_states,
!!(s->flags & SHENG_FLAG_CAN_DIE),
!!(s->flags & SHENG_FLAG_SINGLE_REPORT));
}
-#endif
static
void dumpAux(FILE *f, u32 state, const sstate_aux *aux) {
aux->top & SHENG_STATE_MASK);
}
-#if defined(HAVE_AVX512VBMI)
static
void dumpAux32(FILE *f, u32 state, const sstate_aux *aux) {
fprintf(f, "state id: %u, reports offset: %u, EOD reports offset: %u, "
state, aux->accept, aux->accept_eod, aux->accel,
aux->top & SHENG64_STATE_MASK);
}
-#endif
static
void dumpReports(FILE *f, const report_list *rl) {
}
}
-#if defined(HAVE_AVX512VBMI)
static
void dumpMasks32(FILE *f, const sheng32 *s) {
for (u32 chr = 0; chr < 256; chr++) {
fprintf(f, "\n");
}
}
-#endif
static
void nfaExecSheng_dumpText(const NFA *nfa, FILE *f) {
fprintf(f, "\n");
}
-#if defined(HAVE_AVX512VBMI)
static
void nfaExecSheng32_dumpText(const NFA *nfa, FILE *f) {
assert(nfa->type == SHENG_NFA_32);
fprintf(f, "\n");
}
-#endif
static
void dumpDotPreambleDfa(FILE *f) {
}
}
-#if defined(HAVE_AVX512VBMI)
template <>
void describeNode<sheng32>(const NFA *n, const sheng32 *s, u16 i, FILE *f) {
const sstate_aux *aux = get_aux32(n, i);
fprintf(f, "STARTF -> %u [color = red ]\n", i);
}
}
-#endif
static
void describeEdge(FILE *f, const u16 *t, u16 i) {
t[TOP] = aux->top & SHENG_STATE_MASK;
}
-#if defined(HAVE_AVX512VBMI)
static
void sheng32GetTransitions(const NFA *n, u16 state, u16 *t) {
assert(isSheng32Type(n->type));
t[TOP] = aux->top & SHENG64_STATE_MASK;
}
-#endif
static
void nfaExecSheng_dumpDot(const NFA *nfa, FILE *f) {
fprintf(f, "}\n");
}
-#if defined(HAVE_AVX512VBMI)
static
void nfaExecSheng32_dumpDot(const NFA *nfa, FILE *f) {
assert(nfa->type == SHENG_NFA_32);
fprintf(f, "}\n");
}
-#endif
void nfaExecSheng_dump(const NFA *nfa, const string &base) {
assert(nfa->type == SHENG_NFA);
}
void nfaExecSheng32_dump(UNUSED const NFA *nfa, UNUSED const string &base) {
-#if defined(HAVE_AVX512VBMI)
assert(nfa->type == SHENG_NFA_32);
nfaExecSheng32_dumpText(nfa, StdioFile(base + ".txt", "w"));
nfaExecSheng32_dumpDot(nfa, StdioFile(base + ".dot", "w"));
-#endif
}
void nfaExecSheng64_dump(UNUSED const NFA *nfa, UNUSED const string &base) {
-#if defined(HAVE_AVX512VBMI)
assert(nfa->type == SHENG_NFA_64);
nfaExecSheng64_dumpText(nfa, StdioFile(base + ".txt", "w"));
nfaExecSheng64_dumpDot(nfa, StdioFile(base + ".dot", "w"));
-#endif
}
} // namespace ue2
* bytecode and that they are usually run on small blocks */
dfa = mcshengCompile(rdfa, cc, rm);
}
-
-#if defined(HAVE_AVX512VBMI)
if (!dfa) {
dfa = sheng32Compile(rdfa, cc, rm, false);
}
if (!dfa && !is_transient) {
dfa = mcshengCompile64(rdfa, cc, rm);
}
-#endif
if (!dfa) {
// Sheng wasn't successful, so unleash McClellan!
dfa = mcclellanCompile(rdfa, cc, rm, false);
bytecode_ptr<NFA> dfa = nullptr;
if (cc.grey.allowSmallWriteSheng) {
dfa = shengCompile(rdfa, cc, rm, only_accel_init, &accel_states);
-#if defined(HAVE_AVX512VBMI)
if (!dfa) {
dfa = sheng32Compile(rdfa, cc, rm, only_accel_init, &accel_states);
}
if (!dfa) {
dfa = sheng64Compile(rdfa, cc, rm, only_accel_init, &accel_states);
}
-#endif
}
if (!dfa) {
dfa = mcclellanCompile(rdfa, cc, rm, only_accel_init,