mirror of
https://github.com/mirror/tinycc.git
synced 2024-12-26 03:50:07 +08:00
cd627c6c40
riscv64-asm.c: asm_opcode: add return asm_parse_regvar: add abi register names riscv64-tok.h: add abi register names
194 lines
2.5 KiB
C
194 lines
2.5 KiB
C
/* ------------------------------------------------------------------ */
|
|
/* WARNING: relative order of tokens is important. */
|
|
|
|
// See https://riscv.org/wp-content/uploads/2017/05/riscv-spec-v2.2.pdf
|
|
|
|
/* register */
|
|
|
|
DEF_ASM(x0)
|
|
DEF_ASM(x1)
|
|
DEF_ASM(x2)
|
|
DEF_ASM(x3)
|
|
DEF_ASM(x4)
|
|
DEF_ASM(x5)
|
|
DEF_ASM(x6)
|
|
DEF_ASM(x7)
|
|
DEF_ASM(x8)
|
|
DEF_ASM(x9)
|
|
DEF_ASM(x10)
|
|
DEF_ASM(x11)
|
|
DEF_ASM(x12)
|
|
DEF_ASM(x13)
|
|
DEF_ASM(x14)
|
|
DEF_ASM(x15)
|
|
DEF_ASM(x16)
|
|
DEF_ASM(x17)
|
|
DEF_ASM(x18)
|
|
DEF_ASM(x19)
|
|
DEF_ASM(x20)
|
|
DEF_ASM(x21)
|
|
DEF_ASM(x22)
|
|
DEF_ASM(x23)
|
|
DEF_ASM(x24)
|
|
DEF_ASM(x25)
|
|
DEF_ASM(x26)
|
|
DEF_ASM(x27)
|
|
DEF_ASM(x28)
|
|
DEF_ASM(x29)
|
|
DEF_ASM(x30)
|
|
DEF_ASM(x31)
|
|
|
|
/* register macros */
|
|
|
|
DEF_ASM(zero)
|
|
DEF_ASM(ra)
|
|
DEF_ASM(sp)
|
|
DEF_ASM(gp)
|
|
DEF_ASM(tp)
|
|
DEF_ASM(t0)
|
|
DEF_ASM(t1)
|
|
DEF_ASM(t2)
|
|
DEF_ASM(fp)
|
|
DEF_ASM(s1)
|
|
DEF_ASM(a0)
|
|
DEF_ASM(a1)
|
|
DEF_ASM(a2)
|
|
DEF_ASM(a3)
|
|
DEF_ASM(a4)
|
|
DEF_ASM(a5)
|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
|
|
DEF_ASM(lui)
|
|
DEF_ASM(auipc)
|
|
|
|
DEF_ASM(addw)
|
|
DEF_ASM(addd)
|
|
DEF_ASM(addiw)
|
|
DEF_ASM(addid)
|
|
DEF_ASM(subw)
|
|
DEF_ASM(subd)
|
|
|
|
/* Logical */
|
|
|
|
DEF_ASM(xor)
|
|
DEF_ASM(xori)
|
|
DEF_ASM(or)
|
|
DEF_ASM(ori)
|
|
DEF_ASM(and)
|
|
DEF_ASM(andi)
|
|
|
|
/* Compare */
|
|
|
|
DEF_ASM(slt)
|
|
DEF_ASM(slti)
|
|
DEF_ASM(sltu)
|
|
DEF_ASM(sltiu)
|
|
|
|
/* Branch */
|
|
|
|
DEF_ASM(beq)
|
|
DEF_ASM(bne)
|
|
DEF_ASM(blt)
|
|
DEF_ASM(bge)
|
|
DEF_ASM(bltu)
|
|
DEF_ASM(bgeu)
|
|
|
|
/* Sync */
|
|
|
|
DEF_ASM(fence)
|
|
DEF_ASM_WITH_SUFFIX(fence, i)
|
|
|
|
/* System call */
|
|
|
|
DEF_ASM(scall)
|
|
DEF_ASM(sbreak)
|
|
|
|
/* Counters */
|
|
|
|
DEF_ASM(rdcycle)
|
|
DEF_ASM(rdcycleh)
|
|
DEF_ASM(rdtime)
|
|
DEF_ASM(rdtimeh)
|
|
DEF_ASM(rdinstret)
|
|
DEF_ASM(rdinstreth)
|
|
|
|
/* Privileged Instructions */
|
|
|
|
DEF_ASM(ecall)
|
|
DEF_ASM(ebreak)
|
|
|
|
DEF_ASM(mrts)
|
|
DEF_ASM(mrth)
|
|
DEF_ASM(hrts)
|
|
DEF_ASM(wfi)
|
|
|