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.

I am curious about the IRP usage in spra291

Hi,

I am curious about the IRP usage in spra291. It is in a C callable assembly function. All other registers are saved to dummy (memory), except B4 (an input argument, which is restored in the end of the asm function later) which is saved to IRP. On page 230, TMS320C6000 Optimizing Compiler v7.4 user guide, it says:

The IRP's value must be saved and restored if you use the IRP as a temporary register.

 

I do not see IRP is saved before it uses as a temporary register(?). 

 

 What do you think about this?

 

 Thanks,

 

 

....................

.global dummy

.global _radix4

.bss dummy,52        ; Reserve space for dummy.

.text

_radix4:

MVK .S1 dummy, A0      ; New dummy pointer in A0 and B1

|| MVK  .S2 dummy, B1

MVKH .S1 dummy, A0    ; New dummy pointer in A0 and B1

|| MVKH .S2 dummy, B1

STW .D2 B3, *B1        ; Push return address on dummy.

STW  .D1 A10, *+A0[1]         ; Push A10 on dummy.

|| STW  .D2 B10, *+B1[2] ; Push B10 on dummy.

; *** BEGIN Benchmark Timing ***

B_START:

MVK  .S1 32, A1               ; A1 = 32

|| LMBD .L1 1, A4, A2 ; 31 – log2(n)

|| SHR  .S2X A4, 2, B6 ; n2 = n / 4

|| ZERO .L2 B7 ; Mask

|| STW  .D1 A11, *+A0[3] ; Push A11 on dummy.

|| STW  .D2 B11, *+B1[4] ; Push B11 on dummy.

SUB  .L1 A1, A2, A4 ; log2(n)+1 (circ buff size in bytes)

|| SHR  .S1 A4, 1, A7 ; 2 * n2 = n / 2, a–side

|| SHR .S2X A4, 1, B9 ; 2 * n2 = n / 2, b–side

|| MV .L2 B6, B0 ; n / 4

|| STW  .D1 A12, *+A0[5] ; Push A12 on dummy.

|| STW  .D2 B12, *+B1[6] ; Push B12 on dummy.

SHL  .S1 A4, 16, A4          ; Shift into BK0 field.

|| MVC  .S2 B4, IRP ; Save off x.

|| STW  .D1 A13, *+A0[7] ; Push A13 on dummy.

|| STW  .D2 B13, *+B1[8] ; Push B13 on dummy.

  • Hi,

    Queries on Interrupt Return Pointer(IRP) are best handled by C/C++ Compiler  Forum. Moving your post to C/C++ Compiler  forum to get appropriate assistance.

  • Even if IRP is properly saved and restored, interrupts must be disabled if IRP is written (this is also mentioned on page 230).  If interrupts are enabled, a maskable interrupt could come along at any moment and clobber the contents of IRP.  I see no interrupt disabling code in that function, so I must assume that an unwritten precondition for using that function is that all maskable interrupts are disabled by some parent function.  It is possible that this function is called during an interrupt handler, in which case IRP must be saved and restored, as you say.  If all maskable interrupts are disabled whenever this function is called, and this function is not called during any maskable interrupt handler, then the function is OK as written.

    None of these requirements are caused by the compiler or the C calling convention; these requirements are also true of hand-coded assembly programs, so this query should be directed to the author or maintainer of that document.