fix JSON reading

This commit is contained in:
Eyck Jentzsch 2022-02-01 19:28:11 +01:00
parent 059bd0d371
commit 98b418ff43
3 changed files with 15 additions and 7 deletions

View File

@ -35,12 +35,14 @@ FILE(GLOB TGC_VM_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/vm/interp/vm_*.cpp)
set(LIB_SOURCES set(LIB_SOURCES
src/vm/fp_functions.cpp src/vm/fp_functions.cpp
src/plugin/instruction_count.cpp src/plugin/instruction_count.cpp
src/plugin/cycle_estimate.cpp
src/plugin/cov.cpp src/plugin/cov.cpp
${TGC_SOURCES} ${TGC_SOURCES}
${TGC_VM_SOURCES} ${TGC_VM_SOURCES}
) )
if(TARGET RapidJSON)
list(APPEND LIB_SOURCES src/plugin/cycle_estimate.cpp)
endif()
if(WITH_LLVM) if(WITH_LLVM)
FILE(GLOB TGC_LLVM_SOURCES FILE(GLOB TGC_LLVM_SOURCES
@ -82,6 +84,10 @@ elseif(TARGET elfio::elfio)
else() else()
message(FATAL_ERROR "No elfio library found, maybe a find_package() call is missing") message(FATAL_ERROR "No elfio library found, maybe a find_package() call is missing")
endif() endif()
if(TARGET RapidJSON)
target_link_libraries(${PROJECT_NAME} PUBLIC RapidJSON)
endif()
set_target_properties(${PROJECT_NAME} PROPERTIES set_target_properties(${PROJECT_NAME} PROPERTIES
VERSION ${PROJECT_VERSION} VERSION ${PROJECT_VERSION}

View File

@ -39,6 +39,7 @@
#include "iss/vm_plugin.h" #include "iss/vm_plugin.h"
#include <string> #include <string>
#include <unordered_map> #include <unordered_map>
#include <vector>
namespace iss { namespace iss {

View File

@ -41,6 +41,7 @@
#include "rapidjson/writer.h" #include "rapidjson/writer.h"
#include "rapidjson/stringbuffer.h" #include "rapidjson/stringbuffer.h"
#include <rapidjson/ostreamwrapper.h> #include <rapidjson/ostreamwrapper.h>
#include <rapidjson/error/en.h>
#include <fstream> #include <fstream>
using namespace rapidjson; using namespace rapidjson;
@ -67,13 +68,13 @@ bool iss::plugin::cycle_estimate::registration(const char* const version, vm_if&
Document d; Document d;
ParseResult ok = d.ParseStream(isw); ParseResult ok = d.ParseStream(isw);
if(ok) { if(ok) {
Value& val = d[core_name]; Value& val = d[core_name.c_str()];
if(val.IsArray()){ if(val.IsArray()){
delays.reserve(val.Size()); delays.reserve(val.Size());
for(auto it:val.GetArray()){ for (auto it = val.Begin(); it != val.End(); ++it) {
auto name = it["name"]; auto& name = (*it)["name"];
auto size = it["size"]; auto& size = (*it)["size"];
auto delay = it["delay"]; auto& delay = (*it)["delay"];
if(delay.IsArray()) { if(delay.IsArray()) {
delays.push_back(instr_desc{size.Get<unsigned>(), delay[0].Get<unsigned>(), delay[1].Get<unsigned>()}); delays.push_back(instr_desc{size.Get<unsigned>(), delay[0].Get<unsigned>(), delay[1].Get<unsigned>()});
} else if(delay.Is<unsigned>()) { } else if(delay.Is<unsigned>()) {
@ -86,7 +87,7 @@ bool iss::plugin::cycle_estimate::registration(const char* const version, vm_if&
return false; return false;
} }
} else { } else {
LOG(ERR)<<"plugin cycle_estimate: could not parse in JSON file"<<endl; LOG(ERR)<<"plugin cycle_estimate: could not parse in JSON file at "<< ok.Offset()<<": "<<GetParseError_En(ok.Code())<<endl;
return false; return false;
} }
} catch (runtime_error &e) { } catch (runtime_error &e) {