sword-smith / hfasto Goto Github PK
View Code? Open in Web Editor NEWImplementing a compiler for the fuctional programming language fasto in Haskell
License: MIT License
Implementing a compiler for the fuctional programming language fasto in Haskell
License: MIT License
Troels: Can you make a folder structure which is appropriate for testing? I would like to run unit tests on various function in the different modules located in src/ but when I create test modules in T/, I cannot get those modules to import the modules found in src/
When a function is called with more than four arguments the arguments are loaded from the stack. Currently, the instructions to load these arguments is located in the function loadRegistersH in MipsCodeGenerator.hs. But spilling, which is handled in the MipsRegAlloc, may wrap the entire body in instructions that move the stack pointer and the code generated by loadRegistersH is considered part of the body.
The solution is probably to give the code generated by the loadRegisters function a special place in the mipsFunction record and then rewrite all the load instructions when it is known how much the register allocator moves the stack pointer before the loadRegisters code is executed.
Some of the relevant parts of the code are presented below
saveArgRegs :: [] String -> [] Mips.Instruction
saveArgRegs args = saveArgRegsH 0 args
saveArgRegsH :: Int -> [] String -> [] Mips.Instruction
saveArgRegsH _ [] = []
saveArgRegsH i (arg:args) = if i < 4
then Mips.XOR ("$a" ++ show i) arg zero :
Mips.SW arg "$sp" (show (i*4)) :
saveArgRegsH (i+1) args
else Mips.SW arg "$sp" (show (i*4)) :
saveArgRegsH (i+1) args
-- Atm, no proper liveness analysis is done with these "string:strings"
loadRegisters :: [] String -> [] Mips.Instruction
loadRegisters args = loadRegistersH 0 args
-- The "8" in the below function cannot be hardcoded since the register allocator
-- may invalidate that number.
-- The solution may be to introduce a loadRegisters value with which the
-- register allocator may shift all the special, symbolic lw operations?
-- They can also just be rewritten if the are part of the loadArgs part of the
-- MipsFunction struct.
loadRegistersH :: Int -> [] String -> [] Mips.Instruction
loadRegistersH _ [] = []
loadRegistersH i (arg:args) = if i < 4
then Mips.XOR arg ("$a" ++ (show i)) zero :
loadRegistersH (i + 1) args
else Mips.LW arg "$sp" (show (i*4 + 8)) :
loadRegistersH (i + 1) args
regAllocInst spillingRewrite vtable (Mips.JAL l) = do-- Here the store and load stuff should be handled. Potentially in a monade?
regEnv <- get
i <- incr
let sliveRegs = S.toList $ (livenessInSets regEnv !! i)
rliveRegs <- mapM (mapReg vtable) sliveRegs
store <- storeLive (rliveRegs ++ ["$ra"])
load <- loadLive $ rliveRegs ++ ["$ra"]
if spillingRewrite
then return [Mips.JAL l]
else return $ store ++ [Mips.JAL l] ++ load
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.