aboutsummaryrefslogtreecommitdiff
path: root/snug-clean/src/Snug/Compile.icl
diff options
context:
space:
mode:
authorCamil Staps2023-01-30 21:36:20 +0100
committerCamil Staps2023-01-30 21:36:20 +0100
commitbf4053fdf98c906f1e079ae0332cfaee35b8d071 (patch)
treecce168498513bfe3717f640e1310413d7ae9079a /snug-clean/src/Snug/Compile.icl
parentAlign on double words (diff)
Align on halfwords instead of double words; use data/text boundary to distinguish hnfs and thunks
Diffstat (limited to 'snug-clean/src/Snug/Compile.icl')
-rw-r--r--snug-clean/src/Snug/Compile.icl21
1 files changed, 14 insertions, 7 deletions
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]