Dale,<br><br>Thanks for reviewing this.<br><br>I have some newbie questions regarding the test-suite for you or anyone:<br><br>I'm trying to run the test-suite as described in the "LLVM Testing Infrastructure Guide" on a Ubuntu x86 64 bit system.  Initially I ran into problems with missing tools like yacc, which I fixed as I went along until the make at the test-suite level completed.  However, I get a number of failed tests:<br>
<br>john@john-ubuntu:~/llvm/projects/test-suite$ grep FAILED\! jttestlog.txt<br>******************** TEST (jit) 'tls' FAILED! ********************<br>******************** TEST (llc) 'initp1' FAILED! ********************<br>
******************** TEST (cbe) 'initp1' FAILED! ********************<br>******************** TEST (cbe) 'ctor_dtor_count-2' FAILED! ********************<br>******************** TEST (cbe) 'ctor_dtor_count' FAILED! ********************<br>
******************** TEST (cbe) 'exception_spec_test' FAILED! ********************<br>******************** TEST (cbe) 'function_try_block' FAILED! ********************<br>******************** TEST (cbe) 'simple_rethrow' FAILED! ********************<br>
******************** TEST (cbe) 'simple_throw' FAILED! ********************<br>******************** TEST (cbe) 'throw_rethrow_test' FAILED! ********************<br>******************** TEST (jit) 'ctor_dtor_count-2' FAILED! ********************<br>
******************** TEST (jit) 'ctor_dtor_count' FAILED! ********************<br>******************** TEST (jit) 'exception_spec_test' FAILED! ********************<br>******************** TEST (jit) 'function_try_block' FAILED! ********************<br>
******************** TEST (jit) 'simple_rethrow' FAILED! ********************<br>******************** TEST (jit) 'simple_throw' FAILED! ********************<br>******************** TEST (jit) 'throw_rethrow_test' FAILED! ********************<br>
******************** TEST (cbe) '2004-03-15-IndirectGoto' FAILED! ********************<br>******************** TEST (cbe) 'except' FAILED! ********************<br>******************** TEST (jit) 'except' FAILED! ********************<br>
******************** TEST (cbe) 'bigfib' FAILED! ********************<br>******************** TEST (llc) 'spirit' FAILED! ********************<br>******************** TEST (cbe) 'spirit' FAILED! ********************<br>
******************** TEST (jit) 'spirit' FAILED! ********************<br>******************** TEST (cbe) 'burg' FAILED! ********************<br>******************** TEST (cbe) 'sgefa' FAILED! ********************<br>
******************** TEST (cbe) 'make_dparser' FAILED! ********************<br>******************** TEST (jit) 'spiff' FAILED! ********************<br>******************** TEST (cbe) 'oggenc' FAILED! ********************<br>
******************** TEST (cbe) 'lencod' FAILED! ********************<br>******************** TEST (cbe) 'SIBsim4' FAILED! ********************<br>******************** TEST (llc) 'clamscan' FAILED! ********************<br>
******************** TEST (cbe) 'clamscan' FAILED! ********************<br>******************** TEST (jit) 'clamscan' FAILED! ********************<br>******************** TEST (cbe) 'sqlite3' FAILED! ********************<br>
******************** TEST (jit) 'lemon' FAILED! ********************<br>******************** TEST (cbe) 'OpenSSL' FAILED! ********************<br>******************** TEST (jit) 'OpenSSL' FAILED! ********************<br>
******************** TEST (cbe) 'minisat' FAILED! ********************<br>******************** TEST (jit) 'minisat' FAILED! ********************<br>******************** TEST (cbe) 'lua' FAILED! ********************<br>
******************** TEST (cbe) 'Obsequi' FAILED! ********************<br>******************** TEST (cbe) 'kc' FAILED! ********************<br>******************** TEST (cbe) 'fhourstones3.1' FAILED! ********************<br>
******************** TEST (cbe) 'bh' FAILED! ********************<br>******************** TEST (cbe) 'health' FAILED! ********************<br>******************** TEST (cbe) 'cfrac' FAILED! ********************<br>
******************** TEST (cbe) 'espresso' FAILED! ********************<br>******************** TEST (cbe) 'gs' FAILED! ********************<br>******************** TEST (cbe) 'agrep' FAILED! ********************<br>
******************** TEST (cbe) 'archie' FAILED! ********************<br>******************** TEST (cbe) 'unix-smail' FAILED! ********************<br>******************** TEST (cbe) 'rawcaudio' FAILED! ********************<br>
******************** TEST (cbe) 'rawdaudio' FAILED! ********************<br>******************** TEST (cbe) 'encode' FAILED! ********************<br>******************** TEST (cbe) 'mpeg2decode' FAILED! ********************<br>
******************** TEST (cbe) 'consumer-lame' FAILED! ********************<br>******************** TEST (cbe) 'consumer-typeset' FAILED! ********************<br>******************** TEST (cbe) 'office-ispell' FAILED! ********************<br>
******************** TEST (cbe) 'telecomm-fft' FAILED! ********************<br>******************** TEST (cbe) 'enc-3des' FAILED! ********************<br>******************** TEST (cbe) 'enc-pc1' FAILED! ********************<br>
******************** TEST (cbe) 'enc-rc4' FAILED! ********************<br>******************** TEST (cbe) 'tramp3d-v4' FAILED! ********************<br>******************** TEST (cbe) 'bullet' FAILED! ********************<br>
<br>At this point I'm not sure if its because I'm still missing tools, these errors are expected on this platform, or there's some problem with my tree.  Any suggestions?<br><br>-John<br><br><div class="gmail_quote">
On Thu, Aug 26, 2010 at 7:23 PM, Dale Johannesen <span dir="ltr"><<a href="mailto:dalej@apple.com">dalej@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div class="im"><br>
On Aug 25, 2010, at 12:45 PM, John Thompson wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Hi,<br>
<br>
I'm looking for some feedback on the changes represented in the attached patches, which I'll describe below.<br>
<br>
I'm sending this to both the LLVM and Clang list because it affects both, though the main focus here is LLVM.<br>
Basically, I've partially implemented some changes for choosing multiple alternative constraints largely on the LLVM side.<br>
<br>
The Clang change is to output the multiple constraints using a '|' character in the constraint strings to delimit the alternatives.<br>
</blockquote>
<br></div>
This part is simple, and it can't be worse than it is now.<div class="im"><br>
<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
The LLVM change is as follows.<br>
<br>
In an earlier attempt, I just hacked up SelectionDAGBuilder::visitInlineAsm, and pretty much used the same logic in TargetLowering::ComputeConstraintToUse/ChooseConstraint.  But then I discovered that InlineAsm::ParseConstraints was called in a couple of other places, and in one of those places (IsOperandAMemoryOperand in AddrModeMatcher.cpp), there wasn't a DAG pointer handy (at least I don't think there is, as I'm not too familiar yet with LLVM internals), which meant that I needed to handle multiple alternative constraints in other places besides just SelectionDAGBuilder::visitInlineAsm.<br>

</blockquote>
<br></div>
That's too bad, I didn't know about the AddrModeMatcher reference.  I don't see a DAG pointer either; it seems to be an argument in some places.  Regardless,  unifying the three loops that do pretty much the same thing is surely a good idea.<div class="im">
<br>
<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
 Basically I see that there are three layers of contraint info classes, SDISelAsmOperandInfo -> AsmOperandInfo -> ConstraintInfo.  Therefore, I implemented a different scheme, putting a ParseConstraints function in TargetLowering that returns a vector of AsmOperandInfo objects, and which will do the constraint selection without needing the DAG.  I'm assuming the value info in the operands from the callsite object is sufficient to choose the constraints.  I also added some other virtual functions to TargetLowering to allow the different targets to handle the target-specific contraints.  At present, I only overrode the getSingleConstraintMatchWeight function in X86TargetLowering, and just for one constraint letter, as an example.<br>

<br>
In the three places where the original InlineAsm::ParseConstraints was called (CodeGenPrepare.cpp, AddrModeMatcher.cpp, and SelectionDAGBuilder), I replaced the calls with calls to TargetLowering::ParseConstraints, and revised the loops over the constraints accordingly, which were still needed to set up SDISelAsmOperandInfo objects or get other information the code was looking for.  SelectionDAGBuilder::visitInlineAsm I especially reordered bit at the front, to make things work.  I left in a little bit of overlap in the setting of the CallOperandVal member in the first for loop, which I could factor out, as I really just need the output and input counts.<br>

<br>
Bascially, I wanted to get some feedback before I went too much farther down this road.<br>
</blockquote>
<br></div>
I don't have that good a sense of good class design, but this looks OK to me.<div class="im"><br>
<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
I think the main work left is to add support for all or some subset of both the generic and target-specific constraints, and to write tests for them all.<br>
<br>
Since I had trouble with running tests on a Windows box, I set up a Linux box so I could run the regression tests.  The tests still pass with these changes.<br>
</blockquote>
<br></div>
Those tests don't include any for multiple alternative constraints, since the expectation is the llvm-gcc FE will have removed them.  You should really run the gcc testsuite as well; that's a much better test of inline asm.  If you get this working right there should be some new passes.  I'm not sure how to run it using clang as the compiler, but I think Daniel got it to work.<div class="im">
<br>
<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
So, my main question is, am I on the right track?  And either way, specific information on problems would be appreciated too.<br>
<br>
Another question concerns the weighting I used for choosing the constraints.  Bascially I pretty much used the same prioritization used in TargetLowering::ComputeConstraintToUse/ChooseConstraint, which will chose memory operands over register.  I would have thought a register operand would have been a better choice over memory, but then that raises the question of whether you can know what's already in a register when this instruction is reached.  I haven't gotten deep enough to know yet.  I assume it's like this because it is more likely to be a correct fit, if not optimal.<br>

</blockquote>
<br></div>
I think it's that it's possible to run out of registers if you pick "r" for a large number of "rm" constraints.  This mainly affects asm blocks, where you have hundreds of lines of asm in a single statement.<div class="im">
<br>
<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
It seems that if the value info in the operands from the callsite object is sufficient to choose the constraints, the ComputeConstraintToUse/ChooseConstraint function could also use this scheme, probably just calling the same get weight functions, to be a bit more efficient.  I left it alone for now, because I know it works as it is.<br>

</blockquote>
<br></div>
Thanks for working on this.<br>
<br>
<br>
</blockquote></div><br><br clear="all"><br>-- <br>John Thompson<br><a href="mailto:John.Thompson.JTSoftware@gmail.com">John.Thompson.JTSoftware@gmail.com</a><br><br>