on master help sign in
Complement primitive for bit types
df10078Benjamin Saunders
src/IRTS/Lang.hs+4−4
@@ -42,19 +42,19 @@ data PrimFn = LPlus | LMinus | LTimes | LDiv | LMod
42
42
43 | LB8Lt | LB8Lte | LB8Eq | LB8Gt | LB8Gte
43 | LB8Lt | LB8Lte | LB8Eq | LB8Gt | LB8Gte
44 | LB8Plus | LB8Minus | LB8Times | LB8UDiv | LB8SDiv
44 | LB8Plus | LB8Minus | LB8Times | LB8UDiv | LB8SDiv
45− | LB8Shl | LB8LShr | LB8AShr | LB8And | LB8Or | LB8Xor
45+ | LB8Shl | LB8LShr | LB8AShr | LB8And | LB8Or | LB8Xor | LB8Compl
46 | LB8Z16 | LB8Z32 | LB8Z64 | LB8S16 | LB8S32 | LB8S64 -- Zero/Sign extension
46 | LB8Z16 | LB8Z32 | LB8Z64 | LB8S16 | LB8S32 | LB8S64 -- Zero/Sign extension
47 | LB16Lt | LB16Lte | LB16Eq | LB16Gt | LB16Gte
47 | LB16Lt | LB16Lte | LB16Eq | LB16Gt | LB16Gte
48 | LB16Plus | LB16Minus | LB16Times | LB16UDiv | LB16SDiv
48 | LB16Plus | LB16Minus | LB16Times | LB16UDiv | LB16SDiv
49− | LB16Shl | LB16LShr | LB16AShr | LB16And | LB16Or | LB16Xor
49+ | LB16Shl | LB16LShr | LB16AShr | LB16And | LB16Or | LB16Xor | LB16Compl
50 | LB16Z32 | LB16Z64 | LB16S32 | LB16S64 | LB16T8 -- and Truncation
50 | LB16Z32 | LB16Z64 | LB16S32 | LB16S64 | LB16T8 -- and Truncation
51 | LB32Lt | LB32Lte | LB32Eq | LB32Gt | LB32Gte
51 | LB32Lt | LB32Lte | LB32Eq | LB32Gt | LB32Gte
52 | LB32Plus | LB32Minus | LB32Times | LB32UDiv | LB32SDiv
52 | LB32Plus | LB32Minus | LB32Times | LB32UDiv | LB32SDiv
53− | LB32Shl | LB32LShr | LB32AShr | LB32And | LB32Or | LB32Xor
53+ | LB32Shl | LB32LShr | LB32AShr | LB32And | LB32Or | LB32Xor | LB32Compl
54 | LB32Z64 | LB32S64 | LB32T8 | LB32T16
54 | LB32Z64 | LB32S64 | LB32T8 | LB32T16
55 | LB64Lt | LB64Lte | LB64Eq | LB64Gt | LB64Gte
55 | LB64Lt | LB64Lte | LB64Eq | LB64Gt | LB64Gte
56 | LB64Plus | LB64Minus | LB64Times | LB64UDiv | LB64SDiv
56 | LB64Plus | LB64Minus | LB64Times | LB64UDiv | LB64SDiv
57− | LB64Shl | LB64LShr | LB64AShr | LB64And | LB64Or | LB64Xor
57+ | LB64Shl | LB64LShr | LB64AShr | LB64And | LB64Or | LB64Xor | LB64Compl
58 | LB64T8 | LB64T16 | LB64T32
58 | LB64T8 | LB64T16 | LB64T32
59 | LIntB8 | LIntB16 | LIntB32 | LIntB64 | LB32Int
59 | LIntB8 | LIntB16 | LIntB32 | LIntB64 | LB32Int
60 | LB8Str | LB16Str | LB32Str | LB64Str
60 | LB8Str | LB16Str | LB32Str | LB64Str
src/Idris/Primitives.hs+20
@@ -113,6 +113,8 @@ primitives =
113 (2, LB8Or) total,
113 (2, LB8Or) total,
114 Prim (UN "prim__xorB8") (ty [B8Type, B8Type] B8Type) 2 (b8Bin xor)
114 Prim (UN "prim__xorB8") (ty [B8Type, B8Type] B8Type) 2 (b8Bin xor)
115 (2, LB8Xor) total,
115 (2, LB8Xor) total,
116+ Prim (UN "prim__complB8") (ty [B8Type] B8Type) 1 (b8Un complement)
117+ (1, LB8Compl) total,
116 Prim (UN "prim__zextB8_16") (ty [B8Type] B16Type) 1 zext8_16
118 Prim (UN "prim__zextB8_16") (ty [B8Type] B16Type) 1 zext8_16
117 (1, LB8Z16) total,
119 (1, LB8Z16) total,
118 Prim (UN "prim__zextB8_32") (ty [B8Type] B32Type) 1 zext8_32
120 Prim (UN "prim__zextB8_32") (ty [B8Type] B32Type) 1 zext8_32
@@ -162,6 +164,8 @@ primitives =
162 (2, LB16Or) total,
164 (2, LB16Or) total,
163 Prim (UN "prim__xorB16") (ty [B16Type, B16Type] B16Type) 2 (b16Bin xor)
165 Prim (UN "prim__xorB16") (ty [B16Type, B16Type] B16Type) 2 (b16Bin xor)
164 (2, LB16Xor) total,
166 (2, LB16Xor) total,
167+ Prim (UN "prim__complB16") (ty [B16Type] B16Type) 1 (b8Un complement)
168+ (1, LB16Compl) total,
165 Prim (UN "prim__zextB16_32") (ty [B16Type] B32Type) 1 zext16_32
169 Prim (UN "prim__zextB16_32") (ty [B16Type] B32Type) 1 zext16_32
166 (1, LB16Z32) total,
170 (1, LB16Z32) total,
167 Prim (UN "prim__zextB16_64") (ty [B16Type] B64Type) 1 zext16_64
171 Prim (UN "prim__zextB16_64") (ty [B16Type] B64Type) 1 zext16_64
@@ -209,6 +213,8 @@ primitives =
209 (2, LB32Or) total,
213 (2, LB32Or) total,
210 Prim (UN "prim__xorB32") (ty [B32Type, B32Type] B32Type) 2 (b32Bin xor)
214 Prim (UN "prim__xorB32") (ty [B32Type, B32Type] B32Type) 2 (b32Bin xor)
211 (2, LB32Xor) total,
215 (2, LB32Xor) total,
216+ Prim (UN "prim__complB32") (ty [B32Type] B32Type) 1 (b32Un complement)
217+ (1, LB32Compl) total,
212 Prim (UN "prim__zextB32_64") (ty [B32Type] B64Type) 1 zext32_64
218 Prim (UN "prim__zextB32_64") (ty [B32Type] B64Type) 1 zext32_64
213 (1, LB32Z64) total,
219 (1, LB32Z64) total,
214 Prim (UN "prim__sextB32_64") (ty [B32Type] B64Type) 1 sext32_64
220 Prim (UN "prim__sextB32_64") (ty [B32Type] B64Type) 1 sext32_64
@@ -254,6 +260,8 @@ primitives =
254 (2, LB64Or) total,
260 (2, LB64Or) total,
255 Prim (UN "prim__xorB64") (ty [B64Type, B64Type] B64Type) 2 (b64Bin xor)
261 Prim (UN "prim__xorB64") (ty [B64Type, B64Type] B64Type) 2 (b64Bin xor)
256 (2, LB64Xor) total,
262 (2, LB64Xor) total,
263+ Prim (UN "prim__complB64") (ty [B64Type] B64Type) 1 (b64Un complement)
264+ (1, LB64Compl) total,
257 Prim (UN "prim__truncB64_8") (ty [B64Type] B8Type) 1 trunc64_8
265 Prim (UN "prim__truncB64_8") (ty [B64Type] B8Type) 1 trunc64_8
258 (1, LB64T8) total,
266 (1, LB64T8) total,
259 Prim (UN "prim__truncB64_16") (ty [B64Type] B16Type) 1 trunc64_16
267 Prim (UN "prim__truncB64_16") (ty [B64Type] B16Type) 1 trunc64_16
@@ -450,15 +458,27 @@ b64ToStr _ = Nothing
450b8Bin op [VConstant (B8 x), VConstant (B8 y)] = Just $ VConstant (B8 (op x y))
458b8Bin op [VConstant (B8 x), VConstant (B8 y)] = Just $ VConstant (B8 (op x y))
451b8Bin _ _ = Nothing
459b8Bin _ _ = Nothing
452
460
461+b8Un op [VConstant (B8 x)] = Just $ VConstant (B8 (op x))
462+b8Un _ _ = Nothing
463+
453b16Bin op [VConstant (B16 x), VConstant (B16 y)] = Just $ VConstant (B16 (op x y))
464b16Bin op [VConstant (B16 x), VConstant (B16 y)] = Just $ VConstant (B16 (op x y))
454b16Bin _ _ = Nothing
465b16Bin _ _ = Nothing
455
466
467+b16Un op [VConstant (B16 x)] = Just $ VConstant (B16 (op x))
468+b16Un _ _ = Nothing
469+
456b32Bin op [VConstant (B32 x), VConstant (B32 y)] = Just $ VConstant (B32 (op x y))
470b32Bin op [VConstant (B32 x), VConstant (B32 y)] = Just $ VConstant (B32 (op x y))
457b32Bin _ _ = Nothing
471b32Bin _ _ = Nothing
458
472
473+b32Un op [VConstant (B32 x)] = Just $ VConstant (B32 (op x))
474+b32Un _ _ = Nothing
475+
459b64Bin op [VConstant (B64 x), VConstant (B64 y)] = Just $ VConstant (B64 (op x y))
476b64Bin op [VConstant (B64 x), VConstant (B64 y)] = Just $ VConstant (B64 (op x y))
460b64Bin _ _ = Nothing
477b64Bin _ _ = Nothing
461
478
479+b64Un op [VConstant (B64 x)] = Just $ VConstant (B64 (op x))
480+b64Un _ _ = Nothing
481+
462b8Cmp op [VConstant (B8 x), VConstant (B8 y)] = Just $ VConstant (I (if (op x y) then 1 else 0))
482b8Cmp op [VConstant (B8 x), VConstant (B8 y)] = Just $ VConstant (I (if (op x y) then 1 else 0))
463b8Cmp _ _ = Nothing
483b8Cmp _ _ = Nothing
464
484