Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
herumi committed Oct 7, 2024
2 parents ccdf684 + cb7d994 commit 900c984
Show file tree
Hide file tree
Showing 21 changed files with 89 additions and 21 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.5)

project(xbyak LANGUAGES CXX VERSION 7.07.1)
project(xbyak LANGUAGES CXX VERSION 7.08)

file(GLOB headers xbyak/*.h)

Expand Down
1 change: 1 addition & 0 deletions doc/changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# History

* 2024/Oct/07 ver 7.08 support rdfsbase etc.
* 2024/Aug/29 ver 7.07.1 adapt to NASM 2.16.03 output of xchg (The functionality stays the same.)
* 2024/Jun/11 ver 7.07 support xresldtrk/xsusldtrk
* 2024/Mar/07 ver 7.06 Xbyak::util::Cpu supports AMD processor
Expand Down
9 changes: 9 additions & 0 deletions gen/gen_code.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2057,6 +2057,15 @@ void put64()
// encodekey
puts("void encodekey128(const Reg32& r1, const Reg32& r2) { opEncodeKey(r1, r2, 0xFA, 0xDA); }");
puts("void encodekey256(const Reg32& r1, const Reg32& r2) { opEncodeKey(r1, r2, 0xFB, 0xDB); }");
// read/write fs/gs
{
const char *tbl[] = {
"rdfs", "rdgs", "wrfs", "wrgs"
};
for (int i = 0; i < 4; i++) {
printf("void %sbase(const Reg32e& r) { opRR(%s, r, T_F3|T_0F, 0xAE); }\n", tbl[i], Reg(i, Operand::REG, 32).toString());
}
}
}

void putAMX_TILE()
Expand Down
2 changes: 1 addition & 1 deletion meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
project(
'xbyak',
'cpp',
version: '7.07.1',
version: '7.08',
license: 'BSD-3-Clause',
default_options: 'b_ndebug=if-release'
)
Expand Down
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

# Xbyak 7.07.1 [![Badge Build]][Build Status]
# Xbyak 7.08 [![Badge Build]][Build Status]

*A C++ JIT assembler for x86 (IA32), x64 (AMD64, x86-64)*

Expand Down
3 changes: 2 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

C++用x86(IA-32), x64(AMD64, x86-64) JITアセンブラ Xbyak 7.07.1
C++用x86(IA-32), x64(AMD64, x86-64) JITアセンブラ Xbyak 7.08

-----------------------------------------------------------------------------
◎概要
Expand Down Expand Up @@ -404,6 +404,7 @@ sample/{echo,hello}.bfは http://www.kmonos.net/alang/etc/brainfuck.php から
-----------------------------------------------------------------------------
◎履歴

2024/10/17 ver 7.08 rdfabaseなどサポート
2024/08/29 ver 7.07.1 xchgの仕様をnasm 2.16.03の挙動に合わせる。
2024/06/11 ver 7.07 xresldtrk/xsusldtrkサポート
2024/03/07 ver 7.06 util::Cpuのキャッシュ判定周りがAMD CPU対応
Expand Down
19 changes: 15 additions & 4 deletions sample/bf.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#define XBYAK_NO_OP_NAMES
#include "xbyak/xbyak.h"
#include <stdio.h>
#include <stdlib.h>
Expand Down Expand Up @@ -189,18 +188,30 @@ int main(int argc, char *argv[])
fprintf(stderr, "64bit mode\n");
#endif
if (argc == 1) {
fprintf(stderr, "bf filename.bf [0|1]\n");
fprintf(stderr, "bf filename.bf [0|1|2]\n");
return 1;
}
std::ifstream ifs(argv[1]);
int mode = argc == 3 ? atoi(argv[2]) : 0;
try {
Brainfuck bf(ifs);
if (mode == 0) {
switch (mode) {
case 0: {
static int stack[128 * 1024];
bf.getCode<void (*)(const void*, const void*, int *)>()(reinterpret_cast<const void*>(putchar), reinterpret_cast<const void*>(getchar), stack);
} else {
break;
}
case 1: {
dump(bf.getCode(), bf.getSize());
break;
}
default: {
const char *dumpName = "bf.dump";
printf("dump to %s\n", dumpName);
std::ofstream ofs(dumpName, std::ios::binary);
ofs.write((const char*)bf.getCode(), bf.getSize());
break;
}
}
} catch (std::exception& e) {
printf("ERR:%s\n", e.what());
Expand Down
1 change: 0 additions & 1 deletion sample/calc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#include <stdio.h>
#include <sstream>
#include <map>
#define XBYAK_NO_OP_NAMES
#include "xbyak/xbyak.h"
#ifdef _MSC_VER
#pragma warning(disable : 4127) // for boost(constant condition)
Expand Down
1 change: 0 additions & 1 deletion sample/calc2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#include <assert.h>
#include <string>
#include <vector>
#define XBYAK_NO_OP_NAMES
#include "xbyak/xbyak.h"

enum Operand {
Expand Down
1 change: 0 additions & 1 deletion sample/jmp_table.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
sample of move(reg, LABEL);, L(LABEL), putL(LABEL);
*/
#include <stdio.h>
#define XBYAK_NO_OP_NAMES
#include <xbyak/xbyak.h>

const int expectTbl[] = {
Expand Down
2 changes: 2 additions & 0 deletions sample/memfd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class Code : Xbyak::MmapAllocator, public Xbyak::CodeGenerator {

int main()
{
printf("pid=%d\n", getpid());
Code c1("Xbyak::abc", 123);
Code c2("Xbyak::xyz", 456);
printf("c1 %d\n", c1.getCode<int (*)()>()());
Expand All @@ -36,4 +37,5 @@ int main()
printf("%s\n", line.c_str());
}
}
getchar();
}
1 change: 0 additions & 1 deletion sample/memfunc.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <memory.h>
#define XBYAK_NO_OP_NAMES
#include <xbyak/xbyak.h>

struct A {
Expand Down
1 change: 0 additions & 1 deletion sample/protect-re.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#define XBYAK_NO_OP_NAMES
#include <xbyak/xbyak.h>

struct Code1 : Xbyak::CodeGenerator {
Expand Down
1 change: 0 additions & 1 deletion sample/quantize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define XBYAK_NO_OP_NAMES
#include "xbyak/xbyak.h"
#ifdef _MSC_VER
#pragma warning(disable : 4996) // scanf
Expand Down
1 change: 0 additions & 1 deletion sample/stackframe.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#define XBYAK_NO_OP_NAMES
#include <xbyak/xbyak_util.h>

#ifdef XBYAK32
Expand Down
1 change: 0 additions & 1 deletion sample/static_buf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
sample to use static memory
*/
#include <stdio.h>
#define XBYAK_NO_OP_NAMES
#include "xbyak/xbyak.h"

MIE_ALIGN(4096) char buf[4096];
Expand Down
1 change: 0 additions & 1 deletion sample/test0.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#endif
#include <stdio.h>
#include <stdlib.h>
#define XBYAK_NO_OP_NAMES
#include "xbyak/xbyak.h"

class Sample : public Xbyak::CodeGenerator {
Expand Down
1 change: 0 additions & 1 deletion sample/toyvm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
#include <stdlib.h>
#include <memory.h>
#include <vector>
#define XBYAK_NO_OP_NAMES
#include "xbyak/xbyak.h"
#include "xbyak/xbyak_util.h"
#define NUM_OF_ARRAY(x) (sizeof(x) / sizeof(x[0]))
Expand Down
52 changes: 51 additions & 1 deletion test/misc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2284,5 +2284,55 @@ CYBOZU_TEST_AUTO(avx_vnni_int)
CYBOZU_TEST_EQUAL_ARRAY(c.getCode(), tbl, n);
}


CYBOZU_TEST_AUTO(rdfsbase)
{
struct Code : Xbyak::CodeGenerator {
Code()
{
rdfsbase(rax);
rdfsbase(r15d);
rdfsbase(r30d);
rdfsbase(r31);

rdgsbase(rax);
rdgsbase(r15d);
rdgsbase(r30d);
rdgsbase(r31);

wrfsbase(rax);
wrfsbase(r15d);
wrfsbase(r30d);
wrfsbase(r31);

wrgsbase(rax);
wrgsbase(r15d);
wrgsbase(r30d);
wrgsbase(r31);
}
} c;
const uint8_t tbl[] = {
0xf3, 0x48, 0x0f, 0xae, 0xc0,
0xf3, 0x41, 0x0f, 0xae, 0xc7,
0xf3, 0xd5, 0x91, 0xae, 0xc6,
0xf3, 0xd5, 0x99, 0xae, 0xc7,

0xf3, 0x48, 0x0f, 0xae, 0xc8,
0xf3, 0x41, 0x0f, 0xae, 0xcf,
0xf3, 0xd5, 0x91, 0xae, 0xce,
0xf3, 0xd5, 0x99, 0xae, 0xcf,

0xf3, 0x48, 0x0f, 0xae, 0xd0,
0xf3, 0x41, 0x0f, 0xae, 0xd7,
0xf3, 0xd5, 0x91, 0xae, 0xd6,
0xf3, 0xd5, 0x99, 0xae, 0xd7,

0xf3, 0x48, 0x0f, 0xae, 0xd8,
0xf3, 0x41, 0x0f, 0xae, 0xdf,
0xf3, 0xd5, 0x91, 0xae, 0xde,
0xf3, 0xd5, 0x99, 0xae, 0xdf,
};
const size_t n = sizeof(tbl) / sizeof(tbl[0]);
CYBOZU_TEST_EQUAL(c.getSize(), n);
CYBOZU_TEST_EQUAL_ARRAY(c.getCode(), tbl, n);
}
#endif
2 changes: 1 addition & 1 deletion xbyak/xbyak.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ namespace Xbyak {

enum {
DEFAULT_MAX_CODE_SIZE = 4096,
VERSION = 0x7071 /* 0xABCD = A.BC(.D) */
VERSION = 0x7080 /* 0xABCD = A.BC(.D) */
};

#ifndef MIE_INTEGER_TYPE_DEFINED
Expand Down
6 changes: 5 additions & 1 deletion xbyak/xbyak_mnemonic.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const char *getVersionString() const { return "7.07.1"; }
const char *getVersionString() const { return "7.08"; }
void aadd(const Address& addr, const Reg32e &reg) { opMR(addr, reg, T_0F38, 0x0FC, T_APX); }
void aand(const Address& addr, const Reg32e &reg) { opMR(addr, reg, T_0F38|T_66, 0x0FC, T_APX|T_66); }
void adc(const Operand& op, uint32_t imm) { opOI(op, imm, 0x10, 2); }
Expand Down Expand Up @@ -1937,6 +1937,10 @@ void aesencwide128kl(const Address& addr) { opSSE_APX(xmm0, addr, T_F3|T_0F38, 0
void aesencwide256kl(const Address& addr) { opSSE_APX(xmm2, addr, T_F3|T_0F38, 0xD8, T_F3|T_MUST_EVEX, 0xD8); }
void encodekey128(const Reg32& r1, const Reg32& r2) { opEncodeKey(r1, r2, 0xFA, 0xDA); }
void encodekey256(const Reg32& r1, const Reg32& r2) { opEncodeKey(r1, r2, 0xFB, 0xDB); }
void rdfsbase(const Reg32e& r) { opRR(eax, r, T_F3|T_0F, 0xAE); }
void rdgsbase(const Reg32e& r) { opRR(ecx, r, T_F3|T_0F, 0xAE); }
void wrfsbase(const Reg32e& r) { opRR(edx, r, T_F3|T_0F, 0xAE); }
void wrgsbase(const Reg32e& r) { opRR(ebx, r, T_F3|T_0F, 0xAE); }
void ldtilecfg(const Address& addr) { if (opROO(Reg(), addr, tmm0, T_APX|T_0F38|T_W0, 0x49)) return; opVex(tmm0, &tmm0, addr, T_0F38|T_W0, 0x49); }
void sttilecfg(const Address& addr) { if (opROO(Reg(), addr, tmm0, T_APX|T_66|T_0F38|T_W0, 0x49)) return; opVex(tmm0, &tmm0, addr, T_66|T_0F38 | T_W0, 0x49); }
void tileloadd(const Tmm& tm, const Address& addr) { opAMX(tm, addr, T_F2|T_0F38|T_W0, 0x4B); }
Expand Down

0 comments on commit 900c984

Please sign in to comment.