This repository has been archived by the owner on Feb 18, 2020. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
+ SPARC assembly syntax with virtual instructions
No pretty printing at the moment
- Loading branch information
Showing
1 changed file
with
68 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -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) |