Skip to content

Commit

Permalink
cmpccxadd: improve coding style
Browse files Browse the repository at this point in the history
Signed-off-by: Jiaan Lu <[email protected]>
  • Loading branch information
jiaanlu committed May 24, 2024
1 parent 97bcacc commit ff6fd6e
Show file tree
Hide file tree
Showing 41 changed files with 708 additions and 628 deletions.
34 changes: 18 additions & 16 deletions BM/cmpccxadd/cmpbexadd_above.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
/*
*
* Copyright (c) 2024 Intel Corporation.
* Jiaxi Chen <[email protected]>
Expand All @@ -10,18 +10,20 @@
#include <stdio.h>
#include <limits.h>
#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");
}
}
void main(void)
{
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");
}
}
34 changes: 18 additions & 16 deletions BM/cmpccxadd/cmpbexadd_below.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
/*
*
* Copyright (c) 2024 Intel Corporation.
* Jiaxi Chen <[email protected]>
Expand All @@ -10,18 +10,20 @@
#include <stdio.h>
#include <limits.h>
#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");
}
}
void main(void)
{
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");
}
}
32 changes: 17 additions & 15 deletions BM/cmpccxadd/cmpbexadd_equal.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,20 @@
#include <stdio.h>
#include <limits.h>
#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");
}
}
void main(void)
{
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");
}
}
30 changes: 16 additions & 14 deletions BM/cmpccxadd/cmpbxadd_above.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,20 @@
#include <stdio.h>
#include <limits.h>
#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");
}
void main(void)
{
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");
}
}
32 changes: 17 additions & 15 deletions BM/cmpccxadd/cmpbxadd_below.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,20 @@
#include <stdio.h>
#include <limits.h>
#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");
}
}
void main(void)
{
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");
}
}
30 changes: 16 additions & 14 deletions BM/cmpccxadd/cmpbxadd_equal.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,20 @@
#include <stdio.h>
#include <limits.h>
#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");
}
void main(void)
{
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");
}
}
30 changes: 16 additions & 14 deletions BM/cmpccxadd/cmplexadd_equal.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,20 @@
#include <stdio.h>
#include <limits.h>
#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");
}
void main(void)
{
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");
}
}
30 changes: 16 additions & 14 deletions BM/cmpccxadd/cmplexadd_less.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,20 @@
#include <stdio.h>
#include <limits.h>
#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");
}
void main(void)
{
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");
}
}
30 changes: 16 additions & 14 deletions BM/cmpccxadd/cmplexadd_more.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,20 @@
#include <stdio.h>
#include <limits.h>
#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");
}
void main(void)
{
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");
}
}
32 changes: 17 additions & 15 deletions BM/cmpccxadd/cmplxadd_equal.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,20 @@
#include <stdio.h>
#include <limits.h>
#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");
}
}
void main(void)
{
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");
}
}
Loading

0 comments on commit ff6fd6e

Please sign in to comment.