mirror of
https://github.com/grin-compiler/grin.git
synced 2024-09-11 15:37:54 +03:00
Add ashr primitive.
This commit is contained in:
parent
104557fd89
commit
c825f6da7e
@ -43,11 +43,12 @@ primPrelude = [progConst|
|
||||
|
||||
primop pure
|
||||
-- Int
|
||||
_prim_int_shr :: T_Int64 -> T_Int64
|
||||
_prim_int_shr :: T_Int64 -> T_Int64 -- TODO: Remove?
|
||||
_prim_int_add :: T_Int64 -> T_Int64 -> T_Int64
|
||||
_prim_int_sub :: T_Int64 -> T_Int64 -> T_Int64
|
||||
_prim_int_mul :: T_Int64 -> T_Int64 -> T_Int64
|
||||
_prim_int_div :: T_Int64 -> T_Int64 -> T_Int64
|
||||
_prim_int_ashr :: T_Int64 -> T_Int64 -> T_Int64
|
||||
_prim_int_eq :: T_Int64 -> T_Int64 -> T_Bool
|
||||
_prim_int_ne :: T_Int64 -> T_Int64 -> T_Bool
|
||||
_prim_int_gt :: T_Int64 -> T_Int64 -> T_Bool
|
||||
|
@ -37,6 +37,7 @@ codeGenPrimOp name [opA, opB] = pure $ case name of
|
||||
"_prim_int_sub" -> I cgInt64 $ Sub {nsw=False, nuw=False, operand0=opA, operand1=opB, metadata=[]}
|
||||
"_prim_int_mul" -> I cgInt64 $ Mul {nsw=False, nuw=False, operand0=opA, operand1=opB, metadata=[]}
|
||||
"_prim_int_div" -> I cgInt64 $ SDiv {exact=False, operand0=opA, operand1=opB, metadata=[]}
|
||||
"_prim_int_ashr" -> I cgInt64 $ AShr {exact=False, operand0=opA, operand1=opB, metadata=[]}
|
||||
"_prim_int_eq" -> I cgBool $ ICmp {iPredicate=I.EQ, operand0=opA, operand1=opB, metadata=[]}
|
||||
"_prim_int_ne" -> I cgBool $ ICmp {iPredicate=I.NE, operand0=opA, operand1=opB, metadata=[]}
|
||||
"_prim_int_gt" -> I cgBool $ ICmp {iPredicate=I.SGT, operand0=opA, operand1=opB, metadata=[]}
|
||||
|
@ -14,6 +14,7 @@ import Foreign.C.String
|
||||
|
||||
import Reducer.Base
|
||||
|
||||
import Data.Bits (shift)
|
||||
import Data.Char (chr, ord)
|
||||
import Grin.Grin
|
||||
import Data.Map.Strict as Map
|
||||
@ -65,6 +66,7 @@ evalPrimOp name params args = case name of
|
||||
"_prim_int_sub" -> int_bin_op int (-)
|
||||
"_prim_int_mul" -> int_bin_op int (*)
|
||||
"_prim_int_div" -> int_bin_op int div
|
||||
"_prim_int_ashr" -> int_bin_op int (\v h -> shift v ((-1) * fromIntegral h))
|
||||
"_prim_int_eq" -> int_bin_op bool (==)
|
||||
"_prim_int_ne" -> int_bin_op bool (/=)
|
||||
"_prim_int_gt" -> int_bin_op bool (>)
|
||||
|
Loading…
Reference in New Issue
Block a user