[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] Creating an own target. How to deal with Flags and Bran

From: Edgar E. Iglesias
Subject: Re: [Qemu-devel] Creating an own target. How to deal with Flags and Branches in TCG?
Date: Fri, 28 Aug 2009 14:33:11 +0200
User-agent: Mutt/1.5.16 (2007-06-09)

On Tue, Aug 11, 2009 at 07:42:44PM +0200, Klaus F wrote:
>    Hi,


Sorry for the late answer, I've been offline...

>    I'm interested in creating my own target for qemu
>    My goal is to learn how to implement own target processors and own
>    target peripherals with qemu.
>    I'm having minor difficulties in understanding how comditional branches
>    and the handling of flags is done.
>    I'll continue looking by myself, but if any of you has some ncie
>    pointers, then I would really appreciate it.
>    tcg/README is a nice staring point,
>    but I didn't understand the section about labels and conditions that
>    well.
>    Currently I'm looking at the generation of an own target CPU.
>    I can already execute my first few instructions, which load and modify
>    registers.
>    Now I'd like to work on status registers and conditional branches.
>    What I did so far:
>    - As starting point I took the Xilinx Microblaze target (randomly
>    chosen, as I thought an FPGA core might be relatively simple)

The microblaze port is one of the smaller and simpler ones, so yes it
probably is a good starting point.

>    - I am using gen_intermediate_code_internal() and replaced only the
>    part for decoding instructions
>    - I added decoding for a few instructions and can now load registers
>    and perform ALU operations
>    What I am not 100% clear about is how flags (Carry,Zero, . . .) are
>    synchroniced between the TCG engine und my virtual target.

Regarding status flags, microblaze might not be the best target to look
at because it doesn't have many flags. Microblaze does not store the
traditional Z, N nor V flags in a status reg. They are only used in
the pipe to properly execute the compare-and-conditionally-branch and
compare instructions.

Carry is there though. See helper_addkc() and helper_subkc() for
more detail on how carry is computed and updated.

>    What I'd like to know
>    - which tcg_gen commands modify flags and which ones don't ?

TCG does not really have flags. You have to implement emulation of
whatever target flags you need on top of TCG.

>    - how can I forward the flag values to my target status register ?

The same way you would set or clear bits in any TCG variable.

>    - how can I conditionally branch on flags?

For the microblaze target, I suggest looking at eval_cc(), eval_cond_jmp()
and dec_bcc().


reply via email to

[Prev in Thread] Current Thread [Next in Thread]