diff --git a/BM/README.md b/BM/README.md index 3c309970..22c00ae8 100644 --- a/BM/README.md +++ b/BM/README.md @@ -3,6 +3,7 @@ ## Features * [AMX](amx/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/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..d59d0f77 --- /dev/null +++ b/BM/cmpccxadd/cmpbexadd_above.c @@ -0,0 +1,27 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * + * Copyright (c) 2024 Intel Corporation. + * Jiaxi Chen + * Jiaan Lu + * + */ + +#include +#include +#include "cmpxadd.c" +void main() { + unsigned long uop1, uop2, uop3; + long op1, op2, op3; + struct OutputUnsigned 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..f2ace769 --- /dev/null +++ b/BM/cmpccxadd/cmpbexadd_below.c @@ -0,0 +1,27 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * + * Copyright (c) 2024 Intel Corporation. + * Jiaxi Chen + * Jiaan Lu + * + */ + +#include +#include +#include "cmpxadd.c" +void main() { + unsigned long uop1, uop2, uop3; + long op1, op2, op3; + struct OutputUnsigned 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..02ff6e2a --- /dev/null +++ b/BM/cmpccxadd/cmpbexadd_equal.c @@ -0,0 +1,27 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * + * Copyright (c) 2024 Intel Corporation. + * Jiaxi Chen + * Jiaan Lu + * + */ + +#include +#include +#include "cmpxadd.c" +void main() { + unsigned long uop1, uop2, uop3; + long op1, op2, op3; + struct OutputUnsigned 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..82dd5a25 --- /dev/null +++ b/BM/cmpccxadd/cmpbxadd_above.c @@ -0,0 +1,27 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * + * Copyright (c) 2024 Intel Corporation. + * Jiaxi Chen + * Jiaan Lu + * + */ + +#include +#include +#include "cmpxadd.c" +void main() { + unsigned long uop1, uop2, uop3; + long op1, op2, op3; + struct OutputUnsigned 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..aa1e5f7b --- /dev/null +++ b/BM/cmpccxadd/cmpbxadd_below.c @@ -0,0 +1,27 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * + * Copyright (c) 2024 Intel Corporation. + * Jiaxi Chen + * Jiaan Lu + * + */ + +#include +#include +#include "cmpxadd.c" +void main() { + unsigned long uop1, uop2, uop3; + long op1, op2, op3; + struct OutputUnsigned 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..4dec42e7 --- /dev/null +++ b/BM/cmpccxadd/cmpbxadd_equal.c @@ -0,0 +1,27 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * + * Copyright (c) 2024 Intel Corporation. + * Jiaxi Chen + * Jiaan Lu + * + */ + +#include +#include +#include "cmpxadd.c" +void main() { + unsigned long uop1, uop2, uop3; + long op1, op2, op3; + struct OutputUnsigned 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..d4253aeb --- /dev/null +++ b/BM/cmpccxadd/cmplexadd_equal.c @@ -0,0 +1,27 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * + * Copyright (c) 2024 Intel Corporation. + * Jiaxi Chen + * Jiaan Lu + * + */ + +#include +#include +#include "cmpxadd.c" +void main() { + unsigned long uop1, uop2, uop3; + long op1, op2, op3; + struct OutputSigned 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..ea0eb0ca --- /dev/null +++ b/BM/cmpccxadd/cmplexadd_less.c @@ -0,0 +1,27 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * + * Copyright (c) 2024 Intel Corporation. + * Jiaxi Chen + * Jiaan Lu + * + */ + +#include +#include +#include "cmpxadd.c" +void main() { + unsigned long uop1, uop2, uop3; + long op1, op2, op3; + struct OutputSigned 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..9232c8ab --- /dev/null +++ b/BM/cmpccxadd/cmplexadd_more.c @@ -0,0 +1,27 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * + * Copyright (c) 2024 Intel Corporation. + * Jiaxi Chen + * Jiaan Lu + * + */ + +#include +#include +#include "cmpxadd.c" +void main() { + unsigned long uop1, uop2, uop3; + long op1, op2, op3; + struct OutputSigned 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..ab413e20 --- /dev/null +++ b/BM/cmpccxadd/cmplxadd_equal.c @@ -0,0 +1,27 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * + * Copyright (c) 2024 Intel Corporation. + * Jiaxi Chen + * Jiaan Lu + * + */ + +#include +#include +#include "cmpxadd.c" +void main() { + unsigned long uop1, uop2, uop3; + long op1, op2, op3; + struct OutputSigned 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..30ab7a22 --- /dev/null +++ b/BM/cmpccxadd/cmplxadd_less.c @@ -0,0 +1,27 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * + * Copyright (c) 2024 Intel Corporation. + * Jiaxi Chen + * Jiaan Lu + * + */ + +#include +#include +#include "cmpxadd.c" +void main() { + unsigned long uop1, uop2, uop3; + long op1, op2, op3; + struct OutputSigned 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..0e2103fb --- /dev/null +++ b/BM/cmpccxadd/cmplxadd_more.c @@ -0,0 +1,27 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * + * Copyright (c) 2024 Intel Corporation. + * Jiaxi Chen + * Jiaan Lu + * + */ + +#include +#include +#include "cmpxadd.c" +void main() { + unsigned long uop1, uop2, uop3; + long op1, op2, op3; + struct OutputSigned 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..5159e2b4 --- /dev/null +++ b/BM/cmpccxadd/cmpnbexadd_above.c @@ -0,0 +1,27 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * + * Copyright (c) 2024 Intel Corporation. + * Jiaxi Chen + * Jiaan Lu + * + */ + +#include +#include +#include "cmpxadd.c" +void main() { + unsigned long uop1, uop2, uop3; + long op1, op2, op3; + struct OutputUnsigned 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..8c92ca35 --- /dev/null +++ b/BM/cmpccxadd/cmpnbexadd_below.c @@ -0,0 +1,27 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * + * Copyright (c) 2024 Intel Corporation. + * Jiaxi Chen + * Jiaan Lu + * + */ + +#include +#include +#include "cmpxadd.c" +void main() { + unsigned long uop1, uop2, uop3; + long op1, op2, op3; + struct OutputUnsigned 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..ee7e8f97 --- /dev/null +++ b/BM/cmpccxadd/cmpnbexadd_equal.c @@ -0,0 +1,27 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * + * Copyright (c) 2024 Intel Corporation. + * Jiaxi Chen + * Jiaan Lu + * + */ + +#include +#include +#include "cmpxadd.c" +void main() { + unsigned long uop1, uop2, uop3; + long op1, op2, op3; + struct OutputUnsigned 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..5d4f6e79 --- /dev/null +++ b/BM/cmpccxadd/cmpnbxadd_above.c @@ -0,0 +1,27 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * + * Copyright (c) 2024 Intel Corporation. + * Jiaxi Chen + * Jiaan Lu + * + */ + +#include +#include +#include "cmpxadd.c" +void main() { + unsigned long uop1, uop2, uop3; + long op1, op2, op3; + struct OutputUnsigned 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..51f4afed --- /dev/null +++ b/BM/cmpccxadd/cmpnbxadd_below.c @@ -0,0 +1,27 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * + * Copyright (c) 2024 Intel Corporation. + * Jiaxi Chen + * Jiaan Lu + * + */ + +#include +#include +#include "cmpxadd.c" +void main() { + unsigned long uop1, uop2, uop3; + long op1, op2, op3; + struct OutputUnsigned 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..85debba2 --- /dev/null +++ b/BM/cmpccxadd/cmpnbxadd_equal.c @@ -0,0 +1,27 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * + * Copyright (c) 2024 Intel Corporation. + * Jiaxi Chen + * Jiaan Lu + * + */ + +#include +#include +#include "cmpxadd.c" +void main() { + unsigned long uop1, uop2, uop3; + long op1, op2, op3; + struct OutputUnsigned 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..27fe15dd --- /dev/null +++ b/BM/cmpccxadd/cmpnlexadd_equal.c @@ -0,0 +1,27 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * + * Copyright (c) 2024 Intel Corporation. + * Jiaxi Chen + * Jiaan Lu + * + */ + +#include +#include +#include "cmpxadd.c" +void main() { + unsigned long uop1, uop2, uop3; + long op1, op2, op3; + struct OutputSigned 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..4d6af6a2 --- /dev/null +++ b/BM/cmpccxadd/cmpnlexadd_less.c @@ -0,0 +1,27 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * + * Copyright (c) 2024 Intel Corporation. + * Jiaxi Chen + * Jiaan Lu + * + */ + +#include +#include +#include "cmpxadd.c" +void main() { + unsigned long uop1, uop2, uop3; + long op1, op2, op3; + struct OutputSigned 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..ba5f76b0 --- /dev/null +++ b/BM/cmpccxadd/cmpnlexadd_more.c @@ -0,0 +1,27 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * + * Copyright (c) 2024 Intel Corporation. + * Jiaxi Chen + * Jiaan Lu + * + */ + +#include +#include +#include "cmpxadd.c" +void main() { + unsigned long uop1, uop2, uop3; + long op1, op2, op3; + struct OutputSigned 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..3ec5a481 --- /dev/null +++ b/BM/cmpccxadd/cmpnlxadd_equal.c @@ -0,0 +1,27 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * + * Copyright (c) 2024 Intel Corporation. + * Jiaxi Chen + * Jiaan Lu + * + */ + +#include +#include +#include "cmpxadd.c" +void main() { + unsigned long uop1, uop2, uop3; + long op1, op2, op3; + struct OutputSigned 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..00940bd5 --- /dev/null +++ b/BM/cmpccxadd/cmpnlxadd_less.c @@ -0,0 +1,27 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * + * Copyright (c) 2024 Intel Corporation. + * Jiaxi Chen + * Jiaan Lu + * + */ + +#include +#include +#include "cmpxadd.c" +void main() { + unsigned long uop1, uop2, uop3; + long op1, op2, op3; + struct OutputSigned 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..c797d4d8 --- /dev/null +++ b/BM/cmpccxadd/cmpnlxadd_more.c @@ -0,0 +1,27 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * + * Copyright (c) 2024 Intel Corporation. + * Jiaxi Chen + * Jiaan Lu + * + */ + +#include +#include +#include "cmpxadd.c" +void main() { + unsigned long uop1, uop2, uop3; + long op1, op2, op3; + struct OutputSigned 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..8637492a --- /dev/null +++ b/BM/cmpccxadd/cmpnoxadd_not_overflow.c @@ -0,0 +1,27 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * + * Copyright (c) 2024 Intel Corporation. + * Jiaxi Chen + * Jiaan Lu + * + */ + +#include +#include +#include "cmpxadd.c" +void main() { + unsigned long uop1, uop2, uop3; + long op1, op2, op3; + struct OutputSigned 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..5d9b7e6a --- /dev/null +++ b/BM/cmpccxadd/cmpnoxadd_overflow.c @@ -0,0 +1,27 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * + * Copyright (c) 2024 Intel Corporation. + * Jiaxi Chen + * Jiaan Lu + * + */ + +#include +#include +#include "cmpxadd.c" +void main() { + unsigned long uop1, uop2, uop3; + long op1, op2, op3; + struct OutputSigned 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..35e3102e --- /dev/null +++ b/BM/cmpccxadd/cmpnpxadd_even.c @@ -0,0 +1,27 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * + * Copyright (c) 2024 Intel Corporation. + * Jiaxi Chen + * Jiaan Lu + * + */ + +#include +#include +#include "cmpxadd.c" +void main() { + unsigned long uop1, uop2, uop3; + long op1, op2, op3; + struct OutputUnsigned 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..ad2aaff6 --- /dev/null +++ b/BM/cmpccxadd/cmpnpxadd_odd.c @@ -0,0 +1,27 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * + * Copyright (c) 2024 Intel Corporation. + * Jiaxi Chen + * Jiaan Lu + * + */ + +#include +#include +#include "cmpxadd.c" +void main() { + unsigned long uop1, uop2, uop3; + long op1, op2, op3; + struct OutputUnsigned 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..403cf060 --- /dev/null +++ b/BM/cmpccxadd/cmpnsxadd_negative.c @@ -0,0 +1,27 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * + * Copyright (c) 2024 Intel Corporation. + * Jiaxi Chen + * Jiaan Lu + * + */ + +#include +#include +#include "cmpxadd.c" +void main() { + unsigned long uop1, uop2, uop3; + long op1, op2, op3; + struct OutputSigned 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..a62c7820 --- /dev/null +++ b/BM/cmpccxadd/cmpnsxadd_positive.c @@ -0,0 +1,27 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * + * Copyright (c) 2024 Intel Corporation. + * Jiaxi Chen + * Jiaan Lu + * + */ + +#include +#include +#include "cmpxadd.c" +void main() { + unsigned long uop1, uop2, uop3; + long op1, op2, op3; + struct OutputSigned 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..99e4e570 --- /dev/null +++ b/BM/cmpccxadd/cmpnzxadd_not_zero.c @@ -0,0 +1,27 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * + * Copyright (c) 2024 Intel Corporation. + * Jiaxi Chen + * Jiaan Lu + * + */ + +#include +#include +#include "cmpxadd.c" +void main() { + unsigned long uop1, uop2, uop3; + long op1, op2, op3; + struct OutputUnsigned 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..29f0a287 --- /dev/null +++ b/BM/cmpccxadd/cmpnzxadd_zero.c @@ -0,0 +1,27 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * + * Copyright (c) 2024 Intel Corporation. + * Jiaxi Chen + * Jiaan Lu + * + */ + +#include +#include +#include "cmpxadd.c" +void main() { + unsigned long uop1, uop2, uop3; + long op1, op2, op3; + struct OutputUnsigned 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..b66818f3 --- /dev/null +++ b/BM/cmpccxadd/cmpoxadd_not_overflow.c @@ -0,0 +1,27 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * + * Copyright (c) 2024 Intel Corporation. + * Jiaxi Chen + * Jiaan Lu + * + */ + +#include +#include +#include "cmpxadd.c" +void main() { + unsigned long uop1, uop2, uop3; + long op1, op2, op3; + struct OutputSigned 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..2ceeb08d --- /dev/null +++ b/BM/cmpccxadd/cmpoxadd_overflow.c @@ -0,0 +1,27 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * + * Copyright (c) 2024 Intel Corporation. + * Jiaxi Chen + * Jiaan Lu + * + */ + +#include +#include +#include "cmpxadd.c" +void main() { + unsigned long uop1, uop2, uop3; + long op1, op2, op3; + struct OutputSigned 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..74165078 --- /dev/null +++ b/BM/cmpccxadd/cmppxadd_even.c @@ -0,0 +1,27 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * + * Copyright (c) 2024 Intel Corporation. + * Jiaxi Chen + * Jiaan Lu + * + */ + +#include +#include +#include "cmpxadd.c" +void main() { + unsigned long uop1, uop2, uop3; + long op1, op2, op3; + struct OutputUnsigned 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..19340e16 --- /dev/null +++ b/BM/cmpccxadd/cmppxadd_odd.c @@ -0,0 +1,27 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * + * Copyright (c) 2024 Intel Corporation. + * Jiaxi Chen + * Jiaan Lu + * + */ + +#include +#include +#include "cmpxadd.c" +void main() { + unsigned long uop1, uop2, uop3; + long op1, op2, op3; + struct OutputUnsigned 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..46fa03de --- /dev/null +++ b/BM/cmpccxadd/cmpsxadd_negative.c @@ -0,0 +1,27 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * + * Copyright (c) 2024 Intel Corporation. + * Jiaxi Chen + * Jiaan Lu + * + */ + +#include +#include +#include "cmpxadd.c" +void main() { + unsigned long uop1, uop2, uop3; + long op1, op2, op3; + struct OutputSigned 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..e0d7e1e2 --- /dev/null +++ b/BM/cmpccxadd/cmpsxadd_positive.c @@ -0,0 +1,27 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * + * Copyright (c) 2024 Intel Corporation. + * Jiaxi Chen + * Jiaan Lu + * + */ + +#include +#include +#include "cmpxadd.c" +void main() { + unsigned long uop1, uop2, uop3; + long op1, op2, op3; + struct OutputSigned 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..c499f2cd --- /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 OutputUnsigned { + unsigned long rax; + unsigned long rbx; + unsigned long rcx; + unsigned long rflags; +}; + +struct OutputSigned { + long rax; + long rbx; + long rcx; + unsigned long rflags; +}; + +#define DEF_FUNC_UNSIGNED(name, insr, op1, op2, op3) \ +struct OutputUnsigned name(unsigned long op1, unsigned long op2, unsigned long op3) \ +{ \ + unsigned long rflags; \ + unsigned long rax, rbx, rcx; \ + struct OutputUnsigned 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 OutputSigned name(long op1, long op2, long op3) \ +{ \ + unsigned long rflags; \ + long rax, rbx, rcx; \ + struct OutputSigned 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); \ No newline at end of file diff --git a/BM/cmpccxadd/cmpzxadd_not_zero.c b/BM/cmpccxadd/cmpzxadd_not_zero.c new file mode 100644 index 00000000..3499da6a --- /dev/null +++ b/BM/cmpccxadd/cmpzxadd_not_zero.c @@ -0,0 +1,27 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * + * Copyright (c) 2024 Intel Corporation. + * Jiaxi Chen + * Jiaan Lu + * + */ + +#include +#include +#include "cmpxadd.c" +void main() { + unsigned long uop1, uop2, uop3; + long op1, op2, op3; + struct OutputUnsigned 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..371c9ef4 --- /dev/null +++ b/BM/cmpccxadd/cmpzxadd_zero.c @@ -0,0 +1,27 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * + * Copyright (c) 2024 Intel Corporation. + * Jiaxi Chen + * Jiaan Lu + * + */ + +#include +#include +#include "cmpxadd.c" +void main() { + unsigned long uop1, uop2, uop3; + long op1, op2, op3; + struct OutputUnsigned 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 b4cb9268..0a1d3b8a 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,7 @@ More details please refer to following. ## BM Features * [AMX](BM/amx/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)