Add proper support for the MOVA instruction

This commit is contained in:
fincs 2016-01-24 11:58:16 +01:00
parent 8f402ad02a
commit 956a328a6f
3 changed files with 11 additions and 2 deletions

View File

@ -238,7 +238,7 @@ Syntax | Description
`rcp rDest, rSrc1` |
`rsq rDest, rSrc1` |
`mov rDest, rSrc1` |
`mova rSrc1` |
`mova idxReg, rSrc1` |
`cmp rSrc1, opx, opy, rSrc2` |
`call procName` |
`for iReg` |
@ -261,6 +261,7 @@ Syntax | Description
- In instructions that take two source operands, the first is wide and the second is narrow.
- `dph`/`sge`/`slt` have a special form where the first operand is narrow and the second is wide. This usage is detected automatically by `picasso`.
- `mad`, which takes three source operands, has two forms: the first is wide-wide-narrow, and the second is wide-narrow-wide. This is also detected automatically. Additionally, relative addressing is not supported.
- `idxReg`: Represents an indexing register to write to using the mova instruction. Can be `a0`, `a1` or `a01` (the latter writes to both `a0` and `a1`).
- `iReg`: Represents an integer vector uniform source operand.
- `bReg`: Represents a boolean uniform source operand.
- `procName`: Represents the name of a procedure.

View File

@ -44,6 +44,7 @@ enum
#define OPDESC_MASK_D123 OPDESC_MAKE(0xF, 0x1FF, 0x1FF, 0x1FF)
#define OPDESC_MASK_D12 OPDESC_MAKE(0xF, 0x1FF, 0x1FF, 0)
#define OPDESC_MASK_D1 OPDESC_MAKE(0xF, 0x1FF, 0, 0)
#define OPDESC_MASK_MOVA OPDESC_MAKE(0xC, 0x1FF, 0, 0)
#define OPDESC_MASK_1 OPDESC_MAKE(0, 0x1FF, 0, 0)
#define OPDESC_MASK_12 OPDESC_MAKE(0, 0x1FF, 0x1FF, 0)

View File

@ -855,13 +855,20 @@ DEF_COMMAND(format5)
DEF_COMMAND(formatmova)
{
NEXT_ARG(targetReg);
NEXT_ARG(src1Name);
ENSURE_NO_MORE_ARGS();
int mask;
if (strcmp(targetReg, "a0")==0) mask = BIT(3);
else if (strcmp(targetReg, "a1")==0) mask = BIT(2);
else if (strcmp(targetReg, "a01")==0) mask = BIT(3) | BIT(2);
else return throwError("invalid destination register for mova: %s\n", targetReg);
ARG_TO_SRC1_REG2(rSrc1, src1Name);
int opdesc = 0;
safe_call(findOrAddOpdesc(opdesc, OPDESC_MAKE(0, rSrc1Sw, 0, 0), OPDESC_MASK_1));
safe_call(findOrAddOpdesc(opdesc, OPDESC_MAKE(mask, rSrc1Sw, 0, 0), OPDESC_MASK_MOVA));
#ifdef DEBUG
printf("%s:%02X d%02X (0x%X)\n", cmdName, opcode, rSrc1, opdesc);