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
635 asm_emit_s(token, (0x8 << 2) | 3 | (3 << 12), &ops[0], &ops[1], &ops[2]);635 asm_emit_s(token, (0x8 << 2) | 3 | (3 << 12), &ops[0], &ops[1], &ops[2]);
636 return;636 return;
637 637
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
638 /* C extension */679 /* C extension */
639 /* register-based loads and stores (RD, RS1, IMM); CL-format */680 /* register-based loads and stores (RD, RS1, IMM); CL-format */
640 case TOK_ASM_c_fld:681 case TOK_ASM_c_fld:
@@ -803,6 +844,20 @@ ST_FUNC void asm_opcode(TCCState *s1, int token) · 162 unmodified lines
803 case TOK_ASM_sw:844 case TOK_ASM_sw:
804 case TOK_ASM_xor:845 case TOK_ASM_xor:
805 case TOK_ASM_xori:846 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:
806 asm_ternary_opcode(s1, token);861 asm_ternary_opcode(s1, token);
807 return;862 return;
808 863

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