qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [Consult] tilegx: About floating point instructions


From: Chen Gang
Subject: Re: [Qemu-devel] [Consult] tilegx: About floating point instructions
Date: Wed, 28 Oct 2015 23:53:04 +0800

Oh, sorry, After reference another documents (about sw_64 arch floating
point introduction), I know, 0x7f is fsingle exp '0' (no move), 0x3ff is
fdouble exp '0' (no move).

And for fdouble, we still can calculate the real value base on qemu soft
fpu, so can simplify many details. So for me, the related completely
information are below:

/*
 * From IEEE standard, exp of float is 8-bits, exp of double is 11-bits.
 */
#define TILEGX_F_EXP_FZERO  0x7f  /* Zero exp for single 8-bits */
#define TILEGX_F_EXP_DZERO  0x3ff /* Zero exp for double 11-bits */

/*
 * For fdouble addsub bit
 */
#define TILEGX_F_ADDSUB_ADD 0     /* Perform absolute add operation */
#define TILEGX_F_ADDSUB_SUB 1     /* Perform absolute sub operation */

#pragma pack(push, 1)

/*
 * Single format, it is 64-bit.
 *
 * Single exp analyzing: 0x9e - 0x1e(30) = 0x80
 *
 *   7   6   5   4   3   2   1   0
 *
 *   1   0   0   1   1   1   1   0
 *
 *   0   0   0   1   1   1   1   1    => 0x1f(31)
 *
 *   0   1   1   1   1   1   1   1    => 0x7f
 */
typedef struct TileGXFPSFmt {

    /* According to float(uns)sisf2 and float(uns)sidf2 in gcc tilegx.md */
    uint64_t exp : 8;             /* exp, 0x9e: 31 + TILEGX_F_EXP_FZERO */
    uint64_t unknown0 : 1;        /* unknown */
    uint64_t sign : 1;            /* Sign bit for the total value */
    uint64_t unknown1 : 15;       /* unknown */

    /* Come from TILE-Gx ISA document, Table 7-2 for floating point */
    uint64_t unordered : 1;       /* The two are unordered */
    uint64_t lt : 1;              /* 1st is less than 2nd */
    uint64_t le : 1;              /* 1st is less than or equal to 2nd */
    uint64_t gt : 1;              /* 1st is greater than 2nd */
    uint64_t ge : 1;              /* 1st is greater than or equal to 2nd */
    uint64_t eq : 1;              /* The two operands are equal */
    uint64_t neq : 1;             /* The two operands are not equal */

    /* According to float(uns)sisf2 and float(uns)sidf2 in gcc tilegx.md */
    uint64_t mantissa : 32;       /* mantissa */
} TileGXFPSFmt;
/*
 * FSingle instructions implemenation:
 *
 * fsingle_add1         ; calc srca and srcb,
 *                      ; convert float_32 to TileGXFPSFmt result.
 *                      ; move TileGXFPSFmt result to dest.
 *
 * fsingle_sub1         ; calc srca and srcb.
 *                      ; convert float_32 to TileGXFPSFmt result.
 *                      ; move TileGXFPSFmt result to dest.
 *
 * fsingle_addsub2      ; nop.
 *
 * fsingle_mul1         ; calc srca and srcb.
 *                      ; convert float_32 value to TileGXFPSFmt result.
 *                      ; move TileGXFPSFmt result to dest.
 *
 * fsingle_mul2         ; move srca to dest.
 *
 * fsingle_pack1        ; nop
 *
 * fsingle_pack2        ; treate srca as TileGXFPSFmt result.
 *                      ; convert TileGXFPSFmt result to float_32 value.
 *                      ; move float_32 value to dest.
 */

/*
 * Dobule format. flag: 64 bits, value: 64 bits.
 *
 * Double exp analyzing: (0x21b00 << 1) - 0x36(54) = 0x400
 *
 *   17  16  15  14  13  12  11  10   9   8   7    6   5   4   3   2   1   0
 *
 *    1   0   0   0   0   1   1   0   1   1   0    0   0   0   0   0   0   0
 *
 *    0   0   0   0   0   1   1   0   1   1   1    => 0x37(55)
 *
 *    0   1   1   1   1   1   1   1   1   1   1    => 0x3ff
 *
 */
typedef struct TileGXFPDFmtF {

    uint64_t unknown0 : 7;        /* unknown */
    uint64_t exp : 11;            /* exp, 0x21b << 1: 55 + TILEGX_F_EXP_DZERO */
    uint64_t unknown1 : 2;        /* unknown */
    uint64_t sign : 1;            /* Sign bit for the total value */

    uint64_t addsub: 1;           /* add or sub bit */
    uint64_t unknown2: 3;         /* unknown */

    /* Come from TILE-Gx ISA document, Table 7-2 for floating point */
    uint64_t unordered : 1;       /* The two are unordered */
    uint64_t lt : 1;              /* 1st is less than 2nd */
    uint64_t le : 1;              /* 1st is less than or equal to 2nd */
    uint64_t gt : 1;              /* 1st is greater than 2nd */
    uint64_t ge : 1;              /* 1st is greater than or equal to 2nd */
    uint64_t eq : 1;              /* The two operands are equal */
    uint64_t neq : 1;             /* The two operands are not equal */

    uint64_t unknown3 : 32;       /* unknown */
} TileGXFPDFmtF;

typedef struct TileGXFPDFmtV {
    uint64_t mantissa : 60;       /* mantissa */
    uint64_t unknown1 : 4;        /* unknown */
} TileGXFPDFmtV;
/*
 * FDouble instructions implemenation:
 *
 * fdouble_unpack_min   ; srca and srcb are float_64 value.
 *                      ; get the min absolute value's mantissa.
 *                      ; move mantissa to dest.
 *
 * fdouble_unpack_max   ; srca and srcb are float_64 value.
 *                      ; get the max absolute value's mantissa.
 *                      ; move "mantissa << (exp_max - exp_min)" to dest.
 *
 * fdouble_add_flags    ; srca and srcb are float_64 value.
 *                      ; calc exp (exp_min), sign, and comp bits for flags.
 *                      ; set addsub bit to flags and move flags to dest.
 *
 * fdouble_sub_flags    ; srca and srcb are float_64 value.
 *                      ; calc exp (exp_min), sign, and comp bits for flags.
 *                      ; set addsub bit to flags and move flags to dest.
 *
 * fdouble_addsub:      ; dest, srca (max, min mantissa), and srcb (flags).
 *                      ; "dest +/- srca" depend on the add/sub bit of flags.
 *                      ; move result mantissa to dest.
 *
 * fdouble_mul_flags:   ; srca and srcb are float_64 value.
 *                      ; calc sign (xor), exp (exp_min + exp_max), and comp 
bits.
 *                      ; mix sign, exp, and comp bits as flags to dest.
 *
 * fdouble_pack1        ; move srcb (flags) to dest.
 *
 * fdouble_pack2        ; srca, srcb (high, low mantissa), and dest (flags)
 *                      ; normalize and pack result from srca, srcb, and dest.
 *                      ; move result to dest.
 */

#pragma pack(pop)


Thanks.
-- 
Chen Gang (陈刚)

Open, share, and attitude like air, water, and life which God blessed

                                          

reply via email to

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