[PATCH] D31220: [builtins][ARM] Select correct code fragments when compiling for Thumb1/Thum2/ARM ISA

Michal Meloun via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 27 22:23:09 PDT 2017


strejda added inline comments.


================
Comment at: lib/builtins/assembly.h:105
+#define USE_THUMB_1
+#endif
+#define DEFINE_CODE_MODE .thumb
----------------
weimingz wrote:
> compnerd wrote:
> > weimingz wrote:
> > > compnerd wrote:
> > > > Is there a reason to use this alternate macro rather than directly using `__thumb2__` and `__thumb__` and ordering the sources to prefer thumb2, thumb, arm?
> > > Sort of. For example, to check if it is Thumb1 only, we need to do
> > > #if defined(__thumb__) && !defined(__thumb2)
> > > To check if it's on ARM mode, we need to do
> > > #if defined(__arm__) && !defined(__thumb__) && !defined(__thumb2__)
> > > 
> > > So still nice to have an indirect macro.
> > Or we can do the following:
> > 
> >     #if defined(__thumb2__)
> >       ...
> >     #elif defined(__thumb__)
> >       ...
> >     #else
> >       ...
> >     #endif
> > 
> > The idea being that thumb2 is preferred, thumb1 accepted, and we fall back to ARM otherwise.  Is there something which cannot be represented that way?
> A lot of code work for both thumb2 and arm under the unified syntax.
> What we need is to specialize for thumb1.
> 
> "The idea being that thumb2 is preferred,"

Preferred? I'm afraid that we have not choice.
Thumb[1][2] must be supported by OS, ARM ISA isn't available on all CPUs. Thus so we cannot hard-force  ISA for any file...

Also interworking is slightly problematic, it needs compiler/linker support, and is slow in many cases.
By this all, I don't see any other "realistic" option that compile whole library using one ISA.



https://reviews.llvm.org/D31220





More information about the llvm-commits mailing list