[LLVMdev] IAS and inline assembly
Daniel Sanders
Daniel.Sanders at imgtec.com
Fri Feb 21 09:37:29 PST 2014
There was another option mentioned on the gcc mailing list:
Pass comments through to the output. The current behaviour is to remove them.
I prefer either 'continuing with the current behaviour' or 'current behaviour but report parse errors as warnings for -S'. I'd prefer the former of these two but I'm pushed away from that position by the fact that gas and IAS development aren't synchronised. Sometimes gas will support an instruction set that IAS hasn't implemented yet and I can imagine autoconf/cmake/etc. build systems using 'clang -S' and 'as' together even when the IAS is enabled by default. Ideally, we'd like a diagnostic to encourage bug reports for things we missed, but equally the user also doesn't want the build to fail due to deficiencies in IAS if gas is going to be the one to assemble it.
Regarding the Linux kernel's use of inline assembly for arbitrary text. My starting position at least is that inline assembly is intended for valid assembly text. We could support near-arbitrary text without sacrificing that position by passing comments through to the assembly output. The kernel would have to add the comment characters (which vary between targets) and remove them again in its post-processing though.
> -----Original Message-----
> From: llvmdev-bounces at cs.uiuc.edu [mailto:llvmdev-bounces at cs.uiuc.edu]
> On Behalf Of Rafael EspĂndola
> Sent: 21 February 2014 16:30
> To: Saleem Abdulrasool
> Cc: LLVM Developers Mailing List
> Subject: Re: [LLVMdev] IAS and inline assembly
>
> On 21 February 2014 11:22, Saleem Abdulrasool <compnerd at compnerd.org>
> wrote:
> > (Sorry about the duplicate, I got the mailing list address incorrect
> > the first time around).
> >
> > While working on the IAS, I ran into a behavioural difference between
> > GCC and clang.
> >
> > The Linux Kernel relies on GCC's acceptance of inline assembly as an
> > opaque object which will not have any validation performed on the
> > content. The current behaviour in LLVM is to perform validation of
> > the contents by means of parsing the input if the MC layer can handle it.
> >
> > When compiling to an object file, this distinction is unimportant
> > since the assembler will have to parse the content anyways. However,
> > the case where the emission is an assembly file (as used by the Linux
> > kernel) is something which needs to be discussed.
> >
> > The current options include:
> > - continuing with the current behaviour (the user can disable the IAS
> > even when assembling (-S) if necessary
> > - behaving more like GCC and disabling the validation
> > - introducing a new flag (-W{no-,}inline-asm-syntax ?) to control the
> > behaviour
> > - relaxing all errors to warnings
> >
> > Personally, I think that the LLVM model is better since it allows for
> > earlier diagnosis of errors. But, I am torn between options 1 and 3
> > and could be easily convinced that either is better.
> >
> > This is sufficiently controversial that it deserves a separate thread
> > of conversation.
> >
> > Thanks!
>
> My preference is also for the first option. The files we reject now with -S are
> the ones we used to reject with -c. We just ask for "-S -no-integrated-as" to
> be used when a file contains invalid inline assembly. If that is too strict to
> work in practice, I think the alternatives I would prefer would be
>
> * Have the driver pass -no-integrated-as when given -S but not -integrated-
> as. That is, -no-integrated-as is always the default for -S in clang. This has the
> big advantage that parsing assembly is still just a on/off switch.
> * Have a second TargetOption: StrictIntegratedAS. Have the driver set that
> based on -S/-c and -integrated-as/-no-integrated-as. With this option we
> downgrade assembly parsing errors to warnings and fallback to EmitRawText,
> but without ever calling hasRawTextSupport. I believe this is equivalent to
> Renato's proposal.
>
> Even if we decide to go with the option of downgrading errors to warnings,
> we should probably still do that in a second step and first just have the driver
> disable the integrated assembler with -S for now.
>
> Cheers,
> Rafael
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
More information about the llvm-dev
mailing list