From 281a29f01346bd2f00fbaca8391f38d856a45d6d Mon Sep 17 00:00:00 2001 From: Greg Brown Date: Mon, 21 Feb 2022 12:18:31 +0000 Subject: Replace nat indices with fins. --- src/Helium/Data/Pseudocode/Core.agda | 12 ++-- src/Helium/Instructions/Base.agda | 103 ++++++++++++++-------------- src/Helium/Semantics/Denotational/Core.agda | 10 +-- 3 files changed, 63 insertions(+), 62 deletions(-) (limited to 'src') diff --git a/src/Helium/Data/Pseudocode/Core.agda b/src/Helium/Data/Pseudocode/Core.agda index d683947..5cdf051 100644 --- a/src/Helium/Data/Pseudocode/Core.agda +++ b/src/Helium/Data/Pseudocode/Core.agda @@ -19,7 +19,7 @@ open import Data.Vec.Relation.Unary.All using (All; []; _∷_; reduce) open import Data.Vec.Relation.Unary.Any using (Any; here; there) open import Function as F using (_∘_; _∘′_; _∋_) open import Relation.Binary.PropositionalEquality using (_≡_; refl) -open import Relation.Nullary using (yes; no) +open import Relation.Nullary using (Dec; yes; no) open import Relation.Nullary.Decidable.Core using (True; False; toWitness; fromWitness; map′) open import Relation.Nullary.Product using (_×-dec_) open import Relation.Nullary.Sum using (_⊎-dec_) @@ -131,8 +131,8 @@ module Code {o} (Σ : Vec Type o) where data Expression {n} Γ where lit : ∀ {t} → Literal t → Expression Γ t - state : ∀ i {i>3 (tup ((var 3) ∷ []))) + tup (index (var 5F) (var 3F) ∷ var 0F ∷ []) ≔ call (SignedSatQ (toℕ esize-1)) (var 1F ∷ []) ∙ + if var 0F && hasBit (var 6F) (fin e*esize>>3 (tup ((var 3F) ∷ []))) then FPSCR-QC ≔ lit (true ′x) else skip))) @@ -298,9 +299,9 @@ private helper Instr.32bit i = Fin.combine i zero vqdmulh : Instr.VQDMulH → Procedure [] -vqdmulh d = vqr?dmulh d (skip ∙return lit (2 ′i) * var 0 * var 1 >> toℕ esize) +vqdmulh d = vqr?dmulh d (skip ∙return lit (2 ′i) * var 0F * var 1F >> toℕ esize) where open Instr.VecOp₂ d using (esize) vqrdmulh : Instr.VQRDMulH → Procedure [] -vqrdmulh d = vqr?dmulh d (skip ∙return lit (2 ′i) * var 0 * var 1 + lit (1 ′i) << toℕ esize-1 >> toℕ esize) +vqrdmulh d = vqr?dmulh d (skip ∙return lit (2 ′i) * var 0F * var 1F + lit (1 ′i) << toℕ esize-1 >> toℕ esize) where open Instr.VecOp₂ d using (esize; esize-1) diff --git a/src/Helium/Semantics/Denotational/Core.agda b/src/Helium/Semantics/Denotational/Core.agda index 46d68bc..4897b61 100644 --- a/src/Helium/Semantics/Denotational/Core.agda +++ b/src/Helium/Semantics/Denotational/Core.agda @@ -17,7 +17,7 @@ private open module C = RawPseudocode rawPseudocode open import Data.Bool as Bool using (Bool; true; false) -open import Data.Fin as Fin using (Fin; zero; suc; #_) +open import Data.Fin as Fin using (Fin; zero; suc) import Data.Fin.Properties as Finₚ open import Data.Nat as ℕ using (ℕ; zero; suc) import Data.Nat.Properties as ℕₚ @@ -201,8 +201,8 @@ module Expression update : ∀ {n Γ t e} → CanAssign {n} {Γ} {t} e → ⟦ t ⟧ₜ → ⟦ Σ ⟧ₜ′ → ⟦ Γ ⟧ₜ′ → ⟦ Σ ⟧ₜ′ × ⟦ Γ ⟧ₜ′ ⟦ lit x ⟧ᵉ σ γ = 𝒦 x - ⟦ state i ⟧ᵉ σ γ = fetch Σ σ (# i) - ⟦_⟧ᵉ {Γ = Γ} (var i) σ γ = fetch Γ γ (# i) + ⟦ state i ⟧ᵉ σ γ = fetch Σ σ i + ⟦_⟧ᵉ {Γ = Γ} (var i) σ γ = fetch Γ γ i ⟦ abort e ⟧ᵉ σ γ = case ⟦ e ⟧ᵉ σ γ of λ () ⟦ _≟_ {hasEquality = hasEq} e e₁ ⟧ᵉ σ γ = equal (toWitness hasEq) (⟦ e ⟧ᵉ σ γ) (⟦ e₁ ⟧ᵉ σ γ) ⟦ _