Skip to content

Commit

Permalink
fix compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaszcz committed Oct 14, 2022
1 parent 1aeba80 commit cfb6f42
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/Juvix/Compiler/Reg/Language/Base.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ module Juvix.Compiler.Reg.Language.Base
where

import Juvix.Compiler.Asm.Language.Rep
import Juvix.Compiler.Core.Language.Base hiding (Index, BuiltinOp(..))
import Juvix.Compiler.Core.Language.Base hiding (BuiltinOp (..), Index)
20 changes: 12 additions & 8 deletions src/Juvix/Compiler/Reg/Translation/FromAsm.hs
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,7 @@ fromAsmInstr ::
Sem r Instruction
fromAsmInstr tab mem Asm.CmdInstr {..} =
case _cmdInstrInstruction of
Asm.IntAdd -> return $ mkBinop OpIntAdd
Asm.IntSub -> return $ mkBinop OpIntSub
Asm.IntMul -> return $ mkBinop OpIntMul
Asm.IntDiv -> return $ mkBinop OpIntDiv
Asm.IntMod -> return $ mkBinop OpIntMod
Asm.IntLt -> return $ mkBinop OpIntLt
Asm.IntLe -> return $ mkBinop OpIntLe
Asm.ValEq -> return $ mkBinop OpEq
Asm.Binop op -> return $ mkBinop (mkOpcode op)
Asm.Push val -> return $ mkAssign (VarRef VarGroupStack (n + 1)) (mkValue val)
Asm.Pop -> return Nop
Asm.PushTemp ->
Expand Down Expand Up @@ -130,6 +123,17 @@ fromAsmInstr tab mem Asm.CmdInstr {..} =
}
)

mkOpcode :: Asm.Opcode -> Opcode
mkOpcode = \case
Asm.IntAdd -> OpIntAdd
Asm.IntSub -> OpIntSub
Asm.IntMul -> OpIntMul
Asm.IntDiv -> OpIntDiv
Asm.IntMod -> OpIntMod
Asm.IntLt -> OpIntLt
Asm.IntLe -> OpIntLe
Asm.ValEq -> OpEq

mkAssign :: VarRef -> Value -> Instruction
mkAssign tgt src = Assign (InstrAssign tgt src)

Expand Down

0 comments on commit cfb6f42

Please sign in to comment.