Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: Averethel/OCamlMin
base: 51313d620b
...
head fork: Averethel/OCamlMin
compare: 37c5e6d6aa
Checking mergeability… Don't worry, you can still create the pull request.
  • 2 commits
  • 2 files changed
  • 0 commit comments
  • 1 contributor
Showing with 70 additions and 0 deletions.
  1. +2 −0  README.md
  2. +68 −0 SPARC/Syntax.hs
View
2  README.md
@@ -5,6 +5,8 @@ Implementation of OCamlMin language based on min-caml project.
Changelog
=========
+* 17 III 2013
+ * SPARC assembly syntax defined
* 11 III 2013
* Closure conversion module
* 23 II 2013
View
68 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)

No commit comments for this range

Something went wrong with that request. Please try again.