My name is Isaac. I emailed this mailing list a couple years ago because I was working on an ARM specific target optimization for my thesis, and had questions about moving instructions and properly migrating kill flags. I have managed to get that working properly, and I now have a complete optimization that I wish to test. My question is simply this: Is there any established way to inject ARM assembly code into LLVM such that the ASM you inject has the target-specific optimizations performed on it? In other words, I'm looking for a way to do "ARM ASM test case" -> "LLVM target optimization" -> "optimized ARM ASM." The reason I'm trying to do this is because the specific case I'm optimizing against is proving difficult to generate using C code source files. The optimization requires a particular combination of memory instructions to be present in order to work. I've also tried using asm() C calls to force a specific assembly pattern, but LLVM appears to treat the asm() call like a single atomic block that does not have the optimizer run on its member instructions. I am sure that development on some of the target optimizations for LLVM required some very specific sequences of instructions to be present that might be difficult to generate using C code or even LLVM bitcode. What tools exist to make this testing process easier for developers? Is there some way to run target ASM optimizations using ASM input? Thanks for your time, Isaac Asay P.S.: In case you want more details, I asked a Stack Overflow question on this issue and was referred back to this mail list: http://stackoverflow.com/questions/6084052/testing-a-code-generator-optimization -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20121209/aba7ecc6/attachment.html>
Renato Golin
2012-Dec-10 11:50 UTC
[LLVMdev] Testing Target Optimization via ASM Injection
On 10 December 2012 03:00, Isaac Asay <iasay at calpoly.edu> wrote:> I've also tried using asm() C calls to force a > specific assembly pattern, but LLVM appears to treat the asm() call like a > single atomic block that does not have the optimizer run on its member > instructions.Hi Isaac, AFAIK, inline assembly is only exported at the end and it's generally kept intact, since the compiler has no way to know whether you wanted all the side effects of your hand-coded assembly or not. Also, most LLVM optimizations run on IR, not assembly, so by writing it ASM, you lose most of the power of LLVM. Even if there is a way to enable the compiler to change your inline ASM, the improvements would be very limited. -- cheers, --renato http://systemcall.org/
Hi Renato, Thanks for the response. While it is true that creating an IR optimization gives a better return due to it being applicable to any target ASM, there are also a lot of target specific optimizations that devs have felt are worthwhile enough to create, such as the ARMLoadStoreOptimizer.cpp file which contains ARM specific ASM optimizations. So I know that target specific optimizations are being created and tested, and since I've already gone and created the target specific optimization I'd like to be able to validate that it's working as expected in different test cases. What I'm really looking for is a set of tools to make it easier to generate specific ASM test cases, which I presume must exist somewhere since similar ARM optimizations have been created/tested before. Thanks, Isaac On Mon, Dec 10, 2012 at 3:50 AM, Renato Golin <rengolin at systemcall.org>wrote:> On 10 December 2012 03:00, Isaac Asay <iasay at calpoly.edu> wrote: > > I've also tried using asm() C calls to force a > > specific assembly pattern, but LLVM appears to treat the asm() call like > a > > single atomic block that does not have the optimizer run on its member > > instructions. > > Hi Isaac, > > AFAIK, inline assembly is only exported at the end and it's generally > kept intact, since the compiler has no way to know whether you wanted > all the side effects of your hand-coded assembly or not. > > Also, most LLVM optimizations run on IR, not assembly, so by writing > it ASM, you lose most of the power of LLVM. Even if there is a way to > enable the compiler to change your inline ASM, the improvements would > be very limited. > > > -- > cheers, > --renato > > http://systemcall.org/ >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20121218/736df189/attachment.html>