clangupc / upc2c

Clang based UPC to C Translator
https://clangupc.github.io/clang-upc2c
Other
4 stars 3 forks source link

Alternative PTS-to-Integer conversion using upc_addrfield() #80

Closed PHHargrove closed 10 years ago

PHHargrove commented 10 years ago

This commit implements conversion from pointer-to-shared to integral types using the UPCR functions for implementing upc_addrfield().

The previous code, which produced: upcr_pshared_ptr_t _bupc_spilld0; upcr_shared_ptr_t _bupc_spilld1; int p = (_bupc_spilld0 = x , (int )&_bupc_spilld0); int q = (_bupc_spilld1 = x , (int )&_bupc_spilld1); which may return different portions of the PTS on little-vs-big endian systems, and may not return the same values for two pointers to the same object!

The new code produces int p = (int)upcr_addrfield_pshared(x); int y = (int)upcr_addrfield_shared(y);

swatanabe commented 10 years ago

On 03/14/2014 02:43 AM, Paul H. Hargrove wrote:

This commit implements conversion from pointer-to-shared to integral types using the UPCR functions for implementing upc_addrfield().

The previous code, which produced: upcr_pshared_ptr_t _bupc_spilld0; upcr_shared_ptr_t _bupc_spilld1; int p = (_bupc_spilld0 = x , (int )&_bupc_spilld0); int q = (_bupc_spilld1 = x , (int )&_bupc_spilld1); which may return different portions of the PTS on little-vs-big endian systems, and may not return the same values for two pointers to the same object!

FWIW, I copied this behavior from the berkeley translator.

PHHargrove commented 10 years ago

FWIW, I copied this behavior from the berkeley translator.

Where it is not desirable either, just much harder to change :-(

If you look at BUPC bug #349 you will see that the Berkeley translator currently uses a different conversion for return of a PTS as a long or long long.

swatanabe commented 10 years ago

On 03/14/2014 02:07 PM, Paul H. Hargrove wrote:

FWIW, I copied this behavior from the berkeley translator.

Where it is not desirable either, just much harder to change :-(

Okay. In that case, this change looks good. Please commit it to master.