Skip to content

Commit d3203d5

Browse files
iii-irth7680
authored andcommitted
tcg: Document tb_lookup() and tcg_tb_lookup()
These similarly named functions serve different purposes; add docstrings to highlight them. Suggested-by: Alex Bennée <alex.bennee@linaro.org> Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com> Reviewed-by: Alex Bennée <alex.bennee@linaro.org> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Message-ID: <20250116213214.5695-1-iii@linux.ibm.com>
1 parent 8095f65 commit d3203d5

File tree

2 files changed

+55
-1
lines changed

2 files changed

+55
-1
lines changed

accel/tcg/cpu-exec.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,20 @@ static TranslationBlock *tb_htable_lookup(CPUState *cpu, vaddr pc,
249249
return qht_lookup_custom(&tb_ctx.htable, &desc, h, tb_lookup_cmp);
250250
}
251251

252-
/* Might cause an exception, so have a longjmp destination ready */
252+
/**
253+
* tb_lookup:
254+
* @cpu: CPU that will execute the returned translation block
255+
* @pc: guest PC
256+
* @cs_base: arch-specific value associated with translation block
257+
* @flags: arch-specific translation block flags
258+
* @cflags: CF_* flags
259+
*
260+
* Look up a translation block inside the QHT using @pc, @cs_base, @flags and
261+
* @cflags. Uses @cpu's tb_jmp_cache. Might cause an exception, so have a
262+
* longjmp destination ready.
263+
*
264+
* Returns: an existing translation block or NULL.
265+
*/
253266
static inline TranslationBlock *tb_lookup(CPUState *cpu, vaddr pc,
254267
uint64_t cs_base, uint32_t flags,
255268
uint32_t cflags)

include/tcg/tcg.h

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -638,10 +638,51 @@ void tcg_region_reset_all(void);
638638
size_t tcg_code_size(void);
639639
size_t tcg_code_capacity(void);
640640

641+
/**
642+
* tcg_tb_insert:
643+
* @tb: translation block to insert
644+
*
645+
* Insert @tb into the region trees.
646+
*/
641647
void tcg_tb_insert(TranslationBlock *tb);
648+
649+
/**
650+
* tcg_tb_remove:
651+
* @tb: translation block to remove
652+
*
653+
* Remove @tb from the region trees.
654+
*/
642655
void tcg_tb_remove(TranslationBlock *tb);
656+
657+
/**
658+
* tcg_tb_lookup:
659+
* @tc_ptr: host PC to look up
660+
*
661+
* Look up a translation block inside the region trees by @tc_ptr. This is
662+
* useful for exception handling, but must not be used for the purposes of
663+
* executing the returned translation block. See struct tb_tc for more
664+
* information.
665+
*
666+
* Returns: a translation block previously inserted into the region trees,
667+
* such that @tc_ptr points anywhere inside the code generated for it, or
668+
* NULL.
669+
*/
643670
TranslationBlock *tcg_tb_lookup(uintptr_t tc_ptr);
671+
672+
/**
673+
* tcg_tb_foreach:
674+
* @func: callback
675+
* @user_data: opaque value to pass to @callback
676+
*
677+
* Call @func for each translation block inserted into the region trees.
678+
*/
644679
void tcg_tb_foreach(GTraverseFunc func, gpointer user_data);
680+
681+
/**
682+
* tcg_nb_tbs:
683+
*
684+
* Returns: the number of translation blocks inserted into the region trees.
685+
*/
645686
size_t tcg_nb_tbs(void);
646687

647688
/* user-mode: Called with mmap_lock held. */

0 commit comments

Comments
 (0)