mirror of
https://github.com/grin-compiler/grin.git
synced 2024-09-11 07:25:28 +03:00
Create frontend-test directory.
This commit is contained in:
parent
e93000f707
commit
cb5839c801
1
.gitignore
vendored
1
.gitignore
vendored
@ -20,3 +20,4 @@ cabal.sandbox.config
|
|||||||
cabal.project.local
|
cabal.project.local
|
||||||
.HTF/
|
.HTF/
|
||||||
output/
|
output/
|
||||||
|
*.ibc
|
||||||
|
@ -38,5 +38,5 @@ install:
|
|||||||
script:
|
script:
|
||||||
- mkdir output
|
- mkdir output
|
||||||
- stack exec grin -- grin/grin/sum_simple.grin
|
- stack exec grin -- grin/grin/sum_simple.grin
|
||||||
- stack exec idris -- hello.idr --codegen grin -o hello.grin
|
- stack exec idris -- frontend-test/idris/Hello.idr -i frontend-test/idris --codegen grin -o hello.grin
|
||||||
- stack --no-terminal test --coverage
|
- stack --no-terminal test --coverage
|
||||||
|
7
frontend-test/idris/GrinFFI.idr
Normal file
7
frontend-test/idris/GrinFFI.idr
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
module GrinFFI
|
||||||
|
|
||||||
|
public export
|
||||||
|
int_print : Int -> IO Int
|
||||||
|
int_print i
|
||||||
|
= foreign FFI_C "_prim_int_print" (Int -> IO Int) i
|
||||||
|
|
@ -1,8 +1,7 @@
|
|||||||
module Main
|
module Main
|
||||||
|
|
||||||
int_print : Int -> IO Int
|
import GrinFFI
|
||||||
int_print i
|
|
||||||
= foreign FFI_C "_prim_int_print" (Int -> IO Int) i
|
|
||||||
|
|
||||||
fn : Int -> Int
|
fn : Int -> Int
|
||||||
fn x = if x > 0
|
fn x = if x > 0
|
@ -44,15 +44,15 @@ codegenGrin CodegenInfo{..} = do
|
|||||||
|
|
||||||
idrisPrimOps = [prog|
|
idrisPrimOps = [prog|
|
||||||
|
|
||||||
idris_int_eq a0 b0 =
|
idris_int_eq idris_int_eq0 idris_int_eq1 =
|
||||||
res0 <- _prim_int_eq a0 b0
|
idris_int_eq2 <- _prim_int_eq idris_int_eq0 idris_int_eq1
|
||||||
case res0 of
|
case idris_int_eq2 of
|
||||||
#False -> pure 0
|
#False -> pure 0
|
||||||
#True -> pure 1
|
#True -> pure 1
|
||||||
|
|
||||||
idris_int_lt a1 b1 =
|
idris_int_lt idris_int_lt0 idris_int_lt1 =
|
||||||
res1 <- _prim_int_lt a1 b1
|
idris_int_lt2 <- _prim_int_lt idris_int_lt0 idris_int_lt1
|
||||||
case res1 of
|
case idris_int_lt2 of
|
||||||
#False -> pure 0
|
#False -> pure 0
|
||||||
#True -> pure 1
|
#True -> pure 1
|
||||||
|]
|
|]
|
||||||
@ -104,8 +104,6 @@ sexp fname = \case
|
|||||||
SV lvar0@(Idris.Loc i) -> SReturn (Var $ loc fname lvar0)
|
SV lvar0@(Idris.Loc i) -> SReturn (Var $ loc fname lvar0)
|
||||||
SV lvar0@(Idris.Glob n) -> traceShow "Global call" $ Grin.SApp (lvar fname lvar0) []
|
SV lvar0@(Idris.Glob n) -> traceShow "Global call" $ Grin.SApp (lvar fname lvar0) []
|
||||||
|
|
||||||
-- Keep DExps for describing foreign things, because they get
|
|
||||||
-- translated differently
|
|
||||||
--SForeign fdesc1 fdesc2 fdescLVars -> undefined
|
--SForeign fdesc1 fdesc2 fdescLVars -> undefined
|
||||||
SForeign _ (FStr "_prim_int_print") [(_,arg)] -> Grin.SApp "_prim_int_print" [Var . lvar fname $ arg]
|
SForeign _ (FStr "_prim_int_print") [(_,arg)] -> Grin.SApp "_prim_int_print" [Var . lvar fname $ arg]
|
||||||
SNothing -> traceShow "Erased value" $ SReturn Unit
|
SNothing -> traceShow "Erased value" $ SReturn Unit
|
||||||
@ -267,13 +265,13 @@ idrisPipeLine =
|
|||||||
, T UpdateElimination
|
, T UpdateElimination
|
||||||
, T CopyPropagation
|
, T CopyPropagation
|
||||||
, T ConstantPropagation
|
, T ConstantPropagation
|
||||||
-- , T SparseCaseOptimisation: Illegal type {}
|
, T SparseCaseOptimisation
|
||||||
, T EvaluatedCaseElimination
|
, T EvaluatedCaseElimination
|
||||||
, T ConstantPropagation
|
, T ConstantPropagation
|
||||||
-- , T CommonSubExpressionElimination: Illegal type {}
|
, T CommonSubExpressionElimination
|
||||||
, T CaseCopyPropagation
|
, T CaseCopyPropagation
|
||||||
-- , T GeneralizedUnboxing: Illegal type: {}
|
, T GeneralizedUnboxing
|
||||||
-- , T ArityRaising: Illegal type: {}
|
, T ArityRaising
|
||||||
, SaveGrin "After"
|
, SaveGrin "After"
|
||||||
, PrintGrin ondullblack
|
, PrintGrin ondullblack
|
||||||
, SaveLLVM "high-level-opt-code"
|
, SaveLLVM "high-level-opt-code"
|
||||||
|
Loading…
Reference in New Issue
Block a user