This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Not using TMU for Floating Point Divide



I'm using the F28377D with the compiler options suggested by this post:

http://e2e.ti.com/support/microcontrollers/c2000/f/171/p/333174/1162805.aspx#1162805

But when I take a look at the map file it is still using the divide code from rts2800_fpu32 or rts2800_fpu32_fast_supplement if I include that library.  I've included a piece of my map file.

00082682    00000088     rts2800_fpu32.lib : fs_div.obj (.text)
0008270a    00000068                       : exp.obj (.text)
00082772    00000061                       : log.obj (.text)
000827d3    00000031                       : ldexp.obj (.text)
00082804    00000016                       : frexp.obj (.text)

Shouldn't the compiler use the divide available from the TMU instead of the one provided in the library?

  • Hi Adam,

    Could you take a look at the disassembly and see what is being used? I tried the following with tmu_support set to tmu0 and fp_mode to relaxed

    float a = 12.0, b = 4.0, c = 0.0, d = 0.0, e = 0.0;

    d = sin(a);
    e = cos(b);
    c = a/b;

    It seems to work, all the TMU instructions are being used instead of the std lib calls.

     

    ___relaxed_sin: ADDB SP,#2 ; [CPU_U] MOV32 *-SP[2],R0H ; [CPU_] |258| ;---------------------------------------------------------------------- ; 259 | return __sin(x); ;---------------------------------------------------------------------- DIV2PIF32 R0H,R0H ; [CPU_] |259| NOP ; [CPU_] SINPUF32 R0H,R0H ; [CPU_] |259| NOP ; [CPU_] SUBB SP,#2 ; [CPU_U] LRETR ; [CPU_] ; return occurs ; [] .sect ".text" .clink ;---------------------------------------------------------------------- ; 267 | __inline double __relaxed_cos(double x) ;---------------------------------------------------------------------- ;*************************************************************** ;* FNAME: ___relaxed_cos FR SIZE: 2 * ;* * ;* FUNCTION ENVIRONMENT * ;* * ;* FUNCTION PROPERTIES * ;* 0 Parameter, 2 Auto, 0 SOE * ;*************************************************************** ___relaxed_cos: ADDB SP,#2 ; [CPU_U] MOV32 *-SP[2],R0H ; [CPU_] |268| ;---------------------------------------------------------------------- ; 269 | return __cos(x); ;---------------------------------------------------------------------- DIV2PIF32 R0H,R0H ; [CPU_] |269| NOP ; [CPU_] COSPUF32 R0H,R0H ; [CPU_] |269| NOP ; [CPU_] SUBB SP,#2 ; [CPU_U] LRETR ; [CPU_] ; return occurs ; [] .sect ".text" .clink .global _main ;---------------------------------------------------------------------- ; 100 | void main(void) ; 102 | uint16_t i; ;---------------------------------------------------------------------- ;*************************************************************** ;* FNAME: _main FR SIZE: 10 * ;* * ;* FUNCTION ENVIRONMENT * ;* * ;* FUNCTION PROPERTIES * ;* 0 Parameter, 10 Auto, 0 SOE * ;*************************************************************** _main: ADDB SP,#10 ; [CPU_U] ;---------------------------------------------------------------------- ; 104 | float a = 12.0, b = 4.0, c = 0.0, d = 0.0, e = 0.0; ;---------------------------------------------------------------------- MOVIZ R0H,#16704 ; [CPU_] |104| MOV32 *-SP[2],R0H ; [CPU_] |104| MOVIZ R0H,#16512 ; [CPU_] |104| MOV32 *-SP[4],R0H ; [CPU_] |104| ZERO R0H ; [CPU_] |104| MOV32 *-SP[6],R0H ; [CPU_] |104| MOV32 *-SP[8],R0H ; [CPU_] |104| MOV32 *-SP[10],R0H ; [CPU_] |104| ;---------------------------------------------------------------------- ; 105 | d = sin(a); ;---------------------------------------------------------------------- MOV32 R0H,*-SP[2] ; [CPU_] |105| LCR #___relaxed_sin ; [CPU_] |105| ; call occurs [#___relaxed_sin] ; [] |105| MOV32 *-SP[8],R0H ; [CPU_] |105| ;---------------------------------------------------------------------- ; 106 | e = cos(b); ;---------------------------------------------------------------------- MOV32 R0H,*-SP[4] ; [CPU_] |106| LCR #___relaxed_cos ; [CPU_] |106| ; call occurs [#___relaxed_cos] ; [] |106| MOV32 *-SP[10],R0H ; [CPU_] |106| ;---------------------------------------------------------------------- ; 107 | c = a/b; ;---------------------------------------------------------------------- MOV32 R1H,*-SP[2] ; [CPU_] |107| MOV32 R0H,*-SP[4] ; [CPU_] |107| DIVF32 R0H,R1H,R0H ; [CPU_] |107| NOP ; [CPU_] NOP ; [CPU_] NOP ; [CPU_] NOP ; [CPU_] MOV32 *-SP[6],R0H ; [CPU_] |107|

  • I looked at the disassembly via CCS but it is difficult for me to search the assembly code.  Is there a way that I can put it into a text file so that I can more easily search for the DIVF32 instruction as well as look for the address of the fastRTS div function?

    Also how did you get your disassembly to look like that?

  • what i normally do is i go to the properties for a particular file, in my case it was 'main.c', and then under

    1. Advanced Options -> Advanced Debug Options -> Debugging Model: choose Suppress all symbolic debug generation (--symdebug:none)

    2. Advanced Options -> Assembler Options: enable --keep_asm

     and for Source Interlist: select --c_src_interlist

    The second option will generate an assembly file 'main.asm' in the output folder; the assembly will be displayed with the corresponding C code in comments along with the line number. you can just search this file for the line number to find its assembly snippet

    The first option gets rid of the DWARF debug information - but if you do this you wont be able to step through your C code while debugging so be sure to set ut back to --symdebug:dwarf when you are debugging.

  • Vishal,

    Thanks that was really helpful.  In looking at my assembly it does appear to be using the right instructions.  

    MOVB      XAR0,#16              ; [CPU_] 
    CMPB      AL,#2                 ; [CPU_] |221| 
    DIVF32    R5H,R0H,R2H           ; [CPU_] |220| 
    MOV32     R7H,*+XAR2[AR0]       ; [CPU_] 
    BF        $C$L7,NEQ             ; [CPU_] |221| 
    ; branchcc occurs ; [] |221| 

    and

    MOVB      XAR0,#8               ; [CPU_] |187| 
    ADDF32    R2H,R2H,R2H           ; [CPU_] |184| 
    MOV32     R7H,*+XAR2[AR0]       ; [CPU_] |187| 
    SQRTF32   R0H,R7H               ; [CPU_] |187| 

    Thanks.  I think my confusion came from the div_f32.obj being included in the map file.  But I could not find where it was calling into that object.  

  • Adam,

    It is probably being called somewhere, else i don't think the linker would have roped it in. I might be wrong but its possible that another standard library function that is making the call to div_f32. The std C library is not compiled with tmu support turned on so it would have to use the std math routines.