-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Lean: Add bitvector function definitions for the lean backend (#788)
- Loading branch information
Showing
5 changed files
with
107 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
def bitvector_eq (x : BitVec 16) (y : BitVec 16) : Bool := | ||
(Eq x y) | ||
|
||
def bitvector_neq (x : BitVec 16) (y : BitVec 16) : Bool := | ||
(Ne x y) | ||
|
||
def bitvector_append (x : BitVec 16) (y : BitVec 16) : BitVec 32 := | ||
(BitVec.append x y) | ||
|
||
def bitvector_add (x : BitVec 16) (y : BitVec 16) : BitVec 16 := | ||
(HAdd.hAdd x y) | ||
|
||
def bitvector_sub (x : BitVec 16) (y : BitVec 16) : BitVec 16 := | ||
(HSub.hSub x y) | ||
|
||
def bitvector_not (x : BitVec 16) : BitVec 16 := | ||
(Complement.complement x) | ||
|
||
def bitvector_and (x : BitVec 16) (y : BitVec 16) : BitVec 16 := | ||
(HAnd.hAnd x y) | ||
|
||
def bitvector_or (x : BitVec 16) (y : BitVec 16) : BitVec 16 := | ||
(HOr.hOr x y) | ||
|
||
def bitvector_xor (x : BitVec 16) (y : BitVec 16) : BitVec 16 := | ||
(HXor.hXor x y) | ||
|
||
def initialize_registers : Unit := | ||
() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
default Order dec | ||
|
||
$include <prelude.sail> | ||
|
||
val bitvector_eq : (bits(16), bits(16)) -> bool | ||
function bitvector_eq(x, y) = { | ||
x == y | ||
} | ||
|
||
val bitvector_neq : (bits(16), bits(16)) -> bool | ||
function bitvector_neq(x, y) = { | ||
x != y | ||
} | ||
|
||
val bitvector_append : (bits(16), bits(16)) -> bits(32) | ||
function bitvector_append(x, y) = { | ||
append (x, y) | ||
} | ||
|
||
val bitvector_add : (bits(16), bits(16)) -> bits(16) | ||
function bitvector_add(x, y) = { | ||
x + y | ||
} | ||
|
||
val bitvector_sub : (bits(16), bits(16)) -> bits(16) | ||
function bitvector_sub(x, y) = { | ||
sub_bits (x, y) | ||
} | ||
|
||
val bitvector_not : bits(16) -> bits(16) | ||
function bitvector_not(x) = { | ||
not_vec (x) | ||
} | ||
|
||
val bitvector_and : (bits(16), bits(16)) -> bits(16) | ||
function bitvector_and(x, y) = { | ||
x & y | ||
} | ||
|
||
val bitvector_or : (bits(16), bits(16)) -> bits(16) | ||
function bitvector_or(x, y) = { | ||
x | y | ||
} | ||
|
||
val bitvector_xor : (bits(16), bits(16)) -> bits(16) | ||
function bitvector_xor(x, y) = { | ||
xor_vec (x, y) | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters