LLVMIr code now has the fastcc flag to enable speeed 😎
This commit is contained in:
parent
afbc700db2
commit
4df3f705ed
2 changed files with 29 additions and 13 deletions
|
|
@ -31,20 +31,36 @@
|
||||||
-- main = fibbonaci 10;
|
-- main = fibbonaci 10;
|
||||||
-- answer: 55
|
-- answer: 55
|
||||||
|
|
||||||
succ : Int -> Int;
|
-- succ : Int -> Int;
|
||||||
succ x = x - 1;
|
-- succ x = x - 1;
|
||||||
|
--
|
||||||
|
-- isZero : Int -> Int;
|
||||||
|
-- isZero x = case x of {
|
||||||
|
-- 0 => 1,
|
||||||
|
-- _ => 0
|
||||||
|
-- } : Int;
|
||||||
|
--
|
||||||
|
-- minimization : (Int -> Int) -> Int -> Int;
|
||||||
|
-- minimization p x = case p x of {
|
||||||
|
-- 1 => 0,
|
||||||
|
-- _ => minimization p (succ x)
|
||||||
|
-- } : Int;
|
||||||
|
--
|
||||||
|
-- main : Int;
|
||||||
|
-- main = minimization isZero 10;
|
||||||
|
-- answer: 0
|
||||||
|
|
||||||
isZero : Int -> Int;
|
posMul : Int -> Int -> Int;
|
||||||
isZero x = case x of {
|
posMul a b = case b of {
|
||||||
0 => 1,
|
0 => 0,
|
||||||
_ => 0
|
_ => a + posMul a (b - 1)
|
||||||
} : Int;
|
} : Int;
|
||||||
|
|
||||||
minimization : (Int -> Int) -> Int -> Int;
|
facc : Int -> Int;
|
||||||
minimization p x = case p x of {
|
facc a = case a of {
|
||||||
1 => 0,
|
1 => 1,
|
||||||
_ => minimization p (succ x)
|
_ => posMul a (facc (a - 1))
|
||||||
} : Int;
|
} : Int;
|
||||||
|
|
||||||
main : Int;
|
main : Int;
|
||||||
main = minimization isZero 10;
|
main = facc 27
|
||||||
|
|
@ -136,7 +136,7 @@ llvmIrToString = go 0
|
||||||
replicate i '\t' <> case l of
|
replicate i '\t' <> case l of
|
||||||
(Define t (Ident i) params) ->
|
(Define t (Ident i) params) ->
|
||||||
concat
|
concat
|
||||||
[ "define ", show t, " @", i
|
[ "define fastcc ", show t, " @", i
|
||||||
, "(", intercalate ", " (map (\(Ident y, x) -> unwords [show x, "%" <> y]) params)
|
, "(", intercalate ", " (map (\(Ident y, x) -> unwords [show x, "%" <> y]) params)
|
||||||
, ") {\n"
|
, ") {\n"
|
||||||
]
|
]
|
||||||
|
|
@ -170,7 +170,7 @@ llvmIrToString = go 0
|
||||||
]
|
]
|
||||||
(Call t vis (Ident i) arg) ->
|
(Call t vis (Ident i) arg) ->
|
||||||
concat
|
concat
|
||||||
[ "call ", show t, " ", show vis, i, "("
|
[ "call fastcc ", show t, " ", show vis, i, "("
|
||||||
, intercalate ", " $ Prelude.map (\(x, y) -> show x <> " " <> show y) arg
|
, intercalate ", " $ Prelude.map (\(x, y) -> show x <> " " <> show y) arg
|
||||||
, ")\n"
|
, ")\n"
|
||||||
]
|
]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue