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
|
||||
.HTF/
|
||||
output/
|
||||
*.ibc
|
||||
|
@ -38,5 +38,5 @@ install:
|
||||
script:
|
||||
- mkdir output
|
||||
- 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
|
||||
|
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
|
||||
|
||||
int_print : Int -> IO Int
|
||||
int_print i
|
||||
= foreign FFI_C "_prim_int_print" (Int -> IO Int) i
|
||||
import GrinFFI
|
||||
|
||||
|
||||
fn : Int -> Int
|
||||
fn x = if x > 0
|
@ -44,15 +44,15 @@ codegenGrin CodegenInfo{..} = do
|
||||
|
||||
idrisPrimOps = [prog|
|
||||
|
||||
idris_int_eq a0 b0 =
|
||||
res0 <- _prim_int_eq a0 b0
|
||||
case res0 of
|
||||
idris_int_eq idris_int_eq0 idris_int_eq1 =
|
||||
idris_int_eq2 <- _prim_int_eq idris_int_eq0 idris_int_eq1
|
||||
case idris_int_eq2 of
|
||||
#False -> pure 0
|
||||
#True -> pure 1
|
||||
|
||||
idris_int_lt a1 b1 =
|
||||
res1 <- _prim_int_lt a1 b1
|
||||
case res1 of
|
||||
idris_int_lt idris_int_lt0 idris_int_lt1 =
|
||||
idris_int_lt2 <- _prim_int_lt idris_int_lt0 idris_int_lt1
|
||||
case idris_int_lt2 of
|
||||
#False -> pure 0
|
||||
#True -> pure 1
|
||||
|]
|
||||
@ -104,8 +104,6 @@ sexp fname = \case
|
||||
SV lvar0@(Idris.Loc i) -> SReturn (Var $ loc 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 _ (FStr "_prim_int_print") [(_,arg)] -> Grin.SApp "_prim_int_print" [Var . lvar fname $ arg]
|
||||
SNothing -> traceShow "Erased value" $ SReturn Unit
|
||||
@ -267,13 +265,13 @@ idrisPipeLine =
|
||||
, T UpdateElimination
|
||||
, T CopyPropagation
|
||||
, T ConstantPropagation
|
||||
-- , T SparseCaseOptimisation: Illegal type {}
|
||||
, T SparseCaseOptimisation
|
||||
, T EvaluatedCaseElimination
|
||||
, T ConstantPropagation
|
||||
-- , T CommonSubExpressionElimination: Illegal type {}
|
||||
, T CommonSubExpressionElimination
|
||||
, T CaseCopyPropagation
|
||||
-- , T GeneralizedUnboxing: Illegal type: {}
|
||||
-- , T ArityRaising: Illegal type: {}
|
||||
, T GeneralizedUnboxing
|
||||
, T ArityRaising
|
||||
, SaveGrin "After"
|
||||
, PrintGrin ondullblack
|
||||
, SaveLLVM "high-level-opt-code"
|
||||
|
Loading…
Reference in New Issue
Block a user