return true;
}
- if (splitOffRose(*rose, w, prefilter, rm, cc)) {
+ if (doViolet(*rose, w, prefilter, false, rm, cc)) {
return true;
}
if (splitOffPuffs(*rose, rm, w, prefilter, cc)) {
return true;
}
- if (splitOffRose(*rose, w, prefilter, rm, cc)) {
- return true;
- }
- if (finalChanceRose(*rose, w, prefilter, rm, cc)) {
+ if (doViolet(*rose, w, prefilter, true, rm, cc)) {
return true;
}
/*
- * Copyright (c) 2015-2016, Intel Corporation
+ * Copyright (c) 2015-2017, Intel Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
#include "ng_redundancy.h"
#include "ng_region.h"
#include "ng_reports.h"
-#include "ng_rose.h"
#include "ng_som.h"
#include "ng_som_add_redundancy.h"
#include "ng_som_util.h"
#include "ng_split.h"
#include "ng_util.h"
+#include "ng_violet.h"
#include "ng_width.h"
#include "grey.h"
#include "ue2common.h"
const u32 numSomLocsBefore = ssm.numSomSlots(); /* for rollback */
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
// the graph, then we won't be able to manage it as an outfix either
// when we fall back.
return true;
}
-bool doViolet(RoseBuild &rose, const NGHolder &h, bool prefilter,
- bool last_chance, const ReportManager &rm,
- const CompileContext &cc) {
+static
+RoseInGraph doInitialVioletTransform(const NGHolder &h,
+ const CompileContext &cc) {
assert(!can_never_match(h));
+ RoseInGraph vg = populateTrivialGraph(h);
+
if (!cc.grey.allowViolet) {
- return false;
+ return vg;
}
DEBUG_PRINTF("hello world\n");
- RoseInGraph vg = populateTrivialGraph(h);
-
/* Step 1: avoid outfixes as we always have to run them. */
avoidOutfixes(vg, cc);
if (num_vertices(vg) <= 2) {
- /* only have an outfix; leave for ng_rose for now */
- return false;
+ return vg; /* unable to transform pattern */
}
removeRedundantPrefixes(vg);
renumber_vertices(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 */
if (!ensureImplementable(rose, vg, last_chance, last_chance, rm, cc)) {
return false;
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;
+}
+
}
bool ensureImplementable(RoseBuild &rose, RoseInGraph &vg, bool allow_changes,
bool final_chance, const ReportManager &rm,
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
#endif