Skip to content

Commit

Permalink
Revert unwanted changes in "cleanup mathlib code"
Browse files Browse the repository at this point in the history
This reverts commit 16ba066.
  • Loading branch information
jmalak committed Dec 1, 2023
1 parent 16ba066 commit 06abea3
Show file tree
Hide file tree
Showing 43 changed files with 421 additions and 634 deletions.
397 changes: 159 additions & 238 deletions bld/as/axp/c/alphafmt.c

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bld/cc/c/ccmain.c
Expand Up @@ -1418,7 +1418,7 @@ void CloseFiles( void )
}


int FrontEnd( char **cmdline )
bool FrontEnd( char **cmdline )
{
#if defined(__WATCOMC__) && defined( _M_IX86 )
/*
Expand Down
50 changes: 6 additions & 44 deletions bld/cc/c/cdinit.c
Expand Up @@ -1494,7 +1494,7 @@ static void InitArraySimpleVar( SYMPTR sym, SYM_HANDLE sym_handle, TYPEPTR typ,
AddStmt( AsgnOp( opnd, T_ASSIGN_LAST, value ) );
}

static target_size InitArrayVar( SYMPTR sym, SYM_HANDLE sym_handle, TYPEPTR typ, target_size start )
static void InitArrayVar( SYMPTR sym, SYM_HANDLE sym_handle, TYPEPTR typ )
{
target_size i;
target_size n;
Expand All @@ -1504,7 +1504,6 @@ static target_size InitArrayVar( SYMPTR sym, SYM_HANDLE sym_handle, TYPEPTR typ,
TOKEN token;
target_size j;
target_size dim;
target_size idx;

typ2 = typ->object;
SKIP_TYPEDEFS( typ2 );
Expand All @@ -1531,7 +1530,6 @@ static target_size InitArrayVar( SYMPTR sym, SYM_HANDLE sym_handle, TYPEPTR typ,
* skip over T_LEFT_BRACE
*/
NextToken();
dim = 1;
if( CharArray( typ->object ) ) {
sym2_handle = MakeNewSym( &sym2, 'X', typ, SC_STATIC );
sym2.flags |= SYM_INITIALIZED;
Expand Down Expand Up @@ -1571,68 +1569,33 @@ static target_size InitArrayVar( SYMPTR sym, SYM_HANDLE sym_handle, TYPEPTR typ,
token = CurToken;
if( token == T_LEFT_BRACE )
NextToken();
InitArraySimpleVar( sym, sym_handle, typ2, start + i, CommaExpr() );
InitArraySimpleVar( sym, sym_handle, typ2, i, CommaExpr() );
if( token == T_LEFT_BRACE )
MustRecog( T_RIGHT_BRACE );
++i;
if( dim < i )
dim = i;
if( CurToken == T_EOF )
break;
if( CurToken == T_SEMI_COLON )
break;
if( CurToken == T_RIGHT_BRACE )
break;
MustRecog( T_COMMA );
if( CurToken == T_RIGHT_BRACE )
break;
if( n && i > n ) {
if( n && i >= n ) {
CErr1( ERR_TOO_MANY_INITS );
}
}
if( typ->u.array->unspecified_dim ) {
typ->u.array->dimension = dim;
} else {
for( i = dim; i < n; i++ ) {
InitArraySimpleVar( sym, sym_handle, typ2, start + i, IntLeaf( 0 ) );
dim++;
InitArraySimpleVar( sym, sym_handle, typ2, i, IntLeaf( 0 ) );
}
}
}
MustRecog( T_RIGHT_BRACE );
return( dim );
case TYP_ARRAY:
n = typ->u.array->dimension;
dim = 0;
i = 0;
idx = start;
for( ;; ) { // accept some C++ { {1},.. }
idx += InitArrayVar( sym, sym_handle, typ2, idx );
++i;
if( dim < i )
dim = i;
if( CurToken == T_EOF )
break;
if( CurToken == T_SEMI_COLON )
break;
if( CurToken == T_RIGHT_BRACE )
break;
MustRecog( T_COMMA );
if( CurToken == T_RIGHT_BRACE )
break;
if( n && i > n ) {
CErr1( ERR_TOO_MANY_INITS );
}
}
if( typ->u.array->unspecified_dim ) {
typ->u.array->dimension = dim;
} else {
for( i = dim; i < n; i++ ) {
InitArraySimpleVar( sym, sym_handle, typ2, start + i, IntLeaf( 0 ) );
idx++;
}
}
return( idx );
break;
case TYP_FCOMPLEX:
case TYP_DCOMPLEX:
case TYP_LDCOMPLEX:
Expand Down Expand Up @@ -1692,7 +1655,6 @@ static target_size InitArrayVar( SYMPTR sym, SYM_HANDLE sym_handle, TYPEPTR typ,
AggregateVarDeclEquals( sym, sym_handle );
break;
}
return( 1 );
}

void VarDeclEquals( SYMPTR sym, SYM_HANDLE sym_handle )
Expand Down Expand Up @@ -1720,7 +1682,7 @@ void VarDeclEquals( SYMPTR sym, SYM_HANDLE sym_handle )
sym->flags |= SYM_ASSIGNED;
} else if( typ->decl_type == TYP_ARRAY ) {
if( CurToken == T_LEFT_BRACE && CompFlags.auto_agg_inits ) {
InitArrayVar( sym, sym_handle, typ, 0 );
InitArrayVar( sym, sym_handle, typ );
} else {
AggregateVarDeclEquals( sym, sym_handle );
}
Expand Down
1 change: 0 additions & 1 deletion bld/cc/c/cexpr.c
Expand Up @@ -703,7 +703,6 @@ static TREEPTR AddrOp( TREEPTR tree )
if( tree->op.opr == OPR_ERROR )
return( tree );
typ = tree->u.expr_type;
SKIP_TYPEDEFS( typ );
if( typ->decl_type == TYP_FIELD || typ->decl_type == TYP_UFIELD ) {
CErr1( ERR_CANT_TAKE_ADDR_OF_BIT_FIELD );
return( ErrorNode( tree ) );
Expand Down
4 changes: 2 additions & 2 deletions bld/cc/gml/options.gml
Expand Up @@ -343,8 +343,8 @@
:target. any
:enumerate. debug_info
:timestamp.
:usage. line numbers and some type info
:jusage. line numbers and some type info
:usage. only line numbers
:jusage. 行番号デバッグ情報

:option. d2
:target. any
Expand Down
2 changes: 1 addition & 1 deletion bld/cc/h/cvars.h
Expand Up @@ -389,7 +389,7 @@ extern void ParmAsgnCheck( TYPEPTR typ1, TREEPTR opnd2, int parmno, bool
/* ccmain.c */
extern void FreeRDir( void );
extern void FrontEndInit( bool reuse );
extern int FrontEnd(char **);
extern bool FrontEnd(char **);
extern void FrontEndFini( void );
extern void CppComment(int);
extern bool CppPrinting( void );
Expand Down
2 changes: 1 addition & 1 deletion bld/cg/c/intrface.c
Expand Up @@ -492,7 +492,7 @@ back_handle _CGAPI BENewBack( cg_sym_handle sym )
}
if( NewBackReturn != NULL ) {
#ifdef DEVBUILD
EchoAPI( " -> %B\n", NewBackReturn );
EchoAPI( " -> %B\n", NewBackReturn );
#endif
return( NewBackReturn );
}
Expand Down
4 changes: 2 additions & 2 deletions bld/cg/intel/c/x86data.c
Expand Up @@ -295,8 +295,8 @@ static cg_class ConstDataClass( void )
{
if( _IsTargetModel( CGSW_X86_CONST_IN_CODE ) ) {
return( CG_CLB );
// } else if( _IsTargetModel( CGSW_X86_FLOATING_DS ) && _IsTargetModel( CGSW_X86_FLOATING_SS ) ) {
// return( CG_CLB );
} else if( _IsTargetModel( CGSW_X86_FLOATING_DS ) && _IsTargetModel( CGSW_X86_FLOATING_SS ) ) {
return( CG_CLB );
} else {
return( CG_LBL );
}
Expand Down
8 changes: 2 additions & 6 deletions bld/cg/intel/c/x86index.c
Expand Up @@ -505,20 +505,16 @@ void FixFPConsts( instruction *ins )
* memory reference, (therefore one segment override), will see it as a
* memory reference and treat it accordingly.
*
* TODO!
* now it is useless due to wrong condition, always false (dead code)
* need review
*/
{
#if 0
opcnt i;
type_class_def type_class;

if( _IsTargetModel( CGSW_X86_CONST_IN_CODE ) ) {
} else if( _IsTargetModel( CGSW_X86_FLOATING_DS )
&& _IsTargetModel( CGSW_X86_FLOATING_SS ) ) {
} else if( _IsTargetModel( CGSW_X86_FLOATING_DS )
&& _IsTargetModel( CGSW_X86_FLOATING_SS ) ) {
} else if( _IsTargetModel( CGSW_X86_FLOATING_DS ) && _IsTargetModel( CGSW_X86_FLOATING_SS ) ) {
} else if( _IsTargetModel( CGSW_X86_FLOATING_DS ) && _IsTargetModel( CGSW_X86_FLOATING_SS ) ) {
type_class = FltClass( ins );
if( type_class != XX ) {
for( i = ins->num_operands; i-- > 0; ) {
Expand Down
85 changes: 38 additions & 47 deletions bld/cg/risc/c/rscver.c
Expand Up @@ -2,7 +2,7 @@
*
* Open Watcom Project
*
* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved.
* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved.
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
Expand Down Expand Up @@ -47,8 +47,8 @@ static bool ByteConst( name *operand )
if( operand->n.class == N_CONSTANT ) {
if( operand->c.const_type == CONS_ABSOLUTE ) {
if( operand->c.hi.int_value == 0 ) {
return( operand->c.lo.int_value >= 0
&& operand->c.lo.int_value <= 255 );
return( operand->c.lo.int_value >= 0 &&
operand->c.lo.int_value <= 255 );
}
}
}
Expand All @@ -61,12 +61,12 @@ static bool HalfWordConst( name *operand )
if( operand->n.class == N_CONSTANT ) {
if( operand->c.const_type == CONS_ABSOLUTE ) {
if( operand->c.hi.int_value == 0 ) {
return( operand->c.lo.int_value >= -32768
&& operand->c.lo.int_value <= 32767 );
return( operand->c.lo.int_value >= -32768 &&
operand->c.lo.int_value <= 32767 );
} else {
return( operand->c.hi.int_value == -1
&& operand->c.lo.int_value <= 0
&& operand->c.lo.int_value >= -32768 );
return( operand->c.hi.int_value == -1 &&
operand->c.lo.int_value <= 0 &&
operand->c.lo.int_value >= -32768 );
}
}
}
Expand All @@ -79,20 +79,19 @@ static bool UHalfWordConst( name *operand )
if( operand->n.class == N_CONSTANT ) {
if( operand->c.const_type == CONS_ABSOLUTE ) {
if( operand->c.hi.int_value == 0 ) {
return( operand->c.lo.int_value >= 0
&& operand->c.lo.int_value <= 0xffff );
return( operand->c.lo.int_value >= 0 &&
operand->c.lo.int_value <= 0xffff );
}
}
}
return( false );
}

static bool Is64BitConst( name *operand )
/********************************************
* Return true if constant is not a 32-bit (canonical) const
* A canonical 64-bit constant is one whose bits 63:32 == bit 31
*/
/*******************************************/
{
// Return true if constant is not a 32-bit (canonical) const
// A canonical 64-bit constant is one whose bits 63:32 == bit 31
if( operand->c.const_type == CONS_ABSOLUTE ) {
if( operand->c.hi.int_value != (operand->c.lo.int_value >> 31) ) {
return( true );
Expand Down Expand Up @@ -149,27 +148,23 @@ static bool Aligned( name *op, type_length align, type_class_def type_class
if( op->m.alignment != 0 ) {
return( align <= op->m.alignment );
}
/*
* Note: this assumes we always put global elements on 8-byte
* boundaries
* correction - front end only puts globals on 4-byte boundaries
*/
// Note: this assumes we always put global elements on 8-byte
// boundaries
// correction - front end only puts globals on 4-byte boundaries
if( align == 8 )
return( false );
/* fall through */
case N_TEMP:
/*
* Note: this assumes we are not packing elements of size < 8 into
* 8-byte chunks of the stack - we may do this in the future
*/
// Note: this assumes we are not packing elements of size < 8 into
// 8-byte chunks of the stack - we may do this in the future
return( ( op->v.offset % align ) == 0 );
case N_INDEXED:
actual = natural;
if( HasAlignment( op ) ) {
actual = FlagsToAlignment( op->i.index_flags );
}
if( ( op->i.constant % 8 ) != 0 ) {
if( actual > (op->i.constant & 0x07) ) {
if( (op->i.constant & 0x07) < actual ) {
actual = op->i.constant & 0x07;
}
}
Expand All @@ -191,45 +186,42 @@ bool DoVerify( vertype kind, instruction *ins )
case V_SYMMETRIC:
return( Symmetric( ins->head.opcode ) );
case V_OP1HIGHADDR:
return( ( ins->operands[0]->n.class == N_CONSTANT )
&& ( ins->operands[0]->c.const_type == CONS_HIGH_ADDR ) );
return( ( ins->operands[0]->n.class == N_CONSTANT ) &&
( ins->operands[0]->c.const_type == CONS_HIGH_ADDR ) );
case V_UHALFWORDCONST2:
return( UHalfWordConst( ins->operands[1] ) );
case V_UHALFWORDCONST1:
return( UHalfWordConst( ins->operands[0] ) );
case V_HALFWORDCONST2:
#if _TARGET & _TARG_AXP
if( ins->type_class == Unsigned[ins->type_class]
&& (ins->operands[1]->c.lo.int_value & 0x8000)
&& TypeClassSize[ins->type_class] >= 4 )
if( ins->type_class == Unsigned[ins->type_class] &&
( ins->operands[1]->c.lo.int_value & 0x8000 ) &&
TypeClassSize[ins->type_class] >= 4 )
return( false );
#endif
return( HalfWordConst( ins->operands[1] ) );
case V_HALFWORDCONST1:
#if _TARGET & _TARG_AXP
if( ins->type_class == Unsigned[ins->type_class]
&& (ins->operands[0]->c.lo.int_value & 0x8000)
&& TypeClassSize[ins->type_class] >= 4 )
if( ins->type_class == Unsigned[ins->type_class] &&
( ins->operands[0]->c.lo.int_value & 0x8000 ) &&
TypeClassSize[ins->type_class] >= 4 )
return( false );
#endif
return( HalfWordConst( ins->operands[0] ) );
case V_AXPBRANCH: // FIXME: appears to be unused!
op = ins->operands[1];
return( ins->result == NULL
&& op->n.class == N_CONSTANT
&& op->c.const_type == CONS_ABSOLUTE
&& op->c.lo.int_value == 0 );
return( ins->result == NULL && op->n.class == N_CONSTANT &&
op->c.const_type == CONS_ABSOLUTE && op->c.lo.int_value == 0 );
case V_MIPSBRANCH:
return( ins->result == NULL
&& (ins->head.opcode == OP_CMP_EQUAL
|| ins->head.opcode == OP_CMP_NOT_EQUAL) );
return( ins->result == NULL && (ins->head.opcode == OP_CMP_EQUAL
|| ins->head.opcode == OP_CMP_NOT_EQUAL) );
case V_RESNOTNULL:
return( ins->result != NULL );
case V_RESNULL:
return( ins->result == NULL );
case V_WORD_OR_QUAD:
return( TypeClassSize[ins->type_class] == 4
|| TypeClassSize[ins->type_class] == 8 );
return( TypeClassSize[ins->type_class] == 4 ||
TypeClassSize[ins->type_class] == 8 );
case V_FLOAT:
return( _IsFloating( ins->type_class ) );
case V_REG_SIZE:
Expand Down Expand Up @@ -274,14 +266,13 @@ bool DoVerify( vertype kind, instruction *ins )
case V_RES_AL8:
return( Aligned( ins->result, 8, ins->type_class ) );
case V_OP1_RES_AL8:
return( Aligned( ins->operands[0], 8, InsTypeClass( ins ) )
&& Aligned( ins->result, 8, InsTypeClass( ins ) ) );
return( Aligned( ins->operands[0], 8, InsTypeClass( ins ) ) &&
Aligned( ins->result, 8, InsTypeClass( ins ) ) );
case V_OP1_RES_AL4:
return( Aligned( ins->operands[0], 4, InsTypeClass( ins ) )
&& Aligned( ins->result, 4, InsTypeClass( ins ) ) );
return( Aligned( ins->operands[0], 4, InsTypeClass( ins ) ) &&
Aligned( ins->result, 4, InsTypeClass( ins ) ) );
case V_RES_TEMP:
return( ins->result->n.class == N_TEMP
&& ins->result->t.alias == NULL );
return( ins->result->n.class == N_TEMP && ins->result->t.alias == NULL );
case V_RESCONSTTEMP:
return( _ConstTemp( ins->result ) );
case V_OP164BITCONST:
Expand Down
6 changes: 6 additions & 0 deletions bld/cg/risc/ppc/c/ppcenc.c
Expand Up @@ -650,6 +650,12 @@ static void Encode( instruction *ins )
GenOPIMM( 15, _NameRegTrans( ins->result ), ZERO_SINK,
ins->operands[0]->c.lo.int_value & 0xffff );
break;
case G_MOVE_UI:
/* a load of an unsigned 16-bit immediate */
/* use addi rd, imm(0) */
GenOPIMM( 14, _NameRegTrans( ins->result ), ZERO_SINK,
ins->operands[0]->c.lo.int_value );
break;
case G_LEA:
assert( ins->operands[0]->n.class == N_CONSTANT );
assert( ins->result->n.class == N_REGISTER );
Expand Down
1 change: 1 addition & 0 deletions bld/cg/risc/ppc/c/ppctable.c
Expand Up @@ -126,6 +126,7 @@ _OE( _Un( C, M, NONE ), V_NO, RG_##reg, R_MOVOP1TEM
_OE( _Un( M, R, NONE ), V_NO, RG_##reg, load, FU_MEM ), \
_OE( _Un( C, R, NONE ), V_OP1HIGHADDR, RG_##reg, G_LEA_HIGH, FU_NO ), \
_OE( _Un( C, R, NONE ), V_HALFWORDCONST1,RG_##reg, G_LEA, FU_NO ), \
_OE( _Un( C, R, NONE ), V_UHALFWORDCONST1,RG_##reg, G_MOVE_UI, FU_NO ), \
_OE( _Un( C, R, NONE ), V_NO, RG_##reg, R_CONSTLOAD, FU_NO ), \
_OE( _Un( M, M, NONE ), V_NO, RG_, R_MOVOP1TEMP, FU_NO ), \
_OE( _Un( ANY, ANY, NONE ), V_NO, RG_##reg##_NEED,G_UNKNOWN, FU_NO ), \
Expand Down
1 change: 1 addition & 0 deletions bld/cg/risc/ppc/h/g.h
Expand Up @@ -55,4 +55,5 @@ _G_( G_CMP_FP ),
_G_( G_ZERO ),
_G_( G_SIGN ),
_G_( G_VASTART ),
_G_( G_MOVE_UI ),
_G_( G_FREGTOMI4 ),

0 comments on commit 06abea3

Please sign in to comment.