[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[dotgnu-pnet-commits] pnet ChangeLog codegen/cg_arith.tc cscc/csharp/...
From: |
Klaus Treichel |
Subject: |
[dotgnu-pnet-commits] pnet ChangeLog codegen/cg_arith.tc cscc/csharp/... |
Date: |
Tue, 30 Dec 2008 14:41:55 +0000 |
CVSROOT: /cvsroot/dotgnu-pnet
Module name: pnet
Changes by: Klaus Treichel <ktreichel> 08/12/30 14:41:55
Modified files:
. : ChangeLog
codegen : cg_arith.tc
cscc/csharp : cs_lvalue.tc cs_oper.tc cs_semvalue.c
Log message:
Add some more optimizations in codegen.
Redo unsafe pointer arithmetics and add some code optimizations.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/pnet/ChangeLog?cvsroot=dotgnu-pnet&r1=1.3597&r2=1.3598
http://cvs.savannah.gnu.org/viewcvs/pnet/codegen/cg_arith.tc?cvsroot=dotgnu-pnet&r1=1.18&r2=1.19
http://cvs.savannah.gnu.org/viewcvs/pnet/cscc/csharp/cs_lvalue.tc?cvsroot=dotgnu-pnet&r1=1.69&r2=1.70
http://cvs.savannah.gnu.org/viewcvs/pnet/cscc/csharp/cs_oper.tc?cvsroot=dotgnu-pnet&r1=1.53&r2=1.54
http://cvs.savannah.gnu.org/viewcvs/pnet/cscc/csharp/cs_semvalue.c?cvsroot=dotgnu-pnet&r1=1.1&r2=1.2
Patches:
Index: ChangeLog
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/ChangeLog,v
retrieving revision 1.3597
retrieving revision 1.3598
diff -u -b -r1.3597 -r1.3598
--- ChangeLog 27 Dec 2008 15:55:38 -0000 1.3597
+++ ChangeLog 30 Dec 2008 14:41:54 -0000 1.3598
@@ -1,3 +1,24 @@
+2008-12-30 Klaus Treichel <address@hidden>
+
+ * codegen/cg_arith.tc (ReduceOperator): Add more basic optimizations and
+ apply them even if no optimization is specified.
+ (ILNode_GenValue(ILNode_Add)): Add call to ReduceOperator.
+
+ * cscc/csharp/cs_oper.tc (CreateSizeOf, PointerDelta): Add functions for
+ handling of unsafe constructs involving pointers in an uniform way.
+ (PointerOp): Add function for performing addition or substraction of a
+ numeric value and a pointer value.
+ (ILNode_SemAnalysis(ILNode_Add), ILNode_SemAnalysis(ILNode_Sub)): Use
the
+ new functions where appropriate.
+ (ILNode_SemAnalysis(ILNode_PostDec)): Fix pointer post decrement.
+
+ * cscc/csharp/cs_lvalue.tc (ILNode_SemAnalysis(ILNode_ArrayAccess)): Use
+ the new functions in cs_oper.tc for pointer array access and perform
+ constant propagation if possible.
+
+ * cscc/csharp/cs_semvalue.c (_CSSemReplaceWithConstant): Add support for
+ constant propagation for NativeInt and NativeUInt.
+
2008-12-27 Klaus Treichel <address@hidden>
* engine/jitc_string.c: Add support for inlining for String.get_Chars
Index: codegen/cg_arith.tc
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/codegen/cg_arith.tc,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -b -r1.18 -r1.19
--- codegen/cg_arith.tc 8 Aug 2004 11:39:59 -0000 1.18
+++ codegen/cg_arith.tc 30 Dec 2008 14:41:54 -0000 1.19
@@ -82,15 +82,154 @@
}
/*
+ * Check if the constant is a zero
+ */
+static int IsConstZero(ILEvalValue evalValue)
+{
+ switch(evalValue.valueType)
+ {
+ case ILMachineType_Int8:
+ case ILMachineType_Int16:
+ case ILMachineType_Int32:
+ case ILMachineType_UInt8:
+ case ILMachineType_UInt16:
+ case ILMachineType_UInt32:
+ case ILMachineType_NativeInt:
+ case ILMachineType_NativeUInt:
+ {
+ return (evalValue.un.i4Value == 0);
+ }
+ break;
+
+ case ILMachineType_Int64:
+ case ILMachineType_UInt64:
+ {
+ return (evalValue.un.i8Value == 0);
+ }
+ break;
+
+ case ILMachineType_Float32:
+ {
+ return (evalValue.un.r4Value == (ILFloat)0.0);
+ }
+ break;
+
+ case ILMachineType_Float64:
+ case ILMachineType_NativeFloat:
+ {
+ return (evalValue.un.r8Value == (ILDouble)0.0);
+ }
+ break;
+
+ default:
+ break;
+ }
+ return 0;
+}
+
+/*
+ * Check if the constant is a 1
+ */
+static int IsConstOne(ILEvalValue evalValue)
+{
+ switch(evalValue.valueType)
+ {
+ case ILMachineType_Int8:
+ case ILMachineType_Int16:
+ case ILMachineType_Int32:
+ case ILMachineType_UInt8:
+ case ILMachineType_UInt16:
+ case ILMachineType_UInt32:
+ case ILMachineType_NativeInt:
+ case ILMachineType_NativeUInt:
+ {
+ return (evalValue.un.i4Value == 1);
+ }
+ break;
+
+ case ILMachineType_Int64:
+ case ILMachineType_UInt64:
+ {
+ return (evalValue.un.i8Value == 1);
+ }
+ break;
+
+ case ILMachineType_Float32:
+ {
+ return (evalValue.un.r4Value == (ILFloat)1.0);
+ }
+ break;
+
+ case ILMachineType_Float64:
+ case ILMachineType_NativeFloat:
+ {
+ return (evalValue.un.r8Value == (ILDouble)1.0);
+ }
+ break;
+
+ default:
+ break;
+ }
+ return 0;
+}
+
+/*
+ * Check if the constant is a -1
+ */
+static int IsConstMinusOne(ILEvalValue evalValue)
+{
+ switch(evalValue.valueType)
+ {
+ case ILMachineType_Int8:
+ case ILMachineType_Int16:
+ case ILMachineType_Int32:
+ case ILMachineType_NativeInt:
+ {
+ return (evalValue.un.i4Value == -1);
+ }
+ break;
+
+ case ILMachineType_Int64:
+ {
+ return (evalValue.un.i8Value == -1);
+ }
+ break;
+
+ case ILMachineType_Float32:
+ {
+ return (evalValue.un.r4Value == (ILFloat)-1.0);
+ }
+ break;
+
+ case ILMachineType_Float64:
+ case ILMachineType_NativeFloat:
+ {
+ return (evalValue.un.r8Value == (ILDouble)-1.0);
+ }
+ break;
+
+ default:
+ break;
+ }
+ return 0;
+}
+
+/*
* Reduce operator strength for arithmetic operators
*/
static int ReduceOperator(ILGenInfo *info, ILNode *node,
ILNode** parent,ILMachineType commonType)
{
- ILEvalValue evalValue;
+ ILEvalValue evalValue1;
+ ILEvalValue evalValue2;
+ int expr1IsConst;
+ int expr2IsConst;
+
ILNode_BinaryExpression *expr;
int bitpos;
- if(info->overflowInsns || !(info->optimizeFlag))
+
+ /* if(info->overflowInsns || !(info->optimizeFlag)) */
+ if(info->overflowInsns)
{
return 0;
}
@@ -100,8 +239,10 @@
}
expr=(ILNode_BinaryExpression*)(node);
- if(!ILNode_EvalConst(expr->expr1,info,&evalValue) &&
- !ILNode_EvalConst(expr->expr2,info,&evalValue))
+ expr1IsConst = ILNode_EvalConst(expr->expr1, info, &evalValue1);
+ expr2IsConst = ILNode_EvalConst(expr->expr2, info, &evalValue2);
+
+ if(!expr1IsConst && !expr2IsConst)
{
return 0;
}
@@ -109,45 +250,242 @@
switch(commonType)
{
case ILMachineType_Int8:
- case ILMachineType_UInt8:
case ILMachineType_Int16:
- case ILMachineType_UInt16:
case ILMachineType_Int32:
- case ILMachineType_UInt32:
case ILMachineType_Int64:
+ case ILMachineType_NativeInt:
+ {
+ /*
+ * Handle the optimizations that are allowed only for
numeric
+ * types.
+ */
+ if(expr1IsConst)
+ {
+ if(IsConstMinusOne(evalValue1))
+ {
+ if(yyisa(node, ILNode_Mul))
+ {
+ *parent =
ILNode_Neg_create(expr->expr2);
+ return 1;
+ }
+ }
+ else if((bitpos = IsPowOfTwo(evalValue1)) > 0)
+ {
+ if(yyisa(node, ILNode_Mul))
+ {
+ *parent =
ILNode_Shl_create(expr->expr2,
+
ILNode_Int32_create(bitpos, 0, 0));
+ return 1;
+ }
+ }
+ }
+ else if(expr2IsConst)
+ {
+ if(IsConstMinusOne(evalValue2))
+ {
+ if(yyisa(node, ILNode_Mul) ||
+ yyisa(node, ILNode_Div))
+ {
+ *parent =
ILNode_Neg_create(expr->expr1);
+ return 1;
+ }
+ }
+ else if((bitpos = IsPowOfTwo(evalValue2)) > 0)
+ {
+ if(yyisa(node, ILNode_Mul))
+ {
+ *parent =
ILNode_Shl_create(expr->expr1,
+
ILNode_Int32_create(bitpos, 0, 0));
+ return 1;
+ }
+ }
+ }
+ }
+ /* Fall through */
+
+ case ILMachineType_UnmanagedPtr:
+ case ILMachineType_ManagedPtr:
+ {
+ if(expr1IsConst)
+ {
+ if(IsConstZero(evalValue1))
+ {
+ if(yyisa(node, ILNode_Add))
+ {
+ *parent = expr->expr2;
+ return 1;
+ }
+ }
+ else if(IsConstOne(evalValue1))
+ {
+ if(yyisa(node, ILNode_Mul))
+ {
+ *parent = expr->expr2;
+ return 1;
+ }
+ }
+ }
+ else if(expr2IsConst)
+ {
+ if(IsConstZero(evalValue2))
+ {
+ if(yyisa(node, ILNode_Add) ||
+ yyisa(node, ILNode_Sub))
+ {
+ *parent = expr->expr1;
+ return 1;
+ }
+ }
+ else if(IsConstOne(evalValue2))
+ {
+ if(yyisa(node, ILNode_Mul) ||
+ yyisa(node, ILNode_Div))
+ {
+ *parent = expr->expr1;
+ return 1;
+ }
+ }
+ }
+ }
+ break;
+
+ case ILMachineType_UInt8:
+ case ILMachineType_UInt16:
+ case ILMachineType_UInt32:
case ILMachineType_UInt64:
+ case ILMachineType_NativeUInt:
+ {
+ if(expr1IsConst)
+ {
+ if(IsConstZero(evalValue1))
+ {
+ if(yyisa(node, ILNode_Add))
+ {
+ *parent = expr->expr2;
+ return 1;
+ }
+ }
+ else if(IsConstOne(evalValue1))
+ {
+ if(yyisa(node, ILNode_Mul))
+ {
+ *parent = expr->expr2;
+ return 1;
+ }
+ }
+ else if((bitpos = IsPowOfTwo(evalValue1)) > 0)
+ {
+ if(yyisa(node, ILNode_Mul))
+ {
+ *parent =
ILNode_Shl_create(expr->expr2,
+
ILNode_Int32_create(bitpos, 0, 0));
+ return 1;
+ }
+ }
+ }
+ else if(expr2IsConst)
+ {
+ if(IsConstZero(evalValue2))
+ {
+ if(yyisa(node, ILNode_Add) ||
+ yyisa(node, ILNode_Sub))
+ {
+ *parent = expr->expr1;
+ return 1;
+ }
+ }
+ else if(IsConstOne(evalValue2))
+ {
+ if(yyisa(node, ILNode_Mul) ||
+ yyisa(node, ILNode_Div))
+ {
+ *parent = expr->expr1;
+ return 1;
+ }
+ }
+ else if((bitpos = IsPowOfTwo(evalValue2)) > 0)
+ {
+ if(yyisa(node, ILNode_Mul))
+ {
+ *parent =
ILNode_Shl_create(expr->expr1,
+
ILNode_Int32_create(bitpos, 0, 0));
+ return 1;
+ }
+ else if(yyisa(node, ILNode_Div))
+ {
+ *parent =
ILNode_Shr_create(expr->expr1,
+
ILNode_Int32_create(bitpos, 0, 0));
+ return 1;
+ }
+ }
+ }
+ }
+ break;
+
+ case ILMachineType_Float32:
+ case ILMachineType_Float64:
+ case ILMachineType_NativeFloat:
{
- if(ILNode_EvalConst(expr->expr1,info,&evalValue))
+ if(expr1IsConst)
{
- if((bitpos=IsPowOfTwo(evalValue))>0)
+ if(IsConstZero(evalValue1))
{
- if(yyisa(node,ILNode_Mul))
+ if(yyisa(node, ILNode_Add))
{
-
*parent=ILNode_Shl_create(expr->expr2,
-
ILNode_Int32_create(bitpos,0,0));
+ *parent = expr->expr2;
return 1;
}
}
+ else if(IsConstOne(evalValue1))
+ {
+ if(yyisa(node, ILNode_Mul))
+ {
+ *parent = expr->expr2;
+ return 1;
+ }
}
- else if(ILNode_EvalConst(expr->expr2,info,&evalValue))
+ else if(IsConstMinusOne(evalValue1))
{
- if((bitpos=IsPowOfTwo(evalValue))>0)
+ if(yyisa(node, ILNode_Mul))
{
- if(yyisa(node,ILNode_Mul))
+ *parent =
ILNode_Neg_create(expr->expr2);
+ return 1;
+ }
+ }
+ }
+ else if(expr2IsConst)
+ {
+ if(IsConstZero(evalValue2))
+ {
+ if(yyisa(node, ILNode_Add) ||
+ yyisa(node, ILNode_Sub))
{
-
*parent=ILNode_Shl_create(expr->expr1,
-
ILNode_Int32_create(bitpos,0,0));
+ *parent = expr->expr1;
return 1;
}
- else if(yyisa(node,ILNode_Div))
+ }
+ else if(IsConstOne(evalValue2))
+ {
+ if(yyisa(node, ILNode_Mul) ||
+ yyisa(node, ILNode_Div))
{
-
*parent=ILNode_Shr_create(expr->expr1,
-
ILNode_Int32_create(bitpos,0,0));
+ *parent = expr->expr1;
+ return 1;
+ }
+ }
+ else if(IsConstMinusOne(evalValue2))
+ {
+ if(yyisa(node, ILNode_Mul) ||
+ yyisa(node, ILNode_Div))
+ {
+ *parent =
ILNode_Neg_create(expr->expr1);
return 1;
}
}
}
}
+ break;
+
default:
break;
}
@@ -399,8 +737,18 @@
}
else
{
+ ILNode *reducedNode = NULL;
+
/* Numeric addition operator */
commonType = ILCommonType(info, type1, type2, 0);
+
+ if(ReduceOperator(info, (ILNode*)node, &reducedNode,
commonType))
+ {
+ if(reducedNode != NULL)
+ {
+ return ILNode_GenValue(reducedNode, info);
+ }
+ }
}
/* Evaluate the sub-expressions and cast to the common type */
Index: cscc/csharp/cs_lvalue.tc
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/cscc/csharp/cs_lvalue.tc,v
retrieving revision 1.69
retrieving revision 1.70
diff -u -b -r1.69 -r1.70
--- cscc/csharp/cs_lvalue.tc 18 Nov 2008 20:06:04 -0000 1.69
+++ cscc/csharp/cs_lvalue.tc 30 Dec 2008 14:41:55 -0000 1.70
@@ -1914,6 +1914,8 @@
}
else if(ILType_IsPointer(CSSemGetType(value)))
{
+ CSSemValue value1;
+
/* Access to an array defined by a pointer */
CCUnsafeMessage(info, (ILNode *)node,
"unsafe pointer-based array
access");
@@ -1940,15 +1942,17 @@
}
else
{
- tempNode = ILNode_SizeOf_create(0);
- ((ILNode_SizeOf *)tempNode)->type = objectType;
- tempNode = ILNode_CastSimple_create
- (tempNode, ILMachineType_NativeInt);
- tempNode = ILNode_Add_create(node->array,
- ILNode_Mul_create(args[0].node, tempNode));
+ tempNode = PointerDelta(info, objectType, args[0].node,
+
args[0].type, ILType_Int);
+ tempNode = ILNode_Add_create(node->array, tempNode);
}
yysetfilename(tempNode, yygetfilename(node));
yysetlinenum(tempNode, yygetlinenum(node));
+
+ /* Perform constant propagation if possible */
+ CSSemSetRValue(value1, ILType_Int);
+ EvalOperator(info, tempNode, &tempNode, &value1);
+
*parent = ILNode_Deref_create(tempNode, objectType);
yysetfilename(*parent, yygetfilename(node));
yysetlinenum(*parent, yygetlinenum(node));
Index: cscc/csharp/cs_oper.tc
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/cscc/csharp/cs_oper.tc,v
retrieving revision 1.53
retrieving revision 1.54
diff -u -b -r1.53 -r1.54
--- cscc/csharp/cs_oper.tc 14 Dec 2008 13:03:35 -0000 1.53
+++ cscc/csharp/cs_oper.tc 30 Dec 2008 14:41:55 -0000 1.54
@@ -398,6 +398,81 @@
return value;
}
+/*
+ * Create a SizeOf node for the given type.
+ */
+static ILNode *CreateSizeOf(ILGenInfo *info, ILType *type)
+{
+ ILNode_SizeOf *sizeNode;
+
+ sizeNode = (ILNode_SizeOf *)ILNode_SizeOf_create(0);
+ sizeNode->type = type;
+ sizeNode->size = GetPrimitiveTypeSize(type);
+
+ return (ILNode *)sizeNode;
+}
+
+/*
+ * Create an expression for arthmetic involving a pointer type and a
+ * numeric type.
+ */
+static ILNode *PointerDelta(ILGenInfo *info, ILType *refType, ILNode *numNode,
+ ILType *numType, ILType
*resultType)
+{
+ ILNode *sizeNode;
+ ILNode *resultNode;
+ CSSemValue value;
+ ILMachineType machineType;
+
+ if(resultType == ILType_UInt32 || resultType == ILType_UInt64)
+ {
+ machineType = ILMachineType_NativeUInt;
+ }
+ else
+ {
+ machineType = ILMachineType_NativeInt;
+ }
+
+ if(refType == ILType_Void)
+ {
+ CCErrorOnLine(yygetfilename(numNode), yygetlinenum(numNode),
+ "`void *' cannot be used for
arithmetic operations");
+ refType = ILType_UInt8;
+ }
+ sizeNode = CreateSizeOf(info, refType);
+ sizeNode = ILNode_CastSimple_create(sizeNode, machineType);
+ numNode = ILNode_CastSimple_create(numNode, machineType);
+
+ resultNode = ILNode_Mul_create(numNode, sizeNode);
+ yysetfilename(resultNode, yygetfilename(numNode));
+ yysetlinenum(resultNode, yygetlinenum(numNode));
+
+ /* Perform constant propagation if possible */
+ CSSemSetRValue(value, resultType);
+ EvalOperator(info, resultNode, &resultNode, &value);
+
+ return resultNode;
+}
+
+/*
+ * Perform an add or sub of a numeric type to a pointer.
+ */
+static void PointerOp(ILGenInfo *info, ILNode **parent,
+ ILNode **pointerNode, ILType
*pointerType,
+ ILNode **numNode, ILType *numType,
+ ILType *resultType)
+{
+ CSSemValue value;
+ ILType *elemType;
+
+ elemType = ILTypeStripPrefixes(ILType_Ref(pointerType));
+ ILCoerce(info, *pointerNode, pointerNode, pointerType, resultType, 0);
+ *numNode = PointerDelta(info, elemType, *numNode, numType, resultType);
+
+ CSSemSetRValue(value, resultType);
+ EvalOperator(info, *parent, parent, &value);
+}
+
%}
/*
@@ -410,9 +485,6 @@
CSSemValue value1;
CSSemValue value2;
ILType *resultType;
- ILType *elemType;
- ILNode_SizeOf *sizeNode;
- ILMachineType machineType;
/* Perform semantic analysis on the arguments */
value1 = ILNode_SemAnalysis(node->expr1, info, &(node->expr1));
@@ -515,25 +587,16 @@
resultType = ToNumericType(info, CSSemGetType(value2));
if(resultType)
{
- ILCoerce(info, node->expr2, &(node->expr2),
- CSSemGetType(value2), resultType, 0);
if(resultType == ILType_UInt32 || resultType ==
ILType_UInt64)
{
- machineType = ILMachineType_NativeUInt;
+ resultType = ILType_UInt;
}
else
{
- machineType = ILMachineType_NativeInt;
+ resultType = ILType_Int;
}
- node->expr1 = ILNode_CastSimple_create(node->expr1,
machineType);
- node->expr2 = ILNode_CastSimple_create(node->expr2,
machineType);
- elemType =
ILTypeStripPrefixes(ILType_Ref(CSSemGetType(value1)));
- sizeNode = (ILNode_SizeOf *)ILNode_SizeOf_create(0);
- sizeNode->type = elemType;
- sizeNode->size = GetPrimitiveTypeSize(elemType);
- node->expr2 = ILNode_Mul_create
- (node->expr2, ILNode_CastSimple_create
- ((ILNode *)sizeNode, machineType));
+ PointerOp(info, parent, &(node->expr1),
CSSemGetType(value1),
+ &(node->expr2), CSSemGetType(value2),
resultType);
CSSemSetRValue(value1, CSSemGetType(value1));
return value1;
}
@@ -543,25 +606,16 @@
resultType = ToNumericType(info, CSSemGetType(value1));
if(resultType)
{
- ILCoerce(info, node->expr1, &(node->expr1),
- CSSemGetType(value1), resultType, 0);
if(resultType == ILType_UInt32 || resultType ==
ILType_UInt64)
{
- machineType = ILMachineType_NativeUInt;
+ resultType = ILType_UInt;
}
else
{
- machineType = ILMachineType_NativeInt;
+ resultType = ILType_Int;
}
- node->expr1 = ILNode_CastSimple_create(node->expr1,
machineType);
- node->expr2 = ILNode_CastSimple_create(node->expr2,
machineType);
- elemType =
ILTypeStripPrefixes(ILType_Ref(CSSemGetType(value1)));
- sizeNode = (ILNode_SizeOf *)ILNode_SizeOf_create(0);
- sizeNode->type = elemType;
- sizeNode->size = GetPrimitiveTypeSize(elemType);
- node->expr1 = ILNode_Mul_create
- (node->expr1, ILNode_CastSimple_create
- ((ILNode *)sizeNode, machineType));
+ PointerOp(info, parent, &(node->expr2),
CSSemGetType(value2),
+ &(node->expr1), CSSemGetType(value1),
resultType);
CSSemSetRValue(value2, CSSemGetType(value2));
return value2;
}
@@ -622,8 +676,6 @@
CSSemValue value2;
ILType *resultType;
ILType *elemType;
- ILNode_SizeOf *sizeNode;
- ILMachineType machineType;
/* Perform semantic analysis on the arguments */
value1 = ILNode_SemAnalysis(node->expr1, info, &(node->expr1));
@@ -704,17 +756,17 @@
if(ILTypeIdentical(ILType_Ref(CSSemGetType(value1)),
ILType_Ref(CSSemGetType(value2))))
{
+ ILNode *sizeNode;
+
/* Subtract two pointers of the same type */
elemType = ILTypeStripPrefixes
(ILType_Ref(CSSemGetType(value1)));
- sizeNode = (ILNode_SizeOf *)ILNode_SizeOf_create(0);
- sizeNode->type = elemType;
- sizeNode->size = GetPrimitiveTypeSize(elemType);
+ sizeNode = CreateSizeOf(info, elemType);
*parent = ILNode_CastSimple_create
((ILNode *)node, ILMachineType_Int64);
*parent = ILNode_Div_create
(*parent, ILNode_CastSimple_create
- ((ILNode *)sizeNode,
ILMachineType_Int64));
+ (sizeNode, ILMachineType_Int64));
yysetfilename(*parent, yygetfilename(node));
yysetlinenum(*parent, yygetlinenum(node));
CSSemSetRValue(value1, ILType_Int64);
@@ -726,25 +778,16 @@
resultType = ToNumericType(info, CSSemGetType(value2));
if(resultType)
{
- ILCoerce(info, node->expr2, &(node->expr2),
- CSSemGetType(value2), resultType, 0);
if(resultType == ILType_UInt32 || resultType ==
ILType_UInt64)
{
- machineType = ILMachineType_NativeUInt;
+ resultType = ILType_UInt;
}
else
{
- machineType = ILMachineType_NativeInt;
+ resultType = ILType_Int;
}
- node->expr1 = ILNode_CastSimple_create(node->expr1,
machineType);
- node->expr2 = ILNode_CastSimple_create(node->expr2,
machineType);
- elemType =
ILTypeStripPrefixes(ILType_Ref(CSSemGetType(value1)));
- sizeNode = (ILNode_SizeOf *)ILNode_SizeOf_create(0);
- sizeNode->type = elemType;
- sizeNode->size = GetPrimitiveTypeSize(elemType);
- node->expr2 = ILNode_Mul_create
- (node->expr2, ILNode_CastSimple_create
- ((ILNode *)sizeNode, machineType));
+ PointerOp(info, parent, &(node->expr1),
CSSemGetType(value1),
+ &(node->expr2), CSSemGetType(value2),
resultType);
CSSemSetRValue(value1, CSSemGetType(value1));
return value1;
}
@@ -1411,13 +1454,11 @@
ILTypeStripPrefixes(ILType_Ref(CSSemGetType(value)));
if(elemType != ILType_Void)
{
- ILNode_SizeOf *sizeNode =
(ILNode_SizeOf *)
- ILNode_SizeOf_create(0);
- sizeNode->type = elemType;
- sizeNode->size =
GetPrimitiveTypeSize(elemType);
+ ILNode *sizeNode;
+
+ sizeNode = CreateSizeOf(info, elemType);
*parent = (*createPtrFunc)
- (node->expr,
GetPrimitiveTypeSize(elemType),
- (ILNode *)sizeNode);
+ (node->expr,
GetPrimitiveTypeSize(elemType), sizeNode);
return value;
}
}
@@ -1482,7 +1523,7 @@
{
return IncOrDecSem(info, (ILNode_UnaryExpression *)node, parent,
"op_Decrement", "--",
ILNode_UserPostDec_create,
- ILNode_PostIncPtr_create);
+ ILNode_PostDecPtr_create);
}
/*
Index: cscc/csharp/cs_semvalue.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/cscc/csharp/cs_semvalue.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- cscc/csharp/cs_semvalue.c 3 Sep 2002 06:13:20 -0000 1.1
+++ cscc/csharp/cs_semvalue.c 30 Dec 2008 14:41:55 -0000 1.2
@@ -143,6 +143,32 @@
}
break;
+ case ILMachineType_NativeInt:
+ {
+ if(value->un.i4Value >= 0)
+ {
+ *parent = ILNode_Int32_create
+
((ILUInt64)(ILInt64)(value->un.i4Value), 0, 0);
+ }
+ else
+ {
+ *parent = ILNode_Int32_create
+
((ILUInt64)(-((ILInt64)(value->un.i4Value))), 1, 0);
+ }
+ *parent = ILNode_CastSimple_create(*parent,
+
ILMachineType_NativeInt);
+ }
+ break;
+
+ case ILMachineType_NativeUInt:
+ {
+ *parent = ILNode_UInt32_create
+ ((ILUInt64)(ILUInt32)(value->un.i4Value), 0, 0);
+ *parent = ILNode_CastSimple_create(*parent,
+
ILMachineType_NativeUInt);
+ }
+ break;
+
case ILMachineType_Float32:
{
*parent =
ILNode_Float32_create((ILDouble)(value->un.r4Value));
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [dotgnu-pnet-commits] pnet ChangeLog codegen/cg_arith.tc cscc/csharp/...,
Klaus Treichel <=