Index regs can only be used with uniform regs (discovered by @Tilka)

This commit is contained in:
fincs 2017-12-27 14:44:20 +01:00
parent d19c7b7cd0
commit 9aac60a683
2 changed files with 3 additions and 1 deletions

View File

@ -51,7 +51,7 @@ Registers may also be assigned additional names in order to make the code more l
For convenience, registers may be addressed using an offset from a known register. This is called indexing. For example, `c8[4]` is equivalent to `c12`; and `r4[-2]` is equivalent to `r2`. Indexing is useful for addressing arrays of registers (such as matrices).
Some source operands of instructions (called SRC1) support relative addressing. This means that it is possible to use one of the three built-in indexing registers (`a0`, `a1` and `a2` aka `lcnt`) to address a register, e.g. `someArray[lcnt]`. Adding an offset is also supported, e.g. `someArray[lcnt+2]`. This is useful in FOR loops.
Some source operands of instructions (called SRC1) support relative addressing. This means that it is possible to use one of the three built-in indexing registers (`a0`, `a1` and `a2` aka `lcnt`) to address a register, e.g. `someArray[lcnt]`. Adding an offset is also supported, e.g. `someArray[lcnt+2]`. This is useful in FOR loops. Index registers can only be used with floating-point vector uniform registers, though.
Normal floating-point vector registers may also be negated by prepending a minus sign before it, e.g. `-r2` or `-someArray[lcnt+2]`.

View File

@ -786,6 +786,8 @@ static int parseReg(char* pos, int& outReg, int& outSw, int* idxType = NULL)
return throwError("invalid boolean uniform register: %s\n", pos);
break;
}
if (idxType && *idxType && outReg < 0x20 || outReg >= 0x80)
return throwError("index register not allowed with this kind of register\n");
outReg += regOffset;
return 0;
}