]> git.sur5r.net Git - cc65/blob - src/cc65/coptshift.h
Removed (pretty inconsistently used) tab chars from source code base.
[cc65] / src / cc65 / coptshift.h
1 /*****************************************************************************/
2 /*                                                                           */
3 /*                                coptshift.h                                */
4 /*                                                                           */
5 /*                              Optimize shifts                              */
6 /*                                                                           */
7 /*                                                                           */
8 /*                                                                           */
9 /* (C) 2001-2012, Ullrich von Bassewitz                                      */
10 /*                Roemerstrasse 52                                           */
11 /*                D-70794 Filderstadt                                        */
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 COPTSHIFT_H
37 #define COPTSHIFT_H
38
39
40
41 /* cc65 */
42 #include "codeseg.h"
43
44
45
46 /*****************************************************************************/
47 /*                              Optimize shifts                              */
48 /*****************************************************************************/
49
50
51
52 unsigned OptShift1 (CodeSeg* S);
53 /* A call to the shlaxN routine may get replaced by one or more asl insns
54  * if the value of X is not used later. If X is used later, but it is zero
55  * on entry and it's a shift by one, it may get replaced by:
56  *
57  *      asl     a
58  *      bcc     L1
59  *      inx
60  *  L1:
61  *
62  */                            
63
64 unsigned OptShift2(CodeSeg* S);
65 /* A call to the asrax1 routines may get replaced by something simpler, if
66  * X is not used later:
67  *
68  *      cmp     #$80
69  *      ror     a
70  *
71  */
72
73 unsigned OptShift3 (CodeSeg* S);
74 /* The sequence
75  *
76  *      bcc     L
77  *      inx
78  * L:   jsr     shrax1
79  *
80  * may get replaced by
81  *
82  *      ror     a
83  *
84  * if X is zero on entry and unused later. For shift counts > 1, more
85  *
86  *      shr     a
87  *
88  * must be added.
89  */
90
91 unsigned OptShift4 (CodeSeg* S);
92 /* Calls to the asraxN or shraxN routines may get replaced by one or more lsr
93  * insns if the value of X is zero.
94  */
95
96 unsigned OptShift5 (CodeSeg* S);
97 /* Search for the sequence
98  *
99  *      lda     xxx
100  *      ldx     yyy
101  *      jsr     aslax1/asrax1/shlax1/shrax1
102  *      sta     aaa
103  *      stx     bbb
104  *
105  * and replace it by
106  *
107  *      lda     xxx
108  *      asl     a
109  *      sta     aaa
110  *      lda     yyy
111  *      rol     a
112  *      sta     bbb
113  *
114  * or similar, provided that a/x is not used later
115  */
116
117 unsigned OptShift6 (CodeSeg* S);
118 /* Inline the shift subroutines. */
119
120
121
122 /* End of coptshift.h */
123 #endif
124
125
126