History

rv64: Implement some pseudo-ops from Zicsr

Aleksi Hannula committed 11 months ago

Commit 78e5e691 parent 6da45941 file · +33 −0Browse files

Unified · Split

riscv64-asm.c+33−0
@@ -398,6 +398,15 @@ static void asm_unary_opcode(TCCState *s1, int token) · 397 unmodified lines
398398 case TOK_ASM_rdinstreth:
399399 asm_emit_opcode(opcode | (0xC82 << 20) | ENCODE_RD(op.reg));
400400 return;
401+ case TOK_ASM_frflags:
402+ asm_emit_opcode(opcode | (0x001 << 20) | ENCODE_RD(op.reg));
403+ return;
404+ case TOK_ASM_frrm:
405+ asm_emit_opcode(opcode | (0x002 << 20) | ENCODE_RD(op.reg));
406+ return;
407+ case TOK_ASM_frcsr:
408+ asm_emit_opcode(opcode | (0x003 << 20) | ENCODE_RD(op.reg));
409+ return;
401410
402411 case TOK_ASM_jr:
403412 /* jalr zero, 0(rs)*/
@@ -431,6 +440,7 @@ static void asm_unary_opcode(TCCState *s1, int token) · 27 unmodified lines
431440 case TOK_ASM_c_jr:
432441 asm_emit_cr(token, 2 | (8 << 12), &op, &zero);
433442 return;
443+
434444 default:
435445 expect("unary instruction");
436446 }
@@ -702,6 +712,22 @@ static void asm_binary_opcode(TCCState* s1, int token) · 265 unmodified lines
702712 asm_emit_f(token, 0x53 | (4 << 27) | (0 << 25) | (2 << 12), &ops[0], &ops[1], &ops[1]);
703713 return;
704714
715+ case TOK_ASM_csrs:
716+ /* csrrs x0, csr, rs */
717+ asm_emit_opcode(0x73 | (2 << 12) | (ops[0].e.v << 20) | ENCODE_RS1(ops[1].reg));
718+ return;
719+ case TOK_ASM_csrc:
720+ /* csrrc x0, csr, rs */
721+ asm_emit_opcode(0x73 | (3 << 12) | (ops[0].e.v << 20) | ENCODE_RS1(ops[1].reg));
722+ return;
723+ case TOK_ASM_fsrm:
724+ /* csrrw rd, frm, rs */
725+ asm_emit_opcode(0x73 | (1 << 12) | (2 << 20) | ENCODE_RD(ops[0].reg) | ENCODE_RS1(ops[1].reg));
726+ return;
727+ case TOK_ASM_fscsr:
728+ /* csrrw rd, fcsr, rs */
729+ asm_emit_opcode(0x73 | (1 << 12) | (3 << 20) | ENCODE_RD(ops[0].reg) | ENCODE_RS1(ops[1].reg));
730+ return;
705731 default:
706732 expect("binary instruction");
707733 }
@@ -1564,6 +1590,9 @@ ST_FUNC void asm_opcode(TCCState *s1, int token) · 856 unmodified lines
15641590 case TOK_ASM_jr:
15651591 case TOK_ASM_call:
15661592 case TOK_ASM_tail:
1593+ case TOK_ASM_frflags:
1594+ case TOK_ASM_frrm:
1595+ case TOK_ASM_frcsr:
15671596 asm_unary_opcode(s1, token);
15681597 return;
15691598
@@ -1581,6 +1610,10 @@ ST_FUNC void asm_opcode(TCCState *s1, int token) · 11 unmodified lines
15811610 case TOK_ASM_negw:
15821611 case TOK_ASM_fabs_s:
15831612 case TOK_ASM_fabs_d:
1613+ case TOK_ASM_csrc:
1614+ case TOK_ASM_csrs:
1615+ case TOK_ASM_fsrm:
1616+ case TOK_ASM_fscsr:
15841617 asm_binary_opcode(s1, token);
15851618 return;
15861619

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t