diff options
Diffstat (limited to 'snug-clean/src')
-rw-r--r-- | snug-clean/src/MIPS/MIPS32.dcl | 1 | ||||
-rw-r--r-- | snug-clean/src/MIPS/MIPS32.icl | 1 | ||||
-rw-r--r-- | snug-clean/src/Snug/Compile.icl | 21 | ||||
-rw-r--r-- | snug-clean/src/Snug/Compile/ABI.dcl | 2 | ||||
-rw-r--r-- | snug-clean/src/Snug/Compile/Simulate.icl | 2 |
5 files changed, 19 insertions, 8 deletions
diff --git a/snug-clean/src/MIPS/MIPS32.dcl b/snug-clean/src/MIPS/MIPS32.dcl index 4789507..a2c85dc 100644 --- a/snug-clean/src/MIPS/MIPS32.dcl +++ b/snug-clean/src/MIPS/MIPS32.dcl @@ -7,6 +7,7 @@ from StdOverloaded import class toString | Align !Int | Label !Label | Instr !Instruction + | RawByte !Int | RawWord !Int | RawAscii !String diff --git a/snug-clean/src/MIPS/MIPS32.icl b/snug-clean/src/MIPS/MIPS32.icl index a124007..6e602be 100644 --- a/snug-clean/src/MIPS/MIPS32.icl +++ b/snug-clean/src/MIPS/MIPS32.icl @@ -10,6 +10,7 @@ where toString (Align i) = "\t.align\t" +++ toString i toString (Label l) = l +++ ":" toString (Instr i) = "\t" +++ toString i + toString (RawByte i) = "\t.byte\t" +++ toString i toString (RawWord i) = "\t.word\t" +++ toString i toString (RawAscii s) = concat3 "\t.ascii\t\"" s "\"" // TODO: escaping diff --git a/snug-clean/src/Snug/Compile.icl b/snug-clean/src/Snug/Compile.icl index 26fd5af..c354950 100644 --- a/snug-clean/src/Snug/Compile.icl +++ b/snug-clean/src/Snug/Compile.icl @@ -50,9 +50,16 @@ compileDefinition ns globals (DataDef _ _ constructors) = ] compileDefinition ns globals (FunDef id args ret expr) = [ StartSection "text" - , Align 3 // to have 3 bits unused in addresses - , RawWord (sum [2^i \\ i <- [0..] & _ <- args]) // all strict for now, TODO change - , RawWord (length args) // arity + // TODO: Ideally we would use the following here: + //, Align 1 + //, RawByte (sum [2^i \\ i <- [0..] & _ <- args]) // all strict for now, TODO change + //, RawByte (length args) // arity + // But since SPIM does not allow .byte in the text section, we use: + , Align 2 + , RawWord + (sum [2^i \\ i <- [0..] & _ <- args] bitor // all strict for now, TODO change + (length args << 8)) // arity + // instead... (end modification) , Label (functionLabel ns NodeEntry id) : map Instr (compileExpr ns globals locals expr) ] @@ -65,11 +72,11 @@ where compileConstructor :: !Namespace !Globals !ConstructorDef -> [Line] compileConstructor ns _ (ConstructorDef id args) = - [ Align 3 // to have 3 bits unused in addresses + [ Align 1 , Label (constructorLabel ns id) - , RawWord (length args) // arity - , RawWord (size id) // length name - , RawAscii id // name + , RawByte (length args) // pointer arity + , RawByte 0 // basic value arity + , RawByte 0 // number of arguments still to be curried in ] compileExpr :: !Namespace !Globals !Locals !Expression -> [Instruction] diff --git a/snug-clean/src/Snug/Compile/ABI.dcl b/snug-clean/src/Snug/Compile/ABI.dcl index 938a65e..6de2953 100644 --- a/snug-clean/src/Snug/Compile/ABI.dcl +++ b/snug-clean/src/Snug/Compile/ABI.dcl @@ -13,6 +13,8 @@ FrontPrintPtr :== S 1 BackEvalPtr :== S 2 FrontEvalPtr :== S 3 +TextEndDataStart :== S 7 + HeapPtr :== GP TempImm :== T 0 diff --git a/snug-clean/src/Snug/Compile/Simulate.icl b/snug-clean/src/Snug/Compile/Simulate.icl index 9f09467..620ec3e 100644 --- a/snug-clean/src/Snug/Compile/Simulate.icl +++ b/snug-clean/src/Snug/Compile/Simulate.icl @@ -83,7 +83,7 @@ storeStackValue (SVRegOffset reg offset) doffset dreg = add buildCons :: !Label !Int -> Simulator () buildCons cons nargs = - write_heap (SVImmediate (Address 4 cons)) >>= \addr -> + write_heap (SVImmediate (Address 0 cons)) >>= \addr -> mapM_ (\_ -> pop >>= write_heap) [1..nargs] >>| push addr |