Skip to content

Commit

Permalink
i#1729/i#1569 A64 traces: Reintroduce drcachesim trace_entry_t packing.
Browse files Browse the repository at this point in the history
This now works because XINST_CREATE_store on AArch64 uses OP_stur
instead of OP_str when it detects an "unaligned" offset.

Review-URL: https://codereview.appspot.com/309480043
  • Loading branch information
egrimley-arm committed Sep 21, 2016
1 parent 5509385 commit e844d0d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
8 changes: 2 additions & 6 deletions clients/drcachesim/common/trace_entry.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,7 @@ extern const char * const trace_type_names[];
// - a flush request
// - a prefetch request
// - a thread/process
// FIXME i#1729/i#1569: for offline traces we need to pack this to avoid
// compiler padding differences. Packing should also help online performance,
// and having the two identical is required anyway to avoid complexity in
// reader_t. Once the AArch64 instrumentation handles unaligned offsets we'll
// put back the {START,END}_PACKED_STRUCTURE.
START_PACKED_STRUCTURE
struct _trace_entry_t {
unsigned short type; // 2 bytes: trace_type_t
// 2 bytes: mem ref size, instr length, or num of instrs for instr bundle
Expand All @@ -131,7 +127,7 @@ struct _trace_entry_t {
// The length of each instr in the instr bundle
unsigned char length[sizeof(addr_t)];
};
};
} END_PACKED_STRUCTURE;
typedef struct _trace_entry_t trace_entry_t;

static inline bool
Expand Down
17 changes: 12 additions & 5 deletions core/arch/aarch64/instr_create.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,10 @@
* \param m The destination memory opnd.
* \param r The source register opnd.
*/
#define XINST_CREATE_store(dc, m, r) INSTR_CREATE_str((dc), (m), (r))
#define XINST_CREATE_store(dc, m, r) \
(opnd_is_base_disp(m) && \
opnd_get_disp(m) % opnd_size_in_bytes(opnd_get_size(m)) != 0 ? \
INSTR_CREATE_stur(dc, m, r) : INSTR_CREATE_str(dc, m, r))

/**
* This platform-independent macro creates an instr_t for a 1-byte
Expand Down Expand Up @@ -289,10 +292,14 @@
instr_create_0dst_0src((dc), OP_nop)
#define INSTR_CREATE_ret(dc, Rn) \
instr_create_0dst_1src((dc), OP_ret, (Rn))
#define INSTR_CREATE_str(dc, mem, Rt) \
instr_create_1dst_1src((dc), OP_str, (mem), (Rt))
#define INSTR_CREATE_strh(dc, mem, Rt) \
instr_create_1dst_1src((dc), OP_strh, (mem), (Rt))
#define INSTR_CREATE_str(dc, mem, rt) \
instr_create_1dst_1src(dc, OP_str, mem, rt)
#define INSTR_CREATE_strh(dc, mem, rt) \
instr_create_1dst_1src(dc, OP_strh, mem, rt)
#define INSTR_CREATE_stur(dc, mem, rt) \
instr_create_1dst_1src(dc, OP_stur, mem, rt)
#define INSTR_CREATE_sturh(dc, mem, rt) \
instr_create_1dst_1src(dc, OP_sturh, mem, rt)
#define INSTR_CREATE_sub(dc, rd, rn, rm_or_imm) \
INSTR_CREATE_sub_shift(dc, rd, rn, rm_or_imm, OPND_CREATE_LSL(), OPND_CREATE_INT(0))
#define INSTR_CREATE_sub_extend(dc, rd, rn, rm, ext, exa) \
Expand Down

0 comments on commit e844d0d

Please sign in to comment.