mirror of
https://github.com/VectorCamp/vectorscan.git
synced 2025-06-28 16:41:01 +03:00
Remove CHECK_DEPTH instruction
This commit is contained in:
parent
e051077a26
commit
3d87e382fa
@ -829,18 +829,6 @@ hwlmcb_rv_t roseRunProgram(const struct RoseEngine *t, u32 programOffset,
|
|||||||
}
|
}
|
||||||
PROGRAM_NEXT_INSTRUCTION
|
PROGRAM_NEXT_INSTRUCTION
|
||||||
|
|
||||||
PROGRAM_CASE(CHECK_DEPTH) {
|
|
||||||
DEBUG_PRINTF("current depth %u, check min depth %u\n",
|
|
||||||
tctxt->depth, ri->min_depth);
|
|
||||||
if (ri->min_depth > tctxt->depth) {
|
|
||||||
DEBUG_PRINTF("failed depth check\n");
|
|
||||||
assert(ri->fail_jump); // must progress
|
|
||||||
pc += ri->fail_jump;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
PROGRAM_NEXT_INSTRUCTION
|
|
||||||
|
|
||||||
PROGRAM_CASE(CHECK_ONLY_EOD) {
|
PROGRAM_CASE(CHECK_ONLY_EOD) {
|
||||||
struct core_info *ci = &tctxtToScratch(tctxt)->core_info;
|
struct core_info *ci = &tctxtToScratch(tctxt)->core_info;
|
||||||
if (end != ci->buf_offset + ci->len) {
|
if (end != ci->buf_offset + ci->len) {
|
||||||
|
@ -170,7 +170,6 @@ public:
|
|||||||
|
|
||||||
const void *get() const {
|
const void *get() const {
|
||||||
switch (code()) {
|
switch (code()) {
|
||||||
case ROSE_INSTR_CHECK_DEPTH: return &u.checkDepth;
|
|
||||||
case ROSE_INSTR_CHECK_ONLY_EOD: return &u.checkOnlyEod;
|
case ROSE_INSTR_CHECK_ONLY_EOD: return &u.checkOnlyEod;
|
||||||
case ROSE_INSTR_CHECK_BOUNDS: return &u.checkBounds;
|
case ROSE_INSTR_CHECK_BOUNDS: return &u.checkBounds;
|
||||||
case ROSE_INSTR_CHECK_NOT_HANDLED: return &u.checkNotHandled;
|
case ROSE_INSTR_CHECK_NOT_HANDLED: return &u.checkNotHandled;
|
||||||
@ -199,7 +198,6 @@ public:
|
|||||||
|
|
||||||
size_t length() const {
|
size_t length() const {
|
||||||
switch (code()) {
|
switch (code()) {
|
||||||
case ROSE_INSTR_CHECK_DEPTH: return sizeof(u.checkDepth);
|
|
||||||
case ROSE_INSTR_CHECK_ONLY_EOD: return sizeof(u.checkOnlyEod);
|
case ROSE_INSTR_CHECK_ONLY_EOD: return sizeof(u.checkOnlyEod);
|
||||||
case ROSE_INSTR_CHECK_BOUNDS: return sizeof(u.checkBounds);
|
case ROSE_INSTR_CHECK_BOUNDS: return sizeof(u.checkBounds);
|
||||||
case ROSE_INSTR_CHECK_NOT_HANDLED: return sizeof(u.checkNotHandled);
|
case ROSE_INSTR_CHECK_NOT_HANDLED: return sizeof(u.checkNotHandled);
|
||||||
@ -226,7 +224,6 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
union {
|
union {
|
||||||
ROSE_STRUCT_CHECK_DEPTH checkDepth;
|
|
||||||
ROSE_STRUCT_CHECK_ONLY_EOD checkOnlyEod;
|
ROSE_STRUCT_CHECK_ONLY_EOD checkOnlyEod;
|
||||||
ROSE_STRUCT_CHECK_BOUNDS checkBounds;
|
ROSE_STRUCT_CHECK_BOUNDS checkBounds;
|
||||||
ROSE_STRUCT_CHECK_NOT_HANDLED checkNotHandled;
|
ROSE_STRUCT_CHECK_NOT_HANDLED checkNotHandled;
|
||||||
@ -2633,10 +2630,6 @@ flattenProgram(const vector<vector<RoseInstruction>> &programs) {
|
|||||||
assert(targets[i] > offsets[i]); // jumps always progress
|
assert(targets[i] > offsets[i]); // jumps always progress
|
||||||
ri.u.anchoredDelay.done_jump = targets[i] - offsets[i];
|
ri.u.anchoredDelay.done_jump = targets[i] - offsets[i];
|
||||||
break;
|
break;
|
||||||
case ROSE_INSTR_CHECK_DEPTH:
|
|
||||||
assert(targets[i] > offsets[i]);
|
|
||||||
ri.u.checkDepth.fail_jump = targets[i] - offsets[i];
|
|
||||||
break;
|
|
||||||
case ROSE_INSTR_CHECK_ONLY_EOD:
|
case ROSE_INSTR_CHECK_ONLY_EOD:
|
||||||
assert(targets[i] > offsets[i]);
|
assert(targets[i] > offsets[i]);
|
||||||
ri.u.checkOnlyEod.fail_jump = targets[i] - offsets[i];
|
ri.u.checkOnlyEod.fail_jump = targets[i] - offsets[i];
|
||||||
@ -3365,7 +3358,6 @@ vector<RoseInstruction> makePredProgram(RoseBuildImpl &build, build_context &bc,
|
|||||||
static
|
static
|
||||||
pair<u32, u32> makeSparseIterProgram(build_context &bc,
|
pair<u32, u32> makeSparseIterProgram(build_context &bc,
|
||||||
map<u32, vector<vector<RoseInstruction>>> &predProgramLists,
|
map<u32, vector<vector<RoseInstruction>>> &predProgramLists,
|
||||||
const vector<RoseVertex> &verts,
|
|
||||||
const vector<RoseInstruction> &root_program) {
|
const vector<RoseInstruction> &root_program) {
|
||||||
vector<RoseInstruction> program;
|
vector<RoseInstruction> program;
|
||||||
u32 iter_offset = 0;
|
u32 iter_offset = 0;
|
||||||
@ -3389,17 +3381,6 @@ pair<u32, u32> makeSparseIterProgram(build_context &bc,
|
|||||||
vector<u32> jump_table;
|
vector<u32> jump_table;
|
||||||
u32 curr_offset = 0;
|
u32 curr_offset = 0;
|
||||||
|
|
||||||
// Add a pre-check for min depth, if it's useful.
|
|
||||||
if (!verts.empty()) {
|
|
||||||
u32 min_depth = calcMinDepth(bc.depths, verts);
|
|
||||||
if (min_depth > 1) {
|
|
||||||
auto ri = RoseInstruction(ROSE_INSTR_CHECK_DEPTH);
|
|
||||||
ri.u.checkDepth.min_depth = min_depth;
|
|
||||||
program.push_back(ri);
|
|
||||||
curr_offset = ROUNDUP_N(ri.length(), ROSE_INSTR_MIN_ALIGN);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
program.push_back(RoseInstruction(ROSE_INSTR_SPARSE_ITER_BEGIN));
|
program.push_back(RoseInstruction(ROSE_INSTR_SPARSE_ITER_BEGIN));
|
||||||
curr_offset += ROUNDUP_N(program.back().length(), ROSE_INSTR_MIN_ALIGN);
|
curr_offset += ROUNDUP_N(program.back().length(), ROSE_INSTR_MIN_ALIGN);
|
||||||
|
|
||||||
@ -3436,9 +3417,6 @@ pair<u32, u32> makeSparseIterProgram(build_context &bc,
|
|||||||
for (size_t i = 0; i < program.size(); i++) {
|
for (size_t i = 0; i < program.size(); i++) {
|
||||||
auto &ri = program[i];
|
auto &ri = program[i];
|
||||||
switch (ri.code()) {
|
switch (ri.code()) {
|
||||||
case ROSE_INSTR_CHECK_DEPTH:
|
|
||||||
ri.u.checkDepth.fail_jump = end_offset - curr_offset;
|
|
||||||
break;
|
|
||||||
case ROSE_INSTR_SPARSE_ITER_BEGIN:
|
case ROSE_INSTR_SPARSE_ITER_BEGIN:
|
||||||
ri.u.sparseIterBegin.iter_offset = iter_offset;
|
ri.u.sparseIterBegin.iter_offset = iter_offset;
|
||||||
ri.u.sparseIterBegin.jump_table = jump_table_offset;
|
ri.u.sparseIterBegin.jump_table = jump_table_offset;
|
||||||
@ -3518,8 +3496,7 @@ u32 buildLiteralProgram(RoseBuildImpl &build, build_context &bc,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Put it all together.
|
// Put it all together.
|
||||||
return makeSparseIterProgram(bc, predProgramLists, nonroot_verts,
|
return makeSparseIterProgram(bc, predProgramLists, root_program).first;
|
||||||
root_program).first;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
@ -3632,7 +3609,7 @@ pair<u32, u32> buildEodAnchorProgram(RoseBuildImpl &build, build_context &bc) {
|
|||||||
return {0, 0};
|
return {0, 0};
|
||||||
}
|
}
|
||||||
|
|
||||||
return makeSparseIterProgram(bc, predProgramLists, {}, {});
|
return makeSparseIterProgram(bc, predProgramLists, {});
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
|
@ -203,12 +203,6 @@ void dumpProgram(ofstream &os, const RoseEngine *t, const char *pc) {
|
|||||||
}
|
}
|
||||||
PROGRAM_NEXT_INSTRUCTION
|
PROGRAM_NEXT_INSTRUCTION
|
||||||
|
|
||||||
PROGRAM_CASE(CHECK_DEPTH) {
|
|
||||||
os << " min_depth " << u32{ri->min_depth} << endl;
|
|
||||||
os << " fail_jump +" << ri->fail_jump << endl;
|
|
||||||
}
|
|
||||||
PROGRAM_NEXT_INSTRUCTION
|
|
||||||
|
|
||||||
PROGRAM_CASE(CHECK_ONLY_EOD) {
|
PROGRAM_CASE(CHECK_ONLY_EOD) {
|
||||||
os << " fail_jump +" << ri->fail_jump << endl;
|
os << " fail_jump +" << ri->fail_jump << endl;
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,6 @@
|
|||||||
/** \brief Role program instruction opcodes. */
|
/** \brief Role program instruction opcodes. */
|
||||||
enum RoseInstructionCode {
|
enum RoseInstructionCode {
|
||||||
ROSE_INSTR_ANCHORED_DELAY, //!< Delay until after anchored matcher.
|
ROSE_INSTR_ANCHORED_DELAY, //!< Delay until after anchored matcher.
|
||||||
ROSE_INSTR_CHECK_DEPTH, //!< Check minimum graph depth.
|
|
||||||
ROSE_INSTR_CHECK_ONLY_EOD, //!< Role matches only at EOD.
|
ROSE_INSTR_CHECK_ONLY_EOD, //!< Role matches only at EOD.
|
||||||
ROSE_INSTR_CHECK_BOUNDS, //!< Bounds on distance from offset 0.
|
ROSE_INSTR_CHECK_BOUNDS, //!< Bounds on distance from offset 0.
|
||||||
ROSE_INSTR_CHECK_NOT_HANDLED, //!< Test & set role in "handled".
|
ROSE_INSTR_CHECK_NOT_HANDLED, //!< Test & set role in "handled".
|
||||||
@ -72,12 +71,6 @@ struct ROSE_STRUCT_ANCHORED_DELAY {
|
|||||||
u32 done_jump; //!< Jump forward this many bytes if successful.
|
u32 done_jump; //!< Jump forward this many bytes if successful.
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ROSE_STRUCT_CHECK_DEPTH {
|
|
||||||
u8 code; //!< From enum RoseInstructionCode.
|
|
||||||
u8 min_depth; //!< Minimum depth of this literal in the Rose graph.
|
|
||||||
u32 fail_jump; //!< Jump forward this many bytes on failure.
|
|
||||||
};
|
|
||||||
|
|
||||||
struct ROSE_STRUCT_CHECK_ONLY_EOD {
|
struct ROSE_STRUCT_CHECK_ONLY_EOD {
|
||||||
u8 code; //!< From enum RoseInstructionCode.
|
u8 code; //!< From enum RoseInstructionCode.
|
||||||
u32 fail_jump; //!< Jump forward this many bytes on failure.
|
u32 fail_jump; //!< Jump forward this many bytes on failure.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user