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.

Compiler/TMS320C6746: How does the compiler save B3 when calling a function?

Part Number: TMS320C6746

Tool/software: TI C/C++ Compiler

ccs version is 8.20

there are same information about how  the compiler save B3  when calling a function in《TMS320C6000 Optimizing Compiler v8.2.x User's Guide》.

so, i write some c functions,and debug on c6748 with ccs.but the result puzzled me.

the compiler saves B3 with registers(eg. A31/A30/B6 ...)  instead of stack.


Why the result of compile conflicted with User's Guide. What is the saving rule for B3 when calling a function?

the result is effected by compiler options? there are some other particular User's Guide?

  • There must be conditions where, instead of saving B3 on the stack, it is copied to another register.  I'm not sure what those conditions are.  But I can investigate.  For the source file which generates this assembly code, please follow the directions in the article How to Submit a Compiler Test Case.

    Thanks and regards,

    -George

  • thanks for your reply.

    we're going to develop our own crash dump tools.

    i think the saving rule for B3 is a very important information.

    here is the Compiler Test Case.

    the Compiler Version is

    TMS320C6x Linker PC v8.2.4

    3465.main.pp.txt

    Compiler Options.txt
    **** Build of configuration Debug for project sysbios_6748 ****
    
    "E:\\ti\\ccs820\\ccsv8\\utils\\bin\\gmake" -k -j 4 all -O 
     
    Building file: "../app.cfg"
    Invoking: XDCtools
    "E:/ti/ccs820/xdctools_3_50_08_24_core/xs" --xdcpath="E:/ti/ccs820/bios_6_73_01_01/packages;" xdc.tools.configuro -o configPkg -t ti.targets.elf.C674 -p ti.platforms.evm6748 -r release -c "E:/ti/ccs820/ccsv8/tools/compiler/ti-cgt-c6000_8.2.4" --compileOptions "-g" "../app.cfg"
    making package.mak (because of package.bld) ...
    generating interfaces for package configPkg (because package/package.xdc.inc is older than package.xdc) ...
    configuring app.xe674 from package/cfg/app_pe674.cfg ...
    generating custom ti.sysbios library makefile ... 
    Starting build of library sources ...
    making D:/yangxu/workspace_v8/sysbios_6748/src/sysbios/sysbios.ae674 ...
    gmake[1]: Entering directory `D:/yangxu/workspace_v8/sysbios_6748/src/sysbios'
    cle674 E:/ti/ccs820/bios_6_73_01_01/packages/ti/sysbios/BIOS.c ...
    asme674 E:/ti/ccs820/bios_6_73_01_01/packages/ti/sysbios/family/c64p/Exception_asm.s64P ...
    asme674 E:/ti/ccs820/bios_6_73_01_01/packages/ti/sysbios/family/c64p/Hwi_asm.s62 ...
    asme674 E:/ti/ccs820/bios_6_73_01_01/packages/ti/sysbios/family/c64p/Hwi_asm_switch.s62 ...
    asme674 E:/ti/ccs820/bios_6_73_01_01/packages/ti/sysbios/family/c64p/Hwi_disp_always.s64P ...
    asme674 E:/ti/ccs820/bios_6_73_01_01/packages/ti/sysbios/rts/ti/tls_get_tp.asm ...
    asme674 E:/ti/ccs820/bios_6_73_01_01/packages/ti/sysbios/family/c62/TaskSupport_asm.s62 ...
    asme674 E:/ti/ccs820/bios_6_73_01_01/packages/ti/sysbios/timers/timer64/Timer_asm.s64P ...
    are674 BIOS.obj c64p_Exception_asm.obj c64p_Hwi_asm.obj c64p_Hwi_asm_switch.obj c64p_Hwi_disp_always.obj ti_tls_get_tp.obj c62_TaskSupport_asm.obj timer64_Timer_asm.obj ...
    gmake[1]: Leaving directory `D:/yangxu/workspace_v8/sysbios_6748/src/sysbios'
    Build of libraries done.
    cle674 package/cfg/app_pe674.c ...
    Finished building: "../app.cfg"
     
    �Ѹ���         1 ���ļ���
    making ../src/sysbios/sysbios.ae674 ...
    gmake[1]: Nothing to be done for 'all'.
    Building file: "../main.c"
    Invoking: C6000 Compiler
    "E:/ti/ccs820/ccsv8/tools/compiler/ti-cgt-c6000_8.2.4/bin/cl6x" -mv6740 --opt_for_speed=0 -ms0 --include_path="D:/yangxu/workspace_v8/sysbios_6748" --include_path="E:/ti/ccs820/bios_6_73_01_01/packages/ti/posix/ccs" --include_path="E:/ti/ccs820/ccsv8/tools/compiler/ti-cgt-c6000_8.2.4/include" --define=c6748 -g --preproc_only --preproc_with_comment --preproc_with_compile --diag_warning=225 --diag_wrap=off --display_error_number -k --cmd_file="configPkg/compiler.opt" "../main.c"
    Finished building: "../main.c"
     
    making ../src/sysbios/sysbios.ae674 ...
    gmake[2]: Nothing to be done for 'all'.
    Building target: "sysbios_6748.out"
    Invoking: C6000 Linker
    "E:/ti/ccs820/ccsv8/tools/compiler/ti-cgt-c6000_8.2.4/bin/cl6x" -mv6740 --opt_for_speed=0 -ms0 --define=c6748 -g --diag_warning=225 --diag_wrap=off --display_error_number -k -z -m"sysbios_6748.map" --heap_size=0x800 --stack_size=0x800 -i"E:/ti/ccs820/ccsv8/tools/compiler/ti-cgt-c6000_8.2.4/lib" -i"E:/ti/ccs820/ccsv8/tools/compiler/ti-cgt-c6000_8.2.4/include" --reread_libs --diag_wrap=off --display_error_number --warn_sections --xml_link_info="sysbios_6748_linkInfo.xml" --rom_model -o "sysbios_6748.out" "./main.obj" -l"configPkg/linker.cmd" -llibc.a 
    <Linking>
    Finished building target: "sysbios_6748.out"
     
    
    **** Build Finished ****
    

  • Thank you for the test case.  I can reproduce the same result.

    I have a good understanding of what happens.  However, I have yet to confirm that everything in this post is correct.  I'll get back to you with that.

    Just for now, presume a function named parent calls a function named child.  If the child function is in the same file, and thus the compiler knows which registers are modified by child, then the compiler may copy B3 into a register that is not modified by child instead of saving it to a memory location on the stack.  

    In the test case you sent, this is what happens when the function add3 calls the function add2.  The register B3 is not saved to a memory location on the stack.  Instead, it is saved to A1, a register which is not modified by the function add2.

    There is no method by which you can disable this behavior of the compiler.

    Thanks and regards,

    -George

  • is this behavior of the compiler is a kind of optimization?

    i hope there has a clear documentation.

    otherwise. we will  analyze the machine code to find where the B3 register be saved.

    my goodness~

  • I can confirm that the explanation in my previous post is correct.

    杨旭 said:
    is this behavior of the compiler is a kind of optimization?

    Yes

    杨旭 said:
    i hope there has a clear documentation.

    Unfortunately, no.  I filed the entry EXT_EP-10046 to have the compiler manual corrected.  You are welcome to follow it with the link below in my signature.

    Thanks and regards,

    -George

  • i will, thanks.