[LLVMdev] ARM ELF target and the use of VFP/NEON instructions

Siarhei Siamashka siarhei.siamashka at gmail.com
Fri Feb 25 12:55:20 PST 2011


On Friday 25 February 2011 22:28:14 Jason Kim wrote:
> On Fri, Feb 25, 2011 at 12:16 PM, Siarhei Siamashka
> 
> <siarhei.siamashka at gmail.com> wrote:
> > On Thursday 03 February 2011 14:14:28 Renato Golin wrote:
> >> On 3 February 2011 10:25, Siarhei Siamashka
> >> <siarhei.siamashka at gmail.com>
> > 
> > wrote:
> >> > I have submitted a bug some time ago to LLVM bugtracker:
> >> > http://llvm.org/bugs/show_bug.cgi?id=8931
> >> 
> >> Hi Siarhei,
> >> 
> >> This is a really silly bug with a simple fix.
> >> 
> >> We have a similar patch here locally, but as this is part of another
> >> set of patches we were waiting for it to stabilise. There are some
> >> other build attributes that need to be set when you're using NEON or
> >> VFP, but I'll try to get them working without any other modification
> >> as a clean cut patch.
> >> 
> >> I'll round it up and submit the patch. Thanks for reminding about it.
> > 
> > Hi Renato,
> > 
> > I noticed that support for some elf eabi attributes has been added to
> > LLVM and it is a good progress. But still this is insufficient.
> > 
> > Now with the schedule for 2.9 available, would it be possible to resolve
> > this missing ".fpu" directive issue for 2.9 release in order to have
> > clang working on ARM linux systems out of the box without patching?
> 
> Hi Siarhei,
> 
> if you can get us the sequence of attributes you want emitted for each fpu
> type, and what you expect to see on the .o side, it should be very
> possible to get that squared away for the release.

The elf attributes and cpu/fpu type directives are a bit different things. The
former are the extra information in .o files to be used by static or dynamic
linker. The latter are the directives to assembler, and if you don't specify
the right cpu/fpu type, the assembly code is rejected by gnu assembler and
no .o file is generated at all. Currently LLVM emits ".cpu" directive, but
totally forgets about ".fpu", and this causes problems.

My proposed patch is available in LLVM bug 8931, and I'm also pasting it here
for more convenience:

Index: lib/Target/ARM/ARMAsmPrinter.cpp
===================================================================
--- lib/Target/ARM/ARMAsmPrinter.cpp    (revision 123053)
+++ lib/Target/ARM/ARMAsmPrinter.cpp    (working copy)
@@ -458,7 +458,13 @@
     AttrEmitter->EmitAttribute(ARMBuildAttrs::THUMB_ISA_use, 1);
   }
 
-  // FIXME: Emit FPU type
+  if (Subtarget->hasNEON())
+    OutStreamer.EmitRawText(StringRef("\t.fpu neon"));
+  else if (Subtarget->hasVFP3())
+    OutStreamer.EmitRawText(StringRef("\t.fpu vfpv3"));
+  else if (Subtarget->hasVFP2())
+    OutStreamer.EmitRawText(StringRef("\t.fpu vfpv2"));
+
   if (Subtarget->hasVFP2())
     AttrEmitter->EmitAttribute(ARMBuildAttrs::VFP_arch, 2);

It does not matter if you use this particular code or some other variant, but
please just fix it somehow :)

-- 
Best regards,
Siarhei Siamashka



More information about the llvm-dev mailing list