51 Commits

Author SHA1 Message Date
kobalicek
8fdee13aea [Opt] Added a feature to the Compiler to remove dead moves (moves to itself) when it's provable that it's safe 2022-04-06 13:20:00 +02:00
kobalicek
62ffe595a2 [Bug] Fixed RM features reported by queryRWInfo (X86) 2022-02-19 21:43:07 +01:00
kobalicek
23ddf56b00 [ABI] Initial AArch64 support 2022-02-09 17:08:40 +01:00
kobalicek
996deae327 [ABI] Refactored AsmJit to use strong-typed enums, this breaks both API and ABI
[ABI] Added ABI version as an inline namespace, which forms asmjit::_abi_MAJOR_MINOR
[ABI] Added support for AVX512_FP16, 16-bit broadcast, and AVX512_FP16 tests
[ABI] Added initial support for consecutive registers into instruction database and register allocator
[ABI] Added a possibility to use temporary memory in CodeHolder's zone
[ABI] Compiler::setArg() is now deprecated, use FuncNode::setArg()
[Bug] Fixed correct RW information of instructions that only support implicit zeroing with {k}
[Bug] Fixed broadcast to be able to broadcast bcst16 operands
2021-12-13 19:34:56 +01:00
kobalicek
0a709c7a28 In addition to LEA, allow CL* and PREFETCH* instructions to have memory operand of any size 2021-06-27 00:39:18 +02:00
kobalicek
0dd16b0a98 [Bug] Fixed RW metadata of KXNORx and KXORx instructions (Compiler) 2021-04-13 19:01:36 +02:00
kobalicek
a4dd0b2d8b [ABI] Build improvements - replaced ASMJIT_BUIlD_X86 with ASMJIT_NO_X86 and other changes... 2021-03-21 14:42:47 +01:00
kobalicek
e822fba53e [ABI] Added the possibility to use AVX512 in Compiler and FuncFrame 2021-03-17 18:05:48 +01:00
kobalicek
2ab380e0bd [Bug] [Critical] [ABI] Update that fixes all problems discovered by comparison with LLVM-MC
Fixed POP Sreg instruction, which was incorrectly implemented to emit nothing
Fixed CVTSD2SI, CVTSS2SI, CVTTSD2SI, and CVTTSS2SI instructions to not consider the size of the memory operand when calculagint REX.W prefix
Fixed VCMPPD, VCMPPS, VCMPSD, VCMPSS, VPCMPEQ*, VPCMPGT* instructions to always force EVEX prefix when the first operand is K register
Fixed ENDBR32 and ENDBR64 instructions (wrong opcode)
Fixed CLRSSBSY and RSTORSSP instructions (wrong logic in Assembler)
Fixed SLDT, SMSW, and STR instructions to not consider memory size when determining prefixes
Fixed UD0 and UD1 instructions to consider both operands
Fixed VCVTNE2PS2BF16, VCVTNEPS2BF16, and VDPBF16PS instructions (incorrect calculation of LL field) (AVX512)
Fixed VCVTPD2DQ, VCVTPD2PS, VCVTPD2UDQ, VCVTQQ2PS, VCVTTOD2DQ, VCVTTPD2UDQ, VCVTUQQ2PS in AVX512 case (incorrect calculation of LL field)
Fixed VGATHERPF* and VSCATTERPF* instructions (some instructions were encoded incorrectly by not considering the memory index register type in LL field)
Fixed VPBLENDVB (incorrect calculation of LL field)
Fixed VPEXTRW to use use a shorter encoding when possible (vpextrw r32, xmm, imm)
Fixed VPSLLD, VPSLLQ, VPSLLW, VPSRAD, VPSRAQ, VPSRAW, VPSRLD, VPSRLQ, VPSRLW instructions to always force EVEX prefix when the instruction is RMI (AVX512)
Fixed the accepted memory operand size of MMX PUNPCKL??? instructions from m64 to m32 (only affects validation)
Added explicit forms to XSAVE* and XRSTOR* instructions
Added HRESET and UINTR instructions
Changed MOV and all ARITH instructions to output the same binary as LLVM in 'reg, reg' case (it used an alternative encoding initially)
Renamed LRET to RETF
Renamed VBLENDM* instructions to VPBLENDM* (the name was incorrect)
Renamed VPBROADCASTMB2D to VPBROADCASTMW2D (the name was incorrect)
Renamed SYSEXIT64 to SYSEXITQ and SYSRET64 to SYSRETQ
Removed non-standard IRETW (use IRET, IRETD, or IRETQ to select the form)
2021-02-03 09:36:11 +01:00
kobalicek
0636dd316a [Bug] Fixed instruction signatures issue introduced by the previous commit 2021-01-26 01:09:35 +01:00
kobalicek
58b6c025f2 [ABI] Added more AVX_VNNI instructions, added MOVABS for explicit Imm64 encodings, added more assembler tests 2021-01-26 01:00:29 +01:00
kobalicek
88129d7389 [Bug] Don't unlink immediately when creating anonymous memory file, switch to GH actions (Fixes #312) 2020-11-07 00:02:16 +01:00
kobalicek
cd44f41d9b Preparation for AArch64 support 2020-09-12 18:19:04 +02:00
kobalicek
8474400e82 [Bug] Fixed RW info of string instructions, fixed lodsx() helper intructions in emitter 2020-07-10 23:21:36 +02:00
kobalicek
c130455898 Added ASMJIT_NO_FOREIGN compile-time option to disable non-host architectures in the future 2020-07-07 10:27:46 +02:00
kobalicek
2de7e74244 Instruction validator now doesn't pass 'push/pop [mem]' having unknown size 2020-07-06 00:09:17 +02:00
kobalicek
75f2b69a26 Added new instructions and removed deprecated PCOMMIT 2020-07-05 02:21:24 +02:00
kobalicek
ba30278d66 Added support for more X86 extensions (AMX, AVX512_VP2INTERSECT, MCOMMIT, RDPRU, SERIALIZE, SNP, TSXLDTRK) 2020-07-01 01:07:37 +02:00
kobalicek
f986f7fc44 AsmJit cleanup and refactoring 2020-05-31 23:39:13 +02:00
kobalicek
80098456b6 Improved CI and enhanced project cosmetics (proper license header and include guards) 2020-05-03 20:06:27 +02:00
kobalicek
0072c202db Added support for BND/REPNE call/jmp/jcc/ret 2020-02-23 22:51:53 +01:00
kobalicek
5437d20dbb Added support for MAP_JIT (OSX, IOS), build system and CI improvements 2020-01-26 01:58:00 +01:00
kobalicek
019811d1f0 Added missing vpermpd & vpermps (AVX512) and changed how EVEX prefix is propagated in x86::Assembler 2019-10-05 12:57:22 +02:00
kobalicek
7c8f3150d7 Cosmetic changes, made sbb write-only when used with the same register 2019-09-03 20:55:41 +02:00
Petr Kobalicek
5d40561d14
Refactored register allocator asm Compiler. (#249)
Refactored build system macros (ASMJIT_BUILD_STATIC -> ASMJIT_STATIC)
Refactored AVX512 broadcast {1toN} - moved to operand from instruction.
Refactored naming - renamed getters to not use get prefix.
Refactored code structure - move arch-specific stuff into x86 namespace.
Refactored some compiler/arch-specific macros, respect rel/abs option in mov REG, [ADDR].
Refactored StringBuilder (Renamed to String, added small string optimization).
Refactored LabelId<->LabelEntry mapping, force label offset to 64-bits on all archs.
Renamed Runtime to Target (JitRuntime kept for now).
Renamed VirtMemManager to JitAllocator.
Renamed VirtMem to JitUtils.
Renamed FuncSignatureX to FuncSignatureBuilder.
Fixed xchg [mem], rex-lo, refactored RelocEntry.
Fixed Logger to always show abs|rel when formatting a memory operand
Fixed Logger to prefix HEX numbers with 0x prefix
Fixed Support::ctzGeneric to always return uint32_t, T doesn't matter.
Fixed LightCall to not save MMX and K registers
Fixed CpuInfo constructor to propagate NoInit (#243)
Added VAES, AVX512_VBMI2, AVX512_VNNI, and AVX512_BITALG cpu-features and instructions.
Added emscripten support (asmjit can be now compiled by emscripten).
Added asmjit.natvis for better MSVC experience
Added x86::ptr_abs|ptr_rel
Added support for multibyte nop r/m (#135)
Added support for 32-bit to 64-bit zero-extended addresses, improved validation of memory addresses, and removed wrt address type as this will be reworked
Added support for multiple sections, reworked address table support (previously known as trampolines)
Added the following x86 modifiers to the x86::Emitter - xacquire(), xrelease(), and k(kreg)
Added a possibility to use REP prefix with RET instruction
Added a possibility to relocate [rel addr] during relocate()
Added a variadic function-call support (Compiler), argument duplication (Compiler), better /dev/shm vs /tmp shared memory handling (VirtMem).
Removed imm_u imm_ptr helpers, imm() can now accept any integer and pointer.
Changed the default behavior of optimizing instructions to disabled with a possibility to enable that feature through kOptionOptimizedForSize
Use default copy construction / assignment to prevent new kind of warnings introduced by GCC 9
2019-07-16 01:24:22 +02:00
kobalicek
e8a80ea958 Moved logic from x86inst.cpp to x86instimpl.cpp, moved some instruction methods to Inst from X86Inst, added Inst::checkFeatures() for retrieving which CPU features are required to run a given instruction, minor reorganization and asmdb update 2017-03-09 16:57:54 +01:00
kobalicek
4a94223ebd Added new instructions + xacquire|xrelease prefixes, reorganized instruction options 2017-02-26 12:19:49 +01:00
kobalicek
f589e7165a Fixed encoding of 'CRC32 r64, r8/m8' instruction
Fixed encoding of 'POPCNT|TZCNT|LZCNT r16, r16/m16' instruction
Fixed encoding of EVEX instructions that don't provide VEX prefix equivalent
Added 'LOCK MOV CR8' extension used by AMD processors in 32-bit mode and 'ALTMOVCR8' CPU feature
Renamed some CPU features to respect their names used in X86/X64 architecture manuals
Added validation of immediate operands (correct size, correct sign/zero extension)
Added validation of explicit/implicit size of memory operands
Added validation of LOCK/REP/REPNZ prefixes to x86 validator
Reorganized some X86 instruction tables, removed family specific tables, introduced OperationData
Improved instruction tables generator to automatically generate instruction flags
Regenerated all instruction tables to respect the current state of 'asmdb.x86data'
2017-02-25 19:36:28 +01:00
kobalicek
aa154e3590 Added more instructions (System, MPX, AVX512_VPOPCNTDQ, AVX512_4FMAPS, AVX512_4VNNIW) 2017-02-21 01:55:07 +01:00
kobalicek
43dbe48afc Added CodeCompiler::newSimilarReg, merged generate-xxx tools from next-wip branch, changed pcmpgtq to be in SSE4.2 group 2017-02-09 14:15:08 +01:00
Petr Kobalicek
b7f6d1e369 Merged asmjit:next branch (#149) 2017-01-26 15:55:03 +01:00
kobalicek
c908c3db8d Added ADX, TBM, CLFLUSH_OPT, PREFETCHW, and SHA instruction sets to Assembler and Compiler\nAdded initial support for AVX/AVX2 instructions into X86Compiler\nRenamed oword to dqword (intel convention)\nFixed incorrect XOP and FMA4 detection\nCosmetic changes in documentation\nFixed unused typedef warnings (clang) (related to #132) 2016-07-03 23:05:43 +02:00
kobalicek
d25f392c6e Minor code cleanup, fixed 64-bit BMI and BMI2 instructions 2016-06-30 18:59:59 +02:00
kobalicek
185a96a46a Reworked CpuInfo (removed X86CpuInfo, added ARM CpuInfo support).
Renamed CodeGen to ExternalTool.
Moved logger constants from asmjit namespace to asmjit::Logger.
Moved AssemblerFeature constants from asmjit namespace to asmjit::Assembler.
Added noexcept to most APIs that are not intended to throw.
Added memory utilities that can read/write to unaligned memory location (ongoing ARM support).
Removed unimplemented instruction scheduler, will be added back when it's working.
2016-03-21 21:41:55 +01:00
kobalicek
b9b1ad6fae Added ASMJIT_NOT_REACHED() to better deal with unreachable code.
Added Visual Studio 2015 scripts and fixed asmjit_test_x86 which now compiles under VS2015
Added StringLogger::getLength()
Added methods to X86Compiler to create a variable operand by its ID
2016-01-02 16:24:54 +01:00
kobalicek
3fcd65cf80 - Moved to cxxtool to generate build.h compiler and platform based definitions.
- Compiler no longer works on its own, it requires Assembler.
- Labels created by Assembler and Compiler now share their IDs, so they can be used nearly interchangeably without weird side-effects and hacks.
- Renamed getError() and setError() to getLastError() and setLastError().
- Renamed compiler nodes to "HL" nodes (preparation for HLStream).
- Renamed FuncConv to CallConv.
- Function calling convention is now part of FuncPrototype.
- Added a possibility to align by inserting zeros (kAlignZero)
- Fixed assertion in X86Compiler that didn't like unhandled function argument(s).
- Added Compiler::embedConstPool() helper, which can be handy if you use your own ConstPool.
- Code refactorization and other minor changes.
- CpuTicks::now() renamed to Utils::getTickCount().
- error.h merged with globals.h
- Documentation updates related to recent API changes.
2015-12-07 07:34:25 +01:00
kobalicek
4dbaf70c31 Reduced the size of instruction names array by 2kB by merging shorter names into longer names. 2015-06-20 20:50:55 +02:00
kobalicek
a67e8fc694 Minor refactor of constants (don't use k prefix in enum type, only values), fixed some compilation problems with VS2003. 2015-01-11 20:44:41 +01:00
kobalicek
515d854d10 Refactored slightly some constants and operand handling in X86Assembler.
Refactored asmjit::x86 register definitions (now exported as a single symbol).
Refactored bit utilities, now using proper naming like `or_`, `and_`, `andNot`.
Refactored X86RegCount and X86RegMask to support K instead of Fp register.
Refactored X86 instruction table (won't stay for long, new tool to export it is in development).
Renamed instruction group to instruction encoding.
Added XSAVE/OSXSAVE and other CPU features to X86CpuInfo.
Added proper AVX and AVX-512 detection to X86CpuInfo.
Added support to get content of XCR0 in X86CpuInfo (callXGetBV).
Added XSAVE instruction set support (Assembler/Compiler).
Added SSE4a instruction set support (Assembler/Compiler).
Added X86KReg and X86KVar register/variable support (AVX-512).
Added X86ZmmReg and X86ZmmVar register/variable support (AVX-512).
2014-11-01 13:07:56 +01:00
kobalicek
fa955663e3 Changed asmjit namespaces, each architecture has now only one namespace for registers / memory operands.
Changed instruction table schema to minimize its size and added use of EFLAGS register (for scheduler).
Changed the rest of intrinsics accepting `void*` to accept `Ptr` instead.
Changed clear()/reset() concept - only `reset()` now exists and accepts a `releaseMemory` argument.
Changed unit tests to use bundled `Broken` framework.
Moved podvector and podlist to base/containers.
Added CMPS, LODS, MOVS, SCAS, STOS instructions.
Added Label::isInitialized() and Var::isInitialized().
Added X86Scheduler stub - preparing for instruction reordering.
Added support for tracing (see ASMJIT_TRACE) to allow consumers to find bugs in AsmJit quicker.
Fixed possible Zone memory leak.
Fixed and improved alloc/spill (added support for home register which asmjit honors from now).
Fixed Assembler `LEA REG, [LABEL]` bug.
Fixed [Mem, Imm] instructions with zero-sized operand to return error instead of emitting garbage.
Fixed minor bug in VMemMgr - always point to a correct hProcess so it can be used properly (#41).
2014-07-12 17:50:35 +02:00
kobalicek
a66efd5460 Minor 2014-06-07 21:57:07 +02:00
kobalicek
0dbd42f350 Line endings 2014-06-07 19:23:35 +02:00
kobalicek
db322d5dc1 Added minimalist unit testing (and removed some apps that did some tests). 2014-06-04 22:12:52 +02:00
kobalicek
cc2909f0db Minor changes.
Added possibility to get x86/x64 instruction id by name.
2014-05-30 14:49:22 +02:00
kobalicek
1a73e65534 - Minor reorganization of source code (split defs to operand and instruction info).
- Added JECXZ instruction.
- Doxyfile is now in project root.
- Documentation updates.
2014-05-10 21:19:50 +02:00
kobalicekp
f1ce2383ba - Major documentation reorganization of AsmJit (still far from perfection)
- Documentation - removed verbose @brief and switched to markdown syntax which Doxygen supports.
- Added inline documentation to AVX/AVX2 instructions.
- Added more documentation notes to utility classes.
- Modified documentation groups to be compatible with the new code layout (base/x86).

- Renamed VirtualMemoryManager to VMemMgr.
- Removed MemoryManager interface (not needed).
- Changed JitRuntime to always create a new isolated VMemMgr instance.
- Fixed WinRemoteRuntime to work with the new changes.

- Added missing insertps instruction to database, assembler and compiler.
- Moved global functions in x86cpuinfo to CpuUtil class.

- Should notify Issue #10
2014-05-04 23:11:12 +02:00
kobalicekp
f77f792cc4 X86Assembler - Minor fixes related to illegal instruction/illegal addressing error handling.
X86Compiler - Always create SArg for every stack-based function argument
X86Compiler - Possible to allocate a register that has to be used to convert variable to function argument.
X86Compiler - ContextID generation moved to context_p.h.
X86Compiler - Support for one variable being used by multiple function-call arguments.
X86Defs - Removed support for 'long double' (buggy, never used).
X86Func - Register arguments have to be converted from Fp32/Fp64 to XmmSs/XmmSd, respectively.
2014-03-05 23:27:28 +01:00
kobalicekp
5fe81c40c7 Fixed some bugs described in Issue #3
Added more test cases based on Issue #3
Minor changes.
2014-03-01 17:01:54 +01:00
kobalicekp
1da103fa70 Minor code cleanup. 2014-02-06 20:40:25 +01:00
kobalicekp
2aba235875 Added better sanitizer and sanitized the source code. 2014-02-02 21:39:09 +01:00