Skip to content

Commit 2218312

Browse files
target/arc: remove memory/register access helpers
This commit removes the {get,set}{Memory,Register} macros, as well as a couple of smaller ones, from semfunc-helper.h, and substitutes their contents directly into semfunc-v{2,3}.c. This is done to increase code transparency and to make arc_gen_*() function bodies more uniform. Signed-off-by: Artemiy Volkov <[email protected]>
1 parent 1f78278 commit 2218312

File tree

4 files changed

+165
-249
lines changed

4 files changed

+165
-249
lines changed

target/arc/semfunc-helper.c

Lines changed: 15 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -196,44 +196,6 @@ gen_branch(DisasCtxt *ctx, TCGv target)
196196
}
197197
}
198198

199-
#define MEMIDX (ctx->mem_idx)
200-
201-
#ifdef TARGET_ARC32
202-
const MemOp memop_for_size_sign[2][3] = {
203-
{ MO_UL, MO_UB, MO_UW }, /* non sign-extended */
204-
{ MO_UL, MO_SB, MO_SW } /* sign-extended */
205-
};
206-
#endif
207-
208-
#ifdef TARGET_ARC64
209-
const MemOp memop_for_size_sign[2][4] = {
210-
{ MO_UL, MO_UB, MO_UW, MO_UQ }, /* non sign-extended */
211-
{ MO_SL, MO_SB, MO_SW, MO_SQ } /* sign-extended */
212-
};
213-
#endif
214-
215-
void arc_gen_set_memory(const DisasCtxt *ctx, TCGv vaddr, int size,
216-
TCGv src, bool sign_extend)
217-
{
218-
#ifdef TARGET_ARC32
219-
assert(size != 0x3);
220-
#endif
221-
222-
tcg_gen_qemu_st_tl(src, vaddr, MEMIDX,
223-
memop_for_size_sign[sign_extend][size]);
224-
}
225-
226-
void arc_gen_get_memory(const DisasCtxt *ctx, TCGv dest, TCGv vaddr,
227-
int size, bool sign_extend)
228-
{
229-
#ifdef TARGET_ARC32
230-
assert(size != 0x3);
231-
#endif
232-
233-
tcg_gen_qemu_ld_tl(dest, vaddr, MEMIDX,
234-
memop_for_size_sign[sign_extend][size]);
235-
}
236-
237199
void arc_gen_no_further_loads_pending(const DisasCtxt *ctx, TCGv ret)
238200
{
239201
/* TODO: To complete on SMP support. */
@@ -318,53 +280,27 @@ void arc_gen_extract_bits(TCGv ret, TCGv a, TCGv start, TCGv end)
318280
tcg_temp_free(tmp1);
319281
}
320282

321-
void arc_gen_get_register(TCGv ret, enum arc_registers reg)
283+
/* TODO: Get this from props ... */
284+
void arc_has_interrupts(const DisasCtxt *ctx, TCGv ret)
322285
{
323-
switch (reg) {
324-
case R_SP:
325-
tcg_gen_mov_tl(ret, cpu_sp);
326-
break;
327-
case R_STATUS32:
328-
gen_helper_get_status32(ret, cpu_env);
329-
break;
330-
case R_ACCLO:
331-
tcg_gen_mov_tl(ret, cpu_acclo);
332-
break;
333-
case R_ACCHI:
334-
tcg_gen_mov_tl(ret, cpu_acchi);
335-
break;
336-
default:
337-
g_assert_not_reached();
338-
}
286+
tcg_gen_movi_tl(ret, 1);
339287
}
340288

289+
#ifdef TARGET_ARC32
290+
const MemOp memop_for_size_sign[2][3] = {
291+
{ MO_UL, MO_UB, MO_UW }, /* non sign-extended */
292+
{ MO_UL, MO_SB, MO_SW } /* sign-extended */
293+
};
294+
#endif
341295

342-
void arc_gen_set_register(enum arc_registers reg, TCGv value)
343-
{
344-
switch (reg) {
345-
case R_SP:
346-
tcg_gen_mov_tl(cpu_sp, value);
347-
break;
348-
case R_STATUS32:
349-
gen_helper_set_status32(cpu_env, value);
350-
break;
351-
case R_ACCLO:
352-
tcg_gen_mov_tl(cpu_acclo, value);
353-
break;
354-
case R_ACCHI:
355-
tcg_gen_mov_tl(cpu_acchi, value);
356-
break;
357-
default:
358-
g_assert_not_reached();
359-
}
360-
}
296+
#ifdef TARGET_ARC64
297+
const MemOp memop_for_size_sign[2][4] = {
298+
{ MO_UL, MO_UB, MO_UW, MO_UQ }, /* non sign-extended */
299+
{ MO_SL, MO_SB, MO_SW, MO_SQ } /* sign-extended */
300+
};
301+
#endif
361302

362303

363-
/* TODO: Get this from props ... */
364-
void arc_has_interrupts(const DisasCtxt *ctx, TCGv ret)
365-
{
366-
tcg_gen_movi_tl(ret, 1);
367-
}
368304

369305
/*
370306
***************************************

target/arc/semfunc-helper.h

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -104,22 +104,10 @@ static inline void update_delay_flag(DisasContext *ctx)
104104
void to_implement(const DisasCtxt *ctx);
105105
void to_implement_wo_abort(const DisasCtxt *ctx);
106106

107-
void arc_gen_set_memory(
108-
const DisasCtxt *ctx, TCGv addr, int size, TCGv src, bool sign_extend);
109-
#define setMemory(ADDRESS, SIZE, VALUE) \
110-
arc_gen_set_memory(ctx, ADDRESS, SIZE, VALUE, getFlagX())
111-
void arc_gen_get_memory(
112-
const DisasCtxt *ctx, TCGv ret, TCGv addr, int size, bool sign_extend);
113-
#define getMemory(R, ADDRESS, SIZE) \
114-
arc_gen_get_memory(ctx, R, ADDRESS, SIZE, getFlagX())
115-
116-
#define getFlagX() (ctx->insn.x)
117107
#define getZZFlag() (ctx->insn.zz)
118108
#define getAAFlag() (ctx->insn.aa)
119109

120-
#define SignExtend(VALUE, SIZE) VALUE
121110
void arc_gen_no_further_loads_pending(const DisasCtxt *ctx, TCGv ret);
122-
#define NoFurtherLoadsPending(R) arc_gen_no_further_loads_pending(ctx, R)
123111
void arc_gen_set_debug(const DisasCtxt *ctx, bool value);
124112
#define setDebugLD(A) arc_gen_set_debug(ctx, A)
125113

@@ -273,14 +261,6 @@ void arc_gen_macu(TCGv phi, TCGv b, TCGv c);
273261
void arc_gen_extract_bits(TCGv ret, TCGv a, TCGv start, TCGv end);
274262
#define extractBits(R, ELEM, START, END) \
275263
arc_gen_extract_bits(R, ELEM, START, END)
276-
void arc_gen_get_register(TCGv ret, enum arc_registers reg);
277-
#define getRegister(R, REG) arc_gen_get_register(R, REG)
278-
void arc_gen_set_register(enum arc_registers reg, TCGv value);
279-
#define setRegister(REG, VALUE) \
280-
arc_gen_set_register(REG, VALUE); \
281-
if (REG == R_STATUS32) { \
282-
ret = DISAS_UPDATE; \
283-
} \
284264

285265
#define inKernelMode(R) { \
286266
TCG_GET_STATUS_FIELD_MASKED(R, cpu_pstate, Uf); \
@@ -400,6 +380,14 @@ void tcg_gen_shlfi_tl(TCGv a, int b, TCGv c);
400380

401381
#endif
402382

383+
#ifdef TARGET_ARC32
384+
extern const MemOp memop_for_size_sign[2][3];
385+
#endif
386+
387+
#ifdef TARGET_ARC64
388+
extern const MemOp memop_for_size_sign[2][4];
389+
#endif
390+
403391
enum ato_op {
404392
ATO_ADD = 0b000,
405393
ATO_OR = 0b001,

0 commit comments

Comments
 (0)