aboutsummaryrefslogtreecommitdiffstats
path: root/src/GSA/Types.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/GSA/Types.hs')
-rw-r--r--src/GSA/Types.hs155
1 files changed, 149 insertions, 6 deletions
diff --git a/src/GSA/Types.hs b/src/GSA/Types.hs
index a99cac7..ff6bb15 100644
--- a/src/GSA/Types.hs
+++ b/src/GSA/Types.hs
@@ -1,7 +1,9 @@
module GSA.Types where
import Data.IntMap.Strict (IntMap)
+import Data.Map.Strict (Map)
import Data.Text (Text)
+import Data.Int (Int64)
data Typ
= Tint
@@ -38,6 +40,7 @@ data Chunk
| Mfloat64
| Many32
| Many64
+ deriving (Eq, Show)
signatureMain :: Signature
signatureMain = Signature {sigArgs = [], sigRes = Tret Tint}
@@ -48,11 +51,153 @@ newtype Reg = Reg {getReg :: Int} deriving (Eq, Show)
newtype Ident = Ident {getIdent :: Int} deriving (Eq, Show)
-newtype Addressing = Addressing {getAddressing :: Int} deriving (Eq, Show)
+newtype Ptrofs = Ptrofs { getPtrofs :: Int } deriving (Eq, Show)
+
+data Comparison =
+ Ceq
+ | Cne
+ | Clt
+ | Cle
+ | Cgt
+ | Cge
+ deriving (Eq, Show)
+
+negateComparison Ceq = Cne
+negateComparison Cne = Ceq
+negateComparison Clt = Cge
+negateComparison Cle = Cgt
+negateComparison Cgt = Cle
+negateComparison Cge = Clt
+
+swapComparison Ceq = Ceq
+swapComparison Cne = Cne
+swapComparison Clt = Cgt
+swapComparison Cle = Cge
+swapComparison Cgt = Clt
+swapComparison Cge = Cle
+
+data Condition =
+ Ccomp Comparison
+ | Ccompu Comparison
+ | Ccompimm Comparison Int
+ | Ccompuimm Comparison Int
+ | Ccompl Comparison
+ | Ccomplu Comparison
+ | Ccomplimm Comparison Int64
+ | Ccompluimm Comparison Int64
+ | Ccompf Comparison
+ | Cnotcompf Comparison
+ | Ccompfs Comparison
+ | Cnotcompfs Comparison
+ | Cmaskzero Int
+ | Cmasknotzero Int
+ deriving (Eq, Show)
-newtype Operation = Operation {getOperation :: Int} deriving (Eq, Show)
+data Addressing =
+ Aindexed Integer
+ | Aindexed2 Integer
+ | Ascaled Integer Integer
+ | Aindexed2scaled Integer Integer
+ | Aglobal Ident Ptrofs
+ | Abased Ident Ptrofs
+ | Abasedscaled Integer Ident Ptrofs
+ | Ainstack Ptrofs
+ deriving (Eq, Show)
-type Condition = Int
+data Operation = Omove
+ | Ointconst Int
+ | Olongconst Int64
+ | Ofloatconst Double
+ | Osingleconst Float
+ | Oindirectsymbol Ident
+ | Ocast8signed
+ | Ocast8unsigned
+ | Ocast16signed
+ | Ocast16unsigned
+ | Oneg
+ | Osub
+ | Omul
+ | Omulimm Int
+ | Omulhs
+ | Omulhu
+ | Odiv
+ | Odivu
+ | Omod
+ | Omodu
+ | Oand
+ | Oandimm Int
+ | Oor
+ | Oorimm Int
+ | Oxor
+ | Oxorimm Int
+ | Onot
+ | Oshl
+ | Oshlimm Int
+ | Oshr
+ | Oshrimm Int
+ | Oshrximm Int
+ | Oshru
+ | Oshruimm Int
+ | Ororimm Int
+ | Oshldimm Int
+ | Olea Addressing
+ | Omakelong
+ | Olowlong
+ | Ohighlong
+ | Ocast32signed
+ | Ocast32unsigned
+ | Onegl
+ | Oaddlimm Int64
+ | Osubl
+ | Omull
+ | Omullimm Int64
+ | Omullhs
+ | Omullhu
+ | Odivl
+ | Odivlu
+ | Omodl
+ | Omodlu
+ | Oandl
+ | Oandlimm Int64
+ | Oorl
+ | Oorlimm Int64
+ | Oxorl
+ | Oxorlimm Int64
+ | Onotl
+ | Oshll
+ | Oshllimm Int
+ | Oshrl
+ | Oshrlimm Int
+ | Oshrxlimm Int
+ | Oshrlu
+ | Oshrluimm Int
+ | Ororlimm Int
+ | Oleal Addressing
+ | Onegf
+ | Oabsf
+ | Oaddf
+ | Osubf
+ | Omulf
+ | Odivf
+ | Onegfs
+ | Oabsfs
+ | Oaddfs
+ | Osubfs
+ | Omulfs
+ | Odivfs
+ | Osingleoffloat
+ | Ofloatofsingle
+ | Ointoffloat
+ | Ofloatofint
+ | Ointofsingle
+ | Osingleofint
+ | Olongoffloat
+ | Ofloatoflong
+ | Olongofsingle
+ | Osingleoflong
+ | Ocmp Condition
+ | Osel Condition Typ
+ deriving (Eq, Show)
data Pred a
= Ptrue
@@ -82,8 +227,6 @@ data Instruction
| Imfunc [MergeInstruction]
deriving (Eq, Show)
-newtype MergeBlock = MergeBlock {getMergeBlock :: [MergeInstruction]} deriving (Eq, Show)
-
newtype Code = Code {getCode :: IntMap Instruction} deriving (Eq, Show)
data Function = Function
@@ -96,4 +239,4 @@ data Function = Function
}
deriving (Eq, Show)
-newtype Program = Program {getProgram :: [Function]} deriving (Eq, Show)
+newtype Program = Program {getProgram :: Map Text Function} deriving (Eq, Show)