mirror of
https://github.com/herumi/xbyak
synced 2024-11-20 16:06:14 -07:00
add sample/zero_upper.cpp
This commit is contained in:
parent
f17cb9d6b9
commit
bacd8d34b6
2 changed files with 53 additions and 1 deletions
|
@ -30,7 +30,7 @@ else
|
|||
endif
|
||||
|
||||
ifeq ($(BIT),64)
|
||||
TARGET += test64 bf64 memfunc64 test_util64 jmp_table64
|
||||
TARGET += test64 bf64 memfunc64 test_util64 jmp_table64 zero_upper
|
||||
ifeq ($(BOOST_EXIST),1)
|
||||
TARGET += calc64 #calc2_64
|
||||
endif
|
||||
|
@ -103,6 +103,10 @@ profiler: profiler.cpp ../xbyak/xbyak_util.h
|
|||
$(CXX) $(CFLAGS) profiler.cpp -o $@
|
||||
profiler-vtune: profiler.cpp ../xbyak/xbyak_util.h
|
||||
$(CXX) $(CFLAGS) profiler.cpp -o $@ -DXBYAK_USE_VTUNE -I /opt/intel/vtune_amplifier/include/ -L /opt/intel/vtune_amplifier/lib64 -ljitprofiling -ldl
|
||||
zero_upper: zero_upper.cpp $(XBYAK_INC)
|
||||
$(CXX) $(CFLAGS) zero_upper.cpp -o $@
|
||||
test_zero_upper: zero_upper
|
||||
sde -future -- ./zero_upper
|
||||
|
||||
clean:
|
||||
rm -rf $(TARGET) profiler profiler-vtune
|
||||
|
|
48
sample/zero_upper.cpp
Normal file
48
sample/zero_upper.cpp
Normal file
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
An example of T_zu (zero upper) flag
|
||||
> g++ zero_upper.cpp -I ../xbyak
|
||||
> sde -future -- ./a.out
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <xbyak/xbyak.h>
|
||||
|
||||
using namespace Xbyak;
|
||||
|
||||
struct Code : Xbyak::CodeGenerator {
|
||||
Code(int mode)
|
||||
{
|
||||
mov(eax, 0x12345678);
|
||||
cmp(eax, eax); // ZF=1
|
||||
switch (mode) {
|
||||
case 0: // imul
|
||||
puts("imul");
|
||||
imul(ax,ax, 0x1234);
|
||||
break;
|
||||
case 1: // imul+zu
|
||||
puts("imul+zu");
|
||||
imul(ax|T_zu, ax, 0x1234);
|
||||
break;
|
||||
case 2: // setz
|
||||
puts("setz");
|
||||
setz(al);
|
||||
break;
|
||||
case 3: // setz+zu
|
||||
puts("setz+zu");
|
||||
setz(al|T_zu);
|
||||
break;
|
||||
}
|
||||
ret();
|
||||
}
|
||||
};
|
||||
|
||||
int main()
|
||||
try
|
||||
{
|
||||
for (int mode = 0; mode < 4; mode++) {
|
||||
Code c(mode);
|
||||
auto f = c.getCode<int (*)()>();
|
||||
printf("ret=%08x\n", f());
|
||||
}
|
||||
} catch (std::exception& e) {
|
||||
printf("ERR %s\n", e.what());
|
||||
}
|
Loading…
Reference in a new issue