Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
misc.cpp File Reference
#include <stdio.h>
#include <string.h>
#include <string>
#include <xbyak/xbyak.h>
#include <cybozu/inttype.hpp>
#include <cybozu/test.hpp>
Include dependency graph for misc.cpp:

Go to the source code of this file.

Functions

 CYBOZU_TEST_AUTO (setSize)
 
 CYBOZU_TEST_AUTO (compOperand)
 
 CYBOZU_TEST_AUTO (mov_const)
 
 CYBOZU_TEST_AUTO (align)
 

Function Documentation

◆ CYBOZU_TEST_AUTO() [1/4]

CYBOZU_TEST_AUTO ( align )

Definition at line 85 of file misc.cpp.

86{
87 struct Code : Xbyak::CodeGenerator {
88 Code()
89 {
90 const size_t alignSize = 16;
91 for (int padding = 0; padding < 20; padding++) {
92 for (int i = 0; i < padding; i++) {
93 db(1);
94 }
95 align(alignSize);
96 CYBOZU_TEST_EQUAL(size_t(getCurr()) % alignSize, 0u);
97 }
98 align(alignSize);
99 const uint8 *p = getCurr();
100 // do nothing if aligned
101 align(alignSize);
103 }
104 } c;
105}
#define CYBOZU_TEST_EQUAL(x, y)
Definition test.hpp:199
const mie::Vuint & p
Definition bn.cpp:27
const uint8 * getCurr() const
Definition xbyak.h:908
void align(size_t x=16, bool useMultiByteNop=true)
Definition xbyak.h:2475
void db(int code)
Definition xbyak.h:882
unsigned char uint8
Definition bench.cpp:18
Code()
Definition memfunc.cpp:19
Here is the call graph for this function:

◆ CYBOZU_TEST_AUTO() [2/4]

CYBOZU_TEST_AUTO ( compOperand )

Definition at line 25 of file misc.cpp.

26{
27 using namespace Xbyak::util;
28 CYBOZU_TEST_ASSERT(eax == eax);
29 CYBOZU_TEST_ASSERT(ecx != xmm0);
30 CYBOZU_TEST_ASSERT(ptr[eax] == ptr[eax]);
31 CYBOZU_TEST_ASSERT(dword[eax] != ptr[eax]);
32 CYBOZU_TEST_ASSERT(ptr[eax] != ptr[eax+3]);
33}
#define CYBOZU_TEST_ASSERT(x)
Definition test.hpp:192

◆ CYBOZU_TEST_AUTO() [3/4]

CYBOZU_TEST_AUTO ( mov_const )

Definition at line 35 of file misc.cpp.

36{
37 struct Code : Xbyak::CodeGenerator {
38 Code()
39 {
40 const struct {
41 uint64_t v;
42 int bit;
43 bool error;
44 } tbl[] = {
45 { uint64_t(-1), 8, false },
46 { 0x12, 8, false },
47 { 0x80, 8, false },
48 { 0xff, 8, false },
49 { 0x100, 8, true },
50
51 { 1, 16, false },
52 { uint64_t(-1), 16, false },
53 { 0x7fff, 16, false },
54 { 0xffff, 16, false },
55 { 0x10000, 16, true },
56
57 { uint64_t(-1), 32, false },
58 { 0x7fffffff, 32, false },
59 { uint64_t(-0x7fffffff), 32, false },
60 { 0xffffffff, 32, false },
61 { 0x100000000ull, 32, true },
62
63#ifdef XBYAK64
64 { uint64_t(-1), 64, false },
65 { 0x7fffffff, 64, false },
66 { 0xffffffffffffffffull, 64, false },
67 { 0x80000000, 64, true },
68 { 0xffffffff, 64, true },
69#endif
70 };
71 for (size_t i = 0; i < CYBOZU_NUM_OF_ARRAY(tbl); i++) {
72 const int bit = tbl[i].bit;
73 const uint64_t v = tbl[i].v;
74 const Xbyak::AddressFrame& af = bit == 8 ? byte : bit == 16 ? word : bit == 32 ? dword : qword;
75 if (tbl[i].error) {
77 } else {
79 }
80 }
81 }
82 } code;
83}
#define CYBOZU_NUM_OF_ARRAY(x)
Definition inttype.hpp:58
#define CYBOZU_TEST_EXCEPTION(statement, Exception)
Definition test.hpp:285
#define CYBOZU_TEST_NO_EXCEPTION(statement)
Definition test.hpp:310
const Reg32 eax
Definition xbyak.h:2087
const AddressFrame dword
Definition xbyak.h:2090
const AddressFrame byte
Definition xbyak.h:2090
const AddressFrame qword
Definition xbyak.h:2090
const AddressFrame word
Definition xbyak.h:2090
void mov(const Operand &reg1, const Operand &reg2)
Definition xbyak.h:2210
const struct Ptn tbl[]
unsigned __int64 uint64_t
Definition stdint.h:136
int bit
Definition yubihsm.h:566
Here is the call graph for this function:

◆ CYBOZU_TEST_AUTO() [4/4]

CYBOZU_TEST_AUTO ( setSize )

Definition at line 10 of file misc.cpp.

11{
12 struct Code : Xbyak::CodeGenerator {
13 Code() : Xbyak::CodeGenerator(4096)
14 {
15 setSize(4095);
16 db(1);
17 size_t size = getSize();
18 CYBOZU_TEST_EQUAL(size, 4096u);
21 }
22 } code;
23}
void setSize(size_t size)
Definition xbyak.h:912
size_t getSize() const
Definition xbyak.h:911
Definition xbyak.h:104
Here is the call graph for this function: