3 #include "jitcs_instructionstream.h"
4 #include "jitcs_dumper.h"
5 #include "jitcs_memmgr.h"
6 #include "jitcs_x86_32.h"
7 #include "jitcs_x86_64.h"
8 #include <unordered_set>
9 #include "jitcs_int_machine.h"
10 #include "jitcs_int_bitfuncs.h"
12 using namespace jitcs
;
14 static void test(UnitTest
& t
) {
15 typedef void (__cdecl
*FT0_c
)();
16 RefCounter
<IMachineInfo
> mi
= GetX86_32WinMachineInfo();
17 RefCounter
<TempAllocator
> alloc(new TempAllocator
);
18 RefCounter
<MemoryMgr
> mgr
= MemoryMgr::Create();
20 std::unique_ptr
<Function
> fn
= mi
->createFnc
<FT0_c
>(alloc
);
21 InstructionStreamBuffer
<256> ibuf
;
23 Ref
<BasicBlock
> bb1
= fn
->getStartBlock();
26 x86_32::MOV_WI(ibuf
, x86_32::EAX
, 0);
27 x86_32::ADD_WI(ibuf
, x86_32::EAX
, 1);
31 MemoryMgr::CodeAndData code
= fn
->generate(mgr
, Function::Direct_Code_Gen
);
35 std::string dumpresult
= dumper
.takeResult();
38 for (x86_32::InsClassId i
= x86_32::ICL_First
; i
< x86_32::ICL_Last
; ++i
) {
39 n
+= popcnt(x86_32::ToValidMask(i
));
41 t
.check("x86_32", dumpresult
== expected
);
45 static UnitTestRun
_("AllInstructions", test
);