mirror of
https://github.com/herumi/xbyak
synced 2024-11-20 16:06:14 -07:00
No description
gen | ||
sample | ||
test | ||
xbyak | ||
COPYRIGHT | ||
Makefile | ||
readme.txt | ||
readme_e.txt | ||
xbyak.sln |
C++眙帹x86(IA-32), x64(AMD64, x86-64) JIT邂帰邂幓邈幊邈体Λ Xbyak version 2.24 ----------------------------------------------------------------------------- 泖艰帵り帵<E3828A> 遽棋l遽幆x86, x64(AMD64, x86-64)遽幃邈苠す邈幊瓞茜驴杞帳邂拈取腓厘※邂丹++遽幃邂幆邈帺邂幑邈帺邂帳邈体Λ邈帾遽帶遽荫幖<E88DAB> 邈五Ο邂幇邈帺邈帬臧揸帯歌砚遽帿殡书愉遽帿邂帰邂幓邈幊邈体Ν遽义k遽棋ⅹ遽哥颈镢幗遽帶遽荫幖<E88DAB> ----------------------------------------------------------------------------- 泖奸不昀幋 邈幓邈绣ャ邈€邈叔ぃ邂帳邈帿邂帾邈幊邈帾邈幖 xbyak.h邂腻う邈幊邂幆邈帿邈幖邈插※邂跺ⅱ遽洛ⅸ遽义○殍帺眙帹遽义k遽棋ⅹ遽稿ⅸ遽哄⒗遽荫幖<E88DAB> C++遽幃膻帬罘ㄥ⒘殒<E29298>ⅸ聆插▲遽帵遽ㄥk遽掊a<E68E8A>哥帳屉Κ邂帰邂幓邈幊邈体Λ遽幆韬宏帵㈠ⅸ遽荫幖<E88DAB> 32bit/64bit韬帯瓯幘炅劐ⅸ遽荫幖<E88DAB> 瓯幘炅劐ル邈幖邈帰邈跺ャ邂幆:黹幑飒帺轳幗杞帳聩帳遽劫86, MMX/MMX2/SSE/SSE2/SSE3/SSSE3/SSE4/FPU(韬€胥帹) 邈幓Windows Xp(32bit, 64bit), Vista/Linux(32bit, 64bit)/Intel Mac瓯幘炅<E5B998> Windows Xp韬村ⅸ遽幆VC2005 Express Ed., VC2008 Windows Vista Linux (kernel 2.4.32)韬村ⅸ遽幆gcc 4.3.0, CentOS 5.1韬村ⅸ遽幆gcc 4.1.2 Intel Mac 遽帾遽帺遽帶殡舒幗亻帰幒瓞哄r遽五ⅷ遽ㄥ⒗遽荫幖<E88DAB> 汔幓 gcc遽帶遽幆and, or, xor遽帾遽帺邂蔫幖乳幃午幁厘ⅹ遽五ⅷ皓帲耒板△遽帵遽五⒗遽<E29297>ⅰ邂Ⅰ幖<E285A0> -fno-operator-names邂帾邈五す邈帶邈幊邂年幙幗殛帬遽五ⅷ邂幊邈幊邈洛う邈帿遽五ⅷ遽惧ⅱ遽叔′<E58F94><E280B2> ----------------------------------------------------------------------------- 泖艰幒嚏y xbyak.h xbyak_bin2hex.h xbyak_mnemonic.h 遽棋l邂插r轲告幐€遽幃邈洛せ遽帿殄帴邂稿ⅷ邂帳邈幊邂幆邈帿邈幖邈插ヱ邂幑遽帿鹆幗殛帬遽五ⅷ遽惧ⅱ遽叔′<E58F94><E280B2> Linux遽帶遽幆make install遽帶/usr/local/include/xbyak遽帿邂幊邈儒<E98288>遽叔l遽幘遽荫幖<E88DAB> ----------------------------------------------------------------------------- 泖艰绥斓<E7BBA5> Xbyak::CodeGenerator 邂幆邈帺邂幑邂拈幎诣擦遽务幖稿↓遽幃邂幆邈帺邂幑邈帯邂幗邈﹀ラ殒<E383A9>ⅸx86, x64邂帰邂幓邈幊邈体Λ邂<CE9B> 皙嘘幙幇遽五⒗遽荫幖煎↓遽幃邈帯邂幗邈﹀ラ邂溺戮遽幊殓幒遽五ⅰ昀格幖啡etCode()邈帯邂幗邈﹀ラ邂溺戮遽幊殓幒遽务幖稿↓遽幃腓幓 邂寸€帳邂年<E98282>殍<EFBFBD>§杩幙遽ㄥⅰ遽<E285B0>踏膈幇邈阱う邈幊邂幙遽帿軎茶禁遽五ⅷ殍帺眙帹遽五⒗遽荫幖煎い邂幓邈幊邈体Ν邂帹邈帺邈幖遽幆枥剁帳<E58981> 遽帿邂板j襦蚤蕨遽叔l遽幘遽<E5B998>(cf. main.cpp)<29><> 邈幓辍幒朦幀睑ㄥ<E79D91>nasm遽幃轳幗杞帳遽帶腚幀昃帶邂腻ⅵ遽洛l遽幇邂板′遽帶遽荫幖<E88DAB> mov eax, ebx --> mov(eax, ebx); inc ecx inc(ecx); ret --> ret(); 邈幓邂帰邈插Ξ邈﹀す邈幊邂幇 (ptr|dword|word|byte) [base + index * (1|2|4|8) + displacement] 遽帹遽ㄥ℃昕帰遽帶腱<E5B8B6>幃藻△遽幘遽荫幖煎し邂帳邂幒邂蔫风臧藻※邂剁幙<E58981>帵㈠§遽帾遽<E5B8BE>佯邂逞tr邂逆幗幙遽板⒉邂板′遽帶遽荫幖<E88DAB> 邂幓邈幀邂幆邂幙遽幆邂幍邈阱<E98288>邈板△遽帵遽ㄥ⒗遽皱s<E79AB1><EFBD93> mov eax, [ebx+ecx] --> mov (eax, ptr[ebx+ecx]); test byte [esp], 4 --> test (byte [esp], 4); (斓帹脘<E5B8B9>) dword, word, byte遽幆邂幆邈帺邂幑軎茶什遽帶遽荫幖肩幘棋ⅴ遽帵遽掊ⅹ遽板⒉unsigned int遽幃 遽帳邂ゅj遽帶dword邂谜ypedef遽五<E981BD>遽ㄥⅸ遽惧ⅱ遽叔′<E58F94><E280B2> 邈幓邈帺邈义Ν L(膂<>幁午<E5B981>); 遽帶臧蚤幘帺遽五⒗遽荫幖煎ず邈帲邈幊邈五※邂跺ⅹ遽哄⒈遽阱<E981BD>膂<EFBFBD>幁午<E5B981>邂蔫风臧藻△遽幘遽荫幖肩幘歌袒轱ら<E8BDB1>邂ょ颈镢幗遽帶遽义§<E4B989><C2A7> 睇幐瓯幘邂帰邈插Ξ邂幑遽<E5B991>8邈棋ャ邈板<E98288>轱煎⒗邂插<E98282>遽ㄧ帬幋轲板⒈T_NEAR邂腻ⅵ遽洛<E981BD>遽ㄥⅹ臧揸帯歌砚遽帿枥剁帳体§睐幒眙<E5B992> 遽五⒗遽荫幖<E88DAB> 邈幓hasUndefinedLabel()邂溺戮遽幊殓幒遽五ⅷ睃掊<E79D83>邂插ず邈帲邈幊邈午╄遽哥幁戌鬲遽五<E981BD>遽ㄥ◇遽帹邂拈帳幒遽五⒗遽荫幖<E88DAB> 邂幊邈幖邈插r皎堕侄遽五ⅷ遽惧ⅱ遽叔′<E58F94><E280B2> L("L1"); jmp ("L1"); jmp ("L2"); ... 瓴洛△遽幃轳幗杞帳遽幃辎幋轲榜幖<E6A69C> ... L("L2"); jmp ("L3", T_NEAR); ... 齑帰瓿幈遽幃轳幗杞帳遽稿♀邂剁帬幋轲<E5B98B> ... L("L3"); <炅亻泉罟帹> 1. MASM邈帺邂帳邂幆遽帾@@, @f, @b邂腻し邈阱<E98288>邈<EFBFBD> L("@@"); // <A> jmp("@b"); // jmp to <A> jmp("@f"); // jmp to <B> L("@@"); // <B> jmp("@b"); // jmp to <B> 2. 邈帺邈义Ν遽幃瓿€腴€殪<E282AC> 邈儒Μ邂帾邈插ⅸ戛跺⒗邂跺Λ邈义Ν邂檬nLocalLabel(), outLocalLabel()遽帶腱掊`遽棋ⅹ遽帶瓿€腴€殪体ⅸ遽哄⒗遽荫幖<E88DAB> void func1() { inLocalLabel(); L(".lp"); // <A> ... jmp(".lp"); // jmpt to <A> outLocalLabel(); } void func2() { L(".lp"); // <B> func1(); jmp(".lp"); // jmp to <B> } 韬搓帹绣し邈幊邈五Ν遽帶遽幆inLocalLabel(), outLocalLabel()遽搁ǎ遽ㄥⅹ<E384A5><E285B9> ".lp"邈帺邈义Ν遽幃杓鸽<E69D93>臧蚤幘帺邂帹邈帺邈幖遽帿遽帾邂村⒗遽荫幖<E88DAB> 邈幓Xbyak::CodeGenerator()邂幊邈幊邂幑邈板Λ邂幆邂幙邂帳邈幊邂幙邈叔ぉ邈幖邂幑 @param maxSize [in] 邂幊邈幖邈查取腓黎奏軎帶邂幍邂帳邂幒(邈<>ヵ邂帺邈帿邈<E5B8BF>2048byte) @param userPtr [in] 邈帵邈幖邂幎腱<E5B98E>幃藻Γ邈帰邈帾 CodeGenerator(size_t maxSize = DEFAULT_MAX_CODE_SIZE, void *userPtr = 0); 邈<>ヵ邂帺邈帿邈板さ邈幖邈插し邂帳邂幒遽幆2048(=DEFAULT_MAX_CODE_SIZE)邈厘う邈板ⅸ遽荫幖<E88DAB> 遽阱l邂板j軎帶遽哄<E981BD>邂幊邈幖邈插r眙掼<E79C99>遽义k辎幋轲板⒈CodeGenerator()遽幃邂幊邈幊邂幑邈板Λ邂幆邂幙遽帿腱<E5B8BF>幃藻△遽帵遽惧ⅱ遽叔′<E58F94><E280B2> class Quantize : public Xbyak::CodeGenerator { public: Quantize() : CodeGenerator(8192) { } ... }; # 殡书愉遽帿遽五ⅰ遽幓遽<E5B993>§邂板′遽幃遽帬遽哥幃揸帯哥幈荑€帶遽幃畎帯眇<E5B8AF>§颀帰猷腻ⅸ邂ㄥⅴ遽帵遽幘遽皱s汔帵<E6B194><E5B8B5> 遽幘遽掊Θ邈幖邂幎腱<E5B98E>幃藻Γ邈帰邈帾邂腻さ邈幖邈查取腓黎奏軎帶邂幍邂帳邂幒遽帹殄幈遽帿腱<E5B8BF>幃藻※邂跺ⅹ<E8B7BA>筏odeGenerator遽幆 腱<>幃藻□邂稿ⅰ邈帯邈帰邈帾韬村<E99FAC>邈厘う邈扮<E98288>邂拈取腓厘△遽幘遽荫幖<E88DAB> 邂幍邈阱<E98288>邈半踏膈幇遽帹遽五ⅷ腱<E285B7>幃藻□邂稿ⅰ邂帰邈插Ξ邂幑遽幃臧揸帯哥幈荑€帶邂溺帳茶侄遽义kCodeArray::protect()遽帹 韬煎¤邂插l遽掊<E981BD>邂帳邈幊邂幙遽跺i邂帰邈帺邂帳邈帯邈幊邈板□邂稿ⅰ邈阱う邈幊邂幙邂溺仅昀五※邂丹odeArray::getAlignedAddress() 邂ら泉脘惧△遽幘遽五ⅰ<E4BA94>缄帺幊疃幇遽幆sample/test0.cpp遽幃use memory allocated by user邂溺解镟﹀<E9959F> 遽五ⅷ遽惧ⅱ遽叔′<E58F94><E280B2> /** change exec permission of memory @param addr [in] buffer address @param size [in] buffer size @param canExec [in] true(enable to exec), false(disable to exec) @return true(success), false(failure) */ bool CodeArray::protect(const void *addr, size_t size, bool canExec); /** get aligned memory pointer */ uint8 *CodeArray::getAlignedAddress(uint8 *addr, size_t alignedSize = ALIGN_SIZE); 遽阱<E981BD>杞剃帺幊疃幇遽幆轲ㄩ帹幃邂幍邈幊邈五Ν邂溺解礤帶遽五ⅷ遽惧ⅱ遽叔′<E58F94><E280B2> ----------------------------------------------------------------------------- 泖煎<E6B396>邂幆邈幁 32bit眚幇辘︽幐村ⅸ邂幊邈幊邈洛う邈帿遽义k遽帹XBYAK32遽格幖<E6A0BC>64bit眚幇辘︽幐村ⅸ邂幊邈幊邈洛う邈帿遽义k遽帹XBYAK64遽<34> 臧蚤幘帺遽叔l遽幘遽荫幖煎□邂插<E98282>64bit眚幇辘︽幐村ⅸ遽幆Windows遽帾邂惫BYAK64_WIN<49>啡cc韬村ⅸ遽幆XBYAK64_GCC 邂ょ幃蚤幘帺遽叔l遽幘遽荫幖<E88DAB> ----------------------------------------------------------------------------- 泖兼幗幙眙帹枥<E5B8B9> test0.cpp ; 畈帯轫绣<E8BDAB>枥<EFBFBD>(x86, x64) quantize.cpp ; 殚幉邂撮幃五<E5B983>JIT邂帰邂幓邈幊邈体Ν遽帿邂板k耒剧幁犁扶遽幃颦须€掮扶(x86) calc.cpp ; 韬煎¤邂插l遽掮帳噪帬<E599AA>幖惧r邂帰邂幓邈幊邈体Ν遽五ⅷ臧揸帯<E68FB8>(x86, x64) boost(http://www.boost.org/)遽哥幙<E593A5>帵<EFBFBD> bf.cpp ; JIT Brainfuck(x86, x64) ----------------------------------------------------------------------------- 泖艰幊帹脘<E5B8B9> MMX/SSE轳幗杞帳遽幆遽幓遽幖殄帹遽帵臧揸帲<E68FB8>□邂稿ⅷ遽ㄥ⒗遽义§<E4B989><C2A7>3D Now!轳幗杞帳邂<E5B8B3>幖告幐€胥帹遽幃黹幑彀村<E5BD80> 轳幗杞帳遽幆盹幘膣らせ遽帶遽幆臧揸帲<E68FB8>□邂稿ⅷ遽ㄥ⒗遽皱s<E79AB1>户PU遽幃80bit旆幃殡淑幇捐什遽幆邂幍邈阱<E98288>邈板△遽帵遽ㄥ⒗遽皱s<E79AB1><EFBD93> 杩叔‰遽汝帵㈣<E5B8B5>遽稿♀邂稿⒉遽入€帲罘帯遽惧ⅱ遽叔′<E58F94><E280B2> ----------------------------------------------------------------------------- 泖煎Λ邂帳邂幓邈幊邂幑 枇幃殳帲遽叔l遽掼滩遽五′BSD邈帺邂帳邂幓邈幊邂幑遽帿昀棋′遽幘遽荫幖<E88DAB> http://www.opensource.jp/licenses/bsd-license.html sample/{echo,hello}.bf遽幆 http://www.kmonos.net/alang/etc/brainfuck.php 遽跺i 遽ㄥⅰ遽帬遽哄⒗遽五ⅰ<E4BA94><E285B0> ----------------------------------------------------------------------------- 泖肩幈帴殳幋 2010/04/16 ver 2.24 change the prototype of rewrite() method 2010/04/15 ver 2.23 fix align() and xbyak_util.h for Mac 2010/02/16 ver 2.22 fix inLocalLabel()/outLocalLabel() 2009/12/09 ver 2.21 support cygwin(gcc 4.3.2) 2009/11/28 ver 2.20 FPU遽幃韬€胥帹轳幗杞帳邂幍邈阱<E98288>邈<EFBFBD> 2009/06/25 ver 2.11 64bit邈帰邈幖邈插ⅸ遽幃 mov(qword[rax], imm); 枇幃殳帲(thanks to Martin遽叔s) 2009/03/10 ver 2.10 jmp/call reg64遽幃殒坞使遽帾REG.W殚措姚 2009/02/24 ver 2.09 movq reg64, mmx/xmm; movq mmx/xmm, reg64鹆幗殛帬 2009/02/13 ver 2.08 movd(xmm7, dword[eax])遽<>0x66邂年揽遽帹遽义ヰ邂幇枇幃殳帲(thanks to Gabest遽叔s) 2008/12/30 ver 2.07 call()遽幃睇幐瓯幘邂帰邈插Ξ邂幑遽<E5B991>8bit杞帴韬跺<E99FAC>遽帹遽哄<E981BD>邈厘げ枇幃殳帲(thanks to kato遽叔s) 2008/09/18 ver 2.06 @@, @f, @b遽帹邈帺邈义Ν遽幃瓿€腴€殪惕帺揸<E5B8BA>鹆幗殛帬(thanks to nobu-q遽叔s) 2008/09/18 ver 2.05 ptr [rip + 32bit offset]邂幍邈阱<E98288>邈<EFBFBD>(thanks to 辂帲戬犁吉(Dango-Chu)遽叔s) 2008/06/03 ver 2.04 align()遽幃邈阱き邈掊せ枇幃殳帲<E6AEB3>晃ov(ptr[eax],1);遽帾遽帺邂腻お邈帺邈幖遽帿 2008/06/02 ver 2.03 邈帵邈幖邂幎臧蚤幘帺邈帯邈帰邈帾邂帳邈幊邂幙邈叔ぉ邈幖邂幑邂幍邈阱<E98288>邈<EFBFBD> 2008/05/26 ver 2.02 protect()(on Linux)遽帶韬鸿幁帲遽帾皙幁臧藻<E887A7>遽帾邂跺◇遽帹遽稿♀邂跺<E98282>邂逆幙幃殳帲(thanks to sinichiro_h遽叔s) 2008/04/30 ver 2.01 cmpxchg16b, cdqe鹆幗殛帬 2008/04/29 ver 2.00 x86/x64-64黹扮<E9BBB9>聆<EFBFBD> 2008/04/25 ver 1.90 x86黹靶幉殄幀聆<E5B980> 2008/04/18 ver 1.12 邂幊邈幖邈茶识眇<E8AF86> 2008/04/14 ver 1.11 邂幊邈幖邈茶识眇<E8AF86> 2008/03/12 ver 1.10 bsf/bsr鹆幗殛帬(炅绣l遽帵遽ㄥⅰ) 2008/02/14 ver 1.09 sub eax, 1234遽<34>16bit邈帰邈幖邈插ⅸ殓幒殛皱□邂稿ⅷ遽ㄥⅰ遽幃邂逆幙幃殳帲(thanks to Robert遽叔s) 2007/11/05 ver 1.08 lock, xadd, xchg鹆幗殛帬 2007/11/02 ver 1.07 SSSE3/SSE4瓯幘炅<E5B998>(thanks to 辂帲戬犁吉(Dango-Chu)遽叔s) 2007/09/25 ver 1.06 call((int)聆帰膈幇邈阱う邈幊邂幙); jmp((int)聆帰膈幇邈阱う邈幊邂幙);遽幃邂幍邈阱<E98288>邈<EFBFBD> 2007/08/04 ver 1.05 疃幇遽跺′枇幃殳帲 2007/02/04 昀歌袒遽幐遽幃邂幐邈帲邈幊邈五ⅸT_NEAR邂腻ⅵ遽洛<E981BD>遽ㄥⅹ遽哄<E981BD>8bit睇幐瓯幘邂帰邈插Ξ邂幑遽帿殄帴邂插<E98282>遽<EFBFBD> 辎幋轲板<E8BDB2>枥剁帳体§睐幒眙掊△遽帾遽ㄥヰ邂幇遽幃枇幃殳帲 2007/01/21 [disp]遽幃昕帰遽幃邂帰邈插Ξ邂幑眙掼<E79C99>遽幃邈厘げ枇幃殳帲 mov (eax|ax|al, [disp]); mov([disp], eax|ax|al);遽幃睢幁遽<E5B981>帯帹盹幘襻幐腙<E5B990> 2007/01/17 web邈藻<E98288>邂幐杩罔<E69DA9> 2007/01/04 殄幀聆峨穗戛<E7A997> ----------------------------------------------------------------------------- 泖缄流杩罔帹帺镟<E5B8BA> 殄茶<E6AE84>旖堕取(MITSUNARI Shigeo, herumi at nifty dot com) --- $Revision: 1.56 $ $Date: 2010/04/16 11:58:22 $