summaryrefslogtreecommitdiff
path: root/risc-v/hgen/parser.hgen
blob: 4440ffda639f61746cac6e8eb3309f1780a174e1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
| UTYPE reg COMMA NUM
  { `RISCVUTYPE($4, $2, $1.op) }
| JAL reg COMMA NUM
  { `RISCVJAL($4, $2) }
| JALR reg COMMA reg COMMA NUM
  { `RISCVJALR($6, $4, $2) }
| BTYPE reg COMMA reg COMMA NUM
  { `RISCVBType($6, $4, $2, $1.op) }
| ITYPE reg COMMA reg COMMA NUM
  { `RISCVIType($6, $4, $2, $1.op) }
| SHIFTIOP reg COMMA reg COMMA NUM
  { `RISCVShiftIop($6, $4, $2, $1.op) }
| RTYPE reg COMMA reg COMMA reg
  { `RISCVRType ($6, $4, $2, $1.op) }
| LOAD reg COMMA NUM LPAR reg RPAR
  { `RISCVLoad($4, $6, $2, $1.unsigned, $1.width, $1.aq) }
| STORE reg COMMA NUM LPAR reg RPAR
  { `RISCVStore($4, $2, $6, $1.width, $1.rl) }
| ADDIW reg COMMA reg COMMA NUM
  { `RISCVADDIW ($6, $4, $2) }
| SHIFTW reg COMMA reg COMMA NUM
  { `RISCVSHIFTW ($6, $4, $2, $1.op) }
| RTYPEW reg COMMA reg COMMA reg
  { `RISCVRTYPEW ($6, $4, $2, $1.op) }
| FENCE FENCEOPTION COMMA FENCEOPTION
  { match ($2, $4) with
    | (Fence_RW, Fence_RW) -> `RISCVFENCE (0b0011, 0b0011)
    | (Fence_R,  Fence_RW) -> `RISCVFENCE (0b0010, 0b0011)
    | (Fence_RW, Fence_W)  -> `RISCVFENCE (0b0011, 0b0001)
    | (Fence_W,  Fence_W)  -> `RISCVFENCE (0b0001, 0b0001)
    | (Fence_RW, Fence_R)  -> failwith "'fence rw,r' is not supported"
    | (Fence_R,  Fence_R)  -> failwith "'fence r,r' is not supported"
    | (Fence_R,  Fence_W)  -> failwith "'fence r,w' is not supported"
    | (Fence_W,  Fence_RW) -> failwith "'fence w,rw' is not supported"
    | (Fence_W,  Fence_R)  -> failwith "'fence w,r' is not supported"
  }
| FENCEI
  { `RISCVFENCEI }
| LOADRES reg COMMA LPAR reg RPAR
  { `RISCVLoadRes($1.aq, $1.rl, $5, $1.width, $2) }
| STORECON reg COMMA reg COMMA LPAR reg RPAR
  { `RISCVStoreCon($1.aq, $1.rl, $4, $7, $1.width, $2) }
| AMO reg COMMA reg COMMA LPAR reg RPAR
  { `RISCVAMO($1.op, $1.aq, $1.rl, $4, $7, $1.width, $2) }