Skip to contentSkip to conversation

Difference between tcg_gen_ld_i64 and tcg_gen_qemu_ld_i64.

Qemu-devel Rafael Kioji 2 participants 2 messages Apr 29, 2018

lore
Share & tools
lore
#0 lore raw

Dear all,

What is the difference between these two functions? They are located in the file "tcg/tcg-op.c". Here is their header:

1. static inline void tcg_gen_ld_i64(TCGv_i64 ret, TCGv_ptr arg2, tcg_target_long offset)
2. void tcg_gen_qemu_ld_i64(TCGv_i64 val, TCGv addr, TCGArg idx, TCGMemOp memop)

I don't quite understand the need for function (1). Especially because it is usually passed "cpu_env" for arg2. Like in target/arm/translate-a64.c:595:

Quoted 10 lines

/* Convenience accessors for reading and writing single and double
 * FP registers. Writing clears the upper parts of the associated
 * 128 bit vector register, as required by the architecture.
 * Note that unlike the GP register accessors, the values returned
 * by the read functions must be manually freed.
 */
static TCGv_i64 read_fp_dreg(DisasContext *s, int reg) {
    TCGv_i64 v = tcg_temp_new_i64();

Quoted 3 lines

    tcg_gen_ld_i64(v, cpu_env, fp_reg_offset(s, reg, MO_64)); return v;
}

Thanks!

--
Att.,
Rafael

#1 lore raw
Quoted 7 lines · Rafael Kioji

Dear all,

What is the difference between these two functions? They are located in the file "tcg/tcg-op.c". Here is their header:

1. static inline void tcg_gen_ld_i64(TCGv_i64 ret, TCGv_ptr arg2, tcg_target_long offset)

This is used to access fields of qemu data structures from generated code, e.g. CPUArmState.

Quoted 2 lines

2. void tcg_gen_qemu_ld_i64(TCGv_i64 val, TCGv addr, TCGArg idx, TCGMemOp memop)

This actually generates a load to guest memory.

Quoted 3 lines

I don't quite understand the need for function (1). Especially because it is usually passed "cpu_env" for arg2. Like in target/arm/translate-a64.c:595:

cpu_env is a pointer to CPUArmState.

Cheers,
Bastian