2002-10-17 21:37:01 +00:00
|
|
|
/*****************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* coptstore.h */
|
|
|
|
/* */
|
|
|
|
/* Optimize stores */
|
|
|
|
/* */
|
|
|
|
/* */
|
|
|
|
/* */
|
2006-04-15 20:31:43 +00:00
|
|
|
/* (C) 2002-2006, Ullrich von Bassewitz */
|
2014-06-30 09:10:35 +00:00
|
|
|
/* Roemerstrasse 52 */
|
2006-04-15 20:31:43 +00:00
|
|
|
/* D-70794 Filderstadt */
|
|
|
|
/* EMail: uz@cc65.org */
|
2002-10-17 21:37:01 +00:00
|
|
|
/* */
|
|
|
|
/* */
|
|
|
|
/* This software is provided 'as-is', without any expressed or implied */
|
|
|
|
/* warranty. In no event will the authors be held liable for any damages */
|
|
|
|
/* arising from the use of this software. */
|
|
|
|
/* */
|
|
|
|
/* Permission is granted to anyone to use this software for any purpose, */
|
|
|
|
/* including commercial applications, and to alter it and redistribute it */
|
|
|
|
/* freely, subject to the following restrictions: */
|
|
|
|
/* */
|
|
|
|
/* 1. The origin of this software must not be misrepresented; you must not */
|
|
|
|
/* claim that you wrote the original software. If you use this software */
|
|
|
|
/* in a product, an acknowledgment in the product documentation would be */
|
|
|
|
/* appreciated but is not required. */
|
|
|
|
/* 2. Altered source versions must be plainly marked as such, and must not */
|
|
|
|
/* be misrepresented as being the original software. */
|
|
|
|
/* 3. This notice may not be removed or altered from any source */
|
|
|
|
/* distribution. */
|
|
|
|
/* */
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef COPTSTORE_H
|
|
|
|
#define COPTSTORE_H
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* cc65 */
|
|
|
|
#include "codeseg.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2013-05-09 11:56:54 +00:00
|
|
|
/* Code */
|
2002-10-17 21:37:01 +00:00
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
unsigned OptStore1 (CodeSeg* S);
|
2003-08-13 09:35:49 +00:00
|
|
|
/* Search for the sequence
|
2014-06-30 09:10:35 +00:00
|
|
|
**
|
|
|
|
** ldy #n
|
|
|
|
** jsr staxysp
|
|
|
|
** ldy #n+1
|
|
|
|
** jsr ldaxysp
|
|
|
|
**
|
|
|
|
** and remove the useless load, provided that the next insn doesn't use flags
|
|
|
|
** from the load.
|
|
|
|
*/
|
2003-08-13 09:35:49 +00:00
|
|
|
|
|
|
|
unsigned OptStore2 (CodeSeg* S);
|
2002-10-17 21:37:01 +00:00
|
|
|
/* Search for a call to staxysp. If the ax register is not used later, and
|
2014-06-30 09:10:35 +00:00
|
|
|
** the value is constant, just use the A register and store directly into the
|
|
|
|
** stack.
|
|
|
|
*/
|
2002-10-17 21:37:01 +00:00
|
|
|
|
2003-08-13 09:35:49 +00:00
|
|
|
unsigned OptStore3 (CodeSeg* S);
|
2002-10-17 21:37:01 +00:00
|
|
|
/* Search for a call to steaxysp. If the eax register is not used later, and
|
2014-06-30 09:10:35 +00:00
|
|
|
** the value is constant, just use the A register and store directly into the
|
|
|
|
** stack.
|
|
|
|
*/
|
2002-10-17 21:37:01 +00:00
|
|
|
|
2003-08-13 09:35:49 +00:00
|
|
|
unsigned OptStore4 (CodeSeg* S);
|
|
|
|
/* Search for the sequence
|
2014-06-30 09:10:35 +00:00
|
|
|
**
|
|
|
|
** sta xx
|
|
|
|
** stx yy
|
|
|
|
** lda xx
|
|
|
|
** ldx yy
|
|
|
|
**
|
|
|
|
** and remove the useless load, provided that the next insn doesn't use flags
|
|
|
|
** from the load.
|
|
|
|
*/
|
2003-08-13 09:35:49 +00:00
|
|
|
|
2006-04-15 20:31:43 +00:00
|
|
|
unsigned OptStore5 (CodeSeg* S);
|
|
|
|
/* Search for the sequence
|
2014-06-30 09:10:35 +00:00
|
|
|
**
|
|
|
|
** lda foo
|
|
|
|
** ldx bar
|
|
|
|
** sta something
|
|
|
|
** stx something-else
|
|
|
|
**
|
|
|
|
** and replace it by
|
|
|
|
**
|
|
|
|
** lda foo
|
|
|
|
** sta something
|
|
|
|
** lda bar
|
|
|
|
** sta something-else
|
|
|
|
**
|
|
|
|
** if X is not used later. This replacement doesn't save any cycles or bytes,
|
|
|
|
** but it keeps the value of X, which may be reused later.
|
|
|
|
*/
|
2006-04-15 20:31:43 +00:00
|
|
|
|
2002-10-17 21:37:01 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* End of coptstore.h */
|
|
|
|
|
|
|
|
#endif
|