summaryrefslogtreecommitdiff
path: root/src/Helium/Instructions/Core.agda
blob: 6c9363de072d33d88d3cddda700ffbba21c04607 (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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
------------------------------------------------------------------------
-- Agda Helium
--
-- Definitions of the data for a subset of Armv8-M instructions.
------------------------------------------------------------------------

{-# OPTIONS --safe --without-K #-}

module Helium.Instructions.Core where

open import Data.Bool
open import Data.Fin
open import Data.Nat hiding (pred)
open import Data.Product using (∃; _×_; _,_)
open import Data.Sum
open import Relation.Binary.PropositionalEquality

GenReg : Set
GenReg = Fin 16

VecReg : Set
VecReg = Fin 8

data VecOpSize : Set where
  8bit  : VecOpSize
  16bit : VecOpSize
  32bit : VecOpSize

module Size (size : VecOpSize) where
  elements-1 : Fin 4
  elements-1 = helper size
    where
    helper : VecOpSize → Fin 4
    helper 8bit  = # 3
    helper 16bit = # 1
    helper 32bit = # 0

  elements : Fin 5
  elements = suc elements-1

  esize-1 : Fin 32
  esize-1 = helper size
    where
    helper : VecOpSize → Fin 32
    helper 8bit  = # 7
    helper 16bit = # 15
    helper 32bit = # 31

  esize : Fin 33
  esize = suc esize-1

record VecOp₂ : Set where
  field
    size : VecOpSize
    dest : VecReg
    src₁ : VecReg
    src₂ : GenReg ⊎ VecReg

  open Size size public

VAdd = VecOp₂

VSub = VecOp₂

record VHSub : Set where
  field
    op₂ : VecOp₂
    unsigned : Bool

  open VecOp₂ op₂ public

VMul = VecOp₂

record VMulH : Set where
  field
    op₂ : VecOp₂
    unsigned : Bool

  open VecOp₂ op₂ public

record VRMulH : Set where
  field
    op₂ : VecOp₂
    unsigned : Bool

  open VecOp₂ op₂ public

record VMlA : Set where
  field
    size     : VecOpSize
    unsigned : Bool
    acc      : VecReg
    src₁     : VecReg
    src₂     : GenReg

  open Size size public

VQDMulH = VecOp₂
VQRDMulH = VecOp₂

data Instruction : Set where
  vadd : VAdd → Instruction
  vsub : VSub → Instruction
  vmul : VMul → Instruction
  vmulh : VMulH → Instruction
  vqdmulh : VQDMulH → Instruction