@@ -113,6 +113,8 @@ primitives =
113113 (2, LB8Or) total,
114114 Prim (UN "prim__xorB8") (ty [B8Type, B8Type] B8Type) 2 (b8Bin xor)
115115 (2, LB8Xor) total,
116+ Prim (UN "prim__complB8") (ty [B8Type] B8Type) 1 (b8Un complement)
117+ (1, LB8Compl) total,
116118 Prim (UN "prim__zextB8_16") (ty [B8Type] B16Type) 1 zext8_16
117119 (1, LB8Z16) total,
118120 Prim (UN "prim__zextB8_32") (ty [B8Type] B32Type) 1 zext8_32
@@ -162,6 +164,8 @@ primitives =
162164 (2, LB16Or) total,
163165 Prim (UN "prim__xorB16") (ty [B16Type, B16Type] B16Type) 2 (b16Bin xor)
164166 (2, LB16Xor) total,
167+ Prim (UN "prim__complB16") (ty [B16Type] B16Type) 1 (b8Un complement)
168+ (1, LB16Compl) total,
165169 Prim (UN "prim__zextB16_32") (ty [B16Type] B32Type) 1 zext16_32
166170 (1, LB16Z32) total,
167171 Prim (UN "prim__zextB16_64") (ty [B16Type] B64Type) 1 zext16_64
@@ -209,6 +213,8 @@ primitives =
209213 (2, LB32Or) total,
210214 Prim (UN "prim__xorB32") (ty [B32Type, B32Type] B32Type) 2 (b32Bin xor)
211215 (2, LB32Xor) total,
216+ Prim (UN "prim__complB32") (ty [B32Type] B32Type) 1 (b32Un complement)
217+ (1, LB32Compl) total,
212218 Prim (UN "prim__zextB32_64") (ty [B32Type] B64Type) 1 zext32_64
213219 (1, LB32Z64) total,
214220 Prim (UN "prim__sextB32_64") (ty [B32Type] B64Type) 1 sext32_64
@@ -254,6 +260,8 @@ primitives =
254260 (2, LB64Or) total,
255261 Prim (UN "prim__xorB64") (ty [B64Type, B64Type] B64Type) 2 (b64Bin xor)
256262 (2, LB64Xor) total,
263+ Prim (UN "prim__complB64") (ty [B64Type] B64Type) 1 (b64Un complement)
264+ (1, LB64Compl) total,
257265 Prim (UN "prim__truncB64_8") (ty [B64Type] B8Type) 1 trunc64_8
258266 (1, LB64T8) total,
259267 Prim (UN "prim__truncB64_16") (ty [B64Type] B16Type) 1 trunc64_16
@@ -450,15 +458,27 @@ b64ToStr _ = Nothing
450458b8Bin op [VConstant (B8 x), VConstant (B8 y)] = Just $ VConstant (B8 (op x y))
451459b8Bin _ _ = Nothing
452460
461+b8Un op [VConstant (B8 x)] = Just $ VConstant (B8 (op x))
462+b8Un _ _ = Nothing
463+
453464b16Bin op [VConstant (B16 x), VConstant (B16 y)] = Just $ VConstant (B16 (op x y))
454465b16Bin _ _ = Nothing
455466
467+b16Un op [VConstant (B16 x)] = Just $ VConstant (B16 (op x))
468+b16Un _ _ = Nothing
469+
456470b32Bin op [VConstant (B32 x), VConstant (B32 y)] = Just $ VConstant (B32 (op x y))
457471b32Bin _ _ = Nothing
458472
473+b32Un op [VConstant (B32 x)] = Just $ VConstant (B32 (op x))
474+b32Un _ _ = Nothing
475+
459476b64Bin op [VConstant (B64 x), VConstant (B64 y)] = Just $ VConstant (B64 (op x y))
460477b64Bin _ _ = Nothing
461478
479+b64Un op [VConstant (B64 x)] = Just $ VConstant (B64 (op x))
480+b64Un _ _ = Nothing
481+
462482b8Cmp op [VConstant (B8 x), VConstant (B8 y)] = Just $ VConstant (I (if (op x y) then 1 else 0))
463483b8Cmp _ _ = Nothing
464484