From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Re: Forcing GNAT to use 32-bit load/store instructions on ARM? Date: Tue, 01 Jul 2014 18:18:10 +0100 Organization: A noiseless patient Spider Message-ID: References: <0e0b9ac2-e793-4cc5-8d8d-d3441ca28a58@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: mx05.eternal-september.org; posting-host="117da9042fa4d6f5956a9b8f72035635"; logging-data="20023"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX197hMmJ+7WXXGXuxQVslWVX5FgavOw0BIo=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (darwin) Cancel-Lock: sha1:CpUMZlpE8Z9R9xjf0odcCSwVe1g= sha1:3gtTt8dx+mqG45th/spAz/7f7qA= Xref: news.eternal-september.org comp.lang.ada:20667 Date: 2014-07-01T18:18:10+01:00 List-Id: Simon Clubley writes: > On 2014-06-30, Jeffrey Carter wrote: >> On 06/30/2014 03:11 PM, daniel.dmk@googlemail.com wrote: >>> >>> Does anyone know how I can force GNAT to generate the appropriate >>> instructions? >> >> If you need specific machine instructions, you should use a >> machine-code insertion. >> > > The issue here is that Pragma Atomic should have given him the guarantee > he needs. > > There is a place for specific assembly language insertions (for example, > on ARM when you need to access the CPSR register), but that should not > be required here. Just for fun I tried this on Intel (x86_64) with GNAT GPL 2014 and GCC 4.9.0 on this: procedure Atom is type R is record A : Boolean; B : Boolean; end record with Size => 32; for R use record A at 0 range 0 .. 0; B at 0 range 31 .. 31; end record; V : R with Atomic, Import, Convention => C, External_Name => "foo"; begin V := (A => True, B => True); V.A := False; end Atom; and found that the compiler did a reaonable thing: movl _T3b.2569(%rip), %edx movq _foo@GOTPCREL(%rip), %rax movl %edx, (%rax) mfence movq _foo@GOTPCREL(%rip), %rax movl (%rax), %edx andl $-2, %edx movl %edx, (%rax) .const .align 2 _T3b.2569: .byte 1 .space 2 .byte 128