syn68k/runtime/i486-cleanup.pl

38 lines
1.1 KiB
Perl
Raw Normal View History

2008-09-26 14:25:10 +00:00
#!/usr/bin/perl -ni
# This perl script strips out the extra cruft created as a side effect of
# splitting syn68k.c into many functions. This will make the resulting
# syn68k.o file smaller and also force the real branch targets to be
# aligned optimally.
# Delete the header for each function
if (/^\.globl _?s68k_handle_opcode_0x/ .. /^[#\/]APP$|^_?S68K_HANDLE_0x....:$/)
2008-09-26 14:25:10 +00:00
{
print if (/^[#\/]APP/ || /^L/ || /^_?S68K_HANDLE_0x....:$/);
2008-09-26 14:25:10 +00:00
}
# Delete the trailer for each function
elsif (/_S68K_DONE_WITH/ .. /^\s*ret$|^\s*jmp\s+_s68k_handle_opcode_dummy$/)
2008-09-26 14:25:10 +00:00
{
print if (!/\s*movl %ebp,%esp$/
&& !/\s*leal\s*(-?\d+)?\(%ebp\),%esp$/
&& !/\s*movl\s*(-?\d+)?\(%ebp\),%edi$/
&& !/\s*popl/
&& !/\s*ret$/
&& !/^_S68K_DONE_WITH/
&& !/s68k_handle_opcode/
&& !/^\s*jmp\s+_s68k_handle_opcode_dummy$/);
2008-09-26 14:25:10 +00:00
}
elsif (/^\s*lods/)
{
die "lods not allowed; we're punting cld's these days.";
}
# elsif (/^\s*call/ && !/s68k_handle_opcode/)
# { # no longer necessary since we punted lodsl
# print "$_\tcld\n";
# }
elsif (!/s68k_handle_opcode/)
{
print;
}