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.

Any substitution for long long & in C?

Hi,

I just read SPRU198I , and I found a code expression in some functions, for example: in IMG_sub_8(A.22 section),

_amem8(imgW) = _itoll (res_p7_p6_p5_p4, res_p3_p2_p1_p0);

 

1. "_amem8"  returns  "long long &" , so this sentence will generate an error while compiling using C,  is there any other way to express the same meaning in C language?

2. Here, Does "long long" mean the structure of "VLIW" in Davinci?

Thanks.

 

  • "long long" is a register pair in the C6000 system.  Depending on what family you have (C6000, c64, c64+) you can do various optimizations on that register pair to increase your data throughput.  I didn't see this particular line in SPRU198, but I can get a _amem8() call to compile fine if I just declare a long long and use that variable for its return.  I haven't looked at the C type rules in forever, but my guess is that the & is used to address the contents of a register pair.  Maybe the TI folks can explain the semantics.

    long long dar;

    void *p = something;

    dar = _amem8(p);

  • Sorry, It should be SPRUF30.

    In A.22 section

    /*---------------------------------------------------**
    ** This function performs subtraction of 2           **
    ** images. Each image consist of 8 bits per samples. **
    **---------------------------------------------------*/
    void IMG_sub_8
    (
        char * restrict imgR1,   /* Image 1 read pointer */
        char * restrict imgR2,       /* Image 2 read pointer */
        char * restrict imgW,        /* Output image pointer */
        int count                /* Number of samples in image */
    )
    {
        int i;
        long long im1_p7_p6_p5_p4_p3_p2_p1_p0, im2_p7_p6_p5_p4_p3_p2_p1_p0;
        int im1_p7_p6_p5_p4, im1_p3_p2_p1_p0, im2_p7_p6_p5_p4, im2_p3_p2_p1_p0;
        int res_p7_p6_p5_p4, res_p3_p2_p1_p0;
        for (i = 0; i < count >> 4; i += 16) {
            im1_p7_p6_p5_p4_p3_p2_p1_p0 = _amem8(imgR1);
            im2_p7_p6_p5_p4_p3_p2_p1_p0 = _amem8(imgR2);
            imgR1 += 8;
            imgR2 += 8;
            im1_p3_p2_p1_p0 = _loll (im1_p7_p6_p5_p4_p3_p2_p1_p0);
            im1_p7_p6_p5_p4 = _hill (im1_p7_p6_p5_p4_p3_p2_p1_p0);
            im2_p3_p2_p1_p0 = _loll (im2_p7_p6_p5_p4_p3_p2_p1_p0);
            im2_p7_p6_p5_p4 = _hill (im2_p7_p6_p5_p4_p3_p2_p1_p0);
            res_p3_p2_p1_p0 = _sub4 (im1_p3_p2_p1_p0, im2_p3_p2_p1_p0);
            res_p7_p6_p5_p4 = _sub4 (im1_p7_p6_p5_p4, im2_p7_p6_p5_p4);
            _amem8(imgW) = _itoll (res_p7_p6_p5_p4, res_p3_p2_p1_p0);
            imgW += 8;
            im1_p7_p6_p5_p4_p3_p2_p1_p0 = _amem8(imgR1);
            im2_p7_p6_p5_p4_p3_p2_p1_p0 = _amem8(imgR2);
            imgR1 += 8;
            imgR2 += 8;
            im1_p3_p2_p1_p0 = _loll (im1_p7_p6_p5_p4_p3_p2_p1_p0);
            im1_p7_p6_p5_p4 = _hill (im1_p7_p6_p5_p4_p3_p2_p1_p0);
            im2_p3_p2_p1_p0 = _loll (im2_p7_p6_p5_p4_p3_p2_p1_p0);
            im2_p7_p6_p5_p4 = _hill (im2_p7_p6_p5_p4_p3_p2_p1_p0);
            res_p3_p2_p1_p0 = _sub4 (im1_p3_p2_p1_p0, im2_p3_p2_p1_p0);
            res_p7_p6_p5_p4 = _sub4 (im1_p7_p6_p5_p4, im2_p7_p6_p5_p4);
            _amem8(imgW) = _itoll (res_p7_p6_p5_p4, res_p3_p2_p1_p0);
            imgW += 8;
        }
    }

    I think this code can not be compiled using C compiler, because "_amem8" returns "long long &", we know that "Reference" can be used in C++ instead of C.  Could any experts tell me how to deal with it?

    Thanks.

  • I think if I can get the address returned by "_amem8",  there will work well using C.

    I mean:

    if a function named "_amem8p" can return "long long *".

    long long* p = 0;

    p = _amem8p(imgW);

    *p = _itoll (res_p7_p6_p5_p4, res_p3_p2_p1_p0);

    It works.  Unfortunately I do not find any clues.