@@ -117,7 +117,7 @@ static Operand *EmitAddSub(IRList *irl, Operand *dst, int off);
117
117
static Operand * SizedHubMemRef (int size , Operand * addr , int offset );
118
118
Operand * CogMemRef (Operand * addr , int offset );
119
119
static Operand * ApplyArrayIndex (IRList * irl , Operand * base , Operand * offset , int size );
120
- static Operand * OffsetMemory (IRList * irl , Operand * base , Operand * offset , AST * type );
120
+ static Operand * OffsetMemory (IRList * irl , Operand * base , Operand * offset , AST * type , AST * from );
121
121
122
122
static void AssignOneFuncName (Function * f );
123
123
static void ValidatePushregs (void );
@@ -3054,7 +3054,7 @@ CompileExprList(IRList *irl, AST *fromlist)
3054
3054
for (i = 0 ; i < siz ; i += LONG_SIZE ) {
3055
3055
Operand * tmpfrom ;
3056
3056
if (off ) {
3057
- tmpfrom = OffsetMemory (irl , opfrom , NewImmediate (off ), NULL );
3057
+ tmpfrom = OffsetMemory (irl , opfrom , NewImmediate (off ), NULL , from );
3058
3058
} else {
3059
3059
tmpfrom = opfrom ;
3060
3060
}
@@ -3505,24 +3505,23 @@ CompileMemref(IRList *irl, AST *expr)
3505
3505
}
3506
3506
3507
3507
static Operand *
3508
- OffsetMemory (IRList * irl , Operand * base , Operand * offset , AST * type )
3508
+ OffsetMemory (IRList * irl , Operand * base , Operand * offset , AST * type , AST * linenum )
3509
3509
{
3510
3510
Operand * basereg ;
3511
3511
Operand * newbase ;
3512
3512
Operand * temp ;
3513
3513
int idx ;
3514
3514
int shift ;
3515
3515
int siz ;
3516
- AST * linenum = NULL ;
3517
-
3516
+
3518
3517
// check for COG memory references
3519
3518
if (!IsMemRef (base ) && IsCogMem (base )) {
3520
3519
Operand * addr ;
3521
3520
long offval = offset -> val ;
3522
3521
3523
3522
if (base -> kind == REG_SUBREG ) {
3524
3523
offval += base -> val * LONG_SIZE ;
3525
- base = (Operand * )base ;
3524
+ base = (Operand * )base -> name ;
3526
3525
}
3527
3526
switch (base -> kind ) {
3528
3527
case REG_REG :
@@ -3555,7 +3554,7 @@ OffsetMemory(IRList *irl, Operand *base, Operand *offset, AST *type)
3555
3554
}
3556
3555
}
3557
3556
if (!IsMemRef (base )) {
3558
- ERROR (NULL , "Pointer does not reference memory" );
3557
+ ERROR (linenum , "internal error: pointer does not reference memory" );
3559
3558
return base ;
3560
3559
}
3561
3560
if (base -> kind == COGMEM_REF ) {
@@ -4129,7 +4128,7 @@ doGetAddress(IRList *irl, AST *expr, bool isField)
4129
4128
Operand * tmp ;
4130
4129
AST * type = ExprType (expr );
4131
4130
off = sym -> offset ;
4132
- tmp = OffsetMemory (irl , base , NewImmediate (off ), type );
4131
+ tmp = OffsetMemory (irl , base , NewImmediate (off ), type , expr );
4133
4132
res = GetLea (irl , tmp );
4134
4133
} else if (sym -> kind == SYM_FUNCTION ) {
4135
4134
CompileGetFunctionInfo (irl , expr , NULL , NULL , & res , NULL );
@@ -4623,7 +4622,7 @@ CompileExpression(IRList *irl, AST *expr, Operand *dest)
4623
4622
if (off == 0 && IsCogMem (base )) {
4624
4623
r = base ;
4625
4624
} else {
4626
- r = OffsetMemory (irl , base , NewImmediate (off ), finaltype );
4625
+ r = OffsetMemory (irl , base , NewImmediate (off ), finaltype , expr );
4627
4626
}
4628
4627
return r ;
4629
4628
}
@@ -4664,7 +4663,7 @@ CompileExpression(IRList *irl, AST *expr, Operand *dest)
4664
4663
r = NewImmediate (val );
4665
4664
} else {
4666
4665
base = CompileExpression (irl , expr -> left , NULL );
4667
- r = OffsetMemory (irl , base , NewImmediate (off ), ast_type_long );
4666
+ r = OffsetMemory (irl , base , NewImmediate (off ), ast_type_long , expr );
4668
4667
if (dest ) {
4669
4668
EmitMove (irl , dest , r , expr );
4670
4669
r = dest ;
@@ -4855,7 +4854,7 @@ IR *EmitMove(IRList *irl, Operand *origdst, Operand *origsrc, AST *linenum)
4855
4854
for (i = 0 ; i < num_tmp_regs ; i ++ ) {
4856
4855
ir = EmitCogread (irl , temps [i ], src );
4857
4856
if (i + 1 != num_tmp_regs ) {
4858
- src = OffsetMemory (irl , src , NewImmediate (4 ), NULL );
4857
+ src = OffsetMemory (irl , src , NewImmediate (4 ), NULL , linenum );
4859
4858
}
4860
4859
}
4861
4860
} else if (origsrc -> kind == HUBMEM_REF ) {
0 commit comments