[llvm-dev] Generating object files more efficiently

via llvm-dev llvm-dev at lists.llvm.org
Wed Mar 27 09:49:43 PDT 2019


I see that in your first command, you don't supply the triple:

1) First clang -emit-llvm test.c -o test.bc
but you do supply it in the second command:

2)Then llc -my_triple test.bc -filetype=obj
Is this an oversight, or have you been omitting the triple when you run Clang?
Do I understand correctly that when you do "clang -target my_triple -c test.c" then the wrong things happen?

If the wrong things happen when you give Clang your triple, that suggests that you have the LLVM part hooked up correctly for your target but not the Clang part. Clang, separately from LLVM, needs to know some things about your triple and pass information down to LLVM. This is partly in the Basic and partly in the Driver libraries within Clang.  I've never personally added a new target so I am fuzzy on the details, but if you start looking around in those areas you will probably get a better idea of what is needed.
--paulr

From: J S [mailto:mm92126 at hotmail.com]
Sent: Wednesday, March 27, 2019 11:56 AM
To: Robinson, Paul
Cc: llvm-dev at lists.llvm.org
Subject: Re: [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/a782b6e6/attachment.html>


More information about the llvm-dev mailing list