From bf3ced92f4a1a3dc230c604ca99564debbe3fffa Mon Sep 17 00:00:00 2001 From: Justin Viiret Date: Mon, 26 Jun 2017 14:39:46 +1000 Subject: [PATCH] hwlm_dump: take base filename, like NFA dump API --- src/hwlm/hwlm_dump.cpp | 11 +++++++---- src/hwlm/hwlm_dump.h | 10 +++++----- src/rose/rose_build_dump.cpp | 21 ++++++++------------- 3 files changed, 20 insertions(+), 22 deletions(-) diff --git a/src/hwlm/hwlm_dump.cpp b/src/hwlm/hwlm_dump.cpp index 58411ab2..59353eee 100644 --- a/src/hwlm/hwlm_dump.cpp +++ b/src/hwlm/hwlm_dump.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 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: @@ -38,16 +38,19 @@ #include "ue2common.h" #include "fdr/fdr_dump.h" #include "nfa/accel_dump.h" - -#include +#include "util/dump_util.h" #ifndef DUMP_SUPPORT #error No dump support! #endif +using namespace std; + namespace ue2 { -void hwlmPrintStats(const HWLM *h, FILE *f) { +void hwlmGenerateDumpFiles(const HWLM *h, const string &base) { + StdioFile f(base + ".txt", "w"); + switch (h->type) { case HWLM_ENGINE_NOOD: noodPrintStats((const noodTable *)HWLM_C_DATA(h), f); diff --git a/src/hwlm/hwlm_dump.h b/src/hwlm/hwlm_dump.h index e7e38353..12f61c86 100644 --- a/src/hwlm/hwlm_dump.h +++ b/src/hwlm/hwlm_dump.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 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: @@ -35,16 +35,16 @@ #ifdef DUMP_SUPPORT -#include +#include struct HWLM; namespace ue2 { /** \brief Dump some information about the give HWLM structure. */ -void hwlmPrintStats(const HWLM *h, FILE *f); +void hwlmGenerateDumpFiles(const HWLM *h, const std::string &base); } // namespace ue2 -#endif -#endif +#endif // DUMP_SUPPORT +#endif // HWLM_DUMP_H diff --git a/src/rose/rose_build_dump.cpp b/src/rose/rose_build_dump.cpp index 81acec12..5e9f95f2 100644 --- a/src/rose/rose_build_dump.cpp +++ b/src/rose/rose_build_dump.cpp @@ -2196,26 +2196,21 @@ void roseDumpPrograms(const vector &fragments, const RoseEngine *t, static void roseDumpLiteralMatchers(const RoseEngine *t, const string &base) { - if (const HWLM *ftable = getFloatingMatcher(t)) { - StdioFile f(base + "/lit_table_floating.txt", "w"); - hwlmPrintStats(ftable, f); + if (const HWLM *hwlm = getFloatingMatcher(t)) { + hwlmGenerateDumpFiles(hwlm, base + "/lit_table_floating"); } - if (const HWLM *drtable = getDelayRebuildMatcher(t)) { - StdioFile f(base + "/lit_table_delay_rebuild.txt", "w"); - hwlmPrintStats(drtable, f); + if (const HWLM *hwlm = getDelayRebuildMatcher(t)) { + hwlmGenerateDumpFiles(hwlm, base + "/lit_table_delay_rebuild"); } - if (const HWLM *etable = getEodMatcher(t)) { - StdioFile f(base + "/lit_table_eod.txt", "w"); - hwlmPrintStats(etable, f); + if (const HWLM *hwlm = getEodMatcher(t)) { + hwlmGenerateDumpFiles(hwlm, base + "/lit_table_eod"); } - if (const HWLM *sbtable = getSmallBlockMatcher(t)) { - StdioFile f(base + "/lit_table_small_block.txt", "w"); - hwlmPrintStats(sbtable, f); + if (const HWLM *hwlm = getSmallBlockMatcher(t)) { + hwlmGenerateDumpFiles(hwlm, base + "/lit_table_small_block"); } - } void dumpRose(const RoseBuildImpl &build, const vector &fragments,