From e1955d5cccaec4418e99a283724e919b3274eb3c Mon Sep 17 00:00:00 2001 From: Jiaan Lu Date: Wed, 12 Jun 2024 00:03:05 +0800 Subject: [PATCH] cmpccxadd: merge all cases into cmpccxadd.c Signed-off-by: Jiaan Lu --- BM/cmpccxadd/Makefile | 18 +- BM/cmpccxadd/README.md | 49 +- 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/cmpccxadd.c | 663 ++++++++++++++++++++++++++ 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 - BM/cmpccxadd/tests | 41 ++ 46 files changed, 756 insertions(+), 1279 deletions(-) delete mode 100644 BM/cmpccxadd/cmpbexadd_above.c delete mode 100644 BM/cmpccxadd/cmpbexadd_below.c delete mode 100644 BM/cmpccxadd/cmpbexadd_equal.c delete mode 100644 BM/cmpccxadd/cmpbxadd_above.c delete mode 100644 BM/cmpccxadd/cmpbxadd_below.c delete mode 100644 BM/cmpccxadd/cmpbxadd_equal.c create mode 100644 BM/cmpccxadd/cmpccxadd.c delete mode 100644 BM/cmpccxadd/cmplexadd_equal.c delete mode 100644 BM/cmpccxadd/cmplexadd_less.c delete mode 100644 BM/cmpccxadd/cmplexadd_more.c delete mode 100644 BM/cmpccxadd/cmplxadd_equal.c delete mode 100644 BM/cmpccxadd/cmplxadd_less.c delete mode 100644 BM/cmpccxadd/cmplxadd_more.c delete mode 100644 BM/cmpccxadd/cmpnbexadd_above.c delete mode 100644 BM/cmpccxadd/cmpnbexadd_below.c delete mode 100644 BM/cmpccxadd/cmpnbexadd_equal.c delete mode 100644 BM/cmpccxadd/cmpnbxadd_above.c delete mode 100644 BM/cmpccxadd/cmpnbxadd_below.c delete mode 100644 BM/cmpccxadd/cmpnbxadd_equal.c delete mode 100644 BM/cmpccxadd/cmpnlexadd_equal.c delete mode 100644 BM/cmpccxadd/cmpnlexadd_less.c delete mode 100644 BM/cmpccxadd/cmpnlexadd_more.c delete mode 100644 BM/cmpccxadd/cmpnlxadd_equal.c delete mode 100644 BM/cmpccxadd/cmpnlxadd_less.c delete mode 100644 BM/cmpccxadd/cmpnlxadd_more.c delete mode 100644 BM/cmpccxadd/cmpnoxadd_not_overflow.c delete mode 100644 BM/cmpccxadd/cmpnoxadd_overflow.c delete mode 100644 BM/cmpccxadd/cmpnpxadd_even.c delete mode 100644 BM/cmpccxadd/cmpnpxadd_odd.c delete mode 100644 BM/cmpccxadd/cmpnsxadd_negative.c delete mode 100644 BM/cmpccxadd/cmpnsxadd_positive.c delete mode 100644 BM/cmpccxadd/cmpnzxadd_not_zero.c delete mode 100644 BM/cmpccxadd/cmpnzxadd_zero.c delete mode 100644 BM/cmpccxadd/cmpoxadd_not_overflow.c delete mode 100644 BM/cmpccxadd/cmpoxadd_overflow.c delete mode 100644 BM/cmpccxadd/cmppxadd_even.c delete mode 100644 BM/cmpccxadd/cmppxadd_odd.c delete mode 100644 BM/cmpccxadd/cmpsxadd_negative.c delete mode 100644 BM/cmpccxadd/cmpsxadd_positive.c delete mode 100644 BM/cmpccxadd/cmpxadd.c delete mode 100644 BM/cmpccxadd/cmpzxadd_not_zero.c delete mode 100644 BM/cmpccxadd/cmpzxadd_zero.c delete mode 100755 BM/cmpccxadd/runtest_all.sh create mode 100644 BM/cmpccxadd/tests diff --git a/BM/cmpccxadd/Makefile b/BM/cmpccxadd/Makefile index 9553052f..ca7f2f3c 100644 --- a/BM/cmpccxadd/Makefile +++ b/BM/cmpccxadd/Makefile @@ -1,18 +1,12 @@ # SPDX-License-Identifier: GPL-2.0-only # Copyright (c) 2024 Intel Corporation. -# Jiaan Lu -CFLAGS = -g +CC = gcc +CFLAGS = -g -Wall +TARGET = cmpccxadd -src = $(filter-out cmpxadd.c, $(wildcard *.c)) -target = $(patsubst %.c, %, ${src}) - -.PHONY: all clean - -%:%.c - $(CC) ${CFLAGS} $^ -o $@ - -all: ${target} +$(TARGET): cmpccxadd.c + $(CC) $(CFLAGS) -o $@ $< clean: - rm -f ${target} \ No newline at end of file + rm -f $(TARGET) \ No newline at end of file diff --git a/BM/cmpccxadd/README.md b/BM/cmpccxadd/README.md index 6faafec9..bec4496a 100644 --- a/BM/cmpccxadd/README.md +++ b/BM/cmpccxadd/README.md @@ -12,8 +12,51 @@ This test suite provides basic functional check to ensure CMPccXADD works proper ``` make # To run a specific case -(for example) ./cmpbexadd_above -# To run all cases at once -./runtest_all.sh +./cmpccxadd -t +(for example, cmpbexadd_above) ./cmpccxadd -t 1 ``` Test results (PASS or FAIL) will be printed out. + +## Testcase ID +| Case ID | Case Name | +| ------ | ---------------------------- | +| 1 | cmpbexadd_above | +| 2 | cmpbexadd_below | +| 3 | cmpbexadd_equal | +| 4 | cmpbxadd_above | +| 5 | cmpbxadd_below | +| 6 | cmpbxadd_equal | +| 7 | cmplexadd_equal | +| 8 | cmplexadd_less | +| 9 | cmplexadd_more | +| 10 | cmplxadd_equal | +| 11 | cmplxadd_less | +| 12 | cmplxadd_more | +| 13 | cmpnbexadd_above | +| 14 | cmpnbexadd_below | +| 15 | cmpnbexadd_equal | +| 16 | cmpnbxadd_above | +| 17 | cmpnbxadd_below | +| 18 | cmpnbxadd_equal | +| 19 | cmpnlexadd_equal | +| 20 | cmpnlexadd_less | +| 21 | cmpnlexadd_more | +| 22 | cmpnlxadd_equal | +| 23 | cmpnlxadd_less | +| 24 | cmpnlxadd_more | +| 25 | cmpnoxadd_not_overflow | +| 26 | cmpnoxadd_overflow | +| 27 | cmpnpxadd_even | +| 28 | cmpnpxadd_odd | +| 29 | cmpnsxadd_negative | +| 30 | cmpnsxadd_positive | +| 31 | cmpnzxadd_not_zero | +| 32 | cmpnzxadd_zero | +| 33 | cmpoxadd_not_overflow | +| 34 | cmpoxadd_overflow | +| 35 | cmppxadd_even | +| 36 | cmppxadd_odd | +| 37 | cmpsxadd_negative | +| 38 | cmpsxadd_positive | +| 39 | cmpzxadd_not_zero | +| 40 | cmpzxadd_zero | \ No newline at end of file diff --git a/BM/cmpccxadd/cmpbexadd_above.c b/BM/cmpccxadd/cmpbexadd_above.c deleted file mode 100644 index 91e8f267..00000000 --- a/BM/cmpccxadd/cmpbexadd_above.c +++ /dev/null @@ -1,28 +0,0 @@ -// 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 deleted file mode 100644 index 0dad7c97..00000000 --- a/BM/cmpccxadd/cmpbexadd_below.c +++ /dev/null @@ -1,28 +0,0 @@ -// 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 deleted file mode 100644 index e8922ca3..00000000 --- a/BM/cmpccxadd/cmpbexadd_equal.c +++ /dev/null @@ -1,28 +0,0 @@ -// 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 deleted file mode 100644 index 4da4c97e..00000000 --- a/BM/cmpccxadd/cmpbxadd_above.c +++ /dev/null @@ -1,28 +0,0 @@ -// 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 deleted file mode 100644 index 4eb1276e..00000000 --- a/BM/cmpccxadd/cmpbxadd_below.c +++ /dev/null @@ -1,28 +0,0 @@ -// 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 deleted file mode 100644 index c444da02..00000000 --- a/BM/cmpccxadd/cmpbxadd_equal.c +++ /dev/null @@ -1,28 +0,0 @@ -// 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/cmpccxadd.c b/BM/cmpccxadd/cmpccxadd.c new file mode 100644 index 00000000..6a6ac186 --- /dev/null +++ b/BM/cmpccxadd/cmpccxadd.c @@ -0,0 +1,663 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * + * Copyright (c) 2024 Intel Corporation. + * Jiaxi Chen + * Jiaan Lu + * + */ + +#include +#include +#include +#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", \ + __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", \ + __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); + +void cmp_target_unsigned(unsigned long rax, unsigned long rbx, unsigned long rcx, unsigned long rflags, unsigned long rax_t, unsigned long rbx_t, unsigned long rcx_t, unsigned long rflags_t) +{ + printf("target: *(rax) = %d, rbx = %d, rcx = %d, rflags = 0x%lx\n", rax_t, rbx_t, rcx_t, rflags_t); + + if (rax == rax_t && rbx == rbx_t && rcx == rcx_t && rflags == rflags_t) + printf("Test passed\n\n"); + else + fprintf(stderr, "Test failed\n\n"); +} + +void cmp_target_signed(long rax, long rbx, long rcx, unsigned long rflags, long rax_t, long rbx_t, long rcx_t, unsigned long rflags_t) +{ + printf("target: *(rax) = %d, rbx = %d, rcx = %d, rflags = 0x%lx\n", rax_t, rbx_t, rcx_t, rflags_t); + + if (rax == rax_t && rbx == rbx_t && rcx == rcx_t && rflags == rflags_t) + printf("Test passed\n\n"); + else + fprintf(stderr, "Test failed\n\n"); +} + +unsigned long uop1, uop2, uop3; +long op1, op2, op3; +struct output_unsigned uoutput; +struct output_signed output; + +void cmpbexadd_above(void) +{ + uop1 = 2; + uop2 = 1; + uop3 = 3; + uoutput = cmp_be_add(uop1, uop2, uop3); + cmp_target_unsigned(uoutput.rax, uoutput.rbx, uoutput.rcx, uoutput.rflags, 2, 2, 3, 0x202); +} + +void cmpbexadd_below(void) +{ + uop1 = 1; + uop2 = 2; + uop3 = 3; + uoutput = cmp_be_add(uop1, uop2, uop3); + cmp_target_unsigned(uoutput.rax, uoutput.rbx, uoutput.rcx, uoutput.rflags, 4, 1, 3, 0x297); +} + +void cmpbexadd_equal(void) +{ + uop1 = 2; + uop2 = 2; + uop3 = 3; + uoutput = cmp_be_add(uop1, uop2, uop3); + cmp_target_unsigned(uoutput.rax, uoutput.rbx, uoutput.rcx, uoutput.rflags, 5, 2, 3, 0x246); +} + +void cmpbxadd_above(void) +{ + uop1 = 2; + uop2 = 1; + uop3 = 3; + uoutput = cmp_b_add(uop1, uop2, uop3); + cmp_target_unsigned(uoutput.rax, uoutput.rbx, uoutput.rcx, uoutput.rflags, 2, 2, 3, 0x202); +} + +void cmpbxadd_below(void) +{ + uop1 = 1; + uop2 = 2; + uop3 = 3; + uoutput = cmp_b_add(uop1, uop2, uop3); + cmp_target_unsigned(uoutput.rax, uoutput.rbx, uoutput.rcx, uoutput.rflags, 4, 1, 3, 0x297); +} + +void cmpbxadd_equal(void) +{ + uop1 = 2; + uop2 = 2; + uop3 = 3; + uoutput = cmp_b_add(uop1, uop2, uop3); + cmp_target_unsigned(uoutput.rax, uoutput.rbx, uoutput.rcx, uoutput.rflags, 2, 2, 3, 0x246); +} + +void cmplexadd_equal(void) +{ + op1 = -1; + op2 = -1; + op3 = 2; + output = cmp_le_add(op1, op2, op3); + cmp_target_signed(output.rax, output.rbx, output.rcx, output.rflags, 1, -1, 2, 0x246); +} + +void cmplexadd_less(void) +{ + op1 = -1; + op2 = 1; + op3 = 2; + output = cmp_le_add(op1, op2, op3); + cmp_target_signed(output.rax, output.rbx, output.rcx, output.rflags, 1, -1, 2, 0x282); +} + +void cmplexadd_more(void) +{ + op1 = -1; + op2 = -2; + op3 = 2; + output = cmp_le_add(op1, op2, op3); + cmp_target_signed(output.rax, output.rbx, output.rcx, output.rflags, -1, -1, 2, 0x202); +} + +void cmplxadd_equal(void) +{ + op1 = -1; + op2 = -1; + op3 = 2; + output = cmp_l_add(op1, op2, op3); + cmp_target_signed(output.rax, output.rbx, output.rcx, output.rflags, -1, -1, 2, 0x246); +} + +void cmplxadd_less(void) +{ + op1 = -1; + op2 = 1; + op3 = 2; + output = cmp_l_add(op1, op2, op3); + cmp_target_signed(output.rax, output.rbx, output.rcx, output.rflags, 1, -1, 2, 0x282); +} + +void cmplxadd_more(void) +{ + op1 = -1; + op2 = -2; + op3 = 2; + output = cmp_l_add(op1, op2, op3); + cmp_target_signed(output.rax, output.rbx, output.rcx, output.rflags, -1, -1, 2, 0x202); +} + +void cmpnbexadd_above(void) +{ + uop1 = 2; + uop2 = 1; + uop3 = 3; + uoutput = cmp_nbe_add(uop1, uop2, uop3); + cmp_target_unsigned(uoutput.rax, uoutput.rbx, uoutput.rcx, uoutput.rflags, 5, 2, 3, 0x202); +} + +void cmpnbexadd_below(void) +{ + uop1 = 1; + uop2 = 2; + uop3 = 3; + uoutput = cmp_nbe_add(uop1, uop2, uop3); + cmp_target_unsigned(uoutput.rax, uoutput.rbx, uoutput.rcx, uoutput.rflags, 1, 1, 3, 0x297); +} + +void cmpnbexadd_equal(void) +{ + uop1 = 2; + uop2 = 2; + uop3 = 3; + uoutput = cmp_nbe_add(uop1, uop2, uop3); + cmp_target_unsigned(uoutput.rax, uoutput.rbx, uoutput.rcx, uoutput.rflags, 2, 2, 3, 0x246); +} + +void cmpnbxadd_above(void) +{ + uop1 = 2; + uop2 = 1; + uop3 = 3; + uoutput = cmp_nb_add(uop1, uop2, uop3); + cmp_target_unsigned(uoutput.rax, uoutput.rbx, uoutput.rcx, uoutput.rflags, 5, 2, 3, 0x202); +} + +void cmpnbxadd_below(void) +{ + uop1 = 1; + uop2 = 2; + uop3 = 3; + uoutput = cmp_nb_add(uop1, uop2, uop3); + cmp_target_unsigned(uoutput.rax, uoutput.rbx, uoutput.rcx, uoutput.rflags, 1, 1, 3, 0x297); +} + +void cmpnbxadd_equal(void) +{ + uop1 = 2; + uop2 = 2; + uop3 = 3; + uoutput = cmp_nb_add(uop1, uop2, uop3); + cmp_target_unsigned(uoutput.rax, uoutput.rbx, uoutput.rcx, uoutput.rflags, 5, 2, 3, 0x246); +} + +void cmpnlexadd_equal(void) +{ + op1 = -1; + op2 = -1; + op3 = 2; + output = cmp_nle_add(op1, op2, op3); + cmp_target_signed(output.rax, output.rbx, output.rcx, output.rflags, -1, -1, 2, 0x246); +} + +void cmpnlexadd_less(void) +{ + op1 = -1; + op2 = 1; + op3 = 2; + output = cmp_nle_add(op1, op2, op3); + cmp_target_signed(output.rax, output.rbx, output.rcx, output.rflags, -1, -1, 2, 0x282); +} + +void cmpnlexadd_more(void) +{ + op1 = -1; + op2 = -2; + op3 = 2; + output = cmp_nle_add(op1, op2, op3); + cmp_target_signed(output.rax, output.rbx, output.rcx, output.rflags, 1, -1, 2, 0x202); +} + +void cmpnlxadd_equal(void) +{ + op1 = -1; + op2 = -1; + op3 = 2; + output = cmp_nl_add(op1, op2, op3); + cmp_target_signed(output.rax, output.rbx, output.rcx, output.rflags, 1, -1, 2, 0x246); +} + +void cmpnlxadd_less(void) +{ + op1 = -1; + op2 = 1; + op3 = 2; + output = cmp_nl_add(op1, op2, op3); + cmp_target_signed(output.rax, output.rbx, output.rcx, output.rflags, -1, -1, 2, 0x282); +} + +void cmpnlxadd_more(void) +{ + op1 = -1; + op2 = -2; + op3 = 2; + output = cmp_nl_add(op1, op2, op3); + cmp_target_signed(output.rax, output.rbx, output.rcx, output.rflags, 1, -1, 2, 0x202); +} + +void cmpnoxadd_not_overflow(void) +{ + op1 = -2; + op2 = 1; + op3 = 1; + output = cmp_no_add(op1, op2, op3); + cmp_target_signed(output.rax, output.rbx, output.rcx, output.rflags, -1, -2, 1, 0x282); +} + +void cmpnoxadd_overflow(void) +{ + op1 = -2; + op2 = LONG_MAX; + op3 = 1; + output = cmp_no_add(op1, op2, op3); + cmp_target_signed(output.rax, output.rbx, output.rcx, output.rflags, -2, -2, 1, 0xa16); +} + +void cmpnpxadd_even(void) +{ + uop1 = 4; + uop2 = 1; + uop3 = 3; + uoutput = cmp_np_add(uop1, uop2, uop3); + cmp_target_unsigned(uoutput.rax, uoutput.rbx, uoutput.rcx, uoutput.rflags, 4, 4, 3, 0x206); +} + +void cmpnpxadd_odd(void) +{ + uop1 = 2; + uop2 = 1; + uop3 = 3; + uoutput = cmp_np_add(uop1, uop2, uop3); + cmp_target_unsigned(uoutput.rax, uoutput.rbx, uoutput.rcx, uoutput.rflags, 5, 2, 3, 0x202); +} + +void cmpnsxadd_negative(void) +{ + op1 = 1; + op2 = 2; + op3 = 2; + output = cmp_ns_add(op1, op2, op3); + cmp_target_signed(output.rax, output.rbx, output.rcx, output.rflags, 1, 1, 2, 0x297); +} + +void cmpnsxadd_positive(void) +{ + op1 = 1; + op2 = 1; + op3 = 1; + output = cmp_ns_add(op1, op2, op3); + cmp_target_signed(output.rax, output.rbx, output.rcx, output.rflags, 2, 1, 1, 0x246); +} + +void cmpnzxadd_not_zero(void) +{ + uop1 = 3; + uop2 = 2; + uop3 = 2; + uoutput = cmp_nz_add(uop1, uop2, uop3); + cmp_target_unsigned(uoutput.rax, uoutput.rbx, uoutput.rcx, uoutput.rflags, 5, 3, 2, 0x202); +} + +void cmpnzxadd_zero(void) +{ + uop1 = 2; + uop2 = 2; + uop3 = 2; + uoutput = cmp_nz_add(uop1, uop2, uop3); + cmp_target_unsigned(uoutput.rax, uoutput.rbx, uoutput.rcx, uoutput.rflags, 2, 2, 2, 0x246); +} + +void cmpoxadd_not_overflow(void) +{ + op1 = -2; + op2 = 1; + op3 = 1; + output = cmp_o_add(op1, op2, op3); + cmp_target_signed(output.rax, output.rbx, output.rcx, output.rflags, -2, -2, 1, 0x282); +} + +void cmpoxadd_overflow(void) +{ + op1 = -2; + op2 = LONG_MAX; + op3 = 1; + output = cmp_o_add(op1, op2, op3); + cmp_target_signed(output.rax, output.rbx, output.rcx, output.rflags, -1, -2, 1, 0xa16); +} + +void cmppxadd_even(void) +{ + uop1 = 4; + uop2 = 1; + uop3 = 3; + uoutput = cmp_p_add(uop1, uop2, uop3); + cmp_target_unsigned(uoutput.rax, uoutput.rbx, uoutput.rcx, uoutput.rflags, 7, 4, 3, 0x206); +} + +void cmppxadd_odd(void) +{ + uop1 = 2; + uop2 = 1; + uop3 = 3; + uoutput = cmp_p_add(uop1, uop2, uop3); + cmp_target_unsigned(uoutput.rax, uoutput.rbx, uoutput.rcx, uoutput.rflags, 2, 2, 3, 0x202); +} + +void cmpsxadd_negative(void) +{ + op1 = 1; + op2 = 2; + op3 = 2; + output = cmp_s_add(op1, op2, op3); + cmp_target_signed(output.rax, output.rbx, output.rcx, output.rflags, 3, 1, 2, 0x297); +} + +void cmpsxadd_positive(void) +{ + op1 = 1; + op2 = 1; + op3 = 1; + output = cmp_s_add(op1, op2, op3); + cmp_target_signed(output.rax, output.rbx, output.rcx, output.rflags, 1, 1, 1, 0x246); +} + +void cmpzxadd_not_zero(void) +{ + uop1 = 3; + uop2 = 2; + uop3 = 2; + uoutput = cmp_z_add(uop1, uop2, uop3); + cmp_target_unsigned(uoutput.rax, uoutput.rbx, uoutput.rcx, uoutput.rflags, 3, 3, 2, 0x202); +} + +void cmpzxadd_zero(void) +{ + uop1 = 2; + uop2 = 2; + uop3 = 2; + uoutput = cmp_z_add(uop1, uop2, uop3); + cmp_target_unsigned(uoutput.rax, uoutput.rbx, uoutput.rcx, uoutput.rflags, 4, 2, 2, 0x246); +} + +void main(int32_t argc, char **argv) +{ + if (argc != 3 || strcmp(argv[1], "-t") != 0) + { + fprintf(stderr, "Usage: ./cmpccxadd -t \n"); + return; + } + + int32_t case_id; + case_id = atoi(argv[2]); + + switch (case_id) + { + case 1: + cmpbexadd_above(); + break; + case 2: + cmpbexadd_below(); + break; + case 3: + cmpbexadd_equal(); + case 4: + cmpbxadd_above(); + break; + case 5: + cmpbxadd_below(); + break; + case 6: + cmpbxadd_equal(); + break; + case 7: + cmplexadd_equal(); + break; + case 8: + cmplexadd_less(); + break; + case 9: + cmplexadd_more(); + break; + case 10: + cmplxadd_equal(); + break; + case 11: + cmplxadd_less(); + break; + case 12: + cmplxadd_more(); + break; + case 13: + cmpnbexadd_above(); + break; + case 14: + cmpnbexadd_below(); + break; + case 15: + cmpnbexadd_equal(); + break; + case 16: + cmpnbxadd_above(); + break; + case 17: + cmpnbxadd_below(); + break; + case 18: + cmpnbxadd_equal(); + break; + case 19: + cmpnlexadd_equal(); + break; + case 20: + cmpnlexadd_less(); + break; + case 21: + cmpnlexadd_more(); + break; + case 22: + cmpnlxadd_equal(); + break; + case 23: + cmpnlxadd_less(); + break; + case 24: + cmpnlxadd_more(); + break; + case 25: + cmpnoxadd_not_overflow(); + break; + case 26: + cmpnoxadd_overflow(); + break; + case 27: + cmpnpxadd_even(); + break; + case 28: + cmpnpxadd_odd(); + break; + case 29: + cmpnsxadd_negative(); + break; + case 30: + cmpnsxadd_positive(); + break; + case 31: + cmpnzxadd_not_zero(); + break; + case 32: + cmpnzxadd_zero(); + break; + case 33: + cmpoxadd_not_overflow(); + break; + case 34: + cmpoxadd_overflow(); + break; + case 35: + cmppxadd_even(); + break; + case 36: + cmppxadd_odd(); + break; + case 37: + cmpsxadd_negative(); + break; + case 38: + cmpsxadd_positive(); + break; + case 39: + cmpzxadd_not_zero(); + break; + case 40: + cmpzxadd_zero(); + break; + default: + fprintf(stderr, "Invalid testcase!\n"); + break; + } +} diff --git a/BM/cmpccxadd/cmplexadd_equal.c b/BM/cmpccxadd/cmplexadd_equal.c deleted file mode 100644 index f0b98ac2..00000000 --- a/BM/cmpccxadd/cmplexadd_equal.c +++ /dev/null @@ -1,28 +0,0 @@ -// 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 deleted file mode 100644 index 56b3be8a..00000000 --- a/BM/cmpccxadd/cmplexadd_less.c +++ /dev/null @@ -1,28 +0,0 @@ -// 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 deleted file mode 100644 index 621deb63..00000000 --- a/BM/cmpccxadd/cmplexadd_more.c +++ /dev/null @@ -1,28 +0,0 @@ -// 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 deleted file mode 100644 index b945a6d6..00000000 --- a/BM/cmpccxadd/cmplxadd_equal.c +++ /dev/null @@ -1,28 +0,0 @@ -// 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 deleted file mode 100644 index 85603e0a..00000000 --- a/BM/cmpccxadd/cmplxadd_less.c +++ /dev/null @@ -1,28 +0,0 @@ -// 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 deleted file mode 100644 index c57ee822..00000000 --- a/BM/cmpccxadd/cmplxadd_more.c +++ /dev/null @@ -1,28 +0,0 @@ -// 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 deleted file mode 100644 index 7fdf8920..00000000 --- a/BM/cmpccxadd/cmpnbexadd_above.c +++ /dev/null @@ -1,28 +0,0 @@ -// 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 deleted file mode 100644 index 6c3ad74c..00000000 --- a/BM/cmpccxadd/cmpnbexadd_below.c +++ /dev/null @@ -1,28 +0,0 @@ -// 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 deleted file mode 100644 index 2753f980..00000000 --- a/BM/cmpccxadd/cmpnbexadd_equal.c +++ /dev/null @@ -1,28 +0,0 @@ -// 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 deleted file mode 100644 index 74a525b3..00000000 --- a/BM/cmpccxadd/cmpnbxadd_above.c +++ /dev/null @@ -1,28 +0,0 @@ -// 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 deleted file mode 100644 index dd518bbb..00000000 --- a/BM/cmpccxadd/cmpnbxadd_below.c +++ /dev/null @@ -1,28 +0,0 @@ -// 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 deleted file mode 100644 index aef82ede..00000000 --- a/BM/cmpccxadd/cmpnbxadd_equal.c +++ /dev/null @@ -1,28 +0,0 @@ -// 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 deleted file mode 100644 index 6751fbc0..00000000 --- a/BM/cmpccxadd/cmpnlexadd_equal.c +++ /dev/null @@ -1,28 +0,0 @@ -// 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 deleted file mode 100644 index 42b0ed41..00000000 --- a/BM/cmpccxadd/cmpnlexadd_less.c +++ /dev/null @@ -1,28 +0,0 @@ -// 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 deleted file mode 100644 index bd8a3189..00000000 --- a/BM/cmpccxadd/cmpnlexadd_more.c +++ /dev/null @@ -1,28 +0,0 @@ -// 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 deleted file mode 100644 index 8a033512..00000000 --- a/BM/cmpccxadd/cmpnlxadd_equal.c +++ /dev/null @@ -1,28 +0,0 @@ -// 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 deleted file mode 100644 index 8edf356e..00000000 --- a/BM/cmpccxadd/cmpnlxadd_less.c +++ /dev/null @@ -1,28 +0,0 @@ -// 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 deleted file mode 100644 index 45c1700b..00000000 --- a/BM/cmpccxadd/cmpnlxadd_more.c +++ /dev/null @@ -1,28 +0,0 @@ -// 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 deleted file mode 100644 index 11a07e33..00000000 --- a/BM/cmpccxadd/cmpnoxadd_not_overflow.c +++ /dev/null @@ -1,28 +0,0 @@ -// 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 deleted file mode 100644 index 4c2f6c60..00000000 --- a/BM/cmpccxadd/cmpnoxadd_overflow.c +++ /dev/null @@ -1,28 +0,0 @@ -// 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 deleted file mode 100644 index 074f4963..00000000 --- a/BM/cmpccxadd/cmpnpxadd_even.c +++ /dev/null @@ -1,28 +0,0 @@ -// 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 deleted file mode 100644 index 97404b89..00000000 --- a/BM/cmpccxadd/cmpnpxadd_odd.c +++ /dev/null @@ -1,28 +0,0 @@ -// 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 deleted file mode 100644 index 1cb37804..00000000 --- a/BM/cmpccxadd/cmpnsxadd_negative.c +++ /dev/null @@ -1,28 +0,0 @@ -// 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 deleted file mode 100644 index 626cd21e..00000000 --- a/BM/cmpccxadd/cmpnsxadd_positive.c +++ /dev/null @@ -1,28 +0,0 @@ -// 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 deleted file mode 100644 index f69ea935..00000000 --- a/BM/cmpccxadd/cmpnzxadd_not_zero.c +++ /dev/null @@ -1,28 +0,0 @@ -// 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 deleted file mode 100644 index ff9509f1..00000000 --- a/BM/cmpccxadd/cmpnzxadd_zero.c +++ /dev/null @@ -1,28 +0,0 @@ -// 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 deleted file mode 100644 index 0bcb038e..00000000 --- a/BM/cmpccxadd/cmpoxadd_not_overflow.c +++ /dev/null @@ -1,28 +0,0 @@ -// 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 deleted file mode 100644 index d10c0e72..00000000 --- a/BM/cmpccxadd/cmpoxadd_overflow.c +++ /dev/null @@ -1,28 +0,0 @@ -// 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 deleted file mode 100644 index 64021caa..00000000 --- a/BM/cmpccxadd/cmppxadd_even.c +++ /dev/null @@ -1,28 +0,0 @@ -// 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 deleted file mode 100644 index a079293d..00000000 --- a/BM/cmpccxadd/cmppxadd_odd.c +++ /dev/null @@ -1,28 +0,0 @@ -// 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 deleted file mode 100644 index 6896c255..00000000 --- a/BM/cmpccxadd/cmpsxadd_negative.c +++ /dev/null @@ -1,28 +0,0 @@ -// 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 deleted file mode 100644 index b3771be3..00000000 --- a/BM/cmpccxadd/cmpsxadd_positive.c +++ /dev/null @@ -1,28 +0,0 @@ -// 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 deleted file mode 100644 index c6454165..00000000 --- a/BM/cmpccxadd/cmpxadd.c +++ /dev/null @@ -1,137 +0,0 @@ -// 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 deleted file mode 100644 index 71e62f23..00000000 --- a/BM/cmpccxadd/cmpzxadd_not_zero.c +++ /dev/null @@ -1,28 +0,0 @@ -// 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 deleted file mode 100644 index 0df20427..00000000 --- a/BM/cmpccxadd/cmpzxadd_zero.c +++ /dev/null @@ -1,28 +0,0 @@ -// 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 deleted file mode 100755 index 73acdd5d..00000000 --- a/BM/cmpccxadd/runtest_all.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash -for file in cmp*; do - if [ -x "$file" ]; then - echo -e "\nExecuting $file ..." - ./"$file" - fi -done diff --git a/BM/cmpccxadd/tests b/BM/cmpccxadd/tests new file mode 100644 index 00000000..fd914e90 --- /dev/null +++ b/BM/cmpccxadd/tests @@ -0,0 +1,41 @@ +# This file collects the CMPccXADD cases +./cmpccxadd -t 1 # cmpbexadd_above +./cmpccxadd -t 2 # cmpbexadd_below +./cmpccxadd -t 3 # cmpbexadd_equal +./cmpccxadd -t 4 # cmpbxadd_above +./cmpccxadd -t 5 # cmpbxadd_below +./cmpccxadd -t 6 # cmpbxadd_equal +./cmpccxadd -t 7 # cmplexadd_equal +./cmpccxadd -t 8 # cmplexadd_less +./cmpccxadd -t 9 # cmplexadd_more +./cmpccxadd -t 10 # cmplxadd_equal +./cmpccxadd -t 11 # cmplxadd_less +./cmpccxadd -t 12 # cmplxadd_more +./cmpccxadd -t 13 # cmpnbexadd_above +./cmpccxadd -t 14 # cmpnbexadd_below +./cmpccxadd -t 15 # cmpnbexadd_equal +./cmpccxadd -t 16 # cmpnbxadd_above +./cmpccxadd -t 17 # cmpnbxadd_below +./cmpccxadd -t 18 # cmpnbxadd_equal +./cmpccxadd -t 19 # cmpnlexadd_equal +./cmpccxadd -t 20 # cmpnlexadd_less +./cmpccxadd -t 21 # cmpnlexadd_more +./cmpccxadd -t 22 # cmpnlxadd_equal +./cmpccxadd -t 23 # cmpnlxadd_less +./cmpccxadd -t 24 # cmpnlxadd_more +./cmpccxadd -t 25 # cmpnoxadd_not_overflow +./cmpccxadd -t 26 # cmpnoxadd_overflow +./cmpccxadd -t 27 # cmpnpxadd_even +./cmpccxadd -t 28 # cmpnpxadd_odd +./cmpccxadd -t 29 # cmpnsxadd_negative +./cmpccxadd -t 30 # cmpnsxadd_positive +./cmpccxadd -t 31 # cmpnzxadd_not_zero +./cmpccxadd -t 32 # cmpnzxadd_zero +./cmpccxadd -t 33 # cmpoxadd_not_overflow +./cmpccxadd -t 34 # cmpoxadd_overflow +./cmpccxadd -t 35 # cmppxadd_even +./cmpccxadd -t 36 # cmppxadd_odd +./cmpccxadd -t 37 # cmpsxadd_negative +./cmpccxadd -t 38 # cmpsxadd_positive +./cmpccxadd -t 39 # cmpzxadd_not_zero +./cmpccxadd -t 40 # cmpzxadd_zero \ No newline at end of file