inline.c
来自「开放源码的编译器open watcom 1.6.0版的源代码」· C语言 代码 · 共 493 行 · 第 1/2 页
C
493 行
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: WHEN YOU FIGURE OUT WHAT THIS FILE DOES, PLEASE
* DESCRIBE IT HERE!
*
****************************************************************************/
//
// INLINE : inline pragamas used to optimize certain operations
//
#include "ftnstd.h"
#include "global.h"
#include "cgdefs.h"
#include "cg.h"
#include "wf77aux.h"
#include "wf77defs.h"
#include "fcgbls.h"
#include "cgflags.h"
#include "cpopt.h"
#include "inline.h"
#include "types.h"
#include "fctypes.h"
#include <string.h>
//=================== Back End Code Generation Routines ====================
extern cg_name CGFEName(sym_handle,cg_type);
extern call_handle CGInitCall(cg_name,cg_type,sym_handle);
extern void BEFreeBack(back_handle);
//=========================================================================
extern sym_id STAdd(char *name,int length);
extern sym_id STFree(sym_id sym_ptr);
extern segment_id AllocImpSegId(void);
extern void DoPragma(char *);
extern aux_info *AuxLookupName(char *,uint);
#if _CPU == 386 || _CPU == 8086
extern unsigned_8 CGFlags;
#if _CPU == 386
// Space optimization pragmas (take an awful beating on a pentium)
// edi - destination pointer
// esi - source pointer
// ecx - number of characters to move
static char __RTIStrBlastEqOS[] = { "aux __RTIStrBlastEq \
parm reverse \
[edi] [esi] [ecx] = \
\"rep movsb\" \
" };
// edi - destination pointer
// eax - number of spaces to append
// esi - source pointer
// ecx - number of characters to move
static char __RTIStrBlastNeOS[] = { "aux __RTIStrBlastNe \
parm reverse \
[edi] [eax] [esi] [ecx]=\
\"rep movsb\" \
\"mov ecx, eax\" \
\"mov eax, 0x20202020\" \
\"rep stosb\" \
" };
// Time Optimization pragmas
// edi - destination pointer
// esi - source pointer
// ecx - number of 4 character tuples to move (strlen >> 2)
// eax - number of characters left over after initial 4-tuple move (strlen & 3)
static char __RTIStrBlastEq[] = { "aux __RTIStrBlastEq \
parm reverse \
[edi] [esi] [ecx] [eax] =\
\"rep movsd\" \
\"mov ecx, eax\" \
\"rep movsb\" \
" };
// edi - destination pointer
// eax - number of spaces to append
// esi - source pointer
// ecx - number of characters to move
static char __RTIStrBlastNe[] = { "aux __RTIStrBlastNe \
parm reverse \
[edi] [edx] [esi] [eax] \
modify [ecx] = \
\"mov ecx, eax\" \
\"shr ecx, 2\" \
\"rep movsd\" \
\"mov ecx, eax\" \
\"and ecx, 3\" \
\"rep movsb\" \
\"mov ecx, edx\" \
\"shr ecx, 2\" \
\"mov eax, 0x20202020\" \
\"rep stosd\" \
\"mov ecx, edx\" \
\"and ecx, 3\" \
\"rep stosb\" \
" };
#elif _CPU == 8086
// Space Optimization pragmas
// es di - destination pointer
// ds si - source pointer
// cx - number of characters to move
static char __RTIStrBlastEqOS[] = { "aux __RTIStrBlastEq \
parm reverse \
[es di] [ds si] [cx] \
modify exact [di si cx] = \
\"rep movsb\" \
" };
// es di - destination pointer
// ax - number of spaces to append
// ds si - source pointer
// cx - number of characters to move
static char __RTIStrBlastNeOS[] = { "aux __RTIStrBlastNe \
parm reverse \
[es di] [ax] [ds si] [cx]\
modify exact [di ax si cx] = \
\"rep movsb\" \
\"mov cx, ax\" \
\"mov ax, 0x2020\" \
\"rep stosb\" \
" };
// es di - destination pointer
// ds si - source pointer
// cx - number of 2 character tuples to move (strlen >> 21
// ax - number of characters left over after initial 2-tuple move (strlen & 1)
static char __RTIStrBlastEq[] = { "aux __RTIStrBlastEq \
parm reverse \
[es di] [ds si] [cx] [ax]\
modify exact [cx si di] = \
\"rep movsw\" \
\"mov cx, ax\" \
\"rep movsb\" \
" };
// es di - destination pointer
// ax - number of spaces to append
// ds si - source pointer
// cx - number of characters to move
static char __RTIStrBlastNe[] = { "aux __RTIStrBlastNe \
parm reverse \
[es di] [dx] [ds si] [ax]\
modify exact [di dx si ax cx] =\
\"mov cx,ax\" \
\"shr cx,1\" \
\"rep movsw\" \
\"adc cx,0\" \
\"rep movsb\" \
\"mov cx,dx\" \
\"mov ax,0x2020\" \
\"shr cx,1\" \
\"rep stosw\" \
\"adc cx,0\" \
\"rep stosb\" \
" };
// Windows pragmas (can't use DS as an argument since DS is pegged)
// es di - destination pointer
// si bx - source pointer
// cx - number of characters to move
static char __RTIStrBlastEqWinOS[] = { "aux __RTIStrBlastEq \
parm reverse \
[es di] [si bx] [cx] \
modify exact [di si cx] = \
\"push ds\" \
\"mov ds,si\" \
\"mov si,bx\" \
\"rep movsb\" \
\"pop ds\" \
" };
// es di - destination pointer
// ax - number of spaces to append
// si bx - source pointer
// cx - number of characters to move
static char __RTIStrBlastNeWinOS[] = { "aux __RTIStrBlastNe \
parm reverse \
[es di] [ax] [si bx] [cx]\
modify exact [di ax si cx] = \
\"push ds\" \
\"mov ds,si\" \
\"mov si,bx\" \
\"rep movsb\" \
\"mov cx, ax\" \
\"mov ax, 0x2020\" \
\"rep stosb\" \
\"pop ds\" \
" };
// es di - destination pointer
// si bx - source pointer
// cx - number of 2 character tuples to move (strlen >> 21
// ax - number of characters left over after initial 2-tuple move (strlen & 1)
static char __RTIStrBlastEqWin[] = { "aux __RTIStrBlastEq \
parm reverse \
[es di] [si bx] [cx] [ax]\
modify exact [cx si di] = \
\"push ds\" \
\"mov ds,si\" \
\"mov si,bx\" \
\"rep movsw\" \
\"mov cx,ax\" \
\"rep movsb\" \
\"pop ds\" \
" };
// es di - destination pointer
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?