Article View: pl.comp.lang.asm
Article #2433[gcc] asm register constraints
From: arturb
Date: Sun, 03 Apr 2011 15:49
Date: Sun, 03 Apr 2011 15:49
45 lines
2119 bytes
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
Technical Details
Message-ID:
<ina500$5n2$1@news.task.gda.pl>Path:
mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.gazeta.pl!newsfeed.pionier.net.pl!news.task.gda.pl!not-for-mailShow Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.gazeta.pl!newsfeed.pionier.net.pl!news.task.gda.pl!not-for-mail From: arturb <artur@nospam.ebasoft.com.pl> Newsgroups: pl.comp.lang.asm Subject: [gcc] asm register constraints Date: Sun, 03 Apr 2011 17:49:43 +0200 Organization: CI TASK http://www.task.gda.pl/ Lines: 45 Message-ID: <ina500$5n2$1@news.task.gda.pl> NNTP-Posting-Host: sql.ebasoft.com.pl Mime-Version: 1.0 X-Trace: news.task.gda.pl 1301845824 5858 85.237.185.105 (3 Apr 2011 15:50:24 GMT) X-Complaints-To: abuse@news.task.gda.pl NNTP-Posting-Date: Sun, 3 Apr 2011 15:50:24 +0000 (UTC) User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; pl; rv:1.9.2.15) Gecko/20110303 Thunderbird/3.1.9 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit