Skip to content

Commit a70dd90

Browse files
Make bitwiseNot an extern
1 parent 1a905aa commit a70dd90

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

libraries/common/binstream.effekt

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -254,14 +254,6 @@ def collectBitsBE{ body: => Unit / emit[Bit] }: Int = {
254254
res
255255
}
256256

257-
/// bitwise not on integers
258-
def bitwiseNot(n: Int): Int = {
259-
// TODO currently implemented in Effekt, should use extern ?
260-
collectBitsBE{
261-
try bitsBE(n) with emit[Bit]{ b => resume(do emit(not(b))) }
262-
}
263-
}
264-
265257
/// split emitted bytes and emit the individual bits in big-endian bit order
266258
def ungroupBytes{ body: => Unit / emit[Byte] }: Unit / emit[Bit] =
267259
for[Byte]{body}{ b => bits(b) }

libraries/common/effekt.effekt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -665,6 +665,12 @@ extern pure def bitwiseXor(x: Int, y: Int): Int =
665665
llvm "%z = xor %Int ${x}, ${y} ret %Int %z"
666666
vm "effekt::bitwiseXor(Int, Int)"
667667

668+
extern pure def bitwiseNot(x: Int): Int =
669+
js "(~${x})"
670+
chez "(lognot ${x})"
671+
llvm "%z = xor %Int ${x}, -1 ret %Int %z"
672+
vm "effekt::bitwiseNot(Int)"
673+
668674

669675
// Byte operations
670676
// ===============

0 commit comments

Comments
 (0)