Skip to content

Commit

Permalink
Fix riscv assembler
Browse files Browse the repository at this point in the history
riscv64-asm.c:
	asm_opcode: add return
	asm_parse_regvar: add abi register names

riscv64-tok.h:
	add abi register names
  • Loading branch information
hermantb committed Jun 7, 2022
1 parent afc1362 commit cd627c6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 6 additions & 1 deletion riscv64-asm.c
Original file line number Diff line number Diff line change
Expand Up @@ -643,6 +643,7 @@ ST_FUNC void asm_opcode(TCCState *s1, int token)
case TOK_ASM_sltu:
case TOK_ASM_sltiu:
asm_data_processing_opcode(s1, token);
return;

case TOK_ASM_lb:
case TOK_ASM_lh:
Expand Down Expand Up @@ -712,9 +713,13 @@ ST_FUNC void asm_clobber(uint8_t *clobber_regs, const char *str)
ST_FUNC int asm_parse_regvar (int t)
{
if (t >= TOK_ASM_x0 && t <= TOK_ASM_pc) { /* register name */
if (t >= TOK_ASM_zero && t <= TOK_ASM_t6)
return t - TOK_ASM_zero;
switch (t) {
case TOK_ASM_s0:
return 8;
case TOK_ASM_pc:
return -1; // TODO: Figure out where it can be used after all
tcc_error("PC register not implemented.");
default:
return t - TOK_ASM_x0;
}
Expand Down
2 changes: 0 additions & 2 deletions riscv64-tok.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
/* register macros */

DEF_ASM(zero)
/*
DEF_ASM(ra)
DEF_ASM(sp)
DEF_ASM(gp)
Expand Down Expand Up @@ -75,7 +74,6 @@
DEF_ASM(t6)

DEF_ASM(s0) // = x8
*/

DEF_ASM(pc)

Expand Down

0 comments on commit cd627c6

Please sign in to comment.