Skip to content

Commit 4c95344

Browse files
committed
Fixed a typo in OffsetMemory when dealing with structs in registers
1 parent 7cf1f30 commit 4c95344

File tree

3 files changed

+15
-13
lines changed

3 files changed

+15
-13
lines changed

Changelog.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
Version 7.4.1
2+
- Fixed an internal error computing offsets in structures stored in registers
3+
14
Version 7.4.0
25
- Fixed some errors in C __pasm parsing
36
- Fixed compile time calculations of QLOG and QEXP (thanks to Ada)

backends/asm/outasm.c

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ static Operand *EmitAddSub(IRList *irl, Operand *dst, int off);
117117
static Operand *SizedHubMemRef(int size, Operand *addr, int offset);
118118
Operand *CogMemRef(Operand *addr, int offset);
119119
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);
121121

122122
static void AssignOneFuncName(Function *f);
123123
static void ValidatePushregs(void);
@@ -3054,7 +3054,7 @@ CompileExprList(IRList *irl, AST *fromlist)
30543054
for (i = 0; i < siz; i += LONG_SIZE) {
30553055
Operand *tmpfrom;
30563056
if (off) {
3057-
tmpfrom = OffsetMemory(irl, opfrom, NewImmediate(off), NULL);
3057+
tmpfrom = OffsetMemory(irl, opfrom, NewImmediate(off), NULL, from);
30583058
} else {
30593059
tmpfrom = opfrom;
30603060
}
@@ -3505,24 +3505,23 @@ CompileMemref(IRList *irl, AST *expr)
35053505
}
35063506

35073507
static Operand *
3508-
OffsetMemory(IRList *irl, Operand *base, Operand *offset, AST *type)
3508+
OffsetMemory(IRList *irl, Operand *base, Operand *offset, AST *type, AST *linenum)
35093509
{
35103510
Operand *basereg;
35113511
Operand *newbase;
35123512
Operand *temp;
35133513
int idx;
35143514
int shift;
35153515
int siz;
3516-
AST *linenum = NULL;
3517-
3516+
35183517
// check for COG memory references
35193518
if (!IsMemRef(base) && IsCogMem(base)) {
35203519
Operand *addr;
35213520
long offval = offset->val;
35223521

35233522
if (base->kind == REG_SUBREG) {
35243523
offval += base->val * LONG_SIZE;
3525-
base = (Operand *)base;
3524+
base = (Operand *)base->name;
35263525
}
35273526
switch(base->kind) {
35283527
case REG_REG:
@@ -3555,7 +3554,7 @@ OffsetMemory(IRList *irl, Operand *base, Operand *offset, AST *type)
35553554
}
35563555
}
35573556
if (!IsMemRef(base)) {
3558-
ERROR(NULL, "Pointer does not reference memory");
3557+
ERROR(linenum, "internal error: pointer does not reference memory");
35593558
return base;
35603559
}
35613560
if (base->kind == COGMEM_REF) {
@@ -4129,7 +4128,7 @@ doGetAddress(IRList *irl, AST *expr, bool isField)
41294128
Operand *tmp;
41304129
AST *type = ExprType(expr);
41314130
off = sym->offset;
4132-
tmp = OffsetMemory(irl, base, NewImmediate(off), type);
4131+
tmp = OffsetMemory(irl, base, NewImmediate(off), type, expr);
41334132
res = GetLea(irl, tmp);
41344133
} else if (sym->kind == SYM_FUNCTION) {
41354134
CompileGetFunctionInfo(irl, expr, NULL, NULL, &res, NULL);
@@ -4623,7 +4622,7 @@ CompileExpression(IRList *irl, AST *expr, Operand *dest)
46234622
if (off == 0 && IsCogMem(base)) {
46244623
r = base;
46254624
} else {
4626-
r = OffsetMemory(irl, base, NewImmediate(off), finaltype);
4625+
r = OffsetMemory(irl, base, NewImmediate(off), finaltype, expr);
46274626
}
46284627
return r;
46294628
}
@@ -4664,7 +4663,7 @@ CompileExpression(IRList *irl, AST *expr, Operand *dest)
46644663
r = NewImmediate(val);
46654664
} else {
46664665
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);
46684667
if (dest) {
46694668
EmitMove(irl, dest, r, expr);
46704669
r = dest;
@@ -4855,7 +4854,7 @@ IR *EmitMove(IRList *irl, Operand *origdst, Operand *origsrc, AST *linenum)
48554854
for (i = 0; i < num_tmp_regs; i++) {
48564855
ir = EmitCogread(irl, temps[i], src);
48574856
if (i+1 != num_tmp_regs) {
4858-
src = OffsetMemory(irl, src, NewImmediate(4), NULL);
4857+
src = OffsetMemory(irl, src, NewImmediate(4), NULL, linenum);
48594858
}
48604859
}
48614860
} else if (origsrc->kind == HUBMEM_REF) {

version.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66

77
#define VERSION_MAJOR 7
88
#define VERSION_MINOR 4
9-
#define VERSION_REV 0
10-
//#define BETA "-beta"
9+
#define VERSION_REV 1
10+
#define BETA "-beta"
1111

1212
#define VERSIONSTR version_string
1313

0 commit comments

Comments
 (0)