summaryrefslogtreecommitdiff
path: root/risc-v/hgen/parser.hgen
blob: 10257ecdd4d24c8df36a541088b3283d8bf9370a (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
| 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) }
| 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_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"
    | (Fence_W,  Fence_W)  -> failwith "'fence w,w' is not supported"
  }