target/loongarch: Add generic csr function type
Parameter type TCGv and TCGv_ptr for function GenCSRRead and GenCSRWrite is not used in non-TCG mode. Generic csr function type is added here with parameter void type, so that it passes to compile with non-TCG mode. Signed-off-by: Bibo Mao <maobibo@loongson.cn>
This commit is contained in:
parent
3156b1c1e9
commit
75b2c5da94
@ -44,12 +44,13 @@ GEN_FALSE_TRANS(idle)
|
|||||||
|
|
||||||
typedef void (*GenCSRRead)(TCGv dest, TCGv_ptr env);
|
typedef void (*GenCSRRead)(TCGv dest, TCGv_ptr env);
|
||||||
typedef void (*GenCSRWrite)(TCGv dest, TCGv_ptr env, TCGv src);
|
typedef void (*GenCSRWrite)(TCGv dest, TCGv_ptr env, TCGv src);
|
||||||
|
typedef void (*GenCSRFunc)(void);
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int offset;
|
int offset;
|
||||||
int flags;
|
int flags;
|
||||||
GenCSRRead readfn;
|
GenCSRFunc readfn;
|
||||||
GenCSRWrite writefn;
|
GenCSRFunc writefn;
|
||||||
} CSRInfo;
|
} CSRInfo;
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
@ -184,8 +185,8 @@ static bool set_csr_trans_func(unsigned int csr_num, GenCSRRead readfn,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
csr->readfn = readfn;
|
csr->readfn = (GenCSRFunc)readfn;
|
||||||
csr->writefn = writefn;
|
csr->writefn = (GenCSRFunc)writefn;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -222,6 +223,7 @@ static bool trans_csrrd(DisasContext *ctx, arg_csrrd *a)
|
|||||||
{
|
{
|
||||||
TCGv dest;
|
TCGv dest;
|
||||||
const CSRInfo *csr;
|
const CSRInfo *csr;
|
||||||
|
GenCSRRead readfn;
|
||||||
|
|
||||||
if (check_plv(ctx)) {
|
if (check_plv(ctx)) {
|
||||||
return false;
|
return false;
|
||||||
@ -233,8 +235,9 @@ static bool trans_csrrd(DisasContext *ctx, arg_csrrd *a)
|
|||||||
} else {
|
} else {
|
||||||
check_csr_flags(ctx, csr, false);
|
check_csr_flags(ctx, csr, false);
|
||||||
dest = gpr_dst(ctx, a->rd, EXT_NONE);
|
dest = gpr_dst(ctx, a->rd, EXT_NONE);
|
||||||
if (csr->readfn) {
|
readfn = (GenCSRRead)csr->readfn;
|
||||||
csr->readfn(dest, tcg_env);
|
if (readfn) {
|
||||||
|
readfn(dest, tcg_env);
|
||||||
} else {
|
} else {
|
||||||
tcg_gen_ld_tl(dest, tcg_env, csr->offset);
|
tcg_gen_ld_tl(dest, tcg_env, csr->offset);
|
||||||
}
|
}
|
||||||
@ -247,6 +250,7 @@ static bool trans_csrwr(DisasContext *ctx, arg_csrwr *a)
|
|||||||
{
|
{
|
||||||
TCGv dest, src1;
|
TCGv dest, src1;
|
||||||
const CSRInfo *csr;
|
const CSRInfo *csr;
|
||||||
|
GenCSRWrite writefn;
|
||||||
|
|
||||||
if (check_plv(ctx)) {
|
if (check_plv(ctx)) {
|
||||||
return false;
|
return false;
|
||||||
@ -262,9 +266,10 @@ static bool trans_csrwr(DisasContext *ctx, arg_csrwr *a)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
src1 = gpr_src(ctx, a->rd, EXT_NONE);
|
src1 = gpr_src(ctx, a->rd, EXT_NONE);
|
||||||
if (csr->writefn) {
|
writefn = (GenCSRWrite)csr->writefn;
|
||||||
|
if (writefn) {
|
||||||
dest = gpr_dst(ctx, a->rd, EXT_NONE);
|
dest = gpr_dst(ctx, a->rd, EXT_NONE);
|
||||||
csr->writefn(dest, tcg_env, src1);
|
writefn(dest, tcg_env, src1);
|
||||||
} else {
|
} else {
|
||||||
dest = tcg_temp_new();
|
dest = tcg_temp_new();
|
||||||
tcg_gen_ld_tl(dest, tcg_env, csr->offset);
|
tcg_gen_ld_tl(dest, tcg_env, csr->offset);
|
||||||
@ -278,6 +283,7 @@ static bool trans_csrxchg(DisasContext *ctx, arg_csrxchg *a)
|
|||||||
{
|
{
|
||||||
TCGv src1, mask, oldv, newv, temp;
|
TCGv src1, mask, oldv, newv, temp;
|
||||||
const CSRInfo *csr;
|
const CSRInfo *csr;
|
||||||
|
GenCSRWrite writefn;
|
||||||
|
|
||||||
if (check_plv(ctx)) {
|
if (check_plv(ctx)) {
|
||||||
return false;
|
return false;
|
||||||
@ -308,8 +314,9 @@ static bool trans_csrxchg(DisasContext *ctx, arg_csrxchg *a)
|
|||||||
tcg_gen_andc_tl(temp, oldv, mask);
|
tcg_gen_andc_tl(temp, oldv, mask);
|
||||||
tcg_gen_or_tl(newv, newv, temp);
|
tcg_gen_or_tl(newv, newv, temp);
|
||||||
|
|
||||||
if (csr->writefn) {
|
writefn = (GenCSRWrite)csr->writefn;
|
||||||
csr->writefn(oldv, tcg_env, newv);
|
if (writefn) {
|
||||||
|
writefn(oldv, tcg_env, newv);
|
||||||
} else {
|
} else {
|
||||||
tcg_gen_st_tl(newv, tcg_env, csr->offset);
|
tcg_gen_st_tl(newv, tcg_env, csr->offset);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user