History

riscv64-asm.c: implement M extension

noneofyourbusiness committed 2 years ago

Commit 275dfbe1 parent c71415b1 file · +55 −0Browse files

Unified · Split

riscv64-asm.c+55−0
@@ -635,6 +635,47 @@ static void asm_ternary_opcode(TCCState *s1, int token) · 634 unmodified lines
635635 asm_emit_s(token, (0x8 << 2) | 3 | (3 << 12), &ops[0], &ops[1], &ops[2]);
636636 return;
637637
638+ /* M extension */
639+ case TOK_ASM_div:
640+ asm_emit_r(token, 0x33 | (4 << 12) | (1 << 25), ops, ops + 1, ops + 2);
641+ return;
642+ case TOK_ASM_divu:
643+ asm_emit_r(token, 0x33 | (5 << 12) | (1 << 25), ops, ops + 1, ops + 2);
644+ return;
645+ case TOK_ASM_divuw:
646+ asm_emit_r(token, 0x3b | (5 << 12) | (1 << 25), ops, ops + 1, ops + 2);
647+ return;
648+ case TOK_ASM_divw:
649+ asm_emit_r(token, 0x3b | (4 << 12) | (1 << 25), ops, ops + 1, ops + 2);
650+ return;
651+ case TOK_ASM_mul:
652+ asm_emit_r(token, 0x33 | (1 << 25), ops, ops + 1, ops + 2);
653+ return;
654+ case TOK_ASM_mulh:
655+ asm_emit_r(token, 0x33 | (1 << 12) | (1 << 25), ops, ops + 1, ops + 2);
656+ return;
657+ case TOK_ASM_mulhsu:
658+ asm_emit_r(token, 0x33 | (2 << 12) | (1 << 25), ops, ops + 1, ops + 2);
659+ return;
660+ case TOK_ASM_mulhu:
661+ asm_emit_r(token, 0x33 | (3 << 12) | (1 << 25), ops, ops + 1, ops + 2);
662+ return;
663+ case TOK_ASM_mulw:
664+ asm_emit_r(token, 0x3b | (1 << 25), ops, ops + 1, ops + 2);
665+ return;
666+ case TOK_ASM_rem:
667+ asm_emit_r(token, 0x33 | (6 << 12) | (1 << 25), ops, ops + 1, ops + 2);
668+ return;
669+ case TOK_ASM_remu:
670+ asm_emit_r(token, 0x33 | (7 << 12) | (1 << 25), ops, ops + 1, ops + 2);
671+ return;
672+ case TOK_ASM_remuw:
673+ asm_emit_r(token, 0x3b | (7 << 12) | (1 << 25), ops, ops + 1, ops + 2);
674+ return;
675+ case TOK_ASM_remw:
676+ asm_emit_r(token, 0x3b | (6 << 12) | (1 << 25), ops, ops + 1, ops + 2);
677+ return;
678+
638679 /* C extension */
639680 /* register-based loads and stores (RD, RS1, IMM); CL-format */
640681 case TOK_ASM_c_fld:
@@ -803,6 +844,20 @@ ST_FUNC void asm_opcode(TCCState *s1, int token) · 162 unmodified lines
803844 case TOK_ASM_sw:
804845 case TOK_ASM_xor:
805846 case TOK_ASM_xori:
847+ /* M extension */
848+ case TOK_ASM_div:
849+ case TOK_ASM_divu:
850+ case TOK_ASM_divuw:
851+ case TOK_ASM_divw:
852+ case TOK_ASM_mul:
853+ case TOK_ASM_mulh:
854+ case TOK_ASM_mulhsu:
855+ case TOK_ASM_mulhu:
856+ case TOK_ASM_mulw:
857+ case TOK_ASM_rem:
858+ case TOK_ASM_remu:
859+ case TOK_ASM_remuw:
860+ case TOK_ASM_remw:
806861 asm_ternary_opcode(s1, token);
807862 return;
808863

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