From: weiyu Date: Mon, 22 Jul 2019 22:55:04 +0000 (-0700) Subject: add function calls for volatile loads and stores X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=727d6b73ba2d22dbfca36f98b1136b2de74ac784;p=c11tester.git add function calls for volatile loads and stores --- diff --git a/action.h b/action.h index 5862485b..735b2001 100644 --- a/action.h +++ b/action.h @@ -25,6 +25,7 @@ using std::memory_order_acquire; using std::memory_order_release; using std::memory_order_acq_rel; using std::memory_order_seq_cst; +using std::volatile_order; /** * @brief A recognizable don't-care value for use in the ModelAction::value @@ -70,6 +71,8 @@ typedef enum action_type { ATOMIC_NOTIFY_ALL, // < A notify all action ATOMIC_WAIT, // < A wait action ATOMIC_ANNOTATION, // < An annotation action to pass information to a trace analysis + VOLATILE_READ, + VOLATILE_WRITE, NOOP // no operation, which returns control to scheduler } action_type_t; diff --git a/cmodelint.cc b/cmodelint.cc index 82bf974f..ef56f229 100644 --- a/cmodelint.cc +++ b/cmodelint.cc @@ -9,9 +9,10 @@ #include "snapshot-interface.h" #include "threads-model.h" -memory_order orders[6] = { +memory_order orders[8] = { memory_order_relaxed, memory_order_consume, memory_order_acquire, - memory_order_release, memory_order_acq_rel, memory_order_seq_cst + memory_order_release, memory_order_acq_rel, memory_order_seq_cst, + volatile_order }; static void ensureModel() { @@ -92,6 +93,47 @@ void model_rmwc_action_helper(void *obj, int atomic_index, const char *position) model->switch_to_master(new ModelAction(ATOMIC_RMWC, position, orders[atomic_index], obj)); } +// cds volatile loads +uint8_t cds_volatile_load8(void * obj, int atomic_index, const char * position) { + ensureModel(); + return (uint8_t) model->switch_to_master( + new ModelAction(VOLATILE_READ, position, orders[atomic_index], obj)); +} +uint16_t cds_volatile_load16(void * obj, int atomic_index, const char * position) { + ensureModel(); + return (uint16_t) model->switch_to_master( + new ModelAction(VOLATILE_READ, position, orders[atomic_index], obj)); +} +uint32_t cds_volatile_load32(void * obj, int atomic_index, const char * position) { + ensureModel(); + return (uint32_t) model->switch_to_master( + new ModelAction(VOLATILE_READ, position, orders[atomic_index], obj) + ); +} +uint64_t cds_volatile_load64(void * obj, int atomic_index, const char * position) { + ensureModel(); + return model->switch_to_master( + new ModelAction(VOLATILE_READ, position, orders[atomic_index], obj)); +} + +// cds volatile stores +void cds_volatile_store8(void * obj, uint8_t val, int atomic_index, const char * position) { + ensureModel(); + model->switch_to_master(new ModelAction(VOLATILE_WRITE, position, orders[atomic_index], obj, (uint64_t) val)); +} +void cds_volatile_store16(void * obj, uint16_t val, int atomic_index, const char * position) { + ensureModel(); + model->switch_to_master(new ModelAction(VOLATILE_WRITE, position, orders[atomic_index], obj, (uint64_t) val)); +} +void cds_volatile_store32(void * obj, uint32_t val, int atomic_index, const char * position) { + ensureModel(); + model->switch_to_master(new ModelAction(VOLATILE_WRITE, position, orders[atomic_index], obj, (uint64_t) val)); +} +void cds_volatile_store64(void * obj, uint64_t val, int atomic_index, const char * position) { + ensureModel(); + model->switch_to_master(new ModelAction(VOLATILE_WRITE, position, orders[atomic_index], obj, (uint64_t) val)); +} + // cds atomic inits void cds_atomic_init8(void * obj, uint8_t val, const char * position) { ensureModel(); diff --git a/include/cmodelint.h b/include/cmodelint.h index 6b180a9f..b491c38e 100644 --- a/include/cmodelint.h +++ b/include/cmodelint.h @@ -31,6 +31,17 @@ void model_rmwc_action_helper(void *obj, int atomic_index, const char *position) // void model_fence_action_helper(int atomic_index); /* the following functions are used by llvm pass */ +// cds volatile loads +uint8_t cds_volatile_load8(void * obj, int atomic_index, const char * position); +uint16_t cds_volatile_load16(void * obj, int atomic_index, const char * position); +uint32_t cds_volatile_load32(void * obj, int atomic_index, const char * position); +uint64_t cds_volatile_load64(void * obj, int atomic_index, const char * position); + +// cds volatile stores +void cds_volatile_store8(void * obj, uint8_t val, int atomic_index, const char * position); +void cds_volatile_store16(void * obj, uint16_t val, int atomic_index, const char * position); +void cds_volatile_store32(void * obj, uint32_t val, int atomic_index, const char * position); +void cds_volatile_store64(void * obj, uint64_t val, int atomic_index, const char * position); void cds_atomic_init8(void * obj, uint8_t val, const char * position); void cds_atomic_init16(void * obj, uint16_t val, const char * position);