From 6fe9172f1ff15e6955b5340539f65d5164919d63 Mon Sep 17 00:00:00 2001 From: Jiaan Lu Date: Sat, 25 May 2024 01:46:46 +0800 Subject: [PATCH] cmpccxadd: add 40 functional cases Signed-off-by: Jiaan Lu --- BM/README.md | 1 + BM/cmpccxadd/.vscode/settings.json | 5 + BM/cmpccxadd/Makefile | 18 ++++ BM/cmpccxadd/README.md | 19 ++++ BM/cmpccxadd/cmpbexadd_above.c | 28 ++++++ BM/cmpccxadd/cmpbexadd_below.c | 28 ++++++ BM/cmpccxadd/cmpbexadd_equal.c | 28 ++++++ BM/cmpccxadd/cmpbxadd_above.c | 28 ++++++ BM/cmpccxadd/cmpbxadd_below.c | 28 ++++++ BM/cmpccxadd/cmpbxadd_equal.c | 28 ++++++ BM/cmpccxadd/cmplexadd_equal.c | 28 ++++++ BM/cmpccxadd/cmplexadd_less.c | 28 ++++++ BM/cmpccxadd/cmplexadd_more.c | 28 ++++++ BM/cmpccxadd/cmplxadd_equal.c | 28 ++++++ BM/cmpccxadd/cmplxadd_less.c | 28 ++++++ BM/cmpccxadd/cmplxadd_more.c | 28 ++++++ BM/cmpccxadd/cmpnbexadd_above.c | 28 ++++++ BM/cmpccxadd/cmpnbexadd_below.c | 28 ++++++ BM/cmpccxadd/cmpnbexadd_equal.c | 28 ++++++ BM/cmpccxadd/cmpnbxadd_above.c | 28 ++++++ BM/cmpccxadd/cmpnbxadd_below.c | 28 ++++++ BM/cmpccxadd/cmpnbxadd_equal.c | 28 ++++++ BM/cmpccxadd/cmpnlexadd_equal.c | 28 ++++++ BM/cmpccxadd/cmpnlexadd_less.c | 28 ++++++ BM/cmpccxadd/cmpnlexadd_more.c | 28 ++++++ BM/cmpccxadd/cmpnlxadd_equal.c | 28 ++++++ BM/cmpccxadd/cmpnlxadd_less.c | 28 ++++++ BM/cmpccxadd/cmpnlxadd_more.c | 28 ++++++ BM/cmpccxadd/cmpnoxadd_not_overflow.c | 28 ++++++ BM/cmpccxadd/cmpnoxadd_overflow.c | 28 ++++++ BM/cmpccxadd/cmpnpxadd_even.c | 28 ++++++ BM/cmpccxadd/cmpnpxadd_odd.c | 28 ++++++ BM/cmpccxadd/cmpnsxadd_negative.c | 28 ++++++ BM/cmpccxadd/cmpnsxadd_positive.c | 28 ++++++ BM/cmpccxadd/cmpnzxadd_not_zero.c | 28 ++++++ BM/cmpccxadd/cmpnzxadd_zero.c | 28 ++++++ BM/cmpccxadd/cmpoxadd_not_overflow.c | 28 ++++++ BM/cmpccxadd/cmpoxadd_overflow.c | 28 ++++++ BM/cmpccxadd/cmppxadd_even.c | 28 ++++++ BM/cmpccxadd/cmppxadd_odd.c | 28 ++++++ BM/cmpccxadd/cmpsxadd_negative.c | 28 ++++++ BM/cmpccxadd/cmpsxadd_positive.c | 28 ++++++ BM/cmpccxadd/cmpxadd.c | 137 ++++++++++++++++++++++++++ BM/cmpccxadd/cmpzxadd_not_zero.c | 28 ++++++ BM/cmpccxadd/cmpzxadd_zero.c | 28 ++++++ BM/cmpccxadd/runtest_all.sh | 7 ++ README.md | 1 + 47 files changed, 1308 insertions(+) create mode 100644 BM/cmpccxadd/.vscode/settings.json create mode 100644 BM/cmpccxadd/Makefile create mode 100644 BM/cmpccxadd/README.md create mode 100644 BM/cmpccxadd/cmpbexadd_above.c create mode 100644 BM/cmpccxadd/cmpbexadd_below.c create mode 100644 BM/cmpccxadd/cmpbexadd_equal.c create mode 100644 BM/cmpccxadd/cmpbxadd_above.c create mode 100644 BM/cmpccxadd/cmpbxadd_below.c create mode 100644 BM/cmpccxadd/cmpbxadd_equal.c create mode 100644 BM/cmpccxadd/cmplexadd_equal.c create mode 100644 BM/cmpccxadd/cmplexadd_less.c create mode 100644 BM/cmpccxadd/cmplexadd_more.c create mode 100644 BM/cmpccxadd/cmplxadd_equal.c create mode 100644 BM/cmpccxadd/cmplxadd_less.c create mode 100644 BM/cmpccxadd/cmplxadd_more.c create mode 100644 BM/cmpccxadd/cmpnbexadd_above.c create mode 100644 BM/cmpccxadd/cmpnbexadd_below.c create mode 100644 BM/cmpccxadd/cmpnbexadd_equal.c create mode 100644 BM/cmpccxadd/cmpnbxadd_above.c create mode 100644 BM/cmpccxadd/cmpnbxadd_below.c create mode 100644 BM/cmpccxadd/cmpnbxadd_equal.c create mode 100644 BM/cmpccxadd/cmpnlexadd_equal.c create mode 100644 BM/cmpccxadd/cmpnlexadd_less.c create mode 100644 BM/cmpccxadd/cmpnlexadd_more.c create mode 100644 BM/cmpccxadd/cmpnlxadd_equal.c create mode 100644 BM/cmpccxadd/cmpnlxadd_less.c create mode 100644 BM/cmpccxadd/cmpnlxadd_more.c create mode 100644 BM/cmpccxadd/cmpnoxadd_not_overflow.c create mode 100644 BM/cmpccxadd/cmpnoxadd_overflow.c create mode 100644 BM/cmpccxadd/cmpnpxadd_even.c create mode 100644 BM/cmpccxadd/cmpnpxadd_odd.c create mode 100644 BM/cmpccxadd/cmpnsxadd_negative.c create mode 100644 BM/cmpccxadd/cmpnsxadd_positive.c create mode 100644 BM/cmpccxadd/cmpnzxadd_not_zero.c create mode 100644 BM/cmpccxadd/cmpnzxadd_zero.c create mode 100644 BM/cmpccxadd/cmpoxadd_not_overflow.c create mode 100644 BM/cmpccxadd/cmpoxadd_overflow.c create mode 100644 BM/cmpccxadd/cmppxadd_even.c create mode 100644 BM/cmpccxadd/cmppxadd_odd.c create mode 100644 BM/cmpccxadd/cmpsxadd_negative.c create mode 100644 BM/cmpccxadd/cmpsxadd_positive.c create mode 100644 BM/cmpccxadd/cmpxadd.c create mode 100644 BM/cmpccxadd/cmpzxadd_not_zero.c create mode 100644 BM/cmpccxadd/cmpzxadd_zero.c create mode 100755 BM/cmpccxadd/runtest_all.sh diff --git a/BM/README.md b/BM/README.md index 6e2180be..dc3dab63 100644 --- a/BM/README.md +++ b/BM/README.md @@ -4,6 +4,7 @@ * [AMX](amx/README.md) * [avx512vbmi](avx512vbmi/README.md) * [cet(Control flow Enhancement Technology)](cet/README.md) + * [CMPccXADD](cmpccxadd/README.md) * [cstate](cstate/README.md) * [DSA](dsa/README.md) * [FRED](fred/README.md) (in progress) diff --git a/BM/cmpccxadd/.vscode/settings.json b/BM/cmpccxadd/.vscode/settings.json new file mode 100644 index 00000000..61168feb --- /dev/null +++ b/BM/cmpccxadd/.vscode/settings.json @@ -0,0 +1,5 @@ +{ + "files.associations": { + "limits.h": "c" + } +} \ No newline at end of file diff --git a/BM/cmpccxadd/Makefile b/BM/cmpccxadd/Makefile new file mode 100644 index 00000000..9553052f --- /dev/null +++ b/BM/cmpccxadd/Makefile @@ -0,0 +1,18 @@ +# SPDX-License-Identifier: GPL-2.0-only +# Copyright (c) 2024 Intel Corporation. +# Jiaan Lu + +CFLAGS = -g + +src = $(filter-out cmpxadd.c, $(wildcard *.c)) +target = $(patsubst %.c, %, ${src}) + +.PHONY: all clean + +%:%.c + $(CC) ${CFLAGS} $^ -o $@ + +all: ${target} + +clean: + rm -f ${target} \ No newline at end of file diff --git a/BM/cmpccxadd/README.md b/BM/cmpccxadd/README.md new file mode 100644 index 00000000..6faafec9 --- /dev/null +++ b/BM/cmpccxadd/README.md @@ -0,0 +1,19 @@ +# CMPccXADD + +## Description +CMPccXADD is a new set of instructions in the latest Intel platform +Sierra Forest. This new instruction set includes a semaphore operation +that can compare and add the operands if condition is met, which can +improve database performance. + +This test suite provides basic functional check to ensure CMPccXADD works properly. + +## Usage +``` +make +# To run a specific case +(for example) ./cmpbexadd_above +# To run all cases at once +./runtest_all.sh +``` +Test results (PASS or FAIL) will be printed out. diff --git a/BM/cmpccxadd/cmpbexadd_above.c b/BM/cmpccxadd/cmpbexadd_above.c new file mode 100644 index 00000000..91e8f267 --- /dev/null +++ b/BM/cmpccxadd/cmpbexadd_above.c @@ -0,0 +1,28 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * + * Copyright (c) 2024 Intel Corporation. + * Jiaxi Chen + * Jiaan Lu + * + */ + +#include +#include +#include "cmpxadd.c" +void main(void) +{ + unsigned long uop1, uop2, uop3; + long op1, op2, op3; + struct output_unsigned output; + + uop1 = 2; + uop2 = 1; + uop3 = 3; + output = cmp_be_add(uop1, uop2, uop3); + printf("cmp_be_add - target: *(rax) = 2, rbx = 2, rcx = 3, rflags = 0x202\n"); + if (output.rax == 2 && output.rbx == 2 && output.rcx == 3 && output.rflags == 0x202) + printf("Test passed\n"); + else + printf("Test failed\n"); +} diff --git a/BM/cmpccxadd/cmpbexadd_below.c b/BM/cmpccxadd/cmpbexadd_below.c new file mode 100644 index 00000000..0dad7c97 --- /dev/null +++ b/BM/cmpccxadd/cmpbexadd_below.c @@ -0,0 +1,28 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * + * Copyright (c) 2024 Intel Corporation. + * Jiaxi Chen + * Jiaan Lu + * + */ + +#include +#include +#include "cmpxadd.c" +void main(void) +{ + unsigned long uop1, uop2, uop3; + long op1, op2, op3; + struct output_unsigned output; + + uop1 = 1; + uop2 = 2; + uop3 = 3; + output = cmp_be_add(uop1, uop2, uop3); + printf("cmp_be_add - target: *(rax) = 4, rbx = 1, rcx = 3, rflags = 0x297\n"); + if (output.rax == 4 && output.rbx == 1 && output.rcx == 3 && output.rflags == 0x297) + printf("Test passed\n"); + else + printf("Test failed\n"); +} diff --git a/BM/cmpccxadd/cmpbexadd_equal.c b/BM/cmpccxadd/cmpbexadd_equal.c new file mode 100644 index 00000000..e8922ca3 --- /dev/null +++ b/BM/cmpccxadd/cmpbexadd_equal.c @@ -0,0 +1,28 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * + * Copyright (c) 2024 Intel Corporation. + * Jiaxi Chen + * Jiaan Lu + * + */ + +#include +#include +#include "cmpxadd.c" +void main(void) +{ + unsigned long uop1, uop2, uop3; + long op1, op2, op3; + struct output_unsigned output; + + uop1 = 2; + uop2 = 2; + uop3 = 3; + output = cmp_be_add(uop1, uop2, uop3); + printf("cmp_be_add - target: *(rax) = 5, rbx = 2, rcx = 3, rflags = 0x246\n"); + if (output.rax == 5 && output.rbx == 2 && output.rcx == 3 && output.rflags == 0x246) + printf("Test passed\n"); + else + printf("Test failed\n"); +} diff --git a/BM/cmpccxadd/cmpbxadd_above.c b/BM/cmpccxadd/cmpbxadd_above.c new file mode 100644 index 00000000..4da4c97e --- /dev/null +++ b/BM/cmpccxadd/cmpbxadd_above.c @@ -0,0 +1,28 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * + * Copyright (c) 2024 Intel Corporation. + * Jiaxi Chen + * Jiaan Lu + * + */ + +#include +#include +#include "cmpxadd.c" +void main(void) +{ + unsigned long uop1, uop2, uop3; + long op1, op2, op3; + struct output_unsigned output; + + uop1 = 2; + uop2 = 1; + uop3 = 3; + output = cmp_b_add(uop1, uop2, uop3); + printf("cmp_b_add - target: *(rax) = 2, rbx = 2, rcx = 3, rflags = 0x202\n"); + if (output.rax == 2 && output.rbx == 2 && output.rcx == 3 && output.rflags == 0x202) + printf("Test passed\n"); + else + printf("Test failed\n"); +} diff --git a/BM/cmpccxadd/cmpbxadd_below.c b/BM/cmpccxadd/cmpbxadd_below.c new file mode 100644 index 00000000..4eb1276e --- /dev/null +++ b/BM/cmpccxadd/cmpbxadd_below.c @@ -0,0 +1,28 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * + * Copyright (c) 2024 Intel Corporation. + * Jiaxi Chen + * Jiaan Lu + * + */ + +#include +#include +#include "cmpxadd.c" +void main(void) +{ + unsigned long uop1, uop2, uop3; + long op1, op2, op3; + struct output_unsigned output; + + uop1 = 1; + uop2 = 2; + uop3 = 3; + output = cmp_b_add(uop1, uop2, uop3); + printf("cmp_b_add - target: *(rax) = 4, rbx = 1, rcx = 3, rflags = 0x297\n"); + if (output.rax == 4 && output.rbx == 1 && output.rcx == 3 && output.rflags == 0x297) + printf("Test passed\n"); + else + printf("Test failed\n"); +} diff --git a/BM/cmpccxadd/cmpbxadd_equal.c b/BM/cmpccxadd/cmpbxadd_equal.c new file mode 100644 index 00000000..c444da02 --- /dev/null +++ b/BM/cmpccxadd/cmpbxadd_equal.c @@ -0,0 +1,28 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * + * Copyright (c) 2024 Intel Corporation. + * Jiaxi Chen + * Jiaan Lu + * + */ + +#include +#include +#include "cmpxadd.c" +void main(void) +{ + unsigned long uop1, uop2, uop3; + long op1, op2, op3; + struct output_unsigned output; + + uop1 = 2; + uop2 = 2; + uop3 = 3; + output = cmp_b_add(uop1, uop2, uop3); + printf("cmp_b_add - target: *(rax) = 2, rbx = 2, rcx = 3, rflags = 0x246\n"); + if (output.rax == 2 && output.rbx == 2 && output.rcx == 3 && output.rflags == 0x246) + printf("Test passed\n"); + else + printf("Test failed\n"); +} diff --git a/BM/cmpccxadd/cmplexadd_equal.c b/BM/cmpccxadd/cmplexadd_equal.c new file mode 100644 index 00000000..f0b98ac2 --- /dev/null +++ b/BM/cmpccxadd/cmplexadd_equal.c @@ -0,0 +1,28 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * + * Copyright (c) 2024 Intel Corporation. + * Jiaxi Chen + * Jiaan Lu + * + */ + +#include +#include +#include "cmpxadd.c" +void main(void) +{ + unsigned long uop1, uop2, uop3; + long op1, op2, op3; + struct output_signed output; + + op1 = -1; + op2 = -1; + op3 = 2; + output = cmp_le_add(op1, op2, op3); + printf("cmp_le_add - target: *(rax) = 1, rbx = -1, rcx = 2, rflags = 0x246\n"); + if (output.rax == 1 && output.rbx == -1 && output.rcx == 2 && output.rflags == 0x246) + printf("Test passed\n"); + else + printf("Test failed\n"); +} diff --git a/BM/cmpccxadd/cmplexadd_less.c b/BM/cmpccxadd/cmplexadd_less.c new file mode 100644 index 00000000..56b3be8a --- /dev/null +++ b/BM/cmpccxadd/cmplexadd_less.c @@ -0,0 +1,28 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * + * Copyright (c) 2024 Intel Corporation. + * Jiaxi Chen + * Jiaan Lu + * + */ + +#include +#include +#include "cmpxadd.c" +void main(void) +{ + unsigned long uop1, uop2, uop3; + long op1, op2, op3; + struct output_signed output; + + op1 = -1; + op2 = 1; + op3 = 2; + output = cmp_le_add(op1, op2, op3); + printf("cmp_le_add - target: *(rax) = 1, rbx = -1, rcx = 2, rflags = 0x282\n"); + if (output.rax == 1 && output.rbx == -1 && output.rcx == 2 && output.rflags == 0x282) + printf("Test passed\n"); + else + printf("Test failed\n"); +} diff --git a/BM/cmpccxadd/cmplexadd_more.c b/BM/cmpccxadd/cmplexadd_more.c new file mode 100644 index 00000000..621deb63 --- /dev/null +++ b/BM/cmpccxadd/cmplexadd_more.c @@ -0,0 +1,28 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * + * Copyright (c) 2024 Intel Corporation. + * Jiaxi Chen + * Jiaan Lu + * + */ + +#include +#include +#include "cmpxadd.c" +void main(void) +{ + unsigned long uop1, uop2, uop3; + long op1, op2, op3; + struct output_signed output; + + op1 = -1; + op2 = -2; + op3 = 2; + output = cmp_le_add(op1, op2, op3); + printf("cmp_le_add - target: *(rax) = -1, rbx = -1, rcx = 2, rflags = 0x202\n"); + if (output.rax == -1 && output.rbx == -1 && output.rcx == 2 && output.rflags == 0x202) + printf("Test passed\n"); + else + printf("Test failed\n"); +} diff --git a/BM/cmpccxadd/cmplxadd_equal.c b/BM/cmpccxadd/cmplxadd_equal.c new file mode 100644 index 00000000..b945a6d6 --- /dev/null +++ b/BM/cmpccxadd/cmplxadd_equal.c @@ -0,0 +1,28 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * + * Copyright (c) 2024 Intel Corporation. + * Jiaxi Chen + * Jiaan Lu + * + */ + +#include +#include +#include "cmpxadd.c" +void main(void) +{ + unsigned long uop1, uop2, uop3; + long op1, op2, op3; + struct output_signed output; + + op1 = -1; + op2 = -1; + op3 = 2; + output = cmp_l_add(op1, op2, op3); + printf("cmp_l_add - target: *(rax) = -1, rbx = -1, rcx = 2, rflags = 0x246\n"); + if (output.rax == -1 && output.rbx == -1 && output.rcx == 2 && output.rflags == 0x246) + printf("Test passed\n"); + else + printf("Test failed\n"); +} diff --git a/BM/cmpccxadd/cmplxadd_less.c b/BM/cmpccxadd/cmplxadd_less.c new file mode 100644 index 00000000..85603e0a --- /dev/null +++ b/BM/cmpccxadd/cmplxadd_less.c @@ -0,0 +1,28 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * + * Copyright (c) 2024 Intel Corporation. + * Jiaxi Chen + * Jiaan Lu + * + */ + +#include +#include +#include "cmpxadd.c" +void main(void) +{ + unsigned long uop1, uop2, uop3; + long op1, op2, op3; + struct output_signed output; + + op1 = -1; + op2 = 1; + op3 = 2; + output = cmp_l_add(op1, op2, op3); + printf("cmp_l_add - target: *(rax) = 1, rbx = -1, rcx = 2, rflags = 0x282\n"); + if (output.rax == 1 && output.rbx == -1 && output.rcx == 2 && output.rflags == 0x282) + printf("Test passed\n"); + else + printf("Test failed\n"); +} diff --git a/BM/cmpccxadd/cmplxadd_more.c b/BM/cmpccxadd/cmplxadd_more.c new file mode 100644 index 00000000..c57ee822 --- /dev/null +++ b/BM/cmpccxadd/cmplxadd_more.c @@ -0,0 +1,28 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * + * Copyright (c) 2024 Intel Corporation. + * Jiaxi Chen + * Jiaan Lu + * + */ + +#include +#include +#include "cmpxadd.c" +void main(void) +{ + unsigned long uop1, uop2, uop3; + long op1, op2, op3; + struct output_signed output; + + op1 = -1; + op2 = -2; + op3 = 2; + output = cmp_l_add(op1, op2, op3); + printf("cmp_l_add - target: *(rax) = -1, rbx = -1, rcx = 2, rflags = 0x202\n"); + if (output.rax == -1 && output.rbx == -1 && output.rcx == 2 && output.rflags == 0x202) + printf("Test passed\n"); + else + printf("Test failed\n"); +} diff --git a/BM/cmpccxadd/cmpnbexadd_above.c b/BM/cmpccxadd/cmpnbexadd_above.c new file mode 100644 index 00000000..7fdf8920 --- /dev/null +++ b/BM/cmpccxadd/cmpnbexadd_above.c @@ -0,0 +1,28 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * + * Copyright (c) 2024 Intel Corporation. + * Jiaxi Chen + * Jiaan Lu + * + */ + +#include +#include +#include "cmpxadd.c" +void main(void) +{ + unsigned long uop1, uop2, uop3; + long op1, op2, op3; + struct output_unsigned output; + + uop1 = 2; + uop2 = 1; + uop3 = 3; + output = cmp_nbe_add(uop1, uop2, uop3); + printf("cmp_nbe_add - target: *(rax) = 5, rbx = 2, rcx = 3, rflags = 0x202\n"); + if (output.rax == 5 && output.rbx == 2 && output.rcx == 3 && output.rflags == 0x202) + printf("Test passed\n"); + else + printf("Test failed\n"); +} diff --git a/BM/cmpccxadd/cmpnbexadd_below.c b/BM/cmpccxadd/cmpnbexadd_below.c new file mode 100644 index 00000000..6c3ad74c --- /dev/null +++ b/BM/cmpccxadd/cmpnbexadd_below.c @@ -0,0 +1,28 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * + * Copyright (c) 2024 Intel Corporation. + * Jiaxi Chen + * Jiaan Lu + * + */ + +#include +#include +#include "cmpxadd.c" +void main(void) +{ + unsigned long uop1, uop2, uop3; + long op1, op2, op3; + struct output_unsigned output; + + uop1 = 1; + uop2 = 2; + uop3 = 3; + output = cmp_nbe_add(uop1, uop2, uop3); + printf("cmp_nbe_add - target: *(rax) = 1, rbx = 1, rcx = 3, rflags = 0x297\n"); + if (output.rax == 1 && output.rbx == 1 && output.rcx == 3 && output.rflags == 0x297) + printf("Test passed\n"); + else + printf("Test failed\n"); +} diff --git a/BM/cmpccxadd/cmpnbexadd_equal.c b/BM/cmpccxadd/cmpnbexadd_equal.c new file mode 100644 index 00000000..2753f980 --- /dev/null +++ b/BM/cmpccxadd/cmpnbexadd_equal.c @@ -0,0 +1,28 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * + * Copyright (c) 2024 Intel Corporation. + * Jiaxi Chen + * Jiaan Lu + * + */ + +#include +#include +#include "cmpxadd.c" +void main(void) +{ + unsigned long uop1, uop2, uop3; + long op1, op2, op3; + struct output_unsigned output; + + uop1 = 2; + uop2 = 2; + uop3 = 3; + output = cmp_nbe_add(uop1, uop2, uop3); + printf("cmp_nbe_add - target: *(rax) = 2, rbx = 2, rcx = 3, rflags = 0x246\n"); + if (output.rax == 2 && output.rbx == 2 && output.rcx == 3 && output.rflags == 0x246) + printf("Test passed\n"); + else + printf("Test failed\n"); +} diff --git a/BM/cmpccxadd/cmpnbxadd_above.c b/BM/cmpccxadd/cmpnbxadd_above.c new file mode 100644 index 00000000..74a525b3 --- /dev/null +++ b/BM/cmpccxadd/cmpnbxadd_above.c @@ -0,0 +1,28 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * + * Copyright (c) 2024 Intel Corporation. + * Jiaxi Chen + * Jiaan Lu + * + */ + +#include +#include +#include "cmpxadd.c" +void main(void) +{ + unsigned long uop1, uop2, uop3; + long op1, op2, op3; + struct output_unsigned output; + + uop1 = 2; + uop2 = 1; + uop3 = 3; + output = cmp_nb_add(uop1, uop2, uop3); + printf("cmp_nb_add - target: *(rax) = 5, rbx = 2, rcx = 3, rflags = 0x202\n"); + if (output.rax == 5 && output.rbx == 2 && output.rcx == 3 && output.rflags == 0x202) + printf("Test passed\n"); + else + printf("Test failed\n"); +} diff --git a/BM/cmpccxadd/cmpnbxadd_below.c b/BM/cmpccxadd/cmpnbxadd_below.c new file mode 100644 index 00000000..dd518bbb --- /dev/null +++ b/BM/cmpccxadd/cmpnbxadd_below.c @@ -0,0 +1,28 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * + * Copyright (c) 2024 Intel Corporation. + * Jiaxi Chen + * Jiaan Lu + * + */ + +#include +#include +#include "cmpxadd.c" +void main(void) +{ + unsigned long uop1, uop2, uop3; + long op1, op2, op3; + struct output_unsigned output; + + uop1 = 1; + uop2 = 2; + uop3 = 3; + output = cmp_nb_add(uop1, uop2, uop3); + printf("cmp_nb_add - target: *(rax) = 1, rbx = 1, rcx = 3, rflags = 0x297\n"); + if (output.rax == 1 && output.rbx == 1 && output.rcx == 3 && output.rflags == 0x297) + printf("Test passed\n"); + else + printf("Test failed\n"); +} diff --git a/BM/cmpccxadd/cmpnbxadd_equal.c b/BM/cmpccxadd/cmpnbxadd_equal.c new file mode 100644 index 00000000..aef82ede --- /dev/null +++ b/BM/cmpccxadd/cmpnbxadd_equal.c @@ -0,0 +1,28 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * + * Copyright (c) 2024 Intel Corporation. + * Jiaxi Chen + * Jiaan Lu + * + */ + +#include +#include +#include "cmpxadd.c" +void main(void) +{ + unsigned long uop1, uop2, uop3; + long op1, op2, op3; + struct output_unsigned output; + + uop1 = 2; + uop2 = 2; + uop3 = 3; + output = cmp_nb_add(uop1, uop2, uop3); + printf("cmp_nb_add - target: *(rax) = 5, rbx = 2, rcx = 3, rflags = 0x246\n"); + if (output.rax == 5 && output.rbx == 2 && output.rcx == 3 && output.rflags == 0x246) + printf("Test passed\n"); + else + printf("Test failed\n"); +} diff --git a/BM/cmpccxadd/cmpnlexadd_equal.c b/BM/cmpccxadd/cmpnlexadd_equal.c new file mode 100644 index 00000000..6751fbc0 --- /dev/null +++ b/BM/cmpccxadd/cmpnlexadd_equal.c @@ -0,0 +1,28 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * + * Copyright (c) 2024 Intel Corporation. + * Jiaxi Chen + * Jiaan Lu + * + */ + +#include +#include +#include "cmpxadd.c" +void main(void) +{ + unsigned long uop1, uop2, uop3; + long op1, op2, op3; + struct output_signed output; + + op1 = -1; + op2 = -1; + op3 = 2; + output = cmp_nle_add(op1, op2, op3); + printf("cmp_nle_add - target: *(rax) = -1, rbx = -1, rcx = 2, rflags = 0x246\n"); + if (output.rax == -1 && output.rbx == -1 && output.rcx == 2 && output.rflags == 0x246) + printf("Test passed\n"); + else + printf("Test failed\n"); +} diff --git a/BM/cmpccxadd/cmpnlexadd_less.c b/BM/cmpccxadd/cmpnlexadd_less.c new file mode 100644 index 00000000..42b0ed41 --- /dev/null +++ b/BM/cmpccxadd/cmpnlexadd_less.c @@ -0,0 +1,28 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * + * Copyright (c) 2024 Intel Corporation. + * Jiaxi Chen + * Jiaan Lu + * + */ + +#include +#include +#include "cmpxadd.c" +void main(void) +{ + unsigned long uop1, uop2, uop3; + long op1, op2, op3; + struct output_signed output; + + op1 = -1; + op2 = 1; + op3 = 2; + output = cmp_nle_add(op1, op2, op3); + printf("cmp_nle_add - target: *(rax) = -1, rbx = -1, rcx = 2, rflags = 0x282\n"); + if (output.rax == -1 && output.rbx == -1 && output.rcx == 2 && output.rflags == 0x282) + printf("Test passed\n"); + else + printf("Test failed\n"); +} diff --git a/BM/cmpccxadd/cmpnlexadd_more.c b/BM/cmpccxadd/cmpnlexadd_more.c new file mode 100644 index 00000000..bd8a3189 --- /dev/null +++ b/BM/cmpccxadd/cmpnlexadd_more.c @@ -0,0 +1,28 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * + * Copyright (c) 2024 Intel Corporation. + * Jiaxi Chen + * Jiaan Lu + * + */ + +#include +#include +#include "cmpxadd.c" +void main(void) +{ + unsigned long uop1, uop2, uop3; + long op1, op2, op3; + struct output_signed output; + + op1 = -1; + op2 = -2; + op3 = 2; + output = cmp_nle_add(op1, op2, op3); + printf("cmp_nle_add - target: *(rax) = 1, rbx = -1, rcx = 2, rflags = 0x202\n"); + if (output.rax == 1 && output.rbx == -1 && output.rcx == 2 && output.rflags == 0x202) + printf("Test passed\n"); + else + printf("Test failed\n"); +} diff --git a/BM/cmpccxadd/cmpnlxadd_equal.c b/BM/cmpccxadd/cmpnlxadd_equal.c new file mode 100644 index 00000000..8a033512 --- /dev/null +++ b/BM/cmpccxadd/cmpnlxadd_equal.c @@ -0,0 +1,28 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * + * Copyright (c) 2024 Intel Corporation. + * Jiaxi Chen + * Jiaan Lu + * + */ + +#include +#include +#include "cmpxadd.c" +void main(void) +{ + unsigned long uop1, uop2, uop3; + long op1, op2, op3; + struct output_signed output; + + op1 = -1; + op2 = -1; + op3 = 2; + output = cmp_nl_add(op1, op2, op3); + printf("cmp_nl_add - target: *(rax) = 1, rbx = -1, rcx = 2, rflags = 0x246\n"); + if (output.rax == 1 && output.rbx == -1 && output.rcx == 2 && output.rflags == 0x246) + printf("Test passed\n"); + else + printf("Test failed\n"); +} diff --git a/BM/cmpccxadd/cmpnlxadd_less.c b/BM/cmpccxadd/cmpnlxadd_less.c new file mode 100644 index 00000000..8edf356e --- /dev/null +++ b/BM/cmpccxadd/cmpnlxadd_less.c @@ -0,0 +1,28 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * + * Copyright (c) 2024 Intel Corporation. + * Jiaxi Chen + * Jiaan Lu + * + */ + +#include +#include +#include "cmpxadd.c" +void main(void) +{ + unsigned long uop1, uop2, uop3; + long op1, op2, op3; + struct output_signed output; + + op1 = -1; + op2 = 1; + op3 = 2; + output = cmp_nl_add(op1, op2, op3); + printf("cmp_nl_add - target: *(rax) = -1, rbx = -1, rcx = 2, rflags = 0x282\n"); + if (output.rax == -1 && output.rbx == -1 && output.rcx == 2 && output.rflags == 0x282) + printf("Test passed\n"); + else + printf("Test failed\n"); +} diff --git a/BM/cmpccxadd/cmpnlxadd_more.c b/BM/cmpccxadd/cmpnlxadd_more.c new file mode 100644 index 00000000..45c1700b --- /dev/null +++ b/BM/cmpccxadd/cmpnlxadd_more.c @@ -0,0 +1,28 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * + * Copyright (c) 2024 Intel Corporation. + * Jiaxi Chen + * Jiaan Lu + * + */ + +#include +#include +#include "cmpxadd.c" +void main(void) +{ + unsigned long uop1, uop2, uop3; + long op1, op2, op3; + struct output_signed output; + + op1 = -1; + op2 = -2; + op3 = 2; + output = cmp_nl_add(op1, op2, op3); + printf("cmp_nl_add - target: *(rax) = 1, rbx = -1, rcx = 2, rflags = 0x202\n"); + if (output.rax == 1 && output.rbx == -1 && output.rcx == 2 && output.rflags == 0x202) + printf("Test passed\n"); + else + printf("Test failed\n"); +} diff --git a/BM/cmpccxadd/cmpnoxadd_not_overflow.c b/BM/cmpccxadd/cmpnoxadd_not_overflow.c new file mode 100644 index 00000000..11a07e33 --- /dev/null +++ b/BM/cmpccxadd/cmpnoxadd_not_overflow.c @@ -0,0 +1,28 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * + * Copyright (c) 2024 Intel Corporation. + * Jiaxi Chen + * Jiaan Lu + * + */ + +#include +#include +#include "cmpxadd.c" +void main(void) +{ + unsigned long uop1, uop2, uop3; + long op1, op2, op3; + struct output_signed output; + + op1 = -2; + op2 = 1; + op3 = 1; + output = cmp_no_add(op1, op2, op3); + printf("cmp_no_add - target: *(rax) = -1, rbx = -2, rcx = 1, rflags = 0x282\n"); + if (output.rax == -1 && output.rbx == -2 && output.rcx == 1 && output.rflags == 0x282) + printf("Test passed\n"); + else + printf("Test failed\n"); +} diff --git a/BM/cmpccxadd/cmpnoxadd_overflow.c b/BM/cmpccxadd/cmpnoxadd_overflow.c new file mode 100644 index 00000000..4c2f6c60 --- /dev/null +++ b/BM/cmpccxadd/cmpnoxadd_overflow.c @@ -0,0 +1,28 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * + * Copyright (c) 2024 Intel Corporation. + * Jiaxi Chen + * Jiaan Lu + * + */ + +#include +#include +#include "cmpxadd.c" +void main(void) +{ + unsigned long uop1, uop2, uop3; + long op1, op2, op3; + struct output_signed output; + + op1 = -2; + op2 = LONG_MAX; + op3 = 1; + output = cmp_no_add(op1, op2, op3); + printf("cmp_no_add - target: *(rax) = -2, rbx = -2, rcx = 1, rflags = 0xa16\n"); + if (output.rax == -2 && output.rbx == -2 && output.rcx == 1 && output.rflags == 0xa16) + printf("Test passed\n"); + else + printf("Test failed\n"); +} diff --git a/BM/cmpccxadd/cmpnpxadd_even.c b/BM/cmpccxadd/cmpnpxadd_even.c new file mode 100644 index 00000000..074f4963 --- /dev/null +++ b/BM/cmpccxadd/cmpnpxadd_even.c @@ -0,0 +1,28 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * + * Copyright (c) 2024 Intel Corporation. + * Jiaxi Chen + * Jiaan Lu + * + */ + +#include +#include +#include "cmpxadd.c" +void main(void) +{ + unsigned long uop1, uop2, uop3; + long op1, op2, op3; + struct output_unsigned output; + + uop1 = 4; + uop2 = 1; + uop3 = 3; + output = cmp_np_add(uop1, uop2, uop3); + printf("cmp_np_add - target: *(rax) = 4, rbx = 4, rcx = 3, rflags = 0x206\n"); + if (output.rax == 4 && output.rbx == 4 && output.rcx == 3 && output.rflags == 0x206) + printf("Test passed\n"); + else + printf("Test failed\n"); +} diff --git a/BM/cmpccxadd/cmpnpxadd_odd.c b/BM/cmpccxadd/cmpnpxadd_odd.c new file mode 100644 index 00000000..97404b89 --- /dev/null +++ b/BM/cmpccxadd/cmpnpxadd_odd.c @@ -0,0 +1,28 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * + * Copyright (c) 2024 Intel Corporation. + * Jiaxi Chen + * Jiaan Lu + * + */ + +#include +#include +#include "cmpxadd.c" +void main(void) +{ + unsigned long uop1, uop2, uop3; + long op1, op2, op3; + struct output_unsigned output; + + uop1 = 2; + uop2 = 1; + uop3 = 3; + output = cmp_np_add(uop1, uop2, uop3); + printf("cmp_np_add - target: *(rax) = 5, rbx = 2, rcx = 3, rflags = 0x202\n"); + if (output.rax == 5 && output.rbx == 2 && output.rcx == 3 && output.rflags == 0x202) + printf("Test passed\n"); + else + printf("Test failed\n"); +} diff --git a/BM/cmpccxadd/cmpnsxadd_negative.c b/BM/cmpccxadd/cmpnsxadd_negative.c new file mode 100644 index 00000000..1cb37804 --- /dev/null +++ b/BM/cmpccxadd/cmpnsxadd_negative.c @@ -0,0 +1,28 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * + * Copyright (c) 2024 Intel Corporation. + * Jiaxi Chen + * Jiaan Lu + * + */ + +#include +#include +#include "cmpxadd.c" +void main(void) +{ + unsigned long uop1, uop2, uop3; + long op1, op2, op3; + struct output_signed output; + + uop1 = 1; + uop2 = 2; + uop3 = 2; + output = cmp_ns_add(uop1, uop2, uop3); + printf("cmp_ns_add - target: *(rax) = 1, rbx = 1, rcx = 2, rflags = 0x297\n"); + if (output.rax == 1 && output.rbx == 1 && output.rcx == 2 && output.rflags == 0x297) + printf("Test passed\n"); + else + printf("Test failed\n"); +} diff --git a/BM/cmpccxadd/cmpnsxadd_positive.c b/BM/cmpccxadd/cmpnsxadd_positive.c new file mode 100644 index 00000000..626cd21e --- /dev/null +++ b/BM/cmpccxadd/cmpnsxadd_positive.c @@ -0,0 +1,28 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * + * Copyright (c) 2024 Intel Corporation. + * Jiaxi Chen + * Jiaan Lu + * + */ + +#include +#include +#include "cmpxadd.c" +void main(void) +{ + unsigned long uop1, uop2, uop3; + long op1, op2, op3; + struct output_signed output; + + uop1 = 1; + uop2 = 1; + uop3 = 1; + output = cmp_ns_add(uop1, uop2, uop3); + printf("cmp_ns_add - target: *(rax) = 2, rbx = 1, rcx = 1, rflags = 0x246\n"); + if (output.rax == 2 && output.rbx == 1 && output.rcx == 1 && output.rflags == 0x246) + printf("Test passed\n"); + else + printf("Test failed\n"); +} diff --git a/BM/cmpccxadd/cmpnzxadd_not_zero.c b/BM/cmpccxadd/cmpnzxadd_not_zero.c new file mode 100644 index 00000000..f69ea935 --- /dev/null +++ b/BM/cmpccxadd/cmpnzxadd_not_zero.c @@ -0,0 +1,28 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * + * Copyright (c) 2024 Intel Corporation. + * Jiaxi Chen + * Jiaan Lu + * + */ + +#include +#include +#include "cmpxadd.c" +void main(void) +{ + unsigned long uop1, uop2, uop3; + long op1, op2, op3; + struct output_unsigned output; + + uop1 = 3; + uop2 = 2; + uop3 = 2; + output = cmp_nz_add(uop1, uop2, uop3); + printf("cmp_nz_add - target: *(rax) = 5, rbx = 3, rcx = 2, rflags = 0x202\n"); + if (output.rax == 5 && output.rbx == 3 && output.rcx == 2 && output.rflags == 0x202) + printf("Test passed\n"); + else + printf("Test failed\n"); +} diff --git a/BM/cmpccxadd/cmpnzxadd_zero.c b/BM/cmpccxadd/cmpnzxadd_zero.c new file mode 100644 index 00000000..ff9509f1 --- /dev/null +++ b/BM/cmpccxadd/cmpnzxadd_zero.c @@ -0,0 +1,28 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * + * Copyright (c) 2024 Intel Corporation. + * Jiaxi Chen + * Jiaan Lu + * + */ + +#include +#include +#include "cmpxadd.c" +void main(void) +{ + unsigned long uop1, uop2, uop3; + long op1, op2, op3; + struct output_unsigned output; + + uop1 = 2; + uop2 = 2; + uop3 = 2; + output = cmp_nz_add(uop1, uop2, uop3); + printf("cmp_nz_add - target: *(rax) = 2, rbx = 2, rcx = 2, rflags = 0x246\n"); + if (output.rax == 2 && output.rbx == 2 && output.rcx == 2 && output.rflags == 0x246) + printf("Test passed\n"); + else + printf("Test failed\n"); +} diff --git a/BM/cmpccxadd/cmpoxadd_not_overflow.c b/BM/cmpccxadd/cmpoxadd_not_overflow.c new file mode 100644 index 00000000..0bcb038e --- /dev/null +++ b/BM/cmpccxadd/cmpoxadd_not_overflow.c @@ -0,0 +1,28 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * + * Copyright (c) 2024 Intel Corporation. + * Jiaxi Chen + * Jiaan Lu + * + */ + +#include +#include +#include "cmpxadd.c" +void main(void) +{ + unsigned long uop1, uop2, uop3; + long op1, op2, op3; + struct output_signed output; + + op1 = -2; + op2 = 1; + op3 = 1; + output = cmp_o_add(op1, op2, op3); + printf("cmp_o_add - target: *(rax) = -2, rbx = -2, rcx = 1, rflags = 0x282\n"); + if (output.rax == -2 && output.rbx == -2 && output.rcx == 1 && output.rflags == 0x282) + printf("Test passed\n"); + else + printf("Test failed\n"); +} diff --git a/BM/cmpccxadd/cmpoxadd_overflow.c b/BM/cmpccxadd/cmpoxadd_overflow.c new file mode 100644 index 00000000..d10c0e72 --- /dev/null +++ b/BM/cmpccxadd/cmpoxadd_overflow.c @@ -0,0 +1,28 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * + * Copyright (c) 2024 Intel Corporation. + * Jiaxi Chen + * Jiaan Lu + * + */ + +#include +#include +#include "cmpxadd.c" +void main(void) +{ + unsigned long uop1, uop2, uop3; + long op1, op2, op3; + struct output_signed output; + + op1 = -2; + op2 = LONG_MAX; + op3 = 1; + output = cmp_o_add(op1, op2, op3); + printf("cmp_o_add - target: *(rax) = -1, rbx = -2, rcx = 1, rflags = 0xa16\n"); + if (output.rax == -1 && output.rbx == -2 && output.rcx == 1 && output.rflags == 0xa16) + printf("Test passed\n"); + else + printf("Test failed\n"); +} diff --git a/BM/cmpccxadd/cmppxadd_even.c b/BM/cmpccxadd/cmppxadd_even.c new file mode 100644 index 00000000..64021caa --- /dev/null +++ b/BM/cmpccxadd/cmppxadd_even.c @@ -0,0 +1,28 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * + * Copyright (c) 2024 Intel Corporation. + * Jiaxi Chen + * Jiaan Lu + * + */ + +#include +#include +#include "cmpxadd.c" +void main(void) +{ + unsigned long uop1, uop2, uop3; + long op1, op2, op3; + struct output_unsigned output; + + uop1 = 4; + uop2 = 1; + uop3 = 3; + output = cmp_p_add(uop1, uop2, uop3); + printf("cmp_p_add - target: *(rax) = 7, rbx = 4, rcx = 3, rflags = 0x206\n"); + if (output.rax == 7 && output.rbx == 4 && output.rcx == 3 && output.rflags == 0x206) + printf("Test passed\n"); + else + printf("Test failed\n"); +} diff --git a/BM/cmpccxadd/cmppxadd_odd.c b/BM/cmpccxadd/cmppxadd_odd.c new file mode 100644 index 00000000..a079293d --- /dev/null +++ b/BM/cmpccxadd/cmppxadd_odd.c @@ -0,0 +1,28 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * + * Copyright (c) 2024 Intel Corporation. + * Jiaxi Chen + * Jiaan Lu + * + */ + +#include +#include +#include "cmpxadd.c" +void main(void) +{ + unsigned long uop1, uop2, uop3; + long op1, op2, op3; + struct output_unsigned output; + + uop1 = 2; + uop2 = 1; + uop3 = 3; + output = cmp_p_add(uop1, uop2, uop3); + printf("cmp_p_add - target: *(rax) = 2, rbx = 2, rcx = 3, rflags = 0x202\n"); + if (output.rax == 2 && output.rbx == 2 && output.rcx == 3 && output.rflags == 0x202) + printf("Test passed\n"); + else + printf("Test failed\n"); +} diff --git a/BM/cmpccxadd/cmpsxadd_negative.c b/BM/cmpccxadd/cmpsxadd_negative.c new file mode 100644 index 00000000..6896c255 --- /dev/null +++ b/BM/cmpccxadd/cmpsxadd_negative.c @@ -0,0 +1,28 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * + * Copyright (c) 2024 Intel Corporation. + * Jiaxi Chen + * Jiaan Lu + * + */ + +#include +#include +#include "cmpxadd.c" +void main(void) +{ + unsigned long uop1, uop2, uop3; + long op1, op2, op3; + struct output_signed output; + + uop1 = 1; + uop2 = 2; + uop3 = 2; + output = cmp_s_add(uop1, uop2, uop3); + printf("cmp_s_add - target: *(rax) = 3, rbx = 1, rcx = 2, rflags = 0x297\n"); + if (output.rax == 3 && output.rbx == 1 && output.rcx == 2 && output.rflags == 0x297) + printf("Test passed\n"); + else + printf("Test failed\n"); +} diff --git a/BM/cmpccxadd/cmpsxadd_positive.c b/BM/cmpccxadd/cmpsxadd_positive.c new file mode 100644 index 00000000..b3771be3 --- /dev/null +++ b/BM/cmpccxadd/cmpsxadd_positive.c @@ -0,0 +1,28 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * + * Copyright (c) 2024 Intel Corporation. + * Jiaxi Chen + * Jiaan Lu + * + */ + +#include +#include +#include "cmpxadd.c" +void main(void) +{ + unsigned long uop1, uop2, uop3; + long op1, op2, op3; + struct output_signed output; + + uop1 = 1; + uop2 = 1; + uop3 = 1; + output = cmp_s_add(uop1, uop2, uop3); + printf("cmp_s_add - target: *(rax) = 1, rbx = 1, rcx = 1, rflags = 0x246\n"); + if (output.rax == 1 && output.rbx == 1 && output.rcx == 1 && output.rflags == 0x246) + printf("Test passed\n"); + else + printf("Test failed\n"); +} diff --git a/BM/cmpccxadd/cmpxadd.c b/BM/cmpccxadd/cmpxadd.c new file mode 100644 index 00000000..c6454165 --- /dev/null +++ b/BM/cmpccxadd/cmpxadd.c @@ -0,0 +1,137 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * + * Copyright (c) 2024 Intel Corporation. + * Jiaxi Chen + * Jiaan Lu + * + */ + +#include +#include + +/* Assembling [cmpbexadd qword [rax],rbx,rcx] */ +#define CMPBEXADD ".byte 0xc4,0xe2,0xf1,0xe6,0x18" +/* Assembling [cmpbxadd qword [rax],rbx,rcx] */ +#define CMPBXADD ".byte 0xc4,0xe2,0xf1,0xe2,0x18" +/* Assembling [cmplexadd qword [rax],rbx,rcx] */ +#define CMPLEXADD ".byte 0xc4,0xe2,0xf1,0xee,0x18" +/* Assembling [cmplxadd qword [rax],rbx,rcx] */ +#define CMPLXADD ".byte 0xc4,0xe2,0xf1,0xec,0x18" +/* Assembling [cmpnbexadd qword [rax],rbx,rcx] */ +#define CMPNBEXADD ".byte 0xc4,0xe2,0xf1,0xe7,0x18" +/* Assembling [cmpnbxadd qword [rax],rbx,rcx] */ +#define CMPNBXADD ".byte 0xc4,0xe2,0xf1,0xe3,0x18" +/* Assembling [cmpnlexadd qword [rax],rbx,rcx] */ +#define CMPNLEXADD ".byte 0xc4,0xe2,0xf1,0xef,0x18" +/* Assembling [cmpnlxadd qword [rax],rbx,rcx] */ +#define CMPNLXADD ".byte 0xc4,0xe2,0xf1,0xed,0x18" +/* Assembling [cmpnoxadd qword [rax],rbx,rcx] */ +#define CMPNOXADD ".byte 0xc4,0xe2,0xf1,0xe1,0x18" +/* Assembling [cmpnpxadd qword [rax],rbx,rcx] */ +#define CMPNPXADD ".byte 0xc4,0xe2,0xf1,0xeb,0x18" +/* Assembling [cmpnsxadd qword [rax],rbx,rcx] */ +#define CMPNSXADD ".byte 0xc4,0xe2,0xf1,0xe9,0x18" +/* Assembling [cmpnzxadd qword [rax],rbx,rcx] */ +#define CMPNZXADD ".byte 0xc4,0xe2,0xf1,0xe5,0x18" +/* Assembling [cmpoxadd qword [rax],rbx,rcx] */ +#define CMPOXADD ".byte 0xc4,0xe2,0xf1,0xe0,0x18" +/* Assembling [cmppxadd qword [rax],rbx,rcx] */ +#define CMPPXADD ".byte 0xc4,0xe2,0xf1,0xea,0x18" +/* Assembling [cmpsxadd qword [rax],rbx,rcx] */ +#define CMPSXADD ".byte 0xc4,0xe2,0xf1,0xe8,0x18" +/* Assembling [cmpzxadd qword [rax],rbx,rcx] */ +#define CMPZXADD ".byte 0xc4,0xe2,0xf1,0xe4,0x18" + +struct output_unsigned { + unsigned long rax; + unsigned long rbx; + unsigned long rcx; + unsigned long rflags; +}; + +struct output_signed { + long rax; + long rbx; + long rcx; + unsigned long rflags; +}; + +#define DEF_FUNC_UNSIGNED(name, insr, op1, op2, op3) \ +struct output_unsigned name(unsigned long op1, unsigned long op2, unsigned long op3) \ +{ \ + unsigned long rflags; \ + unsigned long rax, rbx, rcx; \ + struct output_unsigned output; \ + \ + printf("%s - input: op1 = %d, op2 = %d, op3 = %d\n", \ + __func__, op1, op2, op3); \ + asm volatile ("mov %4, %%rax;\n\t" \ + "mov %5, %%rbx;\n\t" \ + "mov %6, %%rcx;\n\t" \ + insr "\n\t" \ + "pushfq;\n\t" \ + "popq %0;\n\t" \ + "mov (%%rax), %1;\n\t" \ + "mov %%rbx, %2;\n\t" \ + "mov %%rcx, %3;\n\t" \ + : "=m"(rflags), "=r"(rax), "=r"(rbx), "=r"(rcx) \ + : "r"(&op1), "r"(op2), "r"(op3) \ + : "rax", "rbx", "rcx"); \ + \ + printf("%s - output: *(rax) = %d, rbx = %d, rcx = %d, rflags = 0x%lx\n\n", \ + __func__, rax, rbx, rcx, rflags); \ + output.rax = rax; \ + output.rbx = rbx; \ + output.rcx = rcx; \ + output.rflags = rflags; \ + return output; \ +} + +#define DEF_FUNC_SIGNED(name, insr, op1, op2, op3) \ +struct output_signed name(long op1, long op2, long op3) \ +{ \ + unsigned long rflags; \ + long rax, rbx, rcx; \ + struct output_signed output; \ + \ + printf("%s - input: op1 = %d, op2 = %d, op3 = %d\n", \ + __func__, op1, op2, op3); \ + asm volatile ("mov %4, %%rax;\n\t" \ + "mov %5, %%rbx;\n\t" \ + "mov %6, %%rcx;\n\t" \ + insr "\n\t" \ + "pushfq;\n\t" \ + "popq %0;\n\t" \ + "mov (%%rax), %1;\n\t" \ + "mov %%rbx, %2;\n\t" \ + "mov %%rcx, %3;\n\t" \ + : "=m"(rflags), "=r"(rax), "=r"(rbx), "=r"(rcx) \ + : "r"(&op1), "r"(op2), "r"(op3) \ + : "rax", "rbx", "rcx"); \ + \ + printf("%s - output: *(rax) = %d, rbx = %d, rcx = %d, rflags = 0x%lx\n\n", \ + __func__, rax, rbx, rcx, rflags); \ + output.rax = rax; \ + output.rbx = rbx; \ + output.rcx = rcx; \ + output.rflags = rflags; \ + return output; \ +} + +DEF_FUNC_UNSIGNED(cmp_be_add, CMPBEXADD, op1, op2, op3); +DEF_FUNC_UNSIGNED(cmp_b_add, CMPBXADD, op1, op2, op3); +DEF_FUNC_SIGNED(cmp_le_add, CMPLEXADD, op1, op2, op3); +DEF_FUNC_SIGNED(cmp_l_add, CMPLXADD, op1, op2, op3); +DEF_FUNC_UNSIGNED(cmp_nbe_add, CMPNBEXADD, op1, op2, op3); +DEF_FUNC_UNSIGNED(cmp_nb_add, CMPNBXADD, op1, op2, op3); +DEF_FUNC_SIGNED(cmp_nle_add, CMPNLEXADD, op1, op2, op3); +DEF_FUNC_SIGNED(cmp_nl_add, CMPNLXADD, op1, op2, op3); +DEF_FUNC_SIGNED(cmp_no_add, CMPNOXADD, op1, op2, op3); +DEF_FUNC_SIGNED(cmp_o_add, CMPOXADD, op1, op2, op3); +DEF_FUNC_UNSIGNED(cmp_p_add, CMPPXADD, op1, op2, op3); +DEF_FUNC_UNSIGNED(cmp_np_add, CMPNPXADD, op1, op2, op3); +DEF_FUNC_SIGNED(cmp_s_add, CMPSXADD, op1, op2, op3); +DEF_FUNC_SIGNED(cmp_ns_add, CMPNSXADD, op1, op2, op3); +DEF_FUNC_UNSIGNED(cmp_z_add, CMPZXADD, op1, op2, op3); +DEF_FUNC_UNSIGNED(cmp_nz_add, CMPNZXADD, op1, op2, op3); diff --git a/BM/cmpccxadd/cmpzxadd_not_zero.c b/BM/cmpccxadd/cmpzxadd_not_zero.c new file mode 100644 index 00000000..71e62f23 --- /dev/null +++ b/BM/cmpccxadd/cmpzxadd_not_zero.c @@ -0,0 +1,28 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * + * Copyright (c) 2024 Intel Corporation. + * Jiaxi Chen + * Jiaan Lu + * + */ + +#include +#include +#include "cmpxadd.c" +void main(void) +{ + unsigned long uop1, uop2, uop3; + long op1, op2, op3; + struct output_unsigned output; + + uop1 = 3; + uop2 = 2; + uop3 = 2; + output = cmp_z_add(uop1, uop2, uop3); + printf("cmp_z_add - target: *(rax) = 3, rbx = 3, rcx = 2, rflags = 0x202\n"); + if (output.rax == 3 && output.rbx == 3 && output.rcx == 2 && output.rflags == 0x202) + printf("Test passed\n"); + else + printf("Test failed\n"); +} diff --git a/BM/cmpccxadd/cmpzxadd_zero.c b/BM/cmpccxadd/cmpzxadd_zero.c new file mode 100644 index 00000000..0df20427 --- /dev/null +++ b/BM/cmpccxadd/cmpzxadd_zero.c @@ -0,0 +1,28 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * + * Copyright (c) 2024 Intel Corporation. + * Jiaxi Chen + * Jiaan Lu + * + */ + +#include +#include +#include "cmpxadd.c" +void main(void) +{ + unsigned long uop1, uop2, uop3; + long op1, op2, op3; + struct output_unsigned output; + + uop1 = 2; + uop2 = 2; + uop3 = 2; + output = cmp_z_add(uop1, uop2, uop3); + printf("cmp_z_add - target: *(rax) = 4, rbx = 2, rcx = 2, rflags = 0x246\n"); + if (output.rax == 4 && output.rbx == 2 && output.rcx == 2 && output.rflags == 0x246) + printf("Test passed\n"); + else + printf("Test failed\n"); +} diff --git a/BM/cmpccxadd/runtest_all.sh b/BM/cmpccxadd/runtest_all.sh new file mode 100755 index 00000000..73acdd5d --- /dev/null +++ b/BM/cmpccxadd/runtest_all.sh @@ -0,0 +1,7 @@ +#!/bin/bash +for file in cmp*; do + if [ -x "$file" ]; then + echo -e "\nExecuting $file ..." + ./"$file" + fi +done diff --git a/README.md b/README.md index 72476634..69305302 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,7 @@ More details please refer to following. * [AMX](BM/amx/README.md) * [avx512vbmi](BM/avx512vbmi/README.md) * [cet(Control flow Enhancement Technology)](BM/cet/README.md) + * [CMPccXADD](BM/cmpccxadd/README.md) * [cstate](BM/cstate/README.md) * [DSA](BM/dsa/README.md) * [FRED](BM/fred/README.md) (in progress)