From 19f0a578fcf784feb129bf1f2190fcd7408e2373 Mon Sep 17 00:00:00 2001 From: Langston Barrett Date: Thu, 2 Nov 2023 09:11:04 -0400 Subject: [PATCH] symbolic-syntax: Add a test that exercises all the operations --- symbolic-syntax/test-data/ops.cbl | 13 ++++++ symbolic-syntax/test-data/ops.out | 62 ++++++++++++++++++++++++++ symbolic-syntax/test-data/ops.out.good | 62 ++++++++++++++++++++++++++ 3 files changed, 137 insertions(+) create mode 100644 symbolic-syntax/test-data/ops.cbl create mode 100644 symbolic-syntax/test-data/ops.out create mode 100644 symbolic-syntax/test-data/ops.out.good diff --git a/symbolic-syntax/test-data/ops.cbl b/symbolic-syntax/test-data/ops.cbl new file mode 100644 index 00000000..f10a9330 --- /dev/null +++ b/symbolic-syntax/test-data/ops.cbl @@ -0,0 +1,13 @@ +; A function that demonstrates the use of all of the operations +(defun @ops ((p Pointer) (q Pointer)) Unit + (start start: + (let b (bv-typed-literal SizeT 42)) + (let v (fresh-vec "v" Short 7)) + (let n (make-null)) + (let d (pointer-diff p q)) + (let r (pointer-add p d)) + (let s (pointer-sub r d)) + (let e (pointer-eq s p)) + (let t (pointer-read Int le s)) + (pointer-write SizeT le s b) + (return ()))) \ No newline at end of file diff --git a/symbolic-syntax/test-data/ops.out b/symbolic-syntax/test-data/ops.out new file mode 100644 index 00000000..5ec28c17 --- /dev/null +++ b/symbolic-syntax/test-data/ops.out @@ -0,0 +1,62 @@ +(defun @ops ((p Pointer) (q Pointer)) Unit + (start start: + (let b (bv-typed-literal SizeT 42)) + (let v (fresh-vec "v" Short 7)) + (let n (make-null)) + (let d (pointer-diff p q)) + (let r (pointer-add p d)) + (let s (pointer-sub r d)) + (let e (pointer-eq s p)) + (let t (pointer-read Int le s)) + (pointer-write SizeT le s b) + (return ()))) + +ops +%0 + % 4:12 + $2 = intLit(42) + % 4:12 + $3 = integerToBV(64, $2) + % internal + $4 = fresh BaseBVRepr 16 v_0 + % internal + $5 = fresh BaseBVRepr 16 v_1 + % internal + $6 = fresh BaseBVRepr 16 v_2 + % internal + $7 = fresh BaseBVRepr 16 v_3 + % internal + $8 = fresh BaseBVRepr 16 v_4 + % internal + $9 = fresh BaseBVRepr 16 v_5 + % internal + $10 = fresh BaseBVRepr 16 v_6 + % 5:12 + $11 = vectorLit(BVRepr 16, [$4, $5, $6, $7, $8, $9, $10]) + % 6:12 + $12 = extensionApp(null_ptr) + % internal + $13 = (ptr_sub $0 $1) + % 7:12 + $14 = extensionApp((ptr_to_bits_64 $13)) + % internal + $15 = extensionApp((bits_to_ptr_64 $14)) + % 8:12 + $16 = (ptr_add $0 $15) + % 9:16 + $17 = (ptr_sub $16 $15) + % 10:16 + $18 = (ptr_eq $17 $0) + % internal + $19 = (macawReadMem bvle4 $17) + % 11:12 + $20 = extensionApp((ptr_to_bits_32 $19)) + % internal + $21 = extensionApp((bits_to_ptr_64 $3)) + % 12:5 + $22 = (macawWriteMem bvle8 $17 $21) + % 13:13 + $23 = emptyApp() + % 13:5 + return $23 + % no postdom diff --git a/symbolic-syntax/test-data/ops.out.good b/symbolic-syntax/test-data/ops.out.good new file mode 100644 index 00000000..5ec28c17 --- /dev/null +++ b/symbolic-syntax/test-data/ops.out.good @@ -0,0 +1,62 @@ +(defun @ops ((p Pointer) (q Pointer)) Unit + (start start: + (let b (bv-typed-literal SizeT 42)) + (let v (fresh-vec "v" Short 7)) + (let n (make-null)) + (let d (pointer-diff p q)) + (let r (pointer-add p d)) + (let s (pointer-sub r d)) + (let e (pointer-eq s p)) + (let t (pointer-read Int le s)) + (pointer-write SizeT le s b) + (return ()))) + +ops +%0 + % 4:12 + $2 = intLit(42) + % 4:12 + $3 = integerToBV(64, $2) + % internal + $4 = fresh BaseBVRepr 16 v_0 + % internal + $5 = fresh BaseBVRepr 16 v_1 + % internal + $6 = fresh BaseBVRepr 16 v_2 + % internal + $7 = fresh BaseBVRepr 16 v_3 + % internal + $8 = fresh BaseBVRepr 16 v_4 + % internal + $9 = fresh BaseBVRepr 16 v_5 + % internal + $10 = fresh BaseBVRepr 16 v_6 + % 5:12 + $11 = vectorLit(BVRepr 16, [$4, $5, $6, $7, $8, $9, $10]) + % 6:12 + $12 = extensionApp(null_ptr) + % internal + $13 = (ptr_sub $0 $1) + % 7:12 + $14 = extensionApp((ptr_to_bits_64 $13)) + % internal + $15 = extensionApp((bits_to_ptr_64 $14)) + % 8:12 + $16 = (ptr_add $0 $15) + % 9:16 + $17 = (ptr_sub $16 $15) + % 10:16 + $18 = (ptr_eq $17 $0) + % internal + $19 = (macawReadMem bvle4 $17) + % 11:12 + $20 = extensionApp((ptr_to_bits_32 $19)) + % internal + $21 = extensionApp((bits_to_ptr_64 $3)) + % 12:5 + $22 = (macawWriteMem bvle8 $17 $21) + % 13:13 + $23 = emptyApp() + % 13:5 + return $23 + % no postdom