From 4373542328b7c77ef9e0a7d0c36db66678689011 Mon Sep 17 00:00:00 2001 From: Vidush Singhal Date: Mon, 2 Dec 2024 13:45:55 -0500 Subject: [PATCH] use type alias for descriptive names --- gibbon-compiler/src/Gibbon/Common.hs | 5 ++++- gibbon-compiler/src/Gibbon/L2/Syntax.hs | 14 +++++++------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/gibbon-compiler/src/Gibbon/Common.hs b/gibbon-compiler/src/Gibbon/Common.hs index d4ce648c..ec4a0520 100644 --- a/gibbon-compiler/src/Gibbon/Common.hs +++ b/gibbon-compiler/src/Gibbon/Common.hs @@ -8,7 +8,7 @@ module Gibbon.Common ( -- * Variables - Var(..), LocVar(..), Location + Var(..), LocVar(..), Location, FieldIndex , RegVar, fromVar, toVar, varAppend, toEndV, toEndVLoc, toSeqV, cleanFunName , TyVar(..), isUserTv , Symbol, intern, unintern @@ -139,6 +139,9 @@ toSeqV v = varAppend v (toVar "_seq") -- | A location variable stores the abstract location. type Location = Var +-- | The position or index of a field in a data constructor value. +type FieldIndex = Int + data LocVar = Single Location deriving (Show, Ord, Eq, Read, Generic, NFData, Out) diff --git a/gibbon-compiler/src/Gibbon/L2/Syntax.hs b/gibbon-compiler/src/Gibbon/L2/Syntax.hs index 3694139d..3e5569e5 100644 --- a/gibbon-compiler/src/Gibbon/L2/Syntax.hs +++ b/gibbon-compiler/src/Gibbon/L2/Syntax.hs @@ -479,13 +479,13 @@ data Region = GlobR Var Multiplicity -- ^ A global region with lifetime equal to -- are no free locations in the program. deriving (Read,Show,Eq,Ord, Generic) -data ExtendedRegion = AoSR Region -- ^ A simple "flat" region where the datatype - -- will reside in an array of structure representation. - | SoAR Region [((String, Int), Region)] -- ^ A complex region representation for a datatype - -- One "flat" buffer makes space for all the data constructors. - -- In addition to a list containing a "flat" buffer for each - -- field. The region can also be mapped to which data constructore - -- and field tuple it belongs to. A structure of arrays representation. +data ExtendedRegion = AoSR Region -- ^ A simple "flat" region where the datatype + -- will reside in an array of structure representation. + | SoAR Region [((DataCon, FieldIndex), Region)] -- ^ A complex region representation for a datatype + -- One "flat" buffer makes space for all the data constructors. + -- In addition to a list containing a "flat" buffer for each + -- field. The region can also be mapped to which data constructore + -- and field tuple it belongs to. A structure of arrays representation. deriving (Read,Show,Eq,Ord, Generic)