rfc and [patch]: Unify -mfpu and .fpu handling, let .fpu toggle features

Nico Weber thakis at chromium.org
Thu Aug 14 11:16:38 PDT 2014


I'm trying to let ".fpu neon" in arm assembly enable neon instructions. For
this, I need to map the fpu name "neon" to subtarget features. The clang
driver already has logic for this, but that logic isn't available in the
assembly parser in llvm.

In fact, the list of accepted strings for the clang driver's -mfpu= and for
the assembly parser's .fpu directive are currently duplicated in both
places, and as a consequence are out of sync and don't agree with each

The attached patch adds a new file,
include/llvm/Target/ARM/ARMSubtargetCommon.h, that exposes FPU names and
their subtargets, and calls this from both the clang driver and the arm
assembly parser to get FPU names and subtarget features. It also uses this
to make the .fpu directive enable and disable subtarget features, so that
neon instructions can be used after .fpu neon (PR20447). The name-reusing
fixes various fpu name bugs, see test/MC/ARM/directive-fpu-names.s in the

One drawback is that the new ARMSubtargetCommon.cpp file is in the library
ARMCodeGen, so clang's driver now depends on ARMCodeGen, which is a bit
icky. I could make it a standalone target I suppose, but that standalone
target's cpp file depends on the ARMCodeGen target's tablegen output, so
that wouldn't be a huge win. And since the driver processes flags related
to ARMCodeGen, the dependency doesn't seem _that_ icky to me.

(There are several places in the driver that say "FIXME: this is
duplicating subtarget code", both for ARM and x86, this patch removes one
of them.)

Do folks think that this is ok as an incremental improvement than what's
currently in the tree? On the bug the suggestion was made to just duplicate
the fpu->feature mapping in two places, which would make this patch much
smaller (and which would undo the .fpu name fixes), but that seems like a
worse alternative to me.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140814/4c42f3cd/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: llvm-clang-fpu.patch
Type: application/octet-stream
Size: 16526 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140814/4c42f3cd/attachment.obj>

More information about the cfe-commits mailing list