mirror of
git://repo.or.cz/tinycc.git
synced 2026-06-17 15:44:18 +08:00
AMO (A-extension):
18 base instructions: amoadd/swap/and/or/xor/max/maxu/min/minu .w/.d
6 aq/rl suffixes: amoadd.w.aq/.rl/.aqrl, amoadd.d.aq/.rl/.aqrl
Correct funct5 (GNU as verified):
amoadd=0x00 amoswap=0x01 amoxor=0x04
amoand=0x0C amoor=0x08 amomax=0x14
amomaxu=0x1C amomin=0x10 amominu=0x18
R-type opcode 0x2F, aq/rl in bits [26:25]
FCVT rounding modes (GNU operand syntax):
fcvt.w.s rd, rs1 [, rtz/rne/rup] -- optional 3rd operand
asm_fcvt_opcode() handler with asm_fcvt_rm() helper
Keywords rne=0, rtz=1, rdn=2, rup=3, rmm=4
FCVT encoding fixes:
fcvt.s.d: funct7 0x40->0x20
fcvt.d.s: funct7 0x42->0x21
Tests: 144 CSR, 145 F/D cmp+cvt, 146 AMO, 147 fcvt round.
All verified against riscv64-linux-gnu-as 2.44 on Spacemit X100.
21 lines
435 B
C
21 lines
435 B
C
#include <stdio.h>
|
|
|
|
#ifdef __riscv
|
|
|
|
int main(void)
|
|
{
|
|
/* fcvt with optional rounding mode operand (GNU as syntax) */
|
|
asm volatile("fcvt.w.s a0, fa0, rne");
|
|
asm volatile("fcvt.w.s a0, fa0, rtz");
|
|
asm volatile("fcvt.w.s a0, fa0, rup");
|
|
asm volatile("fcvt.w.d a0, fa0, rne");
|
|
asm volatile("fcvt.w.d a0, fa0, rtz");
|
|
|
|
printf("PASS\n");
|
|
return 0;
|
|
}
|
|
|
|
#else
|
|
int main(void) { printf("SKIP\n"); return 0; }
|
|
#endif
|