]> git.sur5r.net Git - cc65/blob - src/cc65/coptind.h
bcb9e5a40d2f878ccc3294257db23b52fd8d9d66
[cc65] / src / cc65 / coptind.h
1 /*****************************************************************************/
2 /*                                                                           */
3 /*                                 coptind.h                                 */
4 /*                                                                           */
5 /*              Environment independent low level optimizations              */
6 /*                                                                           */
7 /*                                                                           */
8 /*                                                                           */
9 /* (C) 2001      Ullrich von Bassewitz                                       */
10 /*               Wacholderweg 14                                             */
11 /*               D-70597 Stuttgart                                           */
12 /* EMail:        uz@cc65.org                                                 */
13 /*                                                                           */
14 /*                                                                           */
15 /* This software is provided 'as-is', without any expressed or implied       */
16 /* warranty.  In no event will the authors be held liable for any damages    */
17 /* arising from the use of this software.                                    */
18 /*                                                                           */
19 /* Permission is granted to anyone to use this software for any purpose,     */
20 /* including commercial applications, and to alter it and redistribute it    */
21 /* freely, subject to the following restrictions:                            */
22 /*                                                                           */
23 /* 1. The origin of this software must not be misrepresented; you must not   */
24 /*    claim that you wrote the original software. If you use this software   */
25 /*    in a product, an acknowledgment in the product documentation would be  */
26 /*    appreciated but is not required.                                       */
27 /* 2. Altered source versions must be plainly marked as such, and must not   */
28 /*    be misrepresented as being the original software.                      */
29 /* 3. This notice may not be removed or altered from any source              */
30 /*    distribution.                                                          */
31 /*                                                                           */
32 /*****************************************************************************/
33
34
35
36 #ifndef COPTIND_H
37 #define COPTIND_H
38
39
40
41 #include "codeseg.h"
42
43
44
45 /*****************************************************************************/
46 /*                                   Code                                    */
47 /*****************************************************************************/
48
49
50
51 unsigned OptDeadJumps (CodeSeg* S);
52 /* Remove dead jumps (jumps to the next instruction) */
53
54 unsigned OptDeadCode (CodeSeg* S);
55 /* Remove dead code (code that follows an unconditional jump or an rts/rti
56  * and has no label)
57  */
58
59 unsigned OptJumpCascades (CodeSeg* S);
60 /* Optimize jump cascades (jumps to jumps). In such a case, the jump is
61  * replaced by a jump to the final location. This will in some cases produce
62  * worse code, because some jump targets are no longer reachable by short
63  * branches, but this is quite rare, so there are more advantages than
64  * disadvantages.
65  */
66
67 unsigned OptRTS (CodeSeg* S);
68 /* Optimize subroutine calls followed by an RTS. The subroutine call will get
69  * replaced by a jump. Don't bother to delete the RTS if it does not have a
70  * label, the dead code elimination should take care of it.
71  */
72
73 unsigned OptJumpTarget (CodeSeg* S);
74 /* If the instruction preceeding an unconditional branch is the same as the
75  * instruction preceeding the jump target, the jump target may be moved
76  * one entry back. This is a size optimization, since the instruction before
77  * the branch gets removed.
78  */
79
80 unsigned OptDeadCondBranches (CodeSeg* S);
81 /* If an immidiate load of a register is followed by a conditional jump that
82  * is never taken because the load of the register sets the flags in such a
83  * manner, remove the conditional branch.
84  */
85
86
87
88 /* End of coptind.h */
89 #endif
90
91
92