mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-29 08:13:35 +08:00
Email address change in misc/
git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@5144 7fd9a85b-ad96-42d3-883c-3090e2eb8679
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
# insn32/Makefile
|
||||
#
|
||||
# Copyright (C) 2008 Gregory Nutt. All rights reserved.
|
||||
# Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
# Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* Definitions of built-in function calls.
|
||||
*
|
||||
* Copyright (C) 2008-2009 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* pexec.h
|
||||
*
|
||||
* Copyright (C) 2008-2009 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* 32-bit P-code operation code definitions
|
||||
*
|
||||
* Copyright (C) 2008 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* 32-bit register module instruction definitions
|
||||
*
|
||||
* Copyright (C) 2008-2009 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# insn32/libinsn/Makefile
|
||||
#
|
||||
# Copyright (C) 2008 Gregory Nutt. All rights reserved.
|
||||
# Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
# Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* P-Code access utilities
|
||||
*
|
||||
* Copyright (C) 2008-2009 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* P-Code access utilities
|
||||
*
|
||||
* Copyright (C) 2008-2009 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* P-Code Disassembler
|
||||
*
|
||||
* Copyright (C) 2008-2009 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* P-Code generation logic
|
||||
*
|
||||
* Copyright (C) 2008-2009 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* P-Code access utilities
|
||||
*
|
||||
* Copyright (C) 2008-2009 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* Perform P-Code relocations
|
||||
*
|
||||
* Copyright (C) 2008-2009 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* P-Code access utilities
|
||||
*
|
||||
* Copyright (C) 2008-2009 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# insn32/plist/Makefile
|
||||
#
|
||||
# Copyright (C) 2008 Gregory Nutt. All rights reserved.
|
||||
# Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
# Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* POFF file lister
|
||||
*
|
||||
* Copyright (C) 2008-2009 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# insn32/popt/Makefile
|
||||
#
|
||||
# Copyright (C) 2008 Gregory Nutt. All rights reserved.
|
||||
# Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
# Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* Constant Expression Optimizations
|
||||
*
|
||||
* Copyright (C) 2008-2009 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
|
||||
@@ -1,47 +1,47 @@
|
||||
/***************************************************************************
|
||||
* pcopt.h
|
||||
* External Declarations associated with PCOPT.C
|
||||
*
|
||||
* Copyright (C) 2008 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef __PCOPT_H
|
||||
#define __PCOPT_H
|
||||
|
||||
/***************************************************************************
|
||||
* Global Function Prototypes
|
||||
***************************************************************************/
|
||||
|
||||
extern int unaryOptimize ( void );
|
||||
extern int binaryOptimize ( void );
|
||||
|
||||
#endif /* __PCOPT_H */
|
||||
/***************************************************************************
|
||||
* pcopt.h
|
||||
* External Declarations associated with PCOPT.C
|
||||
*
|
||||
* Copyright (C) 2008 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef __PCOPT_H
|
||||
#define __PCOPT_H
|
||||
|
||||
/***************************************************************************
|
||||
* Global Function Prototypes
|
||||
***************************************************************************/
|
||||
|
||||
extern int unaryOptimize ( void );
|
||||
extern int binaryOptimize ( void );
|
||||
|
||||
#endif /* __PCOPT_H */
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* Finalization of optimized image
|
||||
*
|
||||
* Copyright (C) 2008-2009 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
|
||||
@@ -1,54 +1,54 @@
|
||||
/***************************************************************************
|
||||
* pfopt.h
|
||||
* External Declarations associated with pfopt.c
|
||||
*
|
||||
* Copyright (C) 2008 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef __PFOPT_H
|
||||
#define __PFOPT_H
|
||||
|
||||
/***************************************************************************
|
||||
* Included Files
|
||||
***************************************************************************/
|
||||
|
||||
#include "pofflib.h"
|
||||
|
||||
/***************************************************************************
|
||||
* Global Function Prototypes
|
||||
***************************************************************************/
|
||||
|
||||
extern void optFinalize(poffHandle_t poffHandle,
|
||||
poffProgHandle_t poffProgHandle);
|
||||
|
||||
#endif /* __PFOPT_H */
|
||||
|
||||
/***************************************************************************
|
||||
* pfopt.h
|
||||
* External Declarations associated with pfopt.c
|
||||
*
|
||||
* Copyright (C) 2008 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef __PFOPT_H
|
||||
#define __PFOPT_H
|
||||
|
||||
/***************************************************************************
|
||||
* Included Files
|
||||
***************************************************************************/
|
||||
|
||||
#include "pofflib.h"
|
||||
|
||||
/***************************************************************************
|
||||
* Global Function Prototypes
|
||||
***************************************************************************/
|
||||
|
||||
extern void optFinalize(poffHandle_t poffHandle,
|
||||
poffProgHandle_t poffProgHandle);
|
||||
|
||||
#endif /* __PFOPT_H */
|
||||
|
||||
|
||||
+449
-449
@@ -1,449 +1,449 @@
|
||||
/**********************************************************************
|
||||
* pjopt.c
|
||||
* Branch Optimizations
|
||||
*
|
||||
* Copyright (C) 2008 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
**********************************************************************/
|
||||
|
||||
/**********************************************************************
|
||||
* Included Files
|
||||
**********************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "keywords.h"
|
||||
#include "pdefs.h"
|
||||
#include "pinsn32.h"
|
||||
|
||||
#include "popt.h"
|
||||
#include "polocal.h"
|
||||
#include "pjopt.h"
|
||||
|
||||
/**********************************************************************/
|
||||
|
||||
int BranchOptimize (void)
|
||||
{
|
||||
int nchanges = 0;
|
||||
register int i;
|
||||
|
||||
TRACE(stderr, "[BranchOptimize]");
|
||||
|
||||
/* At least two pcodes are need to perform branch optimizations */
|
||||
|
||||
i = 0;
|
||||
while (i < nops-1)
|
||||
{
|
||||
switch (pptr[i]->op)
|
||||
{
|
||||
case oNOT :
|
||||
switch (pptr[i+1]->op)
|
||||
{
|
||||
case oJEQUZ :
|
||||
pptr[i+1]->op = oJNEQZ;
|
||||
deletePcode(i);
|
||||
nchanges++;
|
||||
break;
|
||||
|
||||
case oJNEQZ :
|
||||
pptr[i+1]->op = oJEQUZ;
|
||||
deletePcode(i);
|
||||
nchanges++;
|
||||
break;
|
||||
|
||||
default :
|
||||
i++;
|
||||
break;
|
||||
} /* end switch */
|
||||
break;
|
||||
|
||||
case oNEG :
|
||||
switch (pptr[i+1]->op)
|
||||
{
|
||||
case oJLTZ :
|
||||
pptr[i+1]->op = oJGTZ;
|
||||
deletePcode(i);
|
||||
nchanges++;
|
||||
break;
|
||||
|
||||
case oJGTEZ :
|
||||
pptr[i+1]->op = oJLTEZ;
|
||||
deletePcode(i);
|
||||
nchanges++;
|
||||
break;
|
||||
|
||||
case oJGTZ :
|
||||
pptr[i+1]->op = oJLTZ;
|
||||
deletePcode(i);
|
||||
nchanges++;
|
||||
break;
|
||||
|
||||
case oJLTEZ :
|
||||
pptr[i+1]->op = oJGTEZ;
|
||||
deletePcode(i);
|
||||
nchanges++;
|
||||
break;
|
||||
|
||||
default :
|
||||
i++;
|
||||
break;
|
||||
} /* end switch */
|
||||
break;
|
||||
|
||||
case oEQU :
|
||||
switch (pptr[i+1]->op)
|
||||
{
|
||||
case oNOT :
|
||||
pptr[i]->op = oNEQ;
|
||||
deletePcode(i+1);
|
||||
nchanges++;
|
||||
break;
|
||||
|
||||
case oJEQUZ :
|
||||
pptr[i+1]->op = oJNEQ;
|
||||
deletePcode(i);
|
||||
nchanges++;
|
||||
break;
|
||||
|
||||
case oJNEQZ :
|
||||
pptr[i+1]->op = oJEQU;
|
||||
deletePcode(i);
|
||||
nchanges++;
|
||||
break;
|
||||
|
||||
default :
|
||||
i++;
|
||||
break;
|
||||
} /* end switch */
|
||||
break;
|
||||
|
||||
case oNEQ :
|
||||
switch (pptr[i+1]->op)
|
||||
{
|
||||
case oNOT :
|
||||
pptr[i]->op = oEQU;
|
||||
deletePcode(i+1);
|
||||
nchanges++;
|
||||
break;
|
||||
|
||||
case oJEQUZ :
|
||||
pptr[i+1]->op = oJEQU;
|
||||
deletePcode(i);
|
||||
nchanges++;
|
||||
break;
|
||||
|
||||
case oJNEQZ :
|
||||
pptr[i+1]->op = oJNEQ;
|
||||
deletePcode(i);
|
||||
nchanges++;
|
||||
break;
|
||||
|
||||
default :
|
||||
i++;
|
||||
break;
|
||||
} /* end switch */
|
||||
break;
|
||||
|
||||
case oLT :
|
||||
switch (pptr[i+1]->op)
|
||||
{
|
||||
case oNOT :
|
||||
pptr[i]->op = oGTE;
|
||||
deletePcode(i+1);
|
||||
nchanges++;
|
||||
break;
|
||||
|
||||
case oJEQUZ :
|
||||
pptr[i+1]->op = oJGTE;
|
||||
deletePcode(i);
|
||||
nchanges++;
|
||||
break;
|
||||
|
||||
case oJNEQZ :
|
||||
pptr[i+1]->op = oJLT;
|
||||
deletePcode(i);
|
||||
nchanges++;
|
||||
break;
|
||||
|
||||
default :
|
||||
i++;
|
||||
break;
|
||||
} /* end switch */
|
||||
break;
|
||||
|
||||
case oGTE :
|
||||
switch (pptr[i+1]->op)
|
||||
{
|
||||
case oNOT :
|
||||
pptr[i]->op = oLT;
|
||||
deletePcode(i+1);
|
||||
nchanges++;
|
||||
break;
|
||||
|
||||
case oJEQUZ :
|
||||
pptr[i+1]->op = oJLT;
|
||||
deletePcode(i);
|
||||
nchanges++;
|
||||
break;
|
||||
|
||||
case oJNEQZ :
|
||||
pptr[i+1]->op = oJGTE;
|
||||
deletePcode(i);
|
||||
nchanges++;
|
||||
break;
|
||||
|
||||
default :
|
||||
i++;
|
||||
break;
|
||||
} /* end switch */
|
||||
break;
|
||||
|
||||
case oGT :
|
||||
switch (pptr[i+1]->op)
|
||||
{
|
||||
case oNOT :
|
||||
pptr[i]->op = oLTE;
|
||||
deletePcode(i+1);
|
||||
nchanges++;
|
||||
break;
|
||||
|
||||
case oJEQUZ :
|
||||
pptr[i+1]->op = oJLTE;
|
||||
deletePcode(i);
|
||||
nchanges++;
|
||||
break;
|
||||
|
||||
case oJNEQZ :
|
||||
pptr[i+1]->op = oJGT;
|
||||
deletePcode(i);
|
||||
nchanges++;
|
||||
break;
|
||||
|
||||
default :
|
||||
i++;
|
||||
break;
|
||||
} /* end switch */
|
||||
break;
|
||||
|
||||
case oLTE :
|
||||
switch (pptr[i+1]->op)
|
||||
{
|
||||
case oNOT :
|
||||
pptr[i]->op = oGT;
|
||||
deletePcode(i+1);
|
||||
nchanges++;
|
||||
break;
|
||||
|
||||
case oJEQUZ :
|
||||
pptr[i+1]->op = oJGT;
|
||||
deletePcode(i);
|
||||
nchanges++;
|
||||
break;
|
||||
|
||||
case oJNEQZ :
|
||||
pptr[i+1]->op = oJLTE;
|
||||
deletePcode(i);
|
||||
nchanges++;
|
||||
break;
|
||||
|
||||
default :
|
||||
i++;
|
||||
break;
|
||||
} /* end switch */
|
||||
break;
|
||||
|
||||
case oEQUZ :
|
||||
switch (pptr[i+1]->op)
|
||||
{
|
||||
case oNOT :
|
||||
pptr[i]->op = oNEQZ;
|
||||
deletePcode(i+1);
|
||||
nchanges++;
|
||||
break;
|
||||
|
||||
case oJEQUZ :
|
||||
pptr[i+1]->op = oJNEQZ;
|
||||
deletePcode(i);
|
||||
nchanges++;
|
||||
break;
|
||||
|
||||
case oJNEQZ :
|
||||
pptr[i+1]->op = oJEQUZ;
|
||||
deletePcode(i);
|
||||
nchanges++;
|
||||
break;
|
||||
|
||||
default :
|
||||
i++;
|
||||
break;
|
||||
} /* end switch */
|
||||
break;
|
||||
|
||||
case oNEQZ :
|
||||
switch (pptr[i+1]->op)
|
||||
{
|
||||
case oNOT :
|
||||
pptr[i]->op = oEQUZ;
|
||||
deletePcode(i+1);
|
||||
nchanges++;
|
||||
break;
|
||||
|
||||
case oJEQUZ :
|
||||
case oJNEQZ :
|
||||
deletePcode(i);
|
||||
nchanges++;
|
||||
break;
|
||||
|
||||
default :
|
||||
i++;
|
||||
break;
|
||||
} /* end switch */
|
||||
break;
|
||||
|
||||
case oLTZ :
|
||||
switch (pptr[i+1]->op)
|
||||
{
|
||||
case oNOT :
|
||||
pptr[i]->op = oGTEZ;
|
||||
deletePcode(i+1);
|
||||
nchanges++;
|
||||
break;
|
||||
|
||||
case oJEQUZ :
|
||||
pptr[i+1]->op = oJGTEZ;
|
||||
deletePcode(i);
|
||||
nchanges++;
|
||||
break;
|
||||
|
||||
case oJNEQZ :
|
||||
pptr[i+1]->op = oJLTZ;
|
||||
deletePcode(i);
|
||||
nchanges++;
|
||||
break;
|
||||
|
||||
default :
|
||||
i++;
|
||||
break;
|
||||
} /* end switch */
|
||||
break;
|
||||
|
||||
case oGTEZ :
|
||||
switch (pptr[i+1]->op)
|
||||
{
|
||||
case oNOT :
|
||||
pptr[i]->op = oLTZ;
|
||||
deletePcode(i+1);
|
||||
nchanges++;
|
||||
break;
|
||||
|
||||
case oJEQUZ :
|
||||
pptr[i+1]->op = oJLTZ;
|
||||
deletePcode(i);
|
||||
nchanges++;
|
||||
break;
|
||||
|
||||
case oJNEQZ :
|
||||
pptr[i+1]->op = oJGTEZ;
|
||||
deletePcode(i);
|
||||
nchanges++;
|
||||
break;
|
||||
|
||||
default :
|
||||
i++;
|
||||
break;
|
||||
} /* end switch */
|
||||
break;
|
||||
|
||||
case oGTZ :
|
||||
switch (pptr[i+1]->op)
|
||||
{
|
||||
case oNOT :
|
||||
pptr[i]->op = oLTEZ;
|
||||
deletePcode(i+1);
|
||||
nchanges++;
|
||||
break;
|
||||
|
||||
case oJEQUZ :
|
||||
pptr[i+1]->op = oJLTEZ;
|
||||
deletePcode(i);
|
||||
nchanges++;
|
||||
break;
|
||||
|
||||
case oJNEQZ :
|
||||
pptr[i+1]->op = oJGTZ;
|
||||
deletePcode(i);
|
||||
nchanges++;
|
||||
break;
|
||||
|
||||
default :
|
||||
i++;
|
||||
break;
|
||||
} /* end switch */
|
||||
break;
|
||||
|
||||
case oLTEZ :
|
||||
switch (pptr[i+1]->op)
|
||||
{
|
||||
case oNOT :
|
||||
pptr[i]->op = oGTZ;
|
||||
deletePcode(i+1);
|
||||
nchanges++;
|
||||
break;
|
||||
|
||||
case oJEQUZ :
|
||||
pptr[i+1]->op = oJGTZ;
|
||||
deletePcode(i);
|
||||
nchanges++;
|
||||
break;
|
||||
|
||||
case oJNEQZ :
|
||||
pptr[i+1]->op = oJLTEZ;
|
||||
deletePcode(i);
|
||||
nchanges++;
|
||||
break;
|
||||
|
||||
default :
|
||||
i++;
|
||||
break;
|
||||
} /* end switch */
|
||||
break;
|
||||
|
||||
default :
|
||||
i++;
|
||||
break;
|
||||
} /* end switch */
|
||||
} /* end while */
|
||||
return (nchanges);
|
||||
|
||||
} /* end BranchOptimize */
|
||||
|
||||
/**********************************************************************/
|
||||
|
||||
/**********************************************************************
|
||||
* pjopt.c
|
||||
* Branch Optimizations
|
||||
*
|
||||
* Copyright (C) 2008 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
**********************************************************************/
|
||||
|
||||
/**********************************************************************
|
||||
* Included Files
|
||||
**********************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "keywords.h"
|
||||
#include "pdefs.h"
|
||||
#include "pinsn32.h"
|
||||
|
||||
#include "popt.h"
|
||||
#include "polocal.h"
|
||||
#include "pjopt.h"
|
||||
|
||||
/**********************************************************************/
|
||||
|
||||
int BranchOptimize (void)
|
||||
{
|
||||
int nchanges = 0;
|
||||
register int i;
|
||||
|
||||
TRACE(stderr, "[BranchOptimize]");
|
||||
|
||||
/* At least two pcodes are need to perform branch optimizations */
|
||||
|
||||
i = 0;
|
||||
while (i < nops-1)
|
||||
{
|
||||
switch (pptr[i]->op)
|
||||
{
|
||||
case oNOT :
|
||||
switch (pptr[i+1]->op)
|
||||
{
|
||||
case oJEQUZ :
|
||||
pptr[i+1]->op = oJNEQZ;
|
||||
deletePcode(i);
|
||||
nchanges++;
|
||||
break;
|
||||
|
||||
case oJNEQZ :
|
||||
pptr[i+1]->op = oJEQUZ;
|
||||
deletePcode(i);
|
||||
nchanges++;
|
||||
break;
|
||||
|
||||
default :
|
||||
i++;
|
||||
break;
|
||||
} /* end switch */
|
||||
break;
|
||||
|
||||
case oNEG :
|
||||
switch (pptr[i+1]->op)
|
||||
{
|
||||
case oJLTZ :
|
||||
pptr[i+1]->op = oJGTZ;
|
||||
deletePcode(i);
|
||||
nchanges++;
|
||||
break;
|
||||
|
||||
case oJGTEZ :
|
||||
pptr[i+1]->op = oJLTEZ;
|
||||
deletePcode(i);
|
||||
nchanges++;
|
||||
break;
|
||||
|
||||
case oJGTZ :
|
||||
pptr[i+1]->op = oJLTZ;
|
||||
deletePcode(i);
|
||||
nchanges++;
|
||||
break;
|
||||
|
||||
case oJLTEZ :
|
||||
pptr[i+1]->op = oJGTEZ;
|
||||
deletePcode(i);
|
||||
nchanges++;
|
||||
break;
|
||||
|
||||
default :
|
||||
i++;
|
||||
break;
|
||||
} /* end switch */
|
||||
break;
|
||||
|
||||
case oEQU :
|
||||
switch (pptr[i+1]->op)
|
||||
{
|
||||
case oNOT :
|
||||
pptr[i]->op = oNEQ;
|
||||
deletePcode(i+1);
|
||||
nchanges++;
|
||||
break;
|
||||
|
||||
case oJEQUZ :
|
||||
pptr[i+1]->op = oJNEQ;
|
||||
deletePcode(i);
|
||||
nchanges++;
|
||||
break;
|
||||
|
||||
case oJNEQZ :
|
||||
pptr[i+1]->op = oJEQU;
|
||||
deletePcode(i);
|
||||
nchanges++;
|
||||
break;
|
||||
|
||||
default :
|
||||
i++;
|
||||
break;
|
||||
} /* end switch */
|
||||
break;
|
||||
|
||||
case oNEQ :
|
||||
switch (pptr[i+1]->op)
|
||||
{
|
||||
case oNOT :
|
||||
pptr[i]->op = oEQU;
|
||||
deletePcode(i+1);
|
||||
nchanges++;
|
||||
break;
|
||||
|
||||
case oJEQUZ :
|
||||
pptr[i+1]->op = oJEQU;
|
||||
deletePcode(i);
|
||||
nchanges++;
|
||||
break;
|
||||
|
||||
case oJNEQZ :
|
||||
pptr[i+1]->op = oJNEQ;
|
||||
deletePcode(i);
|
||||
nchanges++;
|
||||
break;
|
||||
|
||||
default :
|
||||
i++;
|
||||
break;
|
||||
} /* end switch */
|
||||
break;
|
||||
|
||||
case oLT :
|
||||
switch (pptr[i+1]->op)
|
||||
{
|
||||
case oNOT :
|
||||
pptr[i]->op = oGTE;
|
||||
deletePcode(i+1);
|
||||
nchanges++;
|
||||
break;
|
||||
|
||||
case oJEQUZ :
|
||||
pptr[i+1]->op = oJGTE;
|
||||
deletePcode(i);
|
||||
nchanges++;
|
||||
break;
|
||||
|
||||
case oJNEQZ :
|
||||
pptr[i+1]->op = oJLT;
|
||||
deletePcode(i);
|
||||
nchanges++;
|
||||
break;
|
||||
|
||||
default :
|
||||
i++;
|
||||
break;
|
||||
} /* end switch */
|
||||
break;
|
||||
|
||||
case oGTE :
|
||||
switch (pptr[i+1]->op)
|
||||
{
|
||||
case oNOT :
|
||||
pptr[i]->op = oLT;
|
||||
deletePcode(i+1);
|
||||
nchanges++;
|
||||
break;
|
||||
|
||||
case oJEQUZ :
|
||||
pptr[i+1]->op = oJLT;
|
||||
deletePcode(i);
|
||||
nchanges++;
|
||||
break;
|
||||
|
||||
case oJNEQZ :
|
||||
pptr[i+1]->op = oJGTE;
|
||||
deletePcode(i);
|
||||
nchanges++;
|
||||
break;
|
||||
|
||||
default :
|
||||
i++;
|
||||
break;
|
||||
} /* end switch */
|
||||
break;
|
||||
|
||||
case oGT :
|
||||
switch (pptr[i+1]->op)
|
||||
{
|
||||
case oNOT :
|
||||
pptr[i]->op = oLTE;
|
||||
deletePcode(i+1);
|
||||
nchanges++;
|
||||
break;
|
||||
|
||||
case oJEQUZ :
|
||||
pptr[i+1]->op = oJLTE;
|
||||
deletePcode(i);
|
||||
nchanges++;
|
||||
break;
|
||||
|
||||
case oJNEQZ :
|
||||
pptr[i+1]->op = oJGT;
|
||||
deletePcode(i);
|
||||
nchanges++;
|
||||
break;
|
||||
|
||||
default :
|
||||
i++;
|
||||
break;
|
||||
} /* end switch */
|
||||
break;
|
||||
|
||||
case oLTE :
|
||||
switch (pptr[i+1]->op)
|
||||
{
|
||||
case oNOT :
|
||||
pptr[i]->op = oGT;
|
||||
deletePcode(i+1);
|
||||
nchanges++;
|
||||
break;
|
||||
|
||||
case oJEQUZ :
|
||||
pptr[i+1]->op = oJGT;
|
||||
deletePcode(i);
|
||||
nchanges++;
|
||||
break;
|
||||
|
||||
case oJNEQZ :
|
||||
pptr[i+1]->op = oJLTE;
|
||||
deletePcode(i);
|
||||
nchanges++;
|
||||
break;
|
||||
|
||||
default :
|
||||
i++;
|
||||
break;
|
||||
} /* end switch */
|
||||
break;
|
||||
|
||||
case oEQUZ :
|
||||
switch (pptr[i+1]->op)
|
||||
{
|
||||
case oNOT :
|
||||
pptr[i]->op = oNEQZ;
|
||||
deletePcode(i+1);
|
||||
nchanges++;
|
||||
break;
|
||||
|
||||
case oJEQUZ :
|
||||
pptr[i+1]->op = oJNEQZ;
|
||||
deletePcode(i);
|
||||
nchanges++;
|
||||
break;
|
||||
|
||||
case oJNEQZ :
|
||||
pptr[i+1]->op = oJEQUZ;
|
||||
deletePcode(i);
|
||||
nchanges++;
|
||||
break;
|
||||
|
||||
default :
|
||||
i++;
|
||||
break;
|
||||
} /* end switch */
|
||||
break;
|
||||
|
||||
case oNEQZ :
|
||||
switch (pptr[i+1]->op)
|
||||
{
|
||||
case oNOT :
|
||||
pptr[i]->op = oEQUZ;
|
||||
deletePcode(i+1);
|
||||
nchanges++;
|
||||
break;
|
||||
|
||||
case oJEQUZ :
|
||||
case oJNEQZ :
|
||||
deletePcode(i);
|
||||
nchanges++;
|
||||
break;
|
||||
|
||||
default :
|
||||
i++;
|
||||
break;
|
||||
} /* end switch */
|
||||
break;
|
||||
|
||||
case oLTZ :
|
||||
switch (pptr[i+1]->op)
|
||||
{
|
||||
case oNOT :
|
||||
pptr[i]->op = oGTEZ;
|
||||
deletePcode(i+1);
|
||||
nchanges++;
|
||||
break;
|
||||
|
||||
case oJEQUZ :
|
||||
pptr[i+1]->op = oJGTEZ;
|
||||
deletePcode(i);
|
||||
nchanges++;
|
||||
break;
|
||||
|
||||
case oJNEQZ :
|
||||
pptr[i+1]->op = oJLTZ;
|
||||
deletePcode(i);
|
||||
nchanges++;
|
||||
break;
|
||||
|
||||
default :
|
||||
i++;
|
||||
break;
|
||||
} /* end switch */
|
||||
break;
|
||||
|
||||
case oGTEZ :
|
||||
switch (pptr[i+1]->op)
|
||||
{
|
||||
case oNOT :
|
||||
pptr[i]->op = oLTZ;
|
||||
deletePcode(i+1);
|
||||
nchanges++;
|
||||
break;
|
||||
|
||||
case oJEQUZ :
|
||||
pptr[i+1]->op = oJLTZ;
|
||||
deletePcode(i);
|
||||
nchanges++;
|
||||
break;
|
||||
|
||||
case oJNEQZ :
|
||||
pptr[i+1]->op = oJGTEZ;
|
||||
deletePcode(i);
|
||||
nchanges++;
|
||||
break;
|
||||
|
||||
default :
|
||||
i++;
|
||||
break;
|
||||
} /* end switch */
|
||||
break;
|
||||
|
||||
case oGTZ :
|
||||
switch (pptr[i+1]->op)
|
||||
{
|
||||
case oNOT :
|
||||
pptr[i]->op = oLTEZ;
|
||||
deletePcode(i+1);
|
||||
nchanges++;
|
||||
break;
|
||||
|
||||
case oJEQUZ :
|
||||
pptr[i+1]->op = oJLTEZ;
|
||||
deletePcode(i);
|
||||
nchanges++;
|
||||
break;
|
||||
|
||||
case oJNEQZ :
|
||||
pptr[i+1]->op = oJGTZ;
|
||||
deletePcode(i);
|
||||
nchanges++;
|
||||
break;
|
||||
|
||||
default :
|
||||
i++;
|
||||
break;
|
||||
} /* end switch */
|
||||
break;
|
||||
|
||||
case oLTEZ :
|
||||
switch (pptr[i+1]->op)
|
||||
{
|
||||
case oNOT :
|
||||
pptr[i]->op = oGTZ;
|
||||
deletePcode(i+1);
|
||||
nchanges++;
|
||||
break;
|
||||
|
||||
case oJEQUZ :
|
||||
pptr[i+1]->op = oJGTZ;
|
||||
deletePcode(i);
|
||||
nchanges++;
|
||||
break;
|
||||
|
||||
case oJNEQZ :
|
||||
pptr[i+1]->op = oJLTEZ;
|
||||
deletePcode(i);
|
||||
nchanges++;
|
||||
break;
|
||||
|
||||
default :
|
||||
i++;
|
||||
break;
|
||||
} /* end switch */
|
||||
break;
|
||||
|
||||
default :
|
||||
i++;
|
||||
break;
|
||||
} /* end switch */
|
||||
} /* end while */
|
||||
return (nchanges);
|
||||
|
||||
} /* end BranchOptimize */
|
||||
|
||||
/**********************************************************************/
|
||||
|
||||
|
||||
@@ -1,44 +1,44 @@
|
||||
/***************************************************************************
|
||||
* pjopt.h
|
||||
* External Declarations associated with pjopt.c
|
||||
*
|
||||
* Copyright (C) 2008 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef __PJOPT_H
|
||||
#define __PJOPT_H
|
||||
|
||||
extern int BranchOptimize ( void );
|
||||
|
||||
#endif __PJOPT_H
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
* pjopt.h
|
||||
* External Declarations associated with pjopt.c
|
||||
*
|
||||
* Copyright (C) 2008 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef __PJOPT_H
|
||||
#define __PJOPT_H
|
||||
|
||||
extern int BranchOptimize ( void );
|
||||
|
||||
#endif __PJOPT_H
|
||||
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* Load/Store Optimizations
|
||||
*
|
||||
* Copyright (C) 2008-2009 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
|
||||
@@ -1,43 +1,43 @@
|
||||
/***************************************************************************
|
||||
* plopt.h
|
||||
* External Declarations associated with plopt.c
|
||||
*
|
||||
* Copyright (C) 2008 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef __PLOPT_H
|
||||
#define __PLOPT_H
|
||||
|
||||
extern int LoadOptimize ( void );
|
||||
extern int StoreOptimize ( void );
|
||||
|
||||
#endif /* __PLOPT_H */
|
||||
/***************************************************************************
|
||||
* plopt.h
|
||||
* External Declarations associated with plopt.c
|
||||
*
|
||||
* Copyright (C) 2008 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef __PLOPT_H
|
||||
#define __PLOPT_H
|
||||
|
||||
extern int LoadOptimize ( void );
|
||||
extern int StoreOptimize ( void );
|
||||
|
||||
#endif /* __PLOPT_H */
|
||||
|
||||
+271
-271
@@ -1,271 +1,271 @@
|
||||
/**********************************************************************
|
||||
* polocal.c
|
||||
* P-Code Local Optimizer
|
||||
*
|
||||
* Copyright (C) 2008 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
**********************************************************************/
|
||||
|
||||
/**********************************************************************
|
||||
* Included Files
|
||||
**********************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "keywords.h"
|
||||
#include "podefs.h"
|
||||
#include "pinsn32.h"
|
||||
|
||||
#include "pofflib.h"
|
||||
#include "paslib.h"
|
||||
#include "pinsn.h"
|
||||
#include "pcopt.h"
|
||||
#include "plopt.h"
|
||||
#include "pjopt.h"
|
||||
#include "polocal.h"
|
||||
|
||||
/**********************************************************************
|
||||
* Private Function Prototypes
|
||||
**********************************************************************/
|
||||
|
||||
static void initPTable (void);
|
||||
static void putPCodeFromTable (void);
|
||||
static void setupPointer (void);
|
||||
|
||||
/**********************************************************************
|
||||
* Global Variables
|
||||
**********************************************************************/
|
||||
|
||||
OPTYPE ptable [WINDOW]; /* Pcode Table */
|
||||
OPTYPE *pptr [WINDOW]; /* Valid Pcode Pointers */
|
||||
|
||||
int nops = 0; /* No. Valid Pcode Pointers */
|
||||
int end_out = 0; /* 1 = oEND pcode has been output */
|
||||
|
||||
/**********************************************************************
|
||||
* Private Variables
|
||||
**********************************************************************/
|
||||
|
||||
static poffHandle_t myPoffHandle; /* Handle to POFF object */
|
||||
static poffProgHandle_t myPoffProgHandle;/* Handle to temporary POFF object */
|
||||
|
||||
/**********************************************************************
|
||||
* Global Functions
|
||||
**********************************************************************/
|
||||
|
||||
/***********************************************************************/
|
||||
|
||||
void localOptimization(poffHandle_t poffHandle,
|
||||
poffProgHandle_t poffProgHandle)
|
||||
{
|
||||
int nchanges;
|
||||
|
||||
TRACE(stderr, "[pass2]");
|
||||
|
||||
/* Save the handles for use by other, private functions */
|
||||
|
||||
myPoffHandle = poffHandle;
|
||||
myPoffProgHandle = poffProgHandle;
|
||||
|
||||
/* Initialization */
|
||||
|
||||
initPTable();
|
||||
|
||||
/* Outer loop traverse the file op-code by op-code until the oEND P-Code
|
||||
* has been output. NOTE: it is assumed throughout that oEND is the
|
||||
* final P-Code in the program data section.
|
||||
*/
|
||||
|
||||
while (!(end_out))
|
||||
{
|
||||
/* The inner loop optimizes the buffered P-Codes until no further
|
||||
* changes can be made. Then the outer loop will advance the buffer
|
||||
* by one P-Code
|
||||
*/
|
||||
|
||||
do
|
||||
{
|
||||
nchanges = unaryOptimize ();
|
||||
nchanges += binaryOptimize();
|
||||
nchanges += BranchOptimize();
|
||||
nchanges += LoadOptimize();
|
||||
nchanges += StoreOptimize();
|
||||
} while (nchanges);
|
||||
|
||||
putPCodeFromTable();
|
||||
}
|
||||
}
|
||||
|
||||
/***********************************************************************/
|
||||
|
||||
void deletePcode(int delIndex)
|
||||
{
|
||||
TRACE(stderr, "[deletePcode]");
|
||||
|
||||
PUTOP(pptr[delIndex], oNOP);
|
||||
PUTARG(pptr[delIndex], 0);
|
||||
setupPointer();
|
||||
}
|
||||
|
||||
/**********************************************************************/
|
||||
|
||||
void deletePcodePair(int delIndex1, int delIndex2)
|
||||
{
|
||||
TRACE(stderr, "[deletePcodePair]");
|
||||
|
||||
PUTOP(pptr[delIndex1], oNOP);
|
||||
PUTARG(pptr[delIndex1], 0);
|
||||
PUTOP(pptr[delIndex2], oNOP);
|
||||
PUTARG(pptr[delIndex2], 0);
|
||||
setupPointer();
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
* Private Functions
|
||||
**********************************************************************/
|
||||
|
||||
/***********************************************************************/
|
||||
|
||||
static void putPCodeFromTable(void)
|
||||
{
|
||||
register int i;
|
||||
|
||||
TRACE(stderr, "[putPCodeFromTable]");
|
||||
|
||||
/* Transfer all buffered P-Codes (except NOPs) to the optimized file */
|
||||
do
|
||||
{
|
||||
if ((GETOP(&ptable[0]) != oNOP) && !(end_out))
|
||||
{
|
||||
insn_AddTmpOpCode(myPoffProgHandle, &ptable[0]);
|
||||
end_out = (GETOP(&ptable[0]) == oEND);
|
||||
}
|
||||
|
||||
/* Move all P-Codes down one slot */
|
||||
|
||||
for (i = 1; i < WINDOW; i++)
|
||||
{
|
||||
ptable[i-1] = ptable[i];
|
||||
}
|
||||
|
||||
/* Then fill the end slot with a new P-Code from the input file */
|
||||
|
||||
insn_GetOpCode(myPoffHandle, &ptable[WINDOW-1]);
|
||||
|
||||
} while (GETOP(&ptable[0]) == oNOP);
|
||||
setupPointer();
|
||||
}
|
||||
|
||||
/**********************************************************************/
|
||||
|
||||
static void setupPointer(void)
|
||||
{
|
||||
register int pindex;
|
||||
|
||||
TRACE(stderr, "[setupPointer]");
|
||||
|
||||
for (pindex = 0; pindex < WINDOW; pindex++)
|
||||
pptr[pindex] = (OPTYPE *) NULL;
|
||||
|
||||
nops = 0;
|
||||
for (pindex = 0; pindex < WINDOW; pindex++)
|
||||
{
|
||||
switch (GETOP(&ptable[pindex]))
|
||||
{
|
||||
/* Terminate list when a break from sequential logic is
|
||||
* encountered
|
||||
*/
|
||||
|
||||
case oRET :
|
||||
case oEND :
|
||||
case oJMP :
|
||||
case oLABEL :
|
||||
case oPCAL :
|
||||
return;
|
||||
|
||||
/* Terminate list when a condition break from sequential logic is
|
||||
* encountered but include the conditional branch in the list
|
||||
*/
|
||||
|
||||
case oJEQUZ :
|
||||
case oJNEQZ :
|
||||
case oJLTZ :
|
||||
case oJGTEZ :
|
||||
case oJGTZ :
|
||||
case oJLTEZ :
|
||||
pptr[nops] = &ptable[pindex];
|
||||
nops++;
|
||||
return;
|
||||
|
||||
/* Skip over NOPs and comment class pcodes */
|
||||
|
||||
case oNOP :
|
||||
case oLINE :
|
||||
break;
|
||||
|
||||
/* Include all other pcodes in the optimization list and continue */
|
||||
|
||||
default :
|
||||
pptr[nops] = &ptable[pindex];
|
||||
nops++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**********************************************************************/
|
||||
|
||||
static void initPTable(void)
|
||||
{
|
||||
register int i;
|
||||
|
||||
TRACE(stderr, "[intPTable]");
|
||||
|
||||
/* Skip over leading pcodes. NOTE: assumes executable begins after
|
||||
* the first oLABEL pcode
|
||||
*/
|
||||
|
||||
do
|
||||
{
|
||||
insn_GetOpCode(myPoffHandle, &ptable[0]);
|
||||
insn_AddTmpOpCode(myPoffProgHandle, &ptable[0]);
|
||||
}
|
||||
while ((GETOP(&ptable[0]) != oLABEL) && (GETOP(&ptable[0]) != oEND));
|
||||
|
||||
/* Fill the pcode window and setup pointers to working section */
|
||||
|
||||
for (i = 0; i < WINDOW; i++)
|
||||
{
|
||||
insn_GetOpCode(myPoffHandle, &ptable[i]);
|
||||
}
|
||||
setupPointer();
|
||||
}
|
||||
|
||||
/***********************************************************************/
|
||||
/**********************************************************************
|
||||
* polocal.c
|
||||
* P-Code Local Optimizer
|
||||
*
|
||||
* Copyright (C) 2008 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
**********************************************************************/
|
||||
|
||||
/**********************************************************************
|
||||
* Included Files
|
||||
**********************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "keywords.h"
|
||||
#include "podefs.h"
|
||||
#include "pinsn32.h"
|
||||
|
||||
#include "pofflib.h"
|
||||
#include "paslib.h"
|
||||
#include "pinsn.h"
|
||||
#include "pcopt.h"
|
||||
#include "plopt.h"
|
||||
#include "pjopt.h"
|
||||
#include "polocal.h"
|
||||
|
||||
/**********************************************************************
|
||||
* Private Function Prototypes
|
||||
**********************************************************************/
|
||||
|
||||
static void initPTable (void);
|
||||
static void putPCodeFromTable (void);
|
||||
static void setupPointer (void);
|
||||
|
||||
/**********************************************************************
|
||||
* Global Variables
|
||||
**********************************************************************/
|
||||
|
||||
OPTYPE ptable [WINDOW]; /* Pcode Table */
|
||||
OPTYPE *pptr [WINDOW]; /* Valid Pcode Pointers */
|
||||
|
||||
int nops = 0; /* No. Valid Pcode Pointers */
|
||||
int end_out = 0; /* 1 = oEND pcode has been output */
|
||||
|
||||
/**********************************************************************
|
||||
* Private Variables
|
||||
**********************************************************************/
|
||||
|
||||
static poffHandle_t myPoffHandle; /* Handle to POFF object */
|
||||
static poffProgHandle_t myPoffProgHandle;/* Handle to temporary POFF object */
|
||||
|
||||
/**********************************************************************
|
||||
* Global Functions
|
||||
**********************************************************************/
|
||||
|
||||
/***********************************************************************/
|
||||
|
||||
void localOptimization(poffHandle_t poffHandle,
|
||||
poffProgHandle_t poffProgHandle)
|
||||
{
|
||||
int nchanges;
|
||||
|
||||
TRACE(stderr, "[pass2]");
|
||||
|
||||
/* Save the handles for use by other, private functions */
|
||||
|
||||
myPoffHandle = poffHandle;
|
||||
myPoffProgHandle = poffProgHandle;
|
||||
|
||||
/* Initialization */
|
||||
|
||||
initPTable();
|
||||
|
||||
/* Outer loop traverse the file op-code by op-code until the oEND P-Code
|
||||
* has been output. NOTE: it is assumed throughout that oEND is the
|
||||
* final P-Code in the program data section.
|
||||
*/
|
||||
|
||||
while (!(end_out))
|
||||
{
|
||||
/* The inner loop optimizes the buffered P-Codes until no further
|
||||
* changes can be made. Then the outer loop will advance the buffer
|
||||
* by one P-Code
|
||||
*/
|
||||
|
||||
do
|
||||
{
|
||||
nchanges = unaryOptimize ();
|
||||
nchanges += binaryOptimize();
|
||||
nchanges += BranchOptimize();
|
||||
nchanges += LoadOptimize();
|
||||
nchanges += StoreOptimize();
|
||||
} while (nchanges);
|
||||
|
||||
putPCodeFromTable();
|
||||
}
|
||||
}
|
||||
|
||||
/***********************************************************************/
|
||||
|
||||
void deletePcode(int delIndex)
|
||||
{
|
||||
TRACE(stderr, "[deletePcode]");
|
||||
|
||||
PUTOP(pptr[delIndex], oNOP);
|
||||
PUTARG(pptr[delIndex], 0);
|
||||
setupPointer();
|
||||
}
|
||||
|
||||
/**********************************************************************/
|
||||
|
||||
void deletePcodePair(int delIndex1, int delIndex2)
|
||||
{
|
||||
TRACE(stderr, "[deletePcodePair]");
|
||||
|
||||
PUTOP(pptr[delIndex1], oNOP);
|
||||
PUTARG(pptr[delIndex1], 0);
|
||||
PUTOP(pptr[delIndex2], oNOP);
|
||||
PUTARG(pptr[delIndex2], 0);
|
||||
setupPointer();
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
* Private Functions
|
||||
**********************************************************************/
|
||||
|
||||
/***********************************************************************/
|
||||
|
||||
static void putPCodeFromTable(void)
|
||||
{
|
||||
register int i;
|
||||
|
||||
TRACE(stderr, "[putPCodeFromTable]");
|
||||
|
||||
/* Transfer all buffered P-Codes (except NOPs) to the optimized file */
|
||||
do
|
||||
{
|
||||
if ((GETOP(&ptable[0]) != oNOP) && !(end_out))
|
||||
{
|
||||
insn_AddTmpOpCode(myPoffProgHandle, &ptable[0]);
|
||||
end_out = (GETOP(&ptable[0]) == oEND);
|
||||
}
|
||||
|
||||
/* Move all P-Codes down one slot */
|
||||
|
||||
for (i = 1; i < WINDOW; i++)
|
||||
{
|
||||
ptable[i-1] = ptable[i];
|
||||
}
|
||||
|
||||
/* Then fill the end slot with a new P-Code from the input file */
|
||||
|
||||
insn_GetOpCode(myPoffHandle, &ptable[WINDOW-1]);
|
||||
|
||||
} while (GETOP(&ptable[0]) == oNOP);
|
||||
setupPointer();
|
||||
}
|
||||
|
||||
/**********************************************************************/
|
||||
|
||||
static void setupPointer(void)
|
||||
{
|
||||
register int pindex;
|
||||
|
||||
TRACE(stderr, "[setupPointer]");
|
||||
|
||||
for (pindex = 0; pindex < WINDOW; pindex++)
|
||||
pptr[pindex] = (OPTYPE *) NULL;
|
||||
|
||||
nops = 0;
|
||||
for (pindex = 0; pindex < WINDOW; pindex++)
|
||||
{
|
||||
switch (GETOP(&ptable[pindex]))
|
||||
{
|
||||
/* Terminate list when a break from sequential logic is
|
||||
* encountered
|
||||
*/
|
||||
|
||||
case oRET :
|
||||
case oEND :
|
||||
case oJMP :
|
||||
case oLABEL :
|
||||
case oPCAL :
|
||||
return;
|
||||
|
||||
/* Terminate list when a condition break from sequential logic is
|
||||
* encountered but include the conditional branch in the list
|
||||
*/
|
||||
|
||||
case oJEQUZ :
|
||||
case oJNEQZ :
|
||||
case oJLTZ :
|
||||
case oJGTEZ :
|
||||
case oJGTZ :
|
||||
case oJLTEZ :
|
||||
pptr[nops] = &ptable[pindex];
|
||||
nops++;
|
||||
return;
|
||||
|
||||
/* Skip over NOPs and comment class pcodes */
|
||||
|
||||
case oNOP :
|
||||
case oLINE :
|
||||
break;
|
||||
|
||||
/* Include all other pcodes in the optimization list and continue */
|
||||
|
||||
default :
|
||||
pptr[nops] = &ptable[pindex];
|
||||
nops++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**********************************************************************/
|
||||
|
||||
static void initPTable(void)
|
||||
{
|
||||
register int i;
|
||||
|
||||
TRACE(stderr, "[intPTable]");
|
||||
|
||||
/* Skip over leading pcodes. NOTE: assumes executable begins after
|
||||
* the first oLABEL pcode
|
||||
*/
|
||||
|
||||
do
|
||||
{
|
||||
insn_GetOpCode(myPoffHandle, &ptable[0]);
|
||||
insn_AddTmpOpCode(myPoffProgHandle, &ptable[0]);
|
||||
}
|
||||
while ((GETOP(&ptable[0]) != oLABEL) && (GETOP(&ptable[0]) != oEND));
|
||||
|
||||
/* Fill the pcode window and setup pointers to working section */
|
||||
|
||||
for (i = 0; i < WINDOW; i++)
|
||||
{
|
||||
insn_GetOpCode(myPoffHandle, &ptable[i]);
|
||||
}
|
||||
setupPointer();
|
||||
}
|
||||
|
||||
/***********************************************************************/
|
||||
|
||||
@@ -1,73 +1,73 @@
|
||||
/***************************************************************************
|
||||
* polocal.h
|
||||
* External Declarations associated with polocal.c
|
||||
*
|
||||
* Copyright (C) 2008 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef __POLOCAL_H
|
||||
#define __POLOCAL_H
|
||||
|
||||
/***************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include "keywords.h"
|
||||
#include "pdefs.h"
|
||||
#include "pofflib.h"
|
||||
|
||||
/***************************************************************************
|
||||
* Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define WINDOW 10 /* size of optimization window */
|
||||
|
||||
/***************************************************************************
|
||||
* Global Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
extern void localOptimization(poffHandle_t poffHandle,
|
||||
poffProgHandle_t poffProgHandle);
|
||||
extern void deletePcode (int delIndex);
|
||||
extern void deletePcodePair (int delIndex1, int delIndex2);
|
||||
|
||||
/***************************************************************************
|
||||
* Global Variables
|
||||
****************************************************************************/
|
||||
|
||||
extern OPTYPE ptable [WINDOW]; /* Pcode Table */
|
||||
extern OPTYPE *pptr [WINDOW]; /* Valid Pcode Pointers */
|
||||
|
||||
extern int nops; /* No. Valid Pcode Pointers */
|
||||
extern int end_out; /* 1 = oEND pcode has been output */
|
||||
|
||||
#endif /* __PLOCAL_H */
|
||||
/***************************************************************************
|
||||
* polocal.h
|
||||
* External Declarations associated with polocal.c
|
||||
*
|
||||
* Copyright (C) 2008 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef __POLOCAL_H
|
||||
#define __POLOCAL_H
|
||||
|
||||
/***************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include "keywords.h"
|
||||
#include "pdefs.h"
|
||||
#include "pofflib.h"
|
||||
|
||||
/***************************************************************************
|
||||
* Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define WINDOW 10 /* size of optimization window */
|
||||
|
||||
/***************************************************************************
|
||||
* Global Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
extern void localOptimization(poffHandle_t poffHandle,
|
||||
poffProgHandle_t poffProgHandle);
|
||||
extern void deletePcode (int delIndex);
|
||||
extern void deletePcodePair (int delIndex1, int delIndex2);
|
||||
|
||||
/***************************************************************************
|
||||
* Global Variables
|
||||
****************************************************************************/
|
||||
|
||||
extern OPTYPE ptable [WINDOW]; /* Pcode Table */
|
||||
extern OPTYPE *pptr [WINDOW]; /* Valid Pcode Pointers */
|
||||
|
||||
extern int nops; /* No. Valid Pcode Pointers */
|
||||
extern int end_out; /* 1 = oEND pcode has been output */
|
||||
|
||||
#endif /* __PLOCAL_H */
|
||||
|
||||
+327
-327
@@ -1,327 +1,327 @@
|
||||
/**********************************************************************
|
||||
* popt.c
|
||||
* P-Code Optimizer Main Logic
|
||||
*
|
||||
* Copyright (C) 2008 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
**********************************************************************/
|
||||
|
||||
/**********************************************************************
|
||||
* Included Files
|
||||
**********************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "keywords.h"
|
||||
#include "podefs.h"
|
||||
#include "paslib.h"
|
||||
#include "pofflib.h"
|
||||
|
||||
#include "pinsn.h"
|
||||
#include "popt.h"
|
||||
#include "psopt.h"
|
||||
#include "polocal.h"
|
||||
#include "pfopt.h"
|
||||
|
||||
/**********************************************************************
|
||||
* Private Function Prototypes
|
||||
**********************************************************************/
|
||||
|
||||
static void showUsage (const char *progname, int errcode);
|
||||
static void readPoffFile (const char *filename);
|
||||
static void pass1 (void);
|
||||
static void pass2 (void);
|
||||
static void pass3 (void);
|
||||
static void writePoffFile (const char *filename);
|
||||
|
||||
/**********************************************************************
|
||||
* Global Variables
|
||||
**********************************************************************/
|
||||
|
||||
/**********************************************************************
|
||||
* Private Variables
|
||||
**********************************************************************/
|
||||
|
||||
static poffHandle_t poffHandle; /* Handle to POFF object */
|
||||
static int no_resolve = 0;
|
||||
|
||||
/**********************************************************************
|
||||
* Global Functions
|
||||
**********************************************************************/
|
||||
|
||||
/***********************************************************************/
|
||||
|
||||
int main(int argc, char *argv[], char *envp[])
|
||||
{
|
||||
const char *outfilename;
|
||||
TRACE(stderr, "[main]");
|
||||
int option;
|
||||
|
||||
/* Process command line argruments */
|
||||
|
||||
while ((option = getopt(argc, argv, "rh")) > 0)
|
||||
{
|
||||
switch (option)
|
||||
{
|
||||
case 'r' :
|
||||
no_resolve++;
|
||||
break;
|
||||
case 'h' :
|
||||
showUsage(argv[0], 0);
|
||||
default:
|
||||
fprintf(stderr, "Unrecognized option\n");
|
||||
showUsage(argv[0], -1);
|
||||
}
|
||||
}
|
||||
|
||||
/* Check for existence of filename argument */
|
||||
|
||||
if (optind != argc - 1)
|
||||
{
|
||||
printf("Filename required at end of command line.\n");
|
||||
showUsage(argv[0], -1);
|
||||
} /* end if */
|
||||
|
||||
/* Read the POFF file into memory */
|
||||
|
||||
outfilename = argv[optind];
|
||||
readPoffFile(outfilename);
|
||||
|
||||
/* Performs pass1 optimization */
|
||||
|
||||
pass1();
|
||||
|
||||
/* Performs pass2 optimization */
|
||||
|
||||
insn_ResetOpCodeRead(poffHandle);
|
||||
pass2();
|
||||
|
||||
if (!no_resolve)
|
||||
{
|
||||
/* Create final section offsets and relocation entries */
|
||||
|
||||
insn_ResetOpCodeRead(poffHandle);
|
||||
pass3();
|
||||
}
|
||||
|
||||
/* Write the POFF file */
|
||||
|
||||
writePoffFile(outfilename);
|
||||
return 0;
|
||||
|
||||
} /* End main */
|
||||
|
||||
/**********************************************************************
|
||||
* Private Functions
|
||||
**********************************************************************/
|
||||
|
||||
/***********************************************************************/
|
||||
|
||||
static void showUsage(const char *progname, int errcode)
|
||||
{
|
||||
fprintf(stderr, "USAGE:\n");
|
||||
fprintf(stderr, " %s -h\n", progname);
|
||||
fprintf(stderr, " %s [-r] <poff-filename>\n", progname);
|
||||
fprintf(stderr, "WHERE:\n");
|
||||
fprintf(stderr, " -r: Disables label resolution (default: labels resolved)\n");
|
||||
fprintf(stderr, " -h: Shows this message\n");
|
||||
exit(errcode);
|
||||
}
|
||||
|
||||
/***********************************************************************/
|
||||
|
||||
static void readPoffFile(const char *filename)
|
||||
{
|
||||
char objname [FNAME_SIZE+1];
|
||||
FILE *objFile;
|
||||
int errcode;
|
||||
|
||||
TRACE(stderr, "[readPoffFile]");
|
||||
|
||||
/* Open the pass1 POFF object file -- Use .o1 extension */
|
||||
|
||||
(void)extension(filename, "o1", objname, 1);
|
||||
if (!(objFile = fopen(objname, "rb")))
|
||||
{
|
||||
printf("Error Opening %s\n", objname);
|
||||
exit(1);
|
||||
} /* end if */
|
||||
|
||||
/* Get a handle to a POFF input object */
|
||||
|
||||
poffHandle = poffCreateHandle();
|
||||
if (!poffHandle)
|
||||
{
|
||||
printf("Could not get POFF handle\n");
|
||||
exit(1);
|
||||
} /* end if */
|
||||
|
||||
/* Read the POFF file into memory */
|
||||
|
||||
errcode = poffReadFile(poffHandle, objFile);
|
||||
if (errcode != 0)
|
||||
{
|
||||
printf("Could not read POFF file, errcode=0x%02x\n", errcode);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* Close the input file */
|
||||
|
||||
fclose(objFile);
|
||||
} /* end pass1 */
|
||||
|
||||
/***********************************************************************/
|
||||
|
||||
static void pass1(void)
|
||||
{
|
||||
poffProgHandle_t poffProgHandle; /* Handle to temporary POFF object */
|
||||
|
||||
TRACE(stderr, "[pass1]");
|
||||
|
||||
/* Create a handle to a temporary object to store new POFF program
|
||||
* data.
|
||||
*/
|
||||
|
||||
poffProgHandle = poffCreateProgHandle();
|
||||
if (!poffProgHandle)
|
||||
{
|
||||
printf("Could not get POFF handle\n");
|
||||
exit(1);
|
||||
} /* end if */
|
||||
|
||||
/* Clean up garbage left from the wasteful string stack logic */
|
||||
|
||||
stringStackOptimize(poffHandle, poffProgHandle);
|
||||
|
||||
/* Replace the original program data with the new program data */
|
||||
|
||||
poffReplaceProgData(poffHandle, poffProgHandle);
|
||||
|
||||
/* Release the temporary POFF object */
|
||||
|
||||
poffDestroyProgHandle(poffProgHandle);
|
||||
} /* end pass1 */
|
||||
|
||||
/***********************************************************************/
|
||||
|
||||
static void pass2(void)
|
||||
{
|
||||
poffProgHandle_t poffProgHandle; /* Handle to temporary POFF object */
|
||||
|
||||
TRACE(stderr, "[pass2]");
|
||||
|
||||
/* Create a handle to a temporary object to store new POFF program
|
||||
* data.
|
||||
*/
|
||||
|
||||
poffProgHandle = poffCreateProgHandle();
|
||||
if (!poffProgHandle)
|
||||
{
|
||||
printf("Could not get POFF handle\n");
|
||||
exit(1);
|
||||
} /* end if */
|
||||
|
||||
/* Perform Local Optimizatin Initialization */
|
||||
|
||||
localOptimization(poffHandle, poffProgHandle);
|
||||
|
||||
/* Replace the original program data with the new program data */
|
||||
|
||||
poffReplaceProgData(poffHandle, poffProgHandle);
|
||||
|
||||
/* Release the temporary POFF object */
|
||||
|
||||
poffDestroyProgHandle(poffProgHandle);
|
||||
} /* end pass2 */
|
||||
|
||||
/***********************************************************************/
|
||||
|
||||
static void pass3 (void)
|
||||
{
|
||||
poffProgHandle_t poffProgHandle; /* Handle to temporary POFF object */
|
||||
TRACE(stderr, "[pass3]");
|
||||
|
||||
/* Create a handle to a temporary object to store new POFF program
|
||||
* data.
|
||||
*/
|
||||
|
||||
poffProgHandle = poffCreateProgHandle();
|
||||
if (!poffProgHandle)
|
||||
{
|
||||
printf("Could not get POFF handle\n");
|
||||
exit(1);
|
||||
} /* end if */
|
||||
|
||||
/* Finalize program section, create relocation and line number
|
||||
* sections.
|
||||
*/
|
||||
|
||||
optFinalize(poffHandle, poffProgHandle);
|
||||
|
||||
/* Release the temporary POFF object */
|
||||
|
||||
poffDestroyProgHandle(poffProgHandle);
|
||||
}
|
||||
|
||||
/***********************************************************************/
|
||||
|
||||
static void writePoffFile(const char *filename)
|
||||
{
|
||||
char optname [FNAME_SIZE+1];
|
||||
FILE *optFile;
|
||||
|
||||
TRACE(stderr, "[writePoffFile]");
|
||||
|
||||
/* Open optimized p-code file -- Use .o extension */
|
||||
|
||||
(void)extension(filename, "o", optname, 1);
|
||||
if (!(optFile = fopen(optname, "wb")))
|
||||
{
|
||||
printf("Error Opening %s\n", optname);
|
||||
exit(1);
|
||||
} /* end if */
|
||||
|
||||
/* Then write the new POFF file */
|
||||
|
||||
poffWriteFile(poffHandle, optFile);
|
||||
|
||||
/* Destroy the POFF object */
|
||||
|
||||
poffDestroyHandle(poffHandle);
|
||||
|
||||
/* Close the files used on writePoffFile */
|
||||
|
||||
(void)fclose(optFile);
|
||||
} /* end writePoffFile */
|
||||
|
||||
/***********************************************************************/
|
||||
/**********************************************************************
|
||||
* popt.c
|
||||
* P-Code Optimizer Main Logic
|
||||
*
|
||||
* Copyright (C) 2008 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
**********************************************************************/
|
||||
|
||||
/**********************************************************************
|
||||
* Included Files
|
||||
**********************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "keywords.h"
|
||||
#include "podefs.h"
|
||||
#include "paslib.h"
|
||||
#include "pofflib.h"
|
||||
|
||||
#include "pinsn.h"
|
||||
#include "popt.h"
|
||||
#include "psopt.h"
|
||||
#include "polocal.h"
|
||||
#include "pfopt.h"
|
||||
|
||||
/**********************************************************************
|
||||
* Private Function Prototypes
|
||||
**********************************************************************/
|
||||
|
||||
static void showUsage (const char *progname, int errcode);
|
||||
static void readPoffFile (const char *filename);
|
||||
static void pass1 (void);
|
||||
static void pass2 (void);
|
||||
static void pass3 (void);
|
||||
static void writePoffFile (const char *filename);
|
||||
|
||||
/**********************************************************************
|
||||
* Global Variables
|
||||
**********************************************************************/
|
||||
|
||||
/**********************************************************************
|
||||
* Private Variables
|
||||
**********************************************************************/
|
||||
|
||||
static poffHandle_t poffHandle; /* Handle to POFF object */
|
||||
static int no_resolve = 0;
|
||||
|
||||
/**********************************************************************
|
||||
* Global Functions
|
||||
**********************************************************************/
|
||||
|
||||
/***********************************************************************/
|
||||
|
||||
int main(int argc, char *argv[], char *envp[])
|
||||
{
|
||||
const char *outfilename;
|
||||
TRACE(stderr, "[main]");
|
||||
int option;
|
||||
|
||||
/* Process command line argruments */
|
||||
|
||||
while ((option = getopt(argc, argv, "rh")) > 0)
|
||||
{
|
||||
switch (option)
|
||||
{
|
||||
case 'r' :
|
||||
no_resolve++;
|
||||
break;
|
||||
case 'h' :
|
||||
showUsage(argv[0], 0);
|
||||
default:
|
||||
fprintf(stderr, "Unrecognized option\n");
|
||||
showUsage(argv[0], -1);
|
||||
}
|
||||
}
|
||||
|
||||
/* Check for existence of filename argument */
|
||||
|
||||
if (optind != argc - 1)
|
||||
{
|
||||
printf("Filename required at end of command line.\n");
|
||||
showUsage(argv[0], -1);
|
||||
} /* end if */
|
||||
|
||||
/* Read the POFF file into memory */
|
||||
|
||||
outfilename = argv[optind];
|
||||
readPoffFile(outfilename);
|
||||
|
||||
/* Performs pass1 optimization */
|
||||
|
||||
pass1();
|
||||
|
||||
/* Performs pass2 optimization */
|
||||
|
||||
insn_ResetOpCodeRead(poffHandle);
|
||||
pass2();
|
||||
|
||||
if (!no_resolve)
|
||||
{
|
||||
/* Create final section offsets and relocation entries */
|
||||
|
||||
insn_ResetOpCodeRead(poffHandle);
|
||||
pass3();
|
||||
}
|
||||
|
||||
/* Write the POFF file */
|
||||
|
||||
writePoffFile(outfilename);
|
||||
return 0;
|
||||
|
||||
} /* End main */
|
||||
|
||||
/**********************************************************************
|
||||
* Private Functions
|
||||
**********************************************************************/
|
||||
|
||||
/***********************************************************************/
|
||||
|
||||
static void showUsage(const char *progname, int errcode)
|
||||
{
|
||||
fprintf(stderr, "USAGE:\n");
|
||||
fprintf(stderr, " %s -h\n", progname);
|
||||
fprintf(stderr, " %s [-r] <poff-filename>\n", progname);
|
||||
fprintf(stderr, "WHERE:\n");
|
||||
fprintf(stderr, " -r: Disables label resolution (default: labels resolved)\n");
|
||||
fprintf(stderr, " -h: Shows this message\n");
|
||||
exit(errcode);
|
||||
}
|
||||
|
||||
/***********************************************************************/
|
||||
|
||||
static void readPoffFile(const char *filename)
|
||||
{
|
||||
char objname [FNAME_SIZE+1];
|
||||
FILE *objFile;
|
||||
int errcode;
|
||||
|
||||
TRACE(stderr, "[readPoffFile]");
|
||||
|
||||
/* Open the pass1 POFF object file -- Use .o1 extension */
|
||||
|
||||
(void)extension(filename, "o1", objname, 1);
|
||||
if (!(objFile = fopen(objname, "rb")))
|
||||
{
|
||||
printf("Error Opening %s\n", objname);
|
||||
exit(1);
|
||||
} /* end if */
|
||||
|
||||
/* Get a handle to a POFF input object */
|
||||
|
||||
poffHandle = poffCreateHandle();
|
||||
if (!poffHandle)
|
||||
{
|
||||
printf("Could not get POFF handle\n");
|
||||
exit(1);
|
||||
} /* end if */
|
||||
|
||||
/* Read the POFF file into memory */
|
||||
|
||||
errcode = poffReadFile(poffHandle, objFile);
|
||||
if (errcode != 0)
|
||||
{
|
||||
printf("Could not read POFF file, errcode=0x%02x\n", errcode);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* Close the input file */
|
||||
|
||||
fclose(objFile);
|
||||
} /* end pass1 */
|
||||
|
||||
/***********************************************************************/
|
||||
|
||||
static void pass1(void)
|
||||
{
|
||||
poffProgHandle_t poffProgHandle; /* Handle to temporary POFF object */
|
||||
|
||||
TRACE(stderr, "[pass1]");
|
||||
|
||||
/* Create a handle to a temporary object to store new POFF program
|
||||
* data.
|
||||
*/
|
||||
|
||||
poffProgHandle = poffCreateProgHandle();
|
||||
if (!poffProgHandle)
|
||||
{
|
||||
printf("Could not get POFF handle\n");
|
||||
exit(1);
|
||||
} /* end if */
|
||||
|
||||
/* Clean up garbage left from the wasteful string stack logic */
|
||||
|
||||
stringStackOptimize(poffHandle, poffProgHandle);
|
||||
|
||||
/* Replace the original program data with the new program data */
|
||||
|
||||
poffReplaceProgData(poffHandle, poffProgHandle);
|
||||
|
||||
/* Release the temporary POFF object */
|
||||
|
||||
poffDestroyProgHandle(poffProgHandle);
|
||||
} /* end pass1 */
|
||||
|
||||
/***********************************************************************/
|
||||
|
||||
static void pass2(void)
|
||||
{
|
||||
poffProgHandle_t poffProgHandle; /* Handle to temporary POFF object */
|
||||
|
||||
TRACE(stderr, "[pass2]");
|
||||
|
||||
/* Create a handle to a temporary object to store new POFF program
|
||||
* data.
|
||||
*/
|
||||
|
||||
poffProgHandle = poffCreateProgHandle();
|
||||
if (!poffProgHandle)
|
||||
{
|
||||
printf("Could not get POFF handle\n");
|
||||
exit(1);
|
||||
} /* end if */
|
||||
|
||||
/* Perform Local Optimizatin Initialization */
|
||||
|
||||
localOptimization(poffHandle, poffProgHandle);
|
||||
|
||||
/* Replace the original program data with the new program data */
|
||||
|
||||
poffReplaceProgData(poffHandle, poffProgHandle);
|
||||
|
||||
/* Release the temporary POFF object */
|
||||
|
||||
poffDestroyProgHandle(poffProgHandle);
|
||||
} /* end pass2 */
|
||||
|
||||
/***********************************************************************/
|
||||
|
||||
static void pass3 (void)
|
||||
{
|
||||
poffProgHandle_t poffProgHandle; /* Handle to temporary POFF object */
|
||||
TRACE(stderr, "[pass3]");
|
||||
|
||||
/* Create a handle to a temporary object to store new POFF program
|
||||
* data.
|
||||
*/
|
||||
|
||||
poffProgHandle = poffCreateProgHandle();
|
||||
if (!poffProgHandle)
|
||||
{
|
||||
printf("Could not get POFF handle\n");
|
||||
exit(1);
|
||||
} /* end if */
|
||||
|
||||
/* Finalize program section, create relocation and line number
|
||||
* sections.
|
||||
*/
|
||||
|
||||
optFinalize(poffHandle, poffProgHandle);
|
||||
|
||||
/* Release the temporary POFF object */
|
||||
|
||||
poffDestroyProgHandle(poffProgHandle);
|
||||
}
|
||||
|
||||
/***********************************************************************/
|
||||
|
||||
static void writePoffFile(const char *filename)
|
||||
{
|
||||
char optname [FNAME_SIZE+1];
|
||||
FILE *optFile;
|
||||
|
||||
TRACE(stderr, "[writePoffFile]");
|
||||
|
||||
/* Open optimized p-code file -- Use .o extension */
|
||||
|
||||
(void)extension(filename, "o", optname, 1);
|
||||
if (!(optFile = fopen(optname, "wb")))
|
||||
{
|
||||
printf("Error Opening %s\n", optname);
|
||||
exit(1);
|
||||
} /* end if */
|
||||
|
||||
/* Then write the new POFF file */
|
||||
|
||||
poffWriteFile(poffHandle, optFile);
|
||||
|
||||
/* Destroy the POFF object */
|
||||
|
||||
poffDestroyHandle(poffHandle);
|
||||
|
||||
/* Close the files used on writePoffFile */
|
||||
|
||||
(void)fclose(optFile);
|
||||
} /* end writePoffFile */
|
||||
|
||||
/***********************************************************************/
|
||||
|
||||
@@ -1,52 +1,52 @@
|
||||
/***************************************************************************
|
||||
* popt.h
|
||||
* External Declarations associated with popt.c
|
||||
*
|
||||
* Copyright (C) 2008 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef __POPT_H
|
||||
#define __POPT_H
|
||||
|
||||
/***************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* Global Variables
|
||||
****************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* Global Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
#endif /* __POPT_H */
|
||||
/***************************************************************************
|
||||
* popt.h
|
||||
* External Declarations associated with popt.c
|
||||
*
|
||||
* Copyright (C) 2008 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef __POPT_H
|
||||
#define __POPT_H
|
||||
|
||||
/***************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* Global Variables
|
||||
****************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* Global Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
#endif /* __POPT_H */
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* String Stack Optimizaitons
|
||||
*
|
||||
* Copyright (C) 2008-2009 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
|
||||
@@ -1,54 +1,54 @@
|
||||
/***************************************************************************
|
||||
* psopt.h
|
||||
* External Declarations associated with psopt.c
|
||||
*
|
||||
* Copyright (C) 2008 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef __PSOPT_H
|
||||
#define __PSOPT_H
|
||||
|
||||
/***************************************************************************
|
||||
* Included Files
|
||||
***************************************************************************/
|
||||
|
||||
#include "pofflib.h"
|
||||
|
||||
/***************************************************************************
|
||||
* Global Function Prototypes
|
||||
***************************************************************************/
|
||||
|
||||
extern void stringStackOptimize(poffHandle_t poffHandle,
|
||||
poffProgHandle_t poffProgHandle);
|
||||
|
||||
#endif /* __PSOPT_H */
|
||||
|
||||
/***************************************************************************
|
||||
* psopt.h
|
||||
* External Declarations associated with psopt.c
|
||||
*
|
||||
* Copyright (C) 2008 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef __PSOPT_H
|
||||
#define __PSOPT_H
|
||||
|
||||
/***************************************************************************
|
||||
* Included Files
|
||||
***************************************************************************/
|
||||
|
||||
#include "pofflib.h"
|
||||
|
||||
/***************************************************************************
|
||||
* Global Function Prototypes
|
||||
***************************************************************************/
|
||||
|
||||
extern void stringStackOptimize(poffHandle_t poffHandle,
|
||||
poffProgHandle_t poffProgHandle);
|
||||
|
||||
#endif /* __PSOPT_H */
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# insn32/regm/Makefile
|
||||
#
|
||||
# Copyright (C) 2008 Gregory Nutt. All rights reserved.
|
||||
# Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
# Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* Convert 32-bit pcode defintions to a register model
|
||||
*
|
||||
* Copyright (C) 2008-2009 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* External Declarations associated with regm.c
|
||||
*
|
||||
* Copyright (C) 2008-2009 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* Break the pcode data into sections
|
||||
*
|
||||
* Copyright (C) 2008-2009 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
|
||||
@@ -1,58 +1,58 @@
|
||||
/***************************************************************************
|
||||
* regm_pass1.h
|
||||
* External Declarations associated with regm_pass1.c
|
||||
*
|
||||
* Copyright (C) 2008 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef __REGM_PASS1_H
|
||||
#define __REGM_PASS1_H
|
||||
|
||||
/***************************************************************************
|
||||
* Included Files
|
||||
***************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* Definitions
|
||||
***************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* Global Variables
|
||||
***************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* Global Function Prototypes
|
||||
***************************************************************************/
|
||||
|
||||
extern void regm_Pass1(poffHandle_t hPoff);
|
||||
|
||||
#endif /* __REGM_PASS1_H */
|
||||
/***************************************************************************
|
||||
* regm_pass1.h
|
||||
* External Declarations associated with regm_pass1.c
|
||||
*
|
||||
* Copyright (C) 2008 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef __REGM_PASS1_H
|
||||
#define __REGM_PASS1_H
|
||||
|
||||
/***************************************************************************
|
||||
* Included Files
|
||||
***************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* Definitions
|
||||
***************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* Global Variables
|
||||
***************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* Global Function Prototypes
|
||||
***************************************************************************/
|
||||
|
||||
extern void regm_Pass1(poffHandle_t hPoff);
|
||||
|
||||
#endif /* __REGM_PASS1_H */
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* registers) and with 32-bit immediate size.
|
||||
*
|
||||
* Copyright (C) 2008-2009 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* External Declarations associated with regm_pass2.c
|
||||
*
|
||||
* Copyright (C) 2008-2009 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* Pass 2 register management functions
|
||||
*
|
||||
* Copyright (C) 2008-2009 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* Definitions for management of registers
|
||||
*
|
||||
* Copyright (C) 2008-2009 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* Tree managmenet
|
||||
*
|
||||
* Copyright (C) 2008-2009 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* External Declarations associated with regm_tree.c
|
||||
*
|
||||
* Copyright (C) 2008-2009 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
|
||||
Reference in New Issue
Block a user