diff --git a/CMakeLists.txt b/CMakeLists.txt index f5d7912..5878425 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -48,16 +48,22 @@ if(WITH_LLVM) endif() # Define the library -add_library(${PROJECT_NAME} SHARED ${LIB_SOURCES}) +add_library(${PROJECT_NAME} ${LIB_SOURCES}) # list code gen dependencies if(TARGET ${CORE_NAME}_cpp) add_dependencies(${PROJECT_NAME} ${CORE_NAME}_cpp) endif() -target_compile_options(${PROJECT_NAME} PRIVATE -Wno-shift-count-overflow) +if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + target_compile_options(${PROJECT_NAME} PRIVATE -Wno-shift-count-overflow) +endif() target_include_directories(${PROJECT_NAME} PUBLIC incl) target_link_libraries(${PROJECT_NAME} PUBLIC softfloat scc-util jsoncpp) -target_link_libraries(${PROJECT_NAME} PUBLIC -Wl,--whole-archive dbt-core -Wl,--no-whole-archive) +if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + target_link_libraries(${PROJECT_NAME} PUBLIC -Wl,--whole-archive dbt-core -Wl,--no-whole-archive) +else() + target_link_libraries(${PROJECT_NAME} PUBLIC dbt-core) +endif() if(TARGET CONAN_PKG::elfio) target_link_libraries(${PROJECT_NAME} PUBLIC CONAN_PKG::elfio) elseif(TARGET elfio::elfio) @@ -98,16 +104,15 @@ if(WITH_LLVM) target_link_libraries(${PROJECT_NAME} PUBLIC ${llvm_libs}) endif() # Links the target exe against the libraries -target_link_libraries(${PROJECT_NAME} dbt-rise-tgc) -#target_link_libraries(${PROJECT_NAME} jsoncpp) +target_link_libraries(${PROJECT_NAME} PUBLIC dbt-rise-tgc) if(TARGET Boost::program_options) - target_link_libraries(${PROJECT_NAME} Boost::program_options Boost::thread) + target_link_libraries(${PROJECT_NAME} PUBLIC Boost::program_options Boost::thread) else() - target_link_libraries(${PROJECT_NAME} ${BOOST_program_options_LIBRARY} ${BOOST_thread_LIBRARY}) + target_link_libraries(${PROJECT_NAME} PUBLIC ${BOOST_program_options_LIBRARY} ${BOOST_thread_LIBRARY}) endif() -target_link_libraries(${PROJECT_NAME} ${CMAKE_DL_LIBS}) +target_link_libraries(${PROJECT_NAME} PUBLIC ${CMAKE_DL_LIBS}) if (Tcmalloc_FOUND) - target_link_libraries(${PROJECT_NAME} ${Tcmalloc_LIBRARIES}) + target_link_libraries(${PROJECT_NAME} PUBLIC ${Tcmalloc_LIBRARIES}) endif(Tcmalloc_FOUND) install(TARGETS tgc-sim diff --git a/incl/iss/arch/riscv_hart_m_p.h b/incl/iss/arch/riscv_hart_m_p.h index 0104e2c..2a469e5 100644 --- a/incl/iss/arch/riscv_hart_m_p.h +++ b/incl/iss/arch/riscv_hart_m_p.h @@ -397,7 +397,7 @@ template std::pair riscv_hart_m_p::load_fi traits::MEM, pseg->get_physical_address(), fsize, reinterpret_cast(seg_data)); if (res != iss::Ok) - LOG(ERROR) << "problem writing " << fsize << "bytes to 0x" << std::hex + LOG(ERR) << "problem writing " << fsize << "bytes to 0x" << std::hex << pseg->get_physical_address(); } } @@ -948,7 +948,11 @@ template uint64_t riscv_hart_m_p::enter_trap(uint64_t flag this->reg.PRIV = PRIV_M; this->reg.trap_state = 0; std::array buffer; +#if defined(_MSC_VER) + sprintf(buffer.data(), "0x%016llx", addr); +#else sprintf(buffer.data(), "0x%016lx", addr); +#endif if((flags&0xffffffff) != 0xffffffff) CLOG(INFO, disass) << (trap_id ? "Interrupt" : "Trap") << " with cause '" << (trap_id ? irq_str[cause] : trap_str[cause]) << "' (" << cause << ")" diff --git a/softfloat/build/Linux-x86_64-GCC/platform.h b/softfloat/build/Linux-x86_64-GCC/platform.h index 337ca99..92c3044 100644 --- a/softfloat/build/Linux-x86_64-GCC/platform.h +++ b/softfloat/build/Linux-x86_64-GCC/platform.h @@ -49,7 +49,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /*---------------------------------------------------------------------------- *----------------------------------------------------------------------------*/ +#ifdef __GNUC__ #define SOFTFLOAT_BUILTIN_CLZ 1 #define SOFTFLOAT_INTRINSIC_INT128 1 +#endif #include "opts-GCC.h" diff --git a/src/main.cpp b/src/main.cpp index ac139d1..dcab875 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -140,7 +140,7 @@ int main(int argc, char *argv[]) { } else #endif { - LOG(ERROR) << "Illegal argument value for '--isa': " << clim["isa"].as() << std::endl; + LOG(ERR) << "Illegal argument value for '--isa': " << clim["isa"].as() << std::endl; return 127; } if (clim.count("plugin")) { @@ -161,7 +161,7 @@ int main(int argc, char *argv[]) { vm->register_plugin(*ce_plugin); plugin_list.push_back(ce_plugin); } else { - LOG(ERROR) << "Unknown plugin name: " << plugin_name << ", valid names are 'ce', 'ic'" << std::endl; + LOG(ERR) << "Unknown plugin name: " << plugin_name << ", valid names are 'ce', 'ic'" << std::endl; return 127; } } @@ -196,7 +196,7 @@ int main(int argc, char *argv[]) { auto cycles = clim["instructions"].as(); res = vm->start(cycles, dump); } catch (std::exception &e) { - LOG(ERROR) << "Unhandled Exception reached the top of main: " << e.what() << ", application will now exit" + LOG(ERR) << "Unhandled Exception reached the top of main: " << e.what() << ", application will now exit" << std::endl; res = 2; } diff --git a/src/plugin/cycle_estimate.cpp b/src/plugin/cycle_estimate.cpp index 6abf77c..3aa856b 100644 --- a/src/plugin/cycle_estimate.cpp +++ b/src/plugin/cycle_estimate.cpp @@ -47,10 +47,10 @@ iss::plugin::cycle_estimate::cycle_estimate(std::string config_file_name) try { is >> root; } catch (Json::RuntimeError &e) { - LOG(ERROR) << "Could not parse input file " << config_file_name << ", reason: " << e.what(); + LOG(ERR) << "Could not parse input file " << config_file_name << ", reason: " << e.what(); } } else { - LOG(ERROR) << "Could not open input file " << config_file_name; + LOG(ERR) << "Could not open input file " << config_file_name; } } } @@ -77,7 +77,7 @@ bool iss::plugin::cycle_estimate::registration(const char* const version, vm_if& } } } else { - LOG(ERROR)<<"plugin cycle_estimate: could not find an entry for "<get_next_pc()-arch_instr->get_pc()) != (entry.size/8); - uint32_t delay = taken ? entry.taken : entry.not_taken; - if(delay>1) arch_instr->set_curr_instr_cycles(delay); + if (taken && entry.taken > 1) + arch_instr->set_curr_instr_cycles(entry.taken); + else if (entry.not_taken > 1) + arch_instr->set_curr_instr_cycles(entry.not_taken); } diff --git a/src/plugin/instruction_count.cpp b/src/plugin/instruction_count.cpp index 2f33d7c..aba30eb 100644 --- a/src/plugin/instruction_count.cpp +++ b/src/plugin/instruction_count.cpp @@ -46,10 +46,10 @@ iss::plugin::instruction_count::instruction_count(std::string config_file_name) try { is >> root; } catch (Json::RuntimeError &e) { - LOG(ERROR) << "Could not parse input file " << config_file_name << ", reason: " << e.what(); + LOG(ERR) << "Could not parse input file " << config_file_name << ", reason: " << e.what(); } } else { - LOG(ERROR) << "Could not open input file " << config_file_name; + LOG(ERR) << "Could not open input file " << config_file_name; } } } @@ -85,7 +85,7 @@ bool iss::plugin::instruction_count::registration(const char* const version, vm_ } rep_counts.resize(delays.size()); } else { - LOG(ERROR)<<"plugin instruction_count: could not find an entry for "<; #include "iss/arch/tgc_d.h" using tgc_d_plat_type = iss::arch::riscv_hart_mu_p; #endif -#include "iss/debugger/encoderdecoder.h" -#include "iss/debugger/gdb_session.h" -#include "iss/debugger/server.h" -#include "iss/debugger/target_adapter_if.h" -#include "iss/iss.h" -#include "iss/vm_types.h" #include "scc/report.h" #include #include #include +// clang-format on #define STR(X) #X #define CREATE_CORE(CN) \ @@ -72,6 +74,12 @@ using namespace scv_tr; #define GET_PROP_VALUE(P) P.getValue() #endif +#ifdef _MSC_VER +// not #if defined(_WIN32) || defined(_WIN64) because we have strncasecmp in mingw +#define strncasecmp _strnicmp +#define strcasecmp _stricmp +#endif + namespace sysc { namespace tgfs { using namespace std; @@ -287,7 +295,7 @@ public: CREATE_CORE(tgc_d) #endif { - LOG(ERROR) << "Illegal argument value for core type: " << type << std::endl; + LOG(ERR) << "Illegal argument value for core type: " << type << std::endl; } auto *srv = debugger::server::get(); if (srv) tgt_adapter = srv->get_target(); diff --git a/src/vm/interp/vm_tgc_c.cpp b/src/vm/interp/vm_tgc_c.cpp index e142646..a61fb17 100644 --- a/src/vm/interp/vm_tgc_c.cpp +++ b/src/vm/interp/vm_tgc_c.cpp @@ -30,23 +30,21 @@ * *******************************************************************************/ -#include "../fp_functions.h" -#include -#include +// clang-format off #include #include #include +#include +#include #include +#include "../fp_functions.h" #include #include - -#ifndef FMT_HEADER_ONLY -#define FMT_HEADER_ONLY -#endif #include #include #include +// clang-format on namespace iss { namespace interp {