From: Joshua N. <ne...@em...> - 2012-01-19 05:27:39
|
Hey Sherard, I don't know if that is the first test you have written, but I would start with the easy tests first. (see attached, if that works on this list serve) But as far as the test you would like to write based on calling conditions, you are right, the tests written are quite strict, specific, or simply there just to check compilation, and in order to write a test for something like a call, that you would need to know the underlying code, so until Borja commits his code so far you will not be able to write code for this part. For a digression, as far as the philosophy behind having very strict tests, from what I can tell is that once we have decided on a way to compile a piece of LLVM IR it should compile the same way ever time until we change code that affects it. This is a great way to catch code that directly or indirectly affects the testing IR compilation, if we somehow tweak the compilation to work better, it is ok that we fail, for at that time we check the failed code, see that it works correctly (hopefully even better) and tweak the test. Knowing this the smaller and more specific the test is, the better, for instance, write a couple test for a calling convention, each one testing a specific part of the call. I am sorry if I have written too much here, my formal training is in Biology, so I do not expect much prior knowledge from people, as I am often left out in the dark when people do not explain lots of things to the T. Anyways, about how to go about writing the tests, I would first patch clang (I don't know if patch in the repository is up to date, so I attached mine) and execute the following `clang -emit-llvm -ccc-host-triple avr -Os -S -o - scratch.c`, this will emit LLVM IR based on scratch.c so you know what valid IR to use, then use llc to compile this IR into assembly `llc -march=avr arithmetic_instruction_selection.ll -o -` (this you will need the actual backend code, I am currently using my own avr backend code) If it outputs correct assembly, write the test to conform to this output, if not. figure out why it does not and let us know or help fix it. Anyways, I hope this helps, that you get my attached files and do not take offense. Joshua Joshua Nedrud Master of Science, Biomedical Engineering Example, if the attached files do not send: ; RUN: llc < %s -march=avr | FileCheck %s define signext i8 @add8rr(i8 signext %a, i8 signext %b) nounwind readnone optsize { %1 = add i8 %a, %b ret i8 %1 } ; CHECK: add8rr: ; CHECK: ADD This test checks for the function definition add8rr, and then checks if the assembly instruction ADD follows this, which it should for this is about the simplest LLVM IR function you can get when run with -Os optimizations. |