Skip to content
This repository has been archived by the owner on Feb 18, 2020. It is now read-only.

Commit

Permalink
+ SPARC assembly syntax with virtual instructions
Browse files Browse the repository at this point in the history
No pretty printing at the moment
  • Loading branch information
Averethel committed Mar 17, 2013
1 parent 51313d6 commit 795dd51
Showing 1 changed file with 68 additions and 0 deletions.
68 changes: 68 additions & 0 deletions SPARC/Syntax.hs
@@ -0,0 +1,68 @@
module SPARC.Syntax where

data Label = L String deriving Eq

instance Show Label where
show (L s) = s

data IdOrIimm =
V String
| C Integer
deriving Eq

instance Show IdOrIimm where
show (V s) = s
show (C n) = show n

-- Instruction sequence
data Seq =
Ans Instr
| Let String Instr Seq
deriving (Eq, Show)

-- SPARC assembly instructions
data Instr =
Inop
| Iset Integer
| IsetL Label
| Imov String
| Ineg String
| Iadd String IdOrIimm
| Isub String IdOrIimm
| ISLL String IdOrIimm
| Ild String IdOrIimm
| Ist String String IdOrIimm
| IfMovD String
| IfNegD String
| IfAddD String String
| IfSubD String String
| IfMulD String String
| IfDivD String String
| IldDF String IdOrIimm
| IstDF String String IdOrIimm
| Icomment String
-- virtual instructions
| IifEq String IdOrIimm Instr Instr
| IifLE String IdOrIimm Instr Instr
| IifGE String IdOrIimm Instr Instr
| IifFEq String String Instr Instr
| IifFLE String String Instr Instr
-- closure address, integer arguments, and float arguments
| IcallCls String [String] [String]
| IcallDir Label [String] [String]
| Isave String String
| Irestore String
deriving (Eq, Show)

data FunDef = FD {
name :: Label,
args :: [String],
fargs :: [String],
body :: Seq,
} deriving (Eq, Show)

data Program = P {
funTable :: [(Label, Float)],
toplevel :: [FunDef],
main :: Instr
} deriving (Eq, Show)

0 comments on commit 795dd51

Please sign in to comment.