mirror of
https://github.com/VectorCamp/vectorscan.git
synced 2025-06-28 16:41:01 +03:00
add checkViolet and switch SOM path accross to use violet
This commit is contained in:
parent
cde6ebf516
commit
2a1202e1e6
@ -533,16 +533,13 @@ bool NG::addHolder(NGHolder &w) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (splitOffRose(*rose, w, prefilter, rm, cc)) {
|
if (doViolet(*rose, w, prefilter, false, rm, cc)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (splitOffPuffs(*rose, rm, w, prefilter, cc)) {
|
if (splitOffPuffs(*rose, rm, w, prefilter, cc)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (splitOffRose(*rose, w, prefilter, rm, cc)) {
|
if (doViolet(*rose, w, prefilter, true, rm, cc)) {
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (finalChanceRose(*rose, w, prefilter, rm, cc)) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2015-2016, Intel Corporation
|
* Copyright (c) 2015-2017, Intel Corporation
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are met:
|
* modification, are permitted provided that the following conditions are met:
|
||||||
@ -40,12 +40,12 @@
|
|||||||
#include "ng_redundancy.h"
|
#include "ng_redundancy.h"
|
||||||
#include "ng_region.h"
|
#include "ng_region.h"
|
||||||
#include "ng_reports.h"
|
#include "ng_reports.h"
|
||||||
#include "ng_rose.h"
|
|
||||||
#include "ng_som.h"
|
#include "ng_som.h"
|
||||||
#include "ng_som_add_redundancy.h"
|
#include "ng_som_add_redundancy.h"
|
||||||
#include "ng_som_util.h"
|
#include "ng_som_util.h"
|
||||||
#include "ng_split.h"
|
#include "ng_split.h"
|
||||||
#include "ng_util.h"
|
#include "ng_util.h"
|
||||||
|
#include "ng_violet.h"
|
||||||
#include "ng_width.h"
|
#include "ng_width.h"
|
||||||
#include "grey.h"
|
#include "grey.h"
|
||||||
#include "ue2common.h"
|
#include "ue2common.h"
|
||||||
@ -2073,7 +2073,7 @@ sombe_rv doHaigLitSom(NG &ng, NGHolder &g, const NGWrapper &w, u32 comp_id,
|
|||||||
const u32 numSomLocsBefore = ssm.numSomSlots(); /* for rollback */
|
const u32 numSomLocsBefore = ssm.numSomSlots(); /* for rollback */
|
||||||
u32 som_loc = ssm.getPrivateSomSlot();
|
u32 som_loc = ssm.getPrivateSomSlot();
|
||||||
|
|
||||||
if (!checkRose(rm, g, false, cc) && !isImplementableNFA(g, &rm, cc)) {
|
if (!checkViolet(rm, g, false, cc) && !isImplementableNFA(g, &rm, cc)) {
|
||||||
// This is an optimisation: if we can't build a Haig from a portion of
|
// This is an optimisation: if we can't build a Haig from a portion of
|
||||||
// the graph, then we won't be able to manage it as an outfix either
|
// the graph, then we won't be able to manage it as an outfix either
|
||||||
// when we fall back.
|
// when we fall back.
|
||||||
|
@ -2867,25 +2867,24 @@ bool ensureImplementable(RoseBuild &rose, RoseInGraph &vg, bool allow_changes,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool doViolet(RoseBuild &rose, const NGHolder &h, bool prefilter,
|
static
|
||||||
bool last_chance, const ReportManager &rm,
|
RoseInGraph doInitialVioletTransform(const NGHolder &h,
|
||||||
const CompileContext &cc) {
|
const CompileContext &cc) {
|
||||||
assert(!can_never_match(h));
|
assert(!can_never_match(h));
|
||||||
|
|
||||||
|
RoseInGraph vg = populateTrivialGraph(h);
|
||||||
|
|
||||||
if (!cc.grey.allowViolet) {
|
if (!cc.grey.allowViolet) {
|
||||||
return false;
|
return vg;
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUG_PRINTF("hello world\n");
|
DEBUG_PRINTF("hello world\n");
|
||||||
|
|
||||||
RoseInGraph vg = populateTrivialGraph(h);
|
|
||||||
|
|
||||||
/* Step 1: avoid outfixes as we always have to run them. */
|
/* Step 1: avoid outfixes as we always have to run them. */
|
||||||
avoidOutfixes(vg, cc);
|
avoidOutfixes(vg, cc);
|
||||||
|
|
||||||
if (num_vertices(vg) <= 2) {
|
if (num_vertices(vg) <= 2) {
|
||||||
/* only have an outfix; leave for ng_rose for now */
|
return vg; /* unable to transform pattern */
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
removeRedundantPrefixes(vg);
|
removeRedundantPrefixes(vg);
|
||||||
@ -2923,6 +2922,17 @@ bool doViolet(RoseBuild &rose, const NGHolder &h, bool prefilter,
|
|||||||
renumber_vertices(vg);
|
renumber_vertices(vg);
|
||||||
calcVertexOffsets(vg);
|
calcVertexOffsets(vg);
|
||||||
|
|
||||||
|
return vg;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool doViolet(RoseBuild &rose, const NGHolder &h, bool prefilter,
|
||||||
|
bool last_chance, const ReportManager &rm,
|
||||||
|
const CompileContext &cc) {
|
||||||
|
auto vg = doInitialVioletTransform(h, cc);
|
||||||
|
if (num_vertices(vg) <= 2) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/* Step 5: avoid unimplementable, or overly large engines if possible */
|
/* Step 5: avoid unimplementable, or overly large engines if possible */
|
||||||
if (!ensureImplementable(rose, vg, last_chance, last_chance, rm, cc)) {
|
if (!ensureImplementable(rose, vg, last_chance, last_chance, rm, cc)) {
|
||||||
return false;
|
return false;
|
||||||
@ -2935,4 +2945,16 @@ bool doViolet(RoseBuild &rose, const NGHolder &h, bool prefilter,
|
|||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool checkViolet(const ReportManager &rm, const NGHolder &h, bool prefilter,
|
||||||
|
const CompileContext &cc) {
|
||||||
|
auto vg = doInitialVioletTransform(h, cc);
|
||||||
|
if (num_vertices(vg) <= 2) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool rv = roseCheckRose(vg, prefilter, rm, cc);
|
||||||
|
DEBUG_PRINTF("violet: %s\n", rv ? "success" : "fail");
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -53,6 +53,13 @@ bool doViolet(RoseBuild &rose, const NGHolder &h, bool prefilter,
|
|||||||
bool ensureImplementable(RoseBuild &rose, RoseInGraph &vg, bool allow_changes,
|
bool ensureImplementable(RoseBuild &rose, RoseInGraph &vg, bool allow_changes,
|
||||||
bool final_chance, const ReportManager &rm,
|
bool final_chance, const ReportManager &rm,
|
||||||
const CompileContext &cc);
|
const CompileContext &cc);
|
||||||
|
|
||||||
|
/** \brief True if the pattern in \a h is consumable by Rose/Violet. This
|
||||||
|
* function may be conservative (return false even if supported) for
|
||||||
|
* efficiency. */
|
||||||
|
bool checkViolet(const ReportManager &rm, const NGHolder &h, bool prefilter,
|
||||||
|
const CompileContext &cc);
|
||||||
|
|
||||||
} // namespace ue2
|
} // namespace ue2
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user