Correct MAD instruction encoding

This commit is contained in:
fincs 2016-03-26 14:02:02 +01:00
parent 2da4f1b657
commit e5e8127a5d
2 changed files with 8 additions and 4 deletions

View File

@ -286,7 +286,7 @@ Syntax | Description
- In instructions that take one source operand, it is always wide.
- 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.
- `mad`, which takes three source operands, has two forms: the first is narrow-wide-narrow, and the second is narrow-narrow-wide. This is also detected automatically. Additionally, relative addressing applies to the first source operand (which is narrow) instead of the single wide operand.
- `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.

View File

@ -481,6 +481,10 @@ static inline int ensure_valid_condop(int condop, const char* name)
ARG_TO_REG(_reg, _name); \
safe_call(ensure_valid_src_narrow(_reg, _name, 2))
#define ARG_TO_SRC2_REG2(_reg, _name) \
ARG_TO_REG2(_reg, _name); \
safe_call(ensure_valid_src_narrow(_reg, _name, 1))
#define ARG_TO_IREG(_reg, _name) \
ARG_TO_REG(_reg, _name); \
safe_call(ensure_valid_ireg(_reg, _name))
@ -835,7 +839,7 @@ DEF_COMMAND(format5)
ENSURE_NO_MORE_ARGS();
ARG_TO_DEST_REG(rDest, destName);
ARG_TO_SRC1_REG(rSrc1, src1Name);
ARG_TO_SRC2_REG2(rSrc1, src1Name);
ARG_TO_REG(rSrc2, src2Name);
ARG_TO_REG(rSrc3, src3Name);
@ -861,9 +865,9 @@ DEF_COMMAND(format5)
printf("%s:%02X d%02X, d%02X, d%02X, d%02X (0x%X)\n", cmdName, opcode, rDest, rSrc1, rSrc2, rSrc3, opdesc);
#endif
if (!inverted)
BUF.push_back(FMT_OPCODE(opcode) | opdesc | (rSrc3<<5) | (rSrc2<<10) | (rSrc1<<17) | (rDest<<24));
BUF.push_back(FMT_OPCODE(opcode) | opdesc | (rSrc3<<5) | (rSrc2<<10) | (rSrc1<<17) | (rSrc1Idx<<22) | (rDest<<24));
else
BUF.push_back(FMT_OPCODE(opcodei) | opdesc | (rSrc3<<5) | (rSrc2<<12) | (rSrc1<<17) | (rDest<<24));
BUF.push_back(FMT_OPCODE(opcodei) | opdesc | (rSrc3<<5) | (rSrc2<<12) | (rSrc1<<17) | (rSrc1Idx<<22) | (rDest<<24));
return 0;
}