Monthly Archives: February 2025
LLVM Exercise VII
So why does the code produced in the last exercise contain the labels .LBB0_2 and .LBB0_3 but no .LBB0_1? Well that is because I have added a code generation pass that deletes useless jumps like: JNC .LBB0_1 .LBB0_1: Code snippets: void HP41MCODEPassConfig::addPreEmitPass() { addPass(new RemoveUselessJMP()); } … bool RemoveUselessJMP::runOnMachineBasicBlock( MachineBasicBlock &MBB, MachineBasicBlock &MBBN) { bool … Continue reading
LLVM Exercise VI
It is time to bring in some conditionals. Adding an “if” to our friend foo(): int foo() { int retval1 = 0x0AB; int retval2 = 0; if (retval2) return retval2; return retval1; } We need to implement instructions for both conditional and unconditional branches (i.e jumps). An unconditional branch is just like this (assuming no … Continue reading
LLVM Exercise V
Let us add some local variables: int foo() { int retval = 0x0AB; int dummy = 0; return retval; } This requires adding some information about accessing memory. I will just postulate that I have memory available from address 1 growing upwards. As anyone that really knows the HP-41 understands, this is a very bad … Continue reading