J S via llvm-dev
2019-Mar-26 23:42 UTC
[llvm-dev] Generating object files more efficiently
Thanks, Paul. How do I generate the 'as'? When I look at the bin directory , there is an llvm-as that takes llvm assembly as input but no 'as'. ________________________________ From: paul.robinson at sony.com <paul.robinson at sony.com> Sent: Tuesday, March 26, 2019 1:58 PM To: mm92126 at hotmail.com; craig.topper at gmail.com Cc: llvm-dev at lists.llvm.org Subject: RE: [llvm-dev] Generating object files more efficiently There isn't an option to specify a particular assembler. You can use `-fno-integrated-as` to tell Clang to run the `as` tool instead of trying to generate the object file itself. If you can't arrange for your target's assembler to be in the right place and named `as` then you have two choices: (1) have Clang emit assembler source with the `-S` option and run the correct assembler directly; (2) support your target more thoroughly in Clang's 'Driver' component, so that Clang knows what to do when you specify `-fno-integrated-as`. --paulr From: llvm-dev [mailto:llvm-dev-bounces at lists.llvm.org] On Behalf Of J S via llvm-dev Sent: Tuesday, March 26, 2019 4:39 PM To: Craig Topper Cc: llvm-dev at lists.llvm.org Subject: Re: [llvm-dev] Generating object files more efficiently How do I tell clang to use my target CPU's assembler instead of my host's assembler? I found the -fuse-ld option to tell it to use my linker but didn't find an option for the assembler. Thanks. ________________________________ From: llvm-dev <llvm-dev-bounces at lists.llvm.org> on behalf of Craig Topper via llvm-dev <llvm-dev at lists.llvm.org> Sent: Monday, March 25, 2019 11:37 AM To: Alec Ari Cc: llvm-dev at lists.llvm.org Subject: Re: [llvm-dev] Generating object files more efficiently There's a function in lib/Driver/ToolChains/CommonArgs.cpp called tools::getCPUName that needs to be implemented for each target to determine how to process -mcpu/-march You might be able to bypass that for testing purposes by adding "-Xclang -target-cpu -Xclang mycpu" to your driver command line. ~Craig On Mon, Mar 25, 2019 at 11:24 AM Alec Ari via llvm-dev <llvm-dev at lists.llvm.org<mailto:llvm-dev at lists.llvm.org>> wrote: Hi, XYZ is your actual architecture? Are you trolling? Alec _______________________________________________ LLVM Developers mailing list llvm-dev at lists.llvm.org<mailto:llvm-dev at lists.llvm.org> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20190326/564197d7/attachment.html>
Perhaps I misunderstood your description. When you said you wanted Clang to "use my target CPU's assembler instead of my host's assembler" it sounded to me like you already had some other (non-LLVM) assembler for your target CPU, and you wanted Clang to run that (non-LLVM) assembler. What I said previously was guided by that interpretation. But, perhaps you meant that you are seeing Clang taking the code you generate for your target, and then trying to assemble it as if it were code generated for your host. That sounds like you have not implemented all the necessary pieces of Target and MC to turn the generated code into an object file for your target. Let's try this: If you run `clang -S -target your_triple test.c` (where your_triple is the triple for your target) does it produce an assembler file (test.s) that has the proper instructions for your target? If not, then you have some work to do to make that happen. Once your assembler file looks good, if you run `clang -c -target your_triple test.s` what happens? --paulr From: J S [mailto:mm92126 at hotmail.com] Sent: Tuesday, March 26, 2019 7:42 PM To: Robinson, Paul Cc: llvm-dev at lists.llvm.org Subject: Re: [llvm-dev] Generating object files more efficiently Thanks, Paul. How do I generate the 'as'? When I look at the bin directory , there is an llvm-as that takes llvm assembly as input but no 'as'. ________________________________ From: paul.robinson at sony.com <paul.robinson at sony.com> Sent: Tuesday, March 26, 2019 1:58 PM To: mm92126 at hotmail.com; craig.topper at gmail.com Cc: llvm-dev at lists.llvm.org Subject: RE: [llvm-dev] Generating object files more efficiently There isn't an option to specify a particular assembler. You can use `-fno-integrated-as` to tell Clang to run the `as` tool instead of trying to generate the object file itself. If you can't arrange for your target's assembler to be in the right place and named `as` then you have two choices: (1) have Clang emit assembler source with the `-S` option and run the correct assembler directly; (2) support your target more thoroughly in Clang's 'Driver' component, so that Clang knows what to do when you specify `-fno-integrated-as`. --paulr From: llvm-dev [mailto:llvm-dev-bounces at lists.llvm.org] On Behalf Of J S via llvm-dev Sent: Tuesday, March 26, 2019 4:39 PM To: Craig Topper Cc: llvm-dev at lists.llvm.org Subject: Re: [llvm-dev] Generating object files more efficiently How do I tell clang to use my target CPU's assembler instead of my host's assembler? I found the -fuse-ld option to tell it to use my linker but didn't find an option for the assembler. Thanks. ________________________________ From: llvm-dev <llvm-dev-bounces at lists.llvm.org> on behalf of Craig Topper via llvm-dev <llvm-dev at lists.llvm.org> Sent: Monday, March 25, 2019 11:37 AM To: Alec Ari Cc: llvm-dev at lists.llvm.org Subject: Re: [llvm-dev] Generating object files more efficiently There's a function in lib/Driver/ToolChains/CommonArgs.cpp called tools::getCPUName that needs to be implemented for each target to determine how to process -mcpu/-march You might be able to bypass that for testing purposes by adding "-Xclang -target-cpu -Xclang mycpu" to your driver command line. ~Craig On Mon, Mar 25, 2019 at 11:24 AM Alec Ari via llvm-dev <llvm-dev at lists.llvm.org<mailto:llvm-dev at lists.llvm.org>> wrote: Hi, XYZ is your actual architecture? Are you trolling? Alec _______________________________________________ LLVM Developers mailing list llvm-dev at lists.llvm.org<mailto:llvm-dev at lists.llvm.org> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20190327/23bb90b4/attachment.html>
J S via llvm-dev
2019-Mar-27 15:56 UTC
[llvm-dev] Generating object files more efficiently
________________________________ Paul, My answers are in red. But, perhaps you meant that you are seeing Clang taking the code you generate for your target, and then trying to assemble it as if it were code generated for your host. That sounds like you have not implemented all the necessary pieces of Target and MC to turn the generated code into an object file for your target. This is what I meant Let's try this: If you run `clang –S –target your_triple test.c` (where your_triple is the triple for your target) does it produce an assembler file (test.s) that has the proper instructions for your target? Yes If not, then you have some work to do to make that happen. Once your assembler file looks good, if you run `clang –c –target your_triple test.s` what happens? For every instruction in my .s file, there is a message that says "Error: no such instruction: ...". These messages come from /usr/bin/x86_64-linux-gnu-as Also note that if I do it this way in 3 steps then the machine code looks right 1) First clang -emit-llvm test.c -o test.bc 2)Then llc -my_triple test.bc -filetype=obj 3)Then llvm-objdump test.o But I'm trying to do all this with just 1 command --paulr From: J S [mailto:mm92126 at hotmail.com] Sent: Tuesday, March 26, 2019 7:42 PM To: Robinson, Paul Cc: llvm-dev at lists.llvm.org Subject: Re: [llvm-dev] Generating object files more efficiently Thanks, Paul. How do I generate the 'as'? When I look at the bin directory , there is an llvm-as that takes llvm assembly as input but no 'as'. ________________________________ From: paul.robinson at sony.com <paul.robinson at sony.com> Sent: Tuesday, March 26, 2019 1:58 PM To: mm92126 at hotmail.com; craig.topper at gmail.com Cc: llvm-dev at lists.llvm.org Subject: RE: [llvm-dev] Generating object files more efficiently There isn't an option to specify a particular assembler. You can use `-fno-integrated-as` to tell Clang to run the `as` tool instead of trying to generate the object file itself. If you can't arrange for your target's assembler to be in the right place and named `as` then you have two choices: (1) have Clang emit assembler source with the `-S` option and run the correct assembler directly; (2) support your target more thoroughly in Clang's 'Driver' component, so that Clang knows what to do when you specify `-fno-integrated-as`. --paulr From: llvm-dev [mailto:llvm-dev-bounces at lists.llvm.org] On Behalf Of J S via llvm-dev Sent: Tuesday, March 26, 2019 4:39 PM To: Craig Topper Cc: llvm-dev at lists.llvm.org Subject: Re: [llvm-dev] Generating object files more efficiently How do I tell clang to use my target CPU's assembler instead of my host's assembler? I found the -fuse-ld option to tell it to use my linker but didn't find an option for the assembler. Thanks. ________________________________ From: llvm-dev <llvm-dev-bounces at lists.llvm.org> on behalf of Craig Topper via llvm-dev <llvm-dev at lists.llvm.org> Sent: Monday, March 25, 2019 11:37 AM To: Alec Ari Cc: llvm-dev at lists.llvm.org Subject: Re: [llvm-dev] Generating object files more efficiently There's a function in lib/Driver/ToolChains/CommonArgs.cpp called tools::getCPUName that needs to be implemented for each target to determine how to process -mcpu/-march You might be able to bypass that for testing purposes by adding "-Xclang -target-cpu -Xclang mycpu" to your driver command line. ~Craig On Mon, Mar 25, 2019 at 11:24 AM Alec Ari via llvm-dev <llvm-dev at lists.llvm.org<mailto:llvm-dev at lists.llvm.org>> wrote: Hi, XYZ is your actual architecture? Are you trolling? Alec _______________________________________________ LLVM Developers mailing list llvm-dev at lists.llvm.org<mailto:llvm-dev at lists.llvm.org> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20190327/64dbc41b/attachment.html>