<div>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'.<br clear="all">
</div>
<div>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.</div>

<div> </div>
<div>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.</div>

<div> </div>
<div>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.</div>

<div> </div>
<div>Thanks.</div>
<div> </div>
<div>-John</div>
<div><br>-- <br>John Thompson<br><a href="mailto:John.Thompson.JTSoftware@gmail.com">John.Thompson.JTSoftware@gmail.com</a><br><br></div>