Compare commits
	
		
			5 Commits
		
	
	
		
			Trace_enha
			...
			1c90fe765d
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 1c90fe765d | |||
| 52ed8b81a6 | |||
| 0703a0a845 | |||
| 0c542d42aa | |||
| 966d1616c5 | 
							
								
								
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							@@ -30,6 +30,5 @@ language.settings.xml
 | 
				
			|||||||
/.gdbinit
 | 
					/.gdbinit
 | 
				
			||||||
/*.out
 | 
					/*.out
 | 
				
			||||||
/dump.json
 | 
					/dump.json
 | 
				
			||||||
/src-gen/
 | 
					 | 
				
			||||||
/*.yaml
 | 
					/*.yaml
 | 
				
			||||||
/*.json
 | 
					/*.json
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -29,32 +29,35 @@ endif()
 | 
				
			|||||||
add_subdirectory(softfloat)
 | 
					add_subdirectory(softfloat)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# library files
 | 
					# library files
 | 
				
			||||||
FILE(GLOB TGC_SOURCES    ${CMAKE_CURRENT_SOURCE_DIR}/src/iss/*.cpp) 
 | 
					FILE(GLOB GEN_SOURCES
 | 
				
			||||||
FILE(GLOB TGC_VM_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/vm/interp/vm_*.cpp)
 | 
					    ${CMAKE_CURRENT_SOURCE_DIR}/src-gen/iss/arch/*.cpp
 | 
				
			||||||
 | 
						${CMAKE_CURRENT_SOURCE_DIR}/src-gen/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/iss/plugin/instruction_count.cpp
 | 
				
			||||||
    
 | 
						src/iss/arch/tgc_c.cpp    
 | 
				
			||||||
    ${TGC_SOURCES}
 | 
						src/vm/interp/vm_tgc_c.cpp
 | 
				
			||||||
    ${TGC_VM_SOURCES}
 | 
						src/vm/fp_functions.cpp
 | 
				
			||||||
 | 
					    ${GEN_SOURCES}
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
if(TARGET RapidJSON)
 | 
					if(TARGET RapidJSON)
 | 
				
			||||||
    list(APPEND LIB_SOURCES src/plugin/cycle_estimate.cpp src/plugin/pctrace.cpp)
 | 
					    list(APPEND LIB_SOURCES src/iss/plugin/cycle_estimate.cpp src/iss/plugin/pctrace.cpp)
 | 
				
			||||||
endif()
 | 
					endif()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if(WITH_LLVM)
 | 
					if(WITH_LLVM)
 | 
				
			||||||
	FILE(GLOB TGC_LLVM_SOURCES
 | 
						FILE(GLOB LLVM_GEN_SOURCES
 | 
				
			||||||
	    ${CMAKE_CURRENT_SOURCE_DIR}/src/vm/llvm/vm_*.cpp
 | 
						    ${CMAKE_CURRENT_SOURCE_DIR}/src-gen/vm/llvm/vm_*.cpp
 | 
				
			||||||
	)
 | 
						)
 | 
				
			||||||
	list(APPEND LIB_SOURCES ${TGC_LLVM_SOURCES})
 | 
						list(APPEND LIB_SOURCES ${LLVM_GEN_SOURCES})
 | 
				
			||||||
endif()
 | 
					endif()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if(WITH_TCC)
 | 
					if(WITH_TCC)
 | 
				
			||||||
	FILE(GLOB TGC_TCC_SOURCES
 | 
						FILE(GLOB TCC_GEN_SOURCES
 | 
				
			||||||
	    ${CMAKE_CURRENT_SOURCE_DIR}/src/vm/tcc/vm_*.cpp
 | 
						    ${CMAKE_CURRENT_SOURCE_DIR}/src/vm/tcc/vm_*.cpp
 | 
				
			||||||
	)
 | 
						)
 | 
				
			||||||
	list(APPEND LIB_SOURCES ${TGC_TCC_SOURCES})
 | 
						list(APPEND LIB_SOURCES ${TCC_GEN_SOURCES})
 | 
				
			||||||
endif()
 | 
					endif()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Define the library
 | 
					# Define the library
 | 
				
			||||||
@@ -69,7 +72,8 @@ if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
 | 
				
			|||||||
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
 | 
					elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
 | 
				
			||||||
    target_compile_options(${PROJECT_NAME} PRIVATE /wd4293)
 | 
					    target_compile_options(${PROJECT_NAME} PRIVATE /wd4293)
 | 
				
			||||||
endif()
 | 
					endif()
 | 
				
			||||||
target_include_directories(${PROJECT_NAME} PUBLIC incl)
 | 
					target_include_directories(${PROJECT_NAME} PUBLIC src)
 | 
				
			||||||
 | 
					target_include_directories(${PROJECT_NAME} PUBLIC src-gen)
 | 
				
			||||||
target_link_libraries(${PROJECT_NAME} PUBLIC softfloat scc-util jsoncpp Boost::coroutine)
 | 
					target_link_libraries(${PROJECT_NAME} PUBLIC softfloat scc-util jsoncpp Boost::coroutine)
 | 
				
			||||||
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
 | 
					if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
 | 
				
			||||||
    target_link_libraries(${PROJECT_NAME} PUBLIC -Wl,--whole-archive dbt-rise-core -Wl,--no-whole-archive)
 | 
					    target_link_libraries(${PROJECT_NAME} PUBLIC -Wl,--whole-archive dbt-rise-core -Wl,--no-whole-archive)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -37,9 +37,9 @@ def getRegisterSizes(){
 | 
				
			|||||||
    return regs
 | 
					    return regs
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
%>
 | 
					%>
 | 
				
			||||||
 | 
					#include "${coreDef.name.toLowerCase()}.h"
 | 
				
			||||||
#include "util/ities.h"
 | 
					#include "util/ities.h"
 | 
				
			||||||
#include <util/logging.h>
 | 
					#include <util/logging.h>
 | 
				
			||||||
#include <iss/arch/${coreDef.name.toLowerCase()}.h>
 | 
					 | 
				
			||||||
#include <cstdio>
 | 
					#include <cstdio>
 | 
				
			||||||
#include <cstring>
 | 
					#include <cstring>
 | 
				
			||||||
#include <fstream>
 | 
					#include <fstream>
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -36,7 +36,7 @@ def nativeTypeSize(int size){
 | 
				
			|||||||
    if(size<=8) return 8; else if(size<=16) return 16; else if(size<=32) return 32; else return 64;
 | 
					    if(size<=8) return 8; else if(size<=16) return 16; else if(size<=32) return 32; else return 64;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
%>
 | 
					%>
 | 
				
			||||||
#include "../fp_functions.h"
 | 
					#include <vm/fp_functions.h>
 | 
				
			||||||
#include <iss/arch/${coreDef.name.toLowerCase()}.h>
 | 
					#include <iss/arch/${coreDef.name.toLowerCase()}.h>
 | 
				
			||||||
#include <iss/arch/riscv_hart_m_p.h>
 | 
					#include <iss/arch/riscv_hart_m_p.h>
 | 
				
			||||||
#include <iss/debugger/gdb_session.h>
 | 
					#include <iss/debugger/gdb_session.h>
 | 
				
			||||||
@@ -314,8 +314,11 @@ typename vm_base<ARCH>::virt_addr_t vm_impl<ARCH>::execute_inst(finish_cond_e co
 | 
				
			|||||||
		        <%}}%>// calculate next pc value
 | 
							        <%}}%>// calculate next pc value
 | 
				
			||||||
		        *NEXT_PC = *PC + ${instr.length/8};
 | 
							        *NEXT_PC = *PC + ${instr.length/8};
 | 
				
			||||||
		        // execute instruction
 | 
							        // execute instruction
 | 
				
			||||||
		        <%instr.behavior.eachLine{%>${it}
 | 
					                try {
 | 
				
			||||||
		        <%}%>TRAP_${instr.name}:break;
 | 
					                <%instr.behavior.eachLine{%>${it}
 | 
				
			||||||
 | 
							        <%}%>
 | 
				
			||||||
 | 
							        } catch(...){}
 | 
				
			||||||
 | 
							        TRAP_${instr.name}:break;
 | 
				
			||||||
	    	}// @suppress("No break at end of case")<%}%>
 | 
						    	}// @suppress("No break at end of case")<%}%>
 | 
				
			||||||
            default: {
 | 
					            default: {
 | 
				
			||||||
                *NEXT_PC = *PC + ((instr & 3) == 3 ? 4 : 2);
 | 
					                *NEXT_PC = *PC + ((instr & 3) == 3 ? 4 : 2);
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										1
									
								
								incl/iss/arch/.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								incl/iss/arch/.gitignore
									
									
									
									
										vendored
									
									
								
							@@ -1 +0,0 @@
 | 
				
			|||||||
/tgc_*.h
 | 
					 | 
				
			||||||
							
								
								
									
										2
									
								
								src-gen/.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								src-gen/.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,2 @@
 | 
				
			|||||||
 | 
					/iss
 | 
				
			||||||
 | 
					/vm
 | 
				
			||||||
@@ -30,9 +30,9 @@
 | 
				
			|||||||
 *
 | 
					 *
 | 
				
			||||||
 *******************************************************************************/
 | 
					 *******************************************************************************/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "tgc_c.h"
 | 
				
			||||||
#include "util/ities.h"
 | 
					#include "util/ities.h"
 | 
				
			||||||
#include <util/logging.h>
 | 
					#include <util/logging.h>
 | 
				
			||||||
#include <iss/arch/tgc_c.h>
 | 
					 | 
				
			||||||
#include <cstdio>
 | 
					#include <cstdio>
 | 
				
			||||||
#include <cstring>
 | 
					#include <cstring>
 | 
				
			||||||
#include <fstream>
 | 
					#include <fstream>
 | 
				
			||||||
@@ -4,39 +4,44 @@
 | 
				
			|||||||
#include "riscv_hart_m_p.h"
 | 
					#include "riscv_hart_m_p.h"
 | 
				
			||||||
#include "tgc_c.h"
 | 
					#include "tgc_c.h"
 | 
				
			||||||
using tgc_c_plat_type = iss::arch::riscv_hart_m_p<iss::arch::tgc_c>;
 | 
					using tgc_c_plat_type = iss::arch::riscv_hart_m_p<iss::arch::tgc_c>;
 | 
				
			||||||
 | 
					#ifdef CORE_TGC_A
 | 
				
			||||||
 | 
					#include "riscv_hart_m_p.h"
 | 
				
			||||||
 | 
					#include <iss/arch/tgc_a.h>
 | 
				
			||||||
 | 
					using tgc_a_plat_type = iss::arch::riscv_hart_m_p<iss::arch::tgc_a>;
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
#ifdef CORE_TGC_B
 | 
					#ifdef CORE_TGC_B
 | 
				
			||||||
#include "riscv_hart_m_p.h"
 | 
					#include "riscv_hart_m_p.h"
 | 
				
			||||||
#include "tgc_b.h"
 | 
					#include <iss/arch/tgc_b.h>
 | 
				
			||||||
using tgc_b_plat_type = iss::arch::riscv_hart_m_p<iss::arch::tgc_b>;
 | 
					using tgc_b_plat_type = iss::arch::riscv_hart_m_p<iss::arch::tgc_b>;
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
#ifdef CORE_TGC_C_XRB_NN
 | 
					#ifdef CORE_TGC_C_XRB_NN
 | 
				
			||||||
#include "riscv_hart_m_p.h"
 | 
					#include "riscv_hart_m_p.h"
 | 
				
			||||||
#include "tgc_c_xrb_nn.h"
 | 
					#include <iss/arch/tgc_c_xrb_nn.h>
 | 
				
			||||||
using tgc_c_xrb_nn_plat_type = iss::arch::riscv_hart_m_p<iss::arch::tgc_c_xrb_nn>;
 | 
					using tgc_c_xrb_nn_plat_type = iss::arch::riscv_hart_m_p<iss::arch::tgc_c_xrb_nn>;
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
#ifdef CORE_TGC_D
 | 
					#ifdef CORE_TGC_D
 | 
				
			||||||
#include "riscv_hart_mu_p.h"
 | 
					#include "riscv_hart_mu_p.h"
 | 
				
			||||||
#include "tgc_d.h"
 | 
					#include <iss/arch/tgc_d.h>
 | 
				
			||||||
using tgc_d_plat_type = iss::arch::riscv_hart_mu_p<iss::arch::tgc_d, (iss::arch::features_e)(iss::arch::FEAT_PMP | iss::arch::FEAT_CLIC | iss::arch::FEAT_EXT_N)>;
 | 
					using tgc_d_plat_type = iss::arch::riscv_hart_mu_p<iss::arch::tgc_d, (iss::arch::features_e)(iss::arch::FEAT_PMP | iss::arch::FEAT_CLIC | iss::arch::FEAT_EXT_N)>;
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
#ifdef CORE_TGC_D_XRB_MAC
 | 
					#ifdef CORE_TGC_D_XRB_MAC
 | 
				
			||||||
#include "riscv_hart_mu_p.h"
 | 
					#include "riscv_hart_mu_p.h"
 | 
				
			||||||
#include "tgc_d_xrb_mac.h"
 | 
					#include <iss/arch/tgc_d_xrb_mac.h>
 | 
				
			||||||
using tgc_d_xrb_mac_plat_type = iss::arch::riscv_hart_mu_p<iss::arch::tgc_d_xrb_mac, (iss::arch::features_e)(iss::arch::FEAT_PMP | iss::arch::FEAT_CLIC | iss::arch::FEAT_EXT_N)>;
 | 
					using tgc_d_xrb_mac_plat_type = iss::arch::riscv_hart_mu_p<iss::arch::tgc_d_xrb_mac, (iss::arch::features_e)(iss::arch::FEAT_PMP | iss::arch::FEAT_CLIC | iss::arch::FEAT_EXT_N)>;
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
#ifdef CORE_TGC_D_XRB_NN
 | 
					#ifdef CORE_TGC_D_XRB_NN
 | 
				
			||||||
#include "riscv_hart_mu_p.h"
 | 
					#include "riscv_hart_mu_p.h"
 | 
				
			||||||
#include "tgc_d_xrb_nn.h"
 | 
					#include <iss/arch/tgc_d_xrb_nn.h>
 | 
				
			||||||
using tgc_d_xrb_nn_plat_type = iss::arch::riscv_hart_mu_p<iss::arch::tgc_d_xrb_nn, (iss::arch::features_e)(iss::arch::FEAT_PMP | iss::arch::FEAT_CLIC | iss::arch::FEAT_EXT_N)>;
 | 
					using tgc_d_xrb_nn_plat_type = iss::arch::riscv_hart_mu_p<iss::arch::tgc_d_xrb_nn, (iss::arch::features_e)(iss::arch::FEAT_PMP | iss::arch::FEAT_CLIC | iss::arch::FEAT_EXT_N)>;
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
#ifdef CORE_TGC_E
 | 
					#ifdef CORE_TGC_E
 | 
				
			||||||
#include "riscv_hart_mu_p.h"
 | 
					#include "riscv_hart_mu_p.h"
 | 
				
			||||||
#include "tgc_e.h"
 | 
					#include <iss/arch/tgc_e.h>
 | 
				
			||||||
using tgc_e_plat_type = iss::arch::riscv_hart_mu_p<iss::arch::tgc_e, (iss::arch::features_e)(iss::arch::FEAT_PMP | iss::arch::FEAT_CLIC | iss::arch::FEAT_EXT_N)>;
 | 
					using tgc_e_plat_type = iss::arch::riscv_hart_mu_p<iss::arch::tgc_e, (iss::arch::features_e)(iss::arch::FEAT_PMP | iss::arch::FEAT_CLIC | iss::arch::FEAT_EXT_N)>;
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
#ifdef CORE_TGC_X
 | 
					#ifdef CORE_TGC_X
 | 
				
			||||||
#include "riscv_hart_mu_p.h"
 | 
					#include "riscv_hart_mu_p.h"
 | 
				
			||||||
#include "tgc_x.h"
 | 
					#include <iss/arch/tgc_x.h>
 | 
				
			||||||
using tgc_x_plat_type = iss::arch::riscv_hart_mu_p<iss::arch::tgc_x, (iss::arch::features_e)(iss::arch::FEAT_PMP | iss::arch::FEAT_CLIC | iss::arch::FEAT_EXT_N | iss::arch::FEAT_TCM)>;
 | 
					using tgc_x_plat_type = iss::arch::riscv_hart_mu_p<iss::arch::tgc_x, (iss::arch::features_e)(iss::arch::FEAT_PMP | iss::arch::FEAT_CLIC | iss::arch::FEAT_EXT_N | iss::arch::FEAT_TCM)>;
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -32,14 +32,14 @@
 | 
				
			|||||||
 *       eyck@minres.com - initial API and implementation
 | 
					 *       eyck@minres.com - initial API and implementation
 | 
				
			||||||
 ******************************************************************************/
 | 
					 ******************************************************************************/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "iss/plugin/cycle_estimate.h"
 | 
					#include "cycle_estimate.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <iss/arch_if.h>
 | 
					#include <iss/arch_if.h>
 | 
				
			||||||
#include <util/logging.h>
 | 
					#include <util/logging.h>
 | 
				
			||||||
#include <rapidjson/document.h>
 | 
					#include <rapidjson/document.h>
 | 
				
			||||||
#include <rapidjson/istreamwrapper.h>
 | 
					#include <rapidjson/istreamwrapper.h>
 | 
				
			||||||
#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 <rapidjson/error/en.h>
 | 
				
			||||||
#include <fstream>
 | 
					#include <fstream>
 | 
				
			||||||
@@ -32,8 +32,8 @@
 | 
				
			|||||||
 *       eyck@minres.com - initial API and implementation
 | 
					 *       eyck@minres.com - initial API and implementation
 | 
				
			||||||
 ******************************************************************************/
 | 
					 ******************************************************************************/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "iss/plugin/instruction_count.h"
 | 
					#include "instruction_count.h"
 | 
				
			||||||
#include "iss/instrumentation_if.h"
 | 
					#include <iss/instrumentation_if.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <iss/arch_if.h>
 | 
					#include <iss/arch_if.h>
 | 
				
			||||||
#include <util/logging.h>
 | 
					#include <util/logging.h>
 | 
				
			||||||
							
								
								
									
										179
									
								
								src/iss/plugin/pctrace.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										179
									
								
								src/iss/plugin/pctrace.cpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,179 @@
 | 
				
			|||||||
 | 
					#include <iss/arch_if.h>
 | 
				
			||||||
 | 
					#include "pctrace.h"
 | 
				
			||||||
 | 
					#include <util/logging.h>
 | 
				
			||||||
 | 
					#include <util/ities.h>
 | 
				
			||||||
 | 
					#include <rapidjson/document.h>
 | 
				
			||||||
 | 
					#include <rapidjson/istreamwrapper.h>
 | 
				
			||||||
 | 
					#include <rapidjson/writer.h>
 | 
				
			||||||
 | 
					#include <rapidjson/stringbuffer.h>
 | 
				
			||||||
 | 
					#include <rapidjson/ostreamwrapper.h>
 | 
				
			||||||
 | 
					#include <rapidjson/error/en.h>
 | 
				
			||||||
 | 
					#include <fstream>
 | 
				
			||||||
 | 
					#include <iostream>
 | 
				
			||||||
 | 
					#ifdef WITH_LZ4
 | 
				
			||||||
 | 
					#include <lz4frame.h>
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace iss {
 | 
				
			||||||
 | 
					namespace plugin {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					using namespace rapidjson;
 | 
				
			||||||
 | 
					using namespace std;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifdef WITH_LZ4
 | 
				
			||||||
 | 
					class lz4compress_steambuf: public std::streambuf {
 | 
				
			||||||
 | 
					public:
 | 
				
			||||||
 | 
					    lz4compress_steambuf(const lz4compress_steambuf&) = delete;
 | 
				
			||||||
 | 
					    lz4compress_steambuf& operator=(const lz4compress_steambuf&) = delete;
 | 
				
			||||||
 | 
					    lz4compress_steambuf(std::ostream &sink, size_t buf_size)
 | 
				
			||||||
 | 
					    : sink(sink)
 | 
				
			||||||
 | 
					    , src_buf(buf_size)
 | 
				
			||||||
 | 
					    , dest_buf(LZ4F_compressBound(buf_size, nullptr))
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        auto errCode = LZ4F_createCompressionContext(&ctx, LZ4F_VERSION);
 | 
				
			||||||
 | 
					        if (LZ4F_isError(errCode) != 0)
 | 
				
			||||||
 | 
					            throw std::runtime_error(std::string("Failed to create LZ4 context: ") + LZ4F_getErrorName(errCode));
 | 
				
			||||||
 | 
					        size_t ret = LZ4F_compressBegin(ctx, &dest_buf.front(), dest_buf.capacity(), nullptr);
 | 
				
			||||||
 | 
					        if (LZ4F_isError(ret) != 0)
 | 
				
			||||||
 | 
					            throw std::runtime_error(std::string("Failed to start LZ4 compression: ") + LZ4F_getErrorName(ret));
 | 
				
			||||||
 | 
					        setp(src_buf.data(), src_buf.data() + src_buf.size() - 1);
 | 
				
			||||||
 | 
					        sink.write(dest_buf.data(), ret);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    ~lz4compress_steambuf() {
 | 
				
			||||||
 | 
					        close();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    void close() {
 | 
				
			||||||
 | 
					        if (closed)
 | 
				
			||||||
 | 
					            return;
 | 
				
			||||||
 | 
					        sync();
 | 
				
			||||||
 | 
					        auto ret = LZ4F_compressEnd(ctx, dest_buf.data(), dest_buf.capacity(), nullptr);
 | 
				
			||||||
 | 
					        if (LZ4F_isError(ret) != 0)
 | 
				
			||||||
 | 
					            throw std::runtime_error(std::string("Failed to finish LZ4 compression: ") + LZ4F_getErrorName(ret));
 | 
				
			||||||
 | 
					        sink.write(dest_buf.data(), ret);
 | 
				
			||||||
 | 
					        LZ4F_freeCompressionContext(ctx);
 | 
				
			||||||
 | 
					        closed = true;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					private:
 | 
				
			||||||
 | 
					    int_type overflow(int_type ch) override {
 | 
				
			||||||
 | 
					        compress_and_write();
 | 
				
			||||||
 | 
					        *pptr() = static_cast<char_type>(ch);
 | 
				
			||||||
 | 
					        pbump(1);
 | 
				
			||||||
 | 
					        return ch;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    int_type sync() override {
 | 
				
			||||||
 | 
					        compress_and_write();
 | 
				
			||||||
 | 
					        return 0;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    void compress_and_write() {
 | 
				
			||||||
 | 
					        if (closed)
 | 
				
			||||||
 | 
					            throw std::runtime_error("Cannot write to closed stream");
 | 
				
			||||||
 | 
					        if(auto orig_size = pptr() - pbase()){
 | 
				
			||||||
 | 
					            auto ret = LZ4F_compressUpdate(ctx, dest_buf.data(), dest_buf.capacity(), pbase(), orig_size, nullptr);
 | 
				
			||||||
 | 
					            if (LZ4F_isError(ret) != 0)
 | 
				
			||||||
 | 
					                throw std::runtime_error(std::string("LZ4 compression failed: ") + LZ4F_getErrorName(ret));
 | 
				
			||||||
 | 
					            if(ret) sink.write(dest_buf.data(), ret);
 | 
				
			||||||
 | 
					            pbump(-orig_size);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    std::ostream &sink;
 | 
				
			||||||
 | 
					    std::vector<char> src_buf;
 | 
				
			||||||
 | 
					    std::vector<char> dest_buf;
 | 
				
			||||||
 | 
					    LZ4F_compressionContext_t ctx{ nullptr };
 | 
				
			||||||
 | 
					    bool closed{ false };
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					cov::cov(std::string const &filename)
 | 
				
			||||||
 | 
					: instr_if(nullptr)
 | 
				
			||||||
 | 
					, filename(filename)
 | 
				
			||||||
 | 
					, output("output.trc")
 | 
				
			||||||
 | 
					#ifdef WITH_LZ4
 | 
				
			||||||
 | 
					, strbuf(new lz4compress_steambuf(output, 4096))
 | 
				
			||||||
 | 
					, ostr(strbuf.get())
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					{ }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					cov::~cov() { }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					bool cov::registration(const char *const version, vm_if& vm) {
 | 
				
			||||||
 | 
					    instr_if = vm.get_arch()->get_instrumentation_if();
 | 
				
			||||||
 | 
					    if(!instr_if) return false;
 | 
				
			||||||
 | 
					    const string  core_name = instr_if->core_type_name();
 | 
				
			||||||
 | 
					    if (filename.length() > 0) {
 | 
				
			||||||
 | 
					        ifstream is(filename);
 | 
				
			||||||
 | 
					        if (is.is_open()) {
 | 
				
			||||||
 | 
					            try {
 | 
				
			||||||
 | 
					                IStreamWrapper isw(is);
 | 
				
			||||||
 | 
					                Document d;
 | 
				
			||||||
 | 
					                ParseResult ok = d.ParseStream(isw);
 | 
				
			||||||
 | 
					                if(ok) {
 | 
				
			||||||
 | 
					                    Value& val = d[core_name.c_str()];
 | 
				
			||||||
 | 
					                    if(val.IsArray()){
 | 
				
			||||||
 | 
					                        delays.reserve(val.Size());
 | 
				
			||||||
 | 
					                        for (auto it = val.Begin(); it != val.End(); ++it) {
 | 
				
			||||||
 | 
					                            auto& name = (*it)["name"];
 | 
				
			||||||
 | 
					                            auto& size = (*it)["size"];
 | 
				
			||||||
 | 
					                            auto& delay = (*it)["delay"];
 | 
				
			||||||
 | 
					                            auto& branch = (*it)["branch"];
 | 
				
			||||||
 | 
					                            if(delay.IsArray()) {
 | 
				
			||||||
 | 
					                                auto dt = delay[0].Get<unsigned>();
 | 
				
			||||||
 | 
					                                auto dnt = delay[1].Get<unsigned>();
 | 
				
			||||||
 | 
					                                delays.push_back(instr_desc{size.Get<unsigned>(), dt, dnt, branch.Get<bool>()});
 | 
				
			||||||
 | 
					                            } else if(delay.Is<unsigned>()) {
 | 
				
			||||||
 | 
					                                auto d = delay.Get<unsigned>();
 | 
				
			||||||
 | 
					                                delays.push_back(instr_desc{size.Get<unsigned>(), d, d, branch.Get<bool>()});
 | 
				
			||||||
 | 
					                            } else
 | 
				
			||||||
 | 
					                                throw runtime_error("JSON parse error");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                    } else {
 | 
				
			||||||
 | 
					                        LOG(ERR)<<"plugin cycle_estimate: could not find an entry for "<<core_name<<" in JSON file"<<endl;
 | 
				
			||||||
 | 
					                        return false;
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                } else {
 | 
				
			||||||
 | 
					                    LOG(ERR)<<"plugin cycle_estimate: could not parse in JSON file at "<< ok.Offset()<<": "<<GetParseError_En(ok.Code())<<endl;
 | 
				
			||||||
 | 
					                    return false;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            } catch (runtime_error &e) {
 | 
				
			||||||
 | 
					                LOG(ERR) << "Could not parse input file " << filename << ", reason: " << e.what();
 | 
				
			||||||
 | 
					                return false;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
 | 
					            LOG(ERR) << "Could not open input file " << filename;
 | 
				
			||||||
 | 
					            return false;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    return true;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void cov::callback(instr_info_t iinfo, const exec_info& einfo) {
 | 
				
			||||||
 | 
					    auto delay = 0;
 | 
				
			||||||
 | 
					    size_t id = iinfo.instr_id;
 | 
				
			||||||
 | 
					    auto entry = delays[id];
 | 
				
			||||||
 | 
					    auto instr = instr_if->get_instr_word();
 | 
				
			||||||
 | 
					    auto call = (id==2 || id==3) && bit_sub<7,5>(instr)!=0;
 | 
				
			||||||
 | 
					    bool taken = einfo.branch_taken;
 | 
				
			||||||
 | 
					    if (einfo.branch_taken) {
 | 
				
			||||||
 | 
					        delay = entry.taken;
 | 
				
			||||||
 | 
					        if(entry.taken > 1)
 | 
				
			||||||
 | 
					            instr_if->set_curr_instr_cycles(entry.taken);
 | 
				
			||||||
 | 
					    } else {
 | 
				
			||||||
 | 
					        delay = entry.not_taken;
 | 
				
			||||||
 | 
					        if (entry.not_taken > 1)
 | 
				
			||||||
 | 
					            instr_if->set_curr_instr_cycles(entry.not_taken);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					#ifndef WITH_LZ4
 | 
				
			||||||
 | 
					    output<<std::hex <<"0x" << instr_if->get_pc() <<"," << delay <<"," << call<< "\n";
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
 | 
					    auto rdbuf=ostr.rdbuf();
 | 
				
			||||||
 | 
					    ostr<<std::hex <<"0x" << instr_if->get_pc() <<"," << delay <<"," << call<< "\n";
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -35,14 +35,14 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#include <boost/lexical_cast.hpp>
 | 
					#include <boost/lexical_cast.hpp>
 | 
				
			||||||
#include <boost/program_options.hpp>
 | 
					#include <boost/program_options.hpp>
 | 
				
			||||||
#include <iss/arch/tgc_mapper.h>
 | 
					#include "iss/arch/tgc_mapper.h"
 | 
				
			||||||
#ifdef WITH_LLVM
 | 
					#ifdef WITH_LLVM
 | 
				
			||||||
#include <iss/llvm/jit_helper.h>
 | 
					#include <iss/llvm/jit_helper.h>
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
#include <iss/log_categories.h>
 | 
					#include <iss/log_categories.h>
 | 
				
			||||||
#include <iss/plugin/cycle_estimate.h>
 | 
					#include "iss/plugin/cycle_estimate.h"
 | 
				
			||||||
#include <iss/plugin/instruction_count.h>
 | 
					#include "iss/plugin/instruction_count.h"
 | 
				
			||||||
#include <iss/plugin/pctrace.h>
 | 
					#include "iss/plugin/pctrace.h"
 | 
				
			||||||
#include <iss/plugin/loader.h>
 | 
					#include <iss/plugin/loader.h>
 | 
				
			||||||
#if defined(HAS_LUA)
 | 
					#if defined(HAS_LUA)
 | 
				
			||||||
#include <iss/plugin/lua.h>
 | 
					#include <iss/plugin/lua.h>
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -38,7 +38,7 @@
 | 
				
			|||||||
#include <iss/iss.h>
 | 
					#include <iss/iss.h>
 | 
				
			||||||
#include <iss/vm_types.h>
 | 
					#include <iss/vm_types.h>
 | 
				
			||||||
#include <iss/plugin/loader.h>
 | 
					#include <iss/plugin/loader.h>
 | 
				
			||||||
#include <sysc/core_complex.h>
 | 
					#include "core_complex.h"
 | 
				
			||||||
#include <iss/arch/tgc_mapper.h>
 | 
					#include <iss/arch/tgc_mapper.h>
 | 
				
			||||||
#include <scc/report.h>
 | 
					#include <scc/report.h>
 | 
				
			||||||
#include <util/ities.h>
 | 
					#include <util/ities.h>
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										1
									
								
								src/vm/interp/.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								src/vm/interp/.gitignore
									
									
									
									
										vendored
									
									
								
							@@ -1 +0,0 @@
 | 
				
			|||||||
/vm_tgc_*.cpp
 | 
					 | 
				
			||||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							@@ -30,7 +30,7 @@
 | 
				
			|||||||
 *
 | 
					 *
 | 
				
			||||||
 *******************************************************************************/
 | 
					 *******************************************************************************/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <iss/arch/tgf_c.h>
 | 
					#include <iss/arch/tgc_c.h>
 | 
				
			||||||
#include <iss/arch/riscv_hart_m_p.h>
 | 
					#include <iss/arch/riscv_hart_m_p.h>
 | 
				
			||||||
#include <iss/debugger/gdb_session.h>
 | 
					#include <iss/debugger/gdb_session.h>
 | 
				
			||||||
#include <iss/debugger/server.h>
 | 
					#include <iss/debugger/server.h>
 | 
				
			||||||
@@ -52,7 +52,7 @@ namespace fp_impl {
 | 
				
			|||||||
void add_fp_functions_2_module(::llvm::Module *, unsigned, unsigned);
 | 
					void add_fp_functions_2_module(::llvm::Module *, unsigned, unsigned);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace tgf_c {
 | 
					namespace tgc_c {
 | 
				
			||||||
using namespace ::llvm;
 | 
					using namespace ::llvm;
 | 
				
			||||||
using namespace iss::arch;
 | 
					using namespace iss::arch;
 | 
				
			||||||
using namespace iss::debugger;
 | 
					using namespace iss::debugger;
 | 
				
			||||||
@@ -4151,11 +4151,11 @@ template <typename ARCH> inline void vm_impl<ARCH>::gen_trap_check(BasicBlock *b
 | 
				
			|||||||
                          bb, this->trap_blk, 1);
 | 
					                          bb, this->trap_blk, 1);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
} // namespace tgf_c
 | 
					} // namespace tgc_c
 | 
				
			||||||
 | 
					
 | 
				
			||||||
template <>
 | 
					template <>
 | 
				
			||||||
std::unique_ptr<vm_if> create<arch::tgf_c>(arch::tgf_c *core, unsigned short port, bool dump) {
 | 
					std::unique_ptr<vm_if> create<arch::tgc_c>(arch::tgc_c *core, unsigned short port, bool dump) {
 | 
				
			||||||
    auto ret = new tgf_c::vm_impl<arch::tgf_c>(*core, dump);
 | 
					    auto ret = new tgc_c::vm_impl<arch::tgc_c>(*core, dump);
 | 
				
			||||||
    if (port != 0) debugger::server<debugger::gdb_session>::run_server(ret, port);
 | 
					    if (port != 0) debugger::server<debugger::gdb_session>::run_server(ret, port);
 | 
				
			||||||
    return std::unique_ptr<vm_if>(ret);
 | 
					    return std::unique_ptr<vm_if>(ret);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							@@ -30,7 +30,7 @@
 | 
				
			|||||||
 *
 | 
					 *
 | 
				
			||||||
 *******************************************************************************/
 | 
					 *******************************************************************************/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <iss/arch/tgf_c.h>
 | 
					#include <iss/arch/tgc_c.h>
 | 
				
			||||||
#include <iss/arch/riscv_hart_m_p.h>
 | 
					#include <iss/arch/riscv_hart_m_p.h>
 | 
				
			||||||
#include <iss/debugger/gdb_session.h>
 | 
					#include <iss/debugger/gdb_session.h>
 | 
				
			||||||
#include <iss/debugger/server.h>
 | 
					#include <iss/debugger/server.h>
 | 
				
			||||||
@@ -49,7 +49,7 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
namespace iss {
 | 
					namespace iss {
 | 
				
			||||||
namespace tcc {
 | 
					namespace tcc {
 | 
				
			||||||
namespace tgf_c {
 | 
					namespace tgc_c {
 | 
				
			||||||
using namespace iss::arch;
 | 
					using namespace iss::arch;
 | 
				
			||||||
using namespace iss::debugger;
 | 
					using namespace iss::debugger;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -3251,8 +3251,8 @@ template <typename ARCH> void vm_impl<ARCH>::gen_trap_behavior(tu_builder& tu) {
 | 
				
			|||||||
} // namespace mnrv32
 | 
					} // namespace mnrv32
 | 
				
			||||||
 | 
					
 | 
				
			||||||
template <>
 | 
					template <>
 | 
				
			||||||
std::unique_ptr<vm_if> create<arch::tgf_c>(arch::tgf_c *core, unsigned short port, bool dump) {
 | 
					std::unique_ptr<vm_if> create<arch::tgc_c>(arch::tgc_c *core, unsigned short port, bool dump) {
 | 
				
			||||||
    auto ret = new tgf_c::vm_impl<arch::tgf_c>(*core, dump);
 | 
					    auto ret = new tgc_c::vm_impl<arch::tgc_c>(*core, dump);
 | 
				
			||||||
    if (port != 0) debugger::server<debugger::gdb_session>::run_server(ret, port);
 | 
					    if (port != 0) debugger::server<debugger::gdb_session>::run_server(ret, port);
 | 
				
			||||||
    return std::unique_ptr<vm_if>(ret);
 | 
					    return std::unique_ptr<vm_if>(ret);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
		Reference in New Issue
	
	Block a user