From 43f07a97facb044ca67c96cb0aad14d26857ebb7 Mon Sep 17 00:00:00 2001 From: Vidush Singhal Date: Mon, 2 Dec 2024 15:21:37 -0500 Subject: [PATCH] move things around, SoA value for locvar --- gibbon-compiler/src/Gibbon/Common.hs | 28 ++++++++----------- gibbon-compiler/src/Gibbon/L4/Syntax.hs | 2 +- gibbon-compiler/src/Gibbon/Language/Syntax.hs | 3 +- 3 files changed, 14 insertions(+), 19 deletions(-) diff --git a/gibbon-compiler/src/Gibbon/Common.hs b/gibbon-compiler/src/Gibbon/Common.hs index ee5d72979..969a057d8 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, FieldIndex + Var(..), LocVar(..), Location, FieldIndex, DataCon , RegVar, fromVar, toVar, varAppend, toEndV, toEndVLoc, toSeqV, cleanFunName , TyVar(..), isUserTv , Symbol, intern, unintern @@ -66,7 +66,6 @@ import System.IO.Unsafe ( unsafePerformIO ) import System.Random ( randomIO ) import Debug.Trace import Language.C.Quote.CUDA (ToIdent, toIdent) - import Gibbon.DynFlags -------------------------------------------------------------------------------- @@ -138,21 +137,18 @@ toSeqV v = varAppend v (toVar "_seq") -- | A location variable stores the abstract location. type Location = Var --- | Index position of the filed in the data constructor. +-- | The position or index of a field in a data constructor value. type FieldIndex = Int --- | Location of the buffer where all the data constructor tags are stored. -type DataConBuf = Location --- | Store the name of the data constructor as a String. -type DataConName = String --- | Store the location of the buffer with the factored out fields. --- | Stores extra meta data like data constructor to which it comes from and the index position. -type FieldBuf = ((DataConName, FieldIndex), Location) --- | List of field locations for a datatype -type FieldLocs = [FieldBuf] --- | A data type that stores either a single location, AoS --- | or a SoA representation: A data constructor buffer in addition to location for fields. --- | LocVar can also be a pointer. -data LocVar = Single Location | SoA DataConBuf FieldLocs +-- | A data constructor is a String type in the compiler +type DataCon = String + +-- | Single: For storing a single location, useful for adding a cursor in a region. +-- | SoA: A location signature for a structure of arrays representation. +-- The first location points to a location in the data constructor buffer. +-- The list includes locations for each field and a tuple storing +-- information about which data constructor and corresponding index the field +-- comes from. +data LocVar = Single Location | SoA Location [((DataCon, FieldIndex), Location)] deriving (Show, Ord, Eq, Read, Generic, NFData, Out) -- | Abstract region variables. diff --git a/gibbon-compiler/src/Gibbon/L4/Syntax.hs b/gibbon-compiler/src/Gibbon/L4/Syntax.hs index 9ff7cda9e..ec0b4d8ab 100644 --- a/gibbon-compiler/src/Gibbon/L4/Syntax.hs +++ b/gibbon-compiler/src/Gibbon/L4/Syntax.hs @@ -103,7 +103,7 @@ type Label = Var type SymTable = M.Map Word16 String type InfoTable = (M.Map L.TyCon TyConInfo) -type TyConInfo = M.Map L.DataCon DataConInfo +type TyConInfo = M.Map DataCon DataConInfo data DataConInfo = DataConInfo { dcon_tag :: Tag diff --git a/gibbon-compiler/src/Gibbon/Language/Syntax.hs b/gibbon-compiler/src/Gibbon/Language/Syntax.hs index 360ef7c15..4a80b523a 100644 --- a/gibbon-compiler/src/Gibbon/Language/Syntax.hs +++ b/gibbon-compiler/src/Gibbon/Language/Syntax.hs @@ -14,7 +14,7 @@ module Gibbon.Language.Syntax ( -- * Datatype definitions - DDefs, DataCon, TyCon, Tag, IsBoxed, DDef(..) + DDefs, TyCon, Tag, IsBoxed, DDef(..) , lookupDDef, getConOrdering, getTyOfDataCon, lookupDataCon, lkp , lookupDataCon', insertDD, emptyDD, fromListDD, isVoidDDef @@ -78,7 +78,6 @@ import Gibbon.Common type DDefs a = M.Map Var (DDef a) -type DataCon = String type TyCon = String type Tag = Word8