On 7/23/14, 3:30 PM, Tim Northover wrote: [...]> It looks like it's a case of calling Module::setTargetTriple. As with > most JIT setup questions, though, often the best way to find out is to > get something working in lli and then look at what it does > (tools/lli/lli.cpp).Well, it's *almost* working --- hardfloat code is now being generated, and it even seems to be right most of the time! Unfortunately it looks like it's getting calling conventions wrong. This IR code: define void @Entrypoint(float %in, float* %out) { store float %in, float* %out } ...gets compiled to this: STRi12 %R0<kill>, %R1<kill>, 0, pred:14, pred:%noreg; mem:ST4[%out] BX_RET pred:14, pred:%noreg (typed by hand, so may contain typos). So it looks like it's assuming that float parameters are being passed in integer registers, which isn't the case on armhf. Could it be under the impression that I'm running on an armel system? In which case the above code is correct. This would explain why the default setting appears to generate armel code. Is this controllable? -- ┌─── dg@cowlark.com ───── http://www.cowlark.com ───── │ "Feminism encourages women to leave their husbands, kill their │ children, practice withcraft, destroy capitalism and become lesbians." │ --- Rev. Pat Robertson -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 876 bytes Desc: OpenPGP digital signature URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140723/f824b31c/attachment.sig>
> Well, it's *almost* working --- hardfloat code is now being generated, > and it even seems to be right most of the time!OK, so that's probably coming from the default parameters in the armv7/thumbv7 part of the triple. An alternative would have been setting the CPU type manually.> Unfortunately it looks like it's getting calling conventions wrong. This > IR code:Which triple are you using? And is the correct code used when you run the same IR through "llc -mtriple=whatever"? Finally, which version of LLVM are you using? Newer is better, LLVM changes very quickly and we have been working on improving various defaults to make it easier to use.> Could it be under the impression that I'm running on an armel system? In > which case the above code is correct. This would explain why the default > setting appears to generate armel code. Is this controllable?It ought to be the environment part of the triple that controls it: eabihf or gnueabihf, for example. Did you try setting a breakpoint in that function I mentioned and finding out just which test fails on the path to returning AAPCS_VFP? Cheers. Tim.
On 7/24/14, 7:18 AM, Tim Northover wrote: [...]> Which triple are you using? And is the correct code used when you run > the same IR through "llc -mtriple=whatever"?armv7-linux-gnueabihf, as suggested; and if I use llc -mtriple then the code compiles to: vstr s0, [r0] bx lr ...which I would consider correct. (What's more interesting is *without* specifying the triple llc generates armel code. Should llc default to generating code which will actually run on a given platform? Is it possible my version of llvm has been compiled with the wrong options? clang generates correct code, but it looks like it's not going via llc.)> Finally, which version of LLVM are you using?llvm-3.5, as supplied by Debian. [...]> It ought to be the environment part of the triple that controls it: > eabihf or gnueabihf, for example.Does the system support linking together multiple modules with different triples? Since my function is externally visible, is it deliberately using the armel calling convention because it thinks it's being called from code where my triple doesn't apply? Should I be setting the triple on the execution engine as a whole (which I've avoided so far because the API looks painful)? [...]> Did you try setting a breakpoint in that function I mentioned and > finding out just which test fails on the path to returning AAPCS_VFP?No; I don't have a debugger on this platform. -- ┌─── dg@cowlark.com ───── http://www.cowlark.com ───── │ "Feminism encourages women to leave their husbands, kill their │ children, practice withcraft, destroy capitalism and become lesbians." │ --- Rev. Pat Robertson -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 876 bytes Desc: OpenPGP digital signature URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140724/a93136d2/attachment.sig>