tinycc-devel
[Top][All Lists]
Advanced

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

[Tinycc-devel] Statically computed label differences


From: Petr Skocik
Subject: [Tinycc-devel] Statically computed label differences
Date: Sun, 24 May 2020 16:52:55 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0

Hi.

In https://software.intel.com/sites/default/files/m/a/1/e/dsohowto.pdf 
Ulrich Drepper recommends static jump tables based on label offsets
rather than labels' absolute values in order to minimize relocations.

Drepper's example:

int add (int a, int b) {
    static const int offsets[] = {
        &&a0-&&a0, &&a1-&&a0, &&a2-&&a0
    };
    goto *(&&a0 + offsets[b]);
a0:
    return a + 0;
a1:
    return a + 1;
a2:
    return a + 2;
}

This doesn't work on tcc, at least not with the array being `static`
(error: initializer element is not constant).

I guess there isn't an easy fix that would make this work on tinycc's
part (without modifications to the example code)?

Thanks.

Regards,
Petr S.




reply via email to

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