Skip to content

Commit

Permalink
i#3544 RV64: Port sample.memtrace_simple to RISC-V
Browse files Browse the repository at this point in the history
  • Loading branch information
ksco committed Apr 9, 2024
1 parent 59a2c38 commit 4ebcb6f
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 10 deletions.
2 changes: 1 addition & 1 deletion api/samples/memtrace_simple.c
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ event_app_instruction(void *drcontext, void *tag, instrlist_t *bb, instr_t *wher
* Using a fault to handle a full buffer should be more robust, and the
* forthcoming buffer filling API (i#513) will provide that.
*/
IF_AARCHXX_ELSE(!instr_is_exclusive_store(instr_operands), true))
IF_AARCHXX_OR_RISCV64_ELSE(!instr_is_exclusive_store(instr_operands), true))
dr_insert_clean_call(drcontext, bb, where, (void *)clean_call, false, 0);

return DR_EMIT_DEFAULT;
Expand Down
2 changes: 1 addition & 1 deletion core/ir/instr.h
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,7 @@ instr_compute_vector_address(instr_t *instr, priv_mcontext_t *mc, size_t mc_size

uint
instr_branch_type(instr_t *cti_instr);
#ifdef AARCH64
#if defined(AARCH64) || defined(RISCV64)
const char *
get_opcode_name(int opc);
#endif
Expand Down
4 changes: 1 addition & 3 deletions core/ir/riscv64/decode.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,7 @@ DR_API
const char *
decode_opcode_name(int opcode)
{
/* FIXME i#3544: Not implemented */
ASSERT_NOT_IMPLEMENTED(false);
return NULL;
return get_opcode_name(opcode);
}

opnd_size_t
Expand Down
5 changes: 2 additions & 3 deletions core/ir/riscv64/instr.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include "../globals.h"
#include "instr.h"
#include "encode_api.h"
#include "codec.h"

/* XXX i#6690: currently only RISCV64 is supported for instruction encoding.
* We want to add support for RISCV64 decoding and synthetic ISA encoding as well.
Expand Down Expand Up @@ -148,9 +149,7 @@ instr_branch_type(instr_t *cti_instr)
const char *
get_opcode_name(int opc)
{
/* FIXME i#3544: Not implemented */
ASSERT_NOT_IMPLEMENTED(false);
return "<opcode>";
return get_instruction_info(opc)->name;
}

bool
Expand Down
10 changes: 8 additions & 2 deletions suite/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3518,8 +3518,13 @@ if (BUILD_SAMPLES)
foreach (sample ${sample_list})
# FIXME i#4392: Remove sanity checks and replace with functioning tests like
# that done for the opcode_count and memtrace_simple samples.
torunonly_ci(sample.${sample} common.${control_flags}
${sample} common/${control_flags}.c "" "" "")
if (RISCV64 AND sample STREQUAL "memtrace_simple")
torunonly_ci(sample.${sample} common.${control_flags}
${sample} common/${control_flags}.c "" "-max_bb_instrs 8" "")
else ()
torunonly_ci(sample.${sample} common.${control_flags}
${sample} common/${control_flags}.c "" "" "")
endif ()
if (sample STREQUAL "inscount")
# test out-of-line clean call
torunonly_ci(sample.${sample}.cleancall common.${control_flags} ${sample}
Expand Down Expand Up @@ -6195,6 +6200,7 @@ if (RISCV64)
code_api|sample.inscount
code_api|sample.inscount.cleancall
code_api|sample.inscount.prof-pcs.cleancall
code_api|sample.memtrace_simple
code_api|sample.opcode_count
code_api|sample.signal
code_api|sample.stl_test
Expand Down

0 comments on commit 4ebcb6f

Please sign in to comment.