mirror of
https://github.com/VectorCamp/vectorscan.git
synced 2025-06-28 16:41:01 +03:00
truffle hwlm accel
This commit is contained in:
parent
691b08d170
commit
69933edf68
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2015, Intel Corporation
|
* Copyright (c) 2015-2016, 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:
|
||||||
@ -37,6 +37,7 @@
|
|||||||
#include "fdr/fdr.h"
|
#include "fdr/fdr.h"
|
||||||
#include "nfa/accel.h"
|
#include "nfa/accel.h"
|
||||||
#include "nfa/shufti.h"
|
#include "nfa/shufti.h"
|
||||||
|
#include "nfa/truffle.h"
|
||||||
#include "nfa/vermicelli.h"
|
#include "nfa/vermicelli.h"
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
@ -64,8 +65,13 @@ const u8 *run_hwlm_accel(const union AccelAux *aux, const u8 *ptr,
|
|||||||
case ACCEL_SHUFTI:
|
case ACCEL_SHUFTI:
|
||||||
DEBUG_PRINTF("single shufti\n");
|
DEBUG_PRINTF("single shufti\n");
|
||||||
return shuftiExec(aux->shufti.lo, aux->shufti.hi, ptr, end);
|
return shuftiExec(aux->shufti.lo, aux->shufti.hi, ptr, end);
|
||||||
|
case ACCEL_TRUFFLE:
|
||||||
|
DEBUG_PRINTF("truffle\n");
|
||||||
|
return truffleExec(aux->truffle.mask1, aux->truffle.mask2, ptr, end);
|
||||||
default:
|
default:
|
||||||
/* no acceleration, fall through and return current ptr */
|
/* no acceleration, fall through and return current ptr */
|
||||||
|
DEBUG_PRINTF("no accel; %u\n", (int)aux->accel_type);
|
||||||
|
assert(aux->accel_type == ACCEL_NONE);
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -38,6 +38,7 @@
|
|||||||
#include "ue2common.h"
|
#include "ue2common.h"
|
||||||
#include "fdr/fdr_compile.h"
|
#include "fdr/fdr_compile.h"
|
||||||
#include "nfa/shufticompile.h"
|
#include "nfa/shufticompile.h"
|
||||||
|
#include "nfa/trufflecompile.h"
|
||||||
#include "util/alloc.h"
|
#include "util/alloc.h"
|
||||||
#include "util/bitutils.h"
|
#include "util/bitutils.h"
|
||||||
#include "util/charreach.h"
|
#include "util/charreach.h"
|
||||||
@ -372,12 +373,9 @@ void findForwardAccelScheme(const vector<hwlmLiteral> &lits,
|
|||||||
for (u32 i = 0; i < MAX_ACCEL_OFFSET && i < lit.s.length(); i++) {
|
for (u32 i = 0; i < MAX_ACCEL_OFFSET && i < lit.s.length(); i++) {
|
||||||
unsigned char c = lit.s[i];
|
unsigned char c = lit.s[i];
|
||||||
if (lit.nocase) {
|
if (lit.nocase) {
|
||||||
DEBUG_PRINTF("adding %02hhx to %u\n", mytoupper(c), i);
|
|
||||||
DEBUG_PRINTF("adding %02hhx to %u\n", mytolower(c), i);
|
|
||||||
reach[i].set(mytoupper(c));
|
reach[i].set(mytoupper(c));
|
||||||
reach[i].set(mytolower(c));
|
reach[i].set(mytolower(c));
|
||||||
} else {
|
} else {
|
||||||
DEBUG_PRINTF("adding %02hhx to %u\n", c, i);
|
|
||||||
reach[i].set(c);
|
reach[i].set(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -397,7 +395,7 @@ void findForwardAccelScheme(const vector<hwlmLiteral> &lits,
|
|||||||
assert(min_offset <= min_len);
|
assert(min_offset <= min_len);
|
||||||
|
|
||||||
if (min_count > MAX_SHUFTI_WIDTH) {
|
if (min_count > MAX_SHUFTI_WIDTH) {
|
||||||
DEBUG_PRINTF("min shufti with %u chars is too wide\n", min_count);
|
DEBUG_PRINTF("FAIL: min shufti with %u chars is too wide\n", min_count);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -410,7 +408,11 @@ void findForwardAccelScheme(const vector<hwlmLiteral> &lits,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUG_PRINTF("fail\n");
|
truffleBuildMasks(cr, &aux->truffle.mask1, &aux->truffle.mask2);
|
||||||
|
DEBUG_PRINTF("built truffle for %s (%zu chars, offset %u)\n",
|
||||||
|
describeClass(cr).c_str(), cr.count(), min_offset);
|
||||||
|
aux->truffle.accel_type = ACCEL_TRUFFLE;
|
||||||
|
aux->truffle.offset = verify_u8(min_offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
|
Loading…
x
Reference in New Issue
Block a user