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;
|
||||
-- answer: 55
|
||||
|
||||
succ : Int -> Int;
|
||||
succ x = x - 1;
|
||||
-- succ : Int -> Int;
|
||||
-- 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;
|
||||
isZero x = case x of {
|
||||
0 => 1,
|
||||
_ => 0
|
||||
posMul : Int -> Int -> Int;
|
||||
posMul a b = case b of {
|
||||
0 => 0,
|
||||
_ => a + posMul a (b - 1)
|
||||
} : Int;
|
||||
|
||||
minimization : (Int -> Int) -> Int -> Int;
|
||||
minimization p x = case p x of {
|
||||
1 => 0,
|
||||
_ => minimization p (succ x)
|
||||
facc : Int -> Int;
|
||||
facc a = case a of {
|
||||
1 => 1,
|
||||
_ => posMul a (facc (a - 1))
|
||||
} : Int;
|
||||
|
||||
main : Int;
|
||||
main = minimization isZero 10;
|
||||
main = facc 27
|
||||
|
|
@ -136,7 +136,7 @@ llvmIrToString = go 0
|
|||
replicate i '\t' <> case l of
|
||||
(Define t (Ident i) params) ->
|
||||
concat
|
||||
[ "define ", show t, " @", i
|
||||
[ "define fastcc ", show t, " @", i
|
||||
, "(", intercalate ", " (map (\(Ident y, x) -> unwords [show x, "%" <> y]) params)
|
||||
, ") {\n"
|
||||
]
|
||||
|
|
@ -170,7 +170,7 @@ llvmIrToString = go 0
|
|||
]
|
||||
(Call t vis (Ident i) arg) ->
|
||||
concat
|
||||
[ "call ", show t, " ", show vis, i, "("
|
||||
[ "call fastcc ", show t, " ", show vis, i, "("
|
||||
, intercalate ", " $ Prelude.map (\(x, y) -> show x <> " " <> show y) arg
|
||||
, ")\n"
|
||||
]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue