David Peixotto
2011-Oct-22 14:03 UTC
[LLVMdev] Codgen for popcnt intrinsic falls over on MacOSX
I'm having a problem with the code generated for the popcnt intrinsic on MacOSX. The `llc` program will generate the assembly just fine, but the assembler fails with the error: suffix or operands invalid for `popcnt' The problem is that the mac assembler does not support length suffixes on the popcnt instruction (e.g. {w,l,q} suffixes). GCC handles this by not adding the suffixes to popcnt for darwin targets [1]. Indeed if I change the instruction definition in lib/Target/X86/X86InstrSSE.td to drop the suffix, then it works fine. I can submit a patch to that effect, but what is the proper way to handle this? [1]: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34497#c14
Bruno Cardoso Lopes
2011-Oct-23 00:19 UTC
[LLVMdev] Codgen for popcnt intrinsic falls over on MacOSX
Hi, On Sat, Oct 22, 2011 at 12:03 PM, David Peixotto <dmp at rice.edu> wrote:> I'm having a problem with the code generated for the popcnt intrinsic on MacOSX. The `llc` program will generate the assembly just fine, but the assembler fails with the error: > > suffix or operands invalid for `popcnt' > > The problem is that the mac assembler does not support length suffixes on the popcnt instruction (e.g. {w,l,q} suffixes). GCC handles this by not adding the suffixes to popcnt for darwin targets [1]. > > Indeed if I change the instruction definition in lib/Target/X86/X86InstrSSE.td to drop the suffix, then it works fine. I can submit a patch to that effect, but what is the proper way to handle this? > > [1]: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34497#c14 > _______________________________________________Have you tried "llc -filetype=obj ..."? The integrated assembler may do the work! -- Bruno Cardoso Lopes http://www.brunocardoso.cc
David Peixotto
2011-Oct-24 14:43 UTC
[LLVMdev] Codgen for popcnt intrinsic falls over on MacOSX
On Oct 22, 2011, at 7:19 PM, Bruno Cardoso Lopes wrote:> Hi, > > On Sat, Oct 22, 2011 at 12:03 PM, David Peixotto <dmp at rice.edu> wrote: >> I'm having a problem with the code generated for the popcnt intrinsic on MacOSX. The `llc` program will generate the assembly just fine, but the assembler fails with the error: >> >> suffix or operands invalid for `popcnt' >> >> The problem is that the mac assembler does not support length suffixes on the popcnt instruction (e.g. {w,l,q} suffixes). GCC handles this by not adding the suffixes to popcnt for darwin targets [1]. >> >> Indeed if I change the instruction definition in lib/Target/X86/X86InstrSSE.td to drop the suffix, then it works fine. I can submit a patch to that effect, but what is the proper way to handle this? >> >> [1]: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34497#c14 >> _______________________________________________ > > Have you tried "llc -filetype=obj ..."? The integrated assembler may > do the work!Yes, I believe the integrated assembler gets it right, but unfortunately I'm using a toolchain that needs to use the mac assembler so I'd like to get it working with that if possible. Removing the suffix seems to work ok, I just need to know if it needs to be done conditionally for mac os x to get the patch accepted, and if so how to do that.