[cfe-commits] [PATCH] Asm multiple alternative constraints revisited

John Thompson john.thompson.jtsoftware at gmail.com
Wed Aug 4 12:06:12 PDT 2010


To try and find out what the LLVM backend does with constraints I traced
both llvm-as and llc in a debugger, following an inline asm statement.  It
appears that the constraints get passed effectively unchanged through
llvm-asm, and that in llc, the ChooseConstraint function in
CodeGen/SelectionDAG/TargetLowering.cpp is a key part of the handling.  It
appears that ChooseConstraint already has support for selecting from
multiple contraints to some extent, and that it expects them to be
concatenated without the comma and other modifiers, and looks at them
character by character for a given constraint string.  There's not much
support for architecture-specific constraints, but it does seem to try to
select from between at least 'r' and 'm'.
Therefore, it seems that the first step to the solution is to get Clang to
output multiple alternative constraints in the form that llc expects.  The
enclosed patch does this by removing the commas and modifiers not currently
supported in LLVM, and also removing duplicate alternative constraints on a
per-constraint string basis.  I've also added a minimal test to one of the
asm test files.

The next steps would be to start adding support for all the constraint
letters, both the generic and architecture-specific ones that make sense,
but I'll probably leave that until after my work on the front end issues I'm
encountering while compiling a PS3 game, or even better, to others
specializing on the back-end targets.

I know that inline asm is a problematic bit of legacy, but it's pretty
important for clients like Sony that have huge existing code bases they want
to run through Clang code analysis, and eventually even production building.

Thanks.

-John

-- 
John Thompson
John.Thompson.JTSoftware at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20100804/c3131c98/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: multaltconstraints2.patch
Type: application/octet-stream
Size: 3480 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20100804/c3131c98/attachment.obj>


More information about the cfe-commits mailing list