🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: pl.comp.lang.asm
4 messages
4 total messages Started by arturb Sun, 03 Apr 2011 15:49
[gcc] asm register constraints
#2433
Author: arturb
Date: Sun, 03 Apr 2011 15:49
45 lines
2119 bytes
Mam drobny problem bo nie wiem jak zapisać iż pewien rejestr nie może 
być taki sam jak inny aby gcc nie optymalizowalo i powodowalo problem

A wiec mamy funkcje
(armv11
-mcpu=cortex-a8 -mfloat-abi=hard -mlittle-endian -mthumb-interwork 
-funsafe-math-optimizations -mfpu=neon
):

bool operator()( T *ptr, U oldval, U newval ) const
     {
     register int result;
     asm volatile (
	 "1: ldrexd   %%r2, [%1]         \n\t"
	    "cmp      %%r2,  %2          \n\t"
#if defined(__thumb__)
	    "itte eq                     \n\t"
#endif
	    "cmpeq    %%r3, %H2          \n\t"
	    "strexdeq %0,  %3, [%1]\n\t"
#if defined(__thumb__)
	    "clrexne"
#endif
	    : "=r" (result)
	    : "r"(ptr), "r"(oldval),"r"(newval)
	    : "r2", "r3"
	);
     return result ==0;
     }

ktora dla strexdeq nie może mieć w %0 i %3 tej samej nazwy rejestru
a gcc optymalizuje i zaowaza iz %3 jest uzyte ostatni raz w tej 
instrukcji i dla wyniku %0 przypisuje rowniez ten sam rejestr
co powoduje blad

Error: registers may not be the same -- `strexdeq r4,r4,[ip]'

Czytalem roznie howto i manual gcc ale nie moge sie dopatrzyc jak to 
ladnie rozwiazac i narzucic dodatkowy constraint a nie chec robic pseudo 
rozwiazania z dodatkowym kopiowaniem do rejestru podanego by hand.

Jak to roziwązać ?

-- 
Artur
Re: [gcc] asm register constraints
#2434
Author: Tomasz Sowa
Date: Mon, 04 Apr 2011 03:36
16 lines
1530 bytes
Dnia Sun, 03 Apr 2011 17:49:43 +0200, arturb napisał(a):

> Mam drobny problem bo nie wiem jak zapisać iż pewien rejestr nie może 
> być taki sam jak inny aby gcc nie optymalizowalo i powodowalo problem

http://gcc.gnu.org/onlinedocs/gcc/Modifiers.html#Modifiers

`&'
    Means (in a particular alternative) that this operand is an
earlyclobber operand, which is modified before the instruction is finished
using the input operands. Therefore, this operand may not lie in a register
that is used as an input operand or as part of any memory address. 

-- 
Tomek
http://www.ttmath.org
Re: [gcc] asm register constraints
#2435
Author: arturb
Date: Mon, 04 Apr 2011 10:50
6 lines
1031 bytes
W dniu 2011-04-04 05:36, Tomasz Sowa pisze:
> http://gcc.gnu.org/onlinedocs/gcc/Modifiers.html#Modifiers
>
> `&'

racja, dzieki.
Re: [gcc] asm register constraints
#2436
Author: Remek
Date: Fri, 15 Apr 2011 19:42
7 lines
968 bytes
Użytkownik "arturb" napisał:

> aby gcc nie optymalizowalo ...

Co to ma wspólnego z assemblerem?

Remek
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads