aboutsummaryrefslogtreecommitdiff
path: root/i386-asm.c
Commit message (Collapse)AuthorAgeFilesLines
* x86-64-asm: Support high registers %r8 - %r15Michael Matz2016-12-151-40/+170
| | | | | | | This requires correctly handling the REX prefix. As bonus we now also support the four 8bit registers spl,bpl,sil,dil, which are decoded as ah,ch,dh,bh in non-long-mode (and require a REX prefix as well).
* inline-asm: Accept "flags" clobberMichael Matz2016-12-151-2/+3
|
* x86-asm: Fix lar opcode operandsMichael Matz2016-12-151-1/+5
| | | | | | | lar can accept multiple sizes as well (wlx), like lsl. When using autosize it's important to look at the destination operand first; when it's a register that one determines the size, not the input operand.
* inline asm: Accept 'R' constraintMichael Matz2016-12-151-0/+2
| | | | | This is like 'r' but only accepts the eight legacy regs. Currently that's the same as 'r' because we don't support the high ones.
* inline asm: Accept "e" constraintMichael Matz2016-12-151-0/+2
| | | | | This is meant to be a (sign-extended) 32bit constant (possibly symbolic). We don't do any checks and simply regard it as "i".
* inline asm: Fix 'P' and accept some r<nr> registersMichael Matz2016-12-151-1/+9
| | | | | | A 'P' template modifier should avoid adding a '$' to literal arguments. Also accept the numbered r8+ registers in an inline asm clobber list (ignoring them for now).
* x86-64-asm: More opcodesMichael Matz2016-12-151-0/+9
| | | | Implement some more opcodes, syscall, sysret, lfence, mfence, sfence.
* x86-64-asm: Accept expressions for .quadMichael Matz2016-12-151-1/+1
| | | | | The x86-64 target has 64bit relocs, and hence can accept generic expressions for '.quad'.
* inline asm: Accept 'p' constraint and 'P' template modMichael Matz2016-12-151-0/+2
| | | | | 'p' is conservatively the same as 'r' and 'P' as template modifier can be ignored in TCC.
* Accept more asm expressionsMichael Matz2016-12-151-5/+9
| | | | | | In particular subtracting a defined symbol from current section makes the value PC relative, and .org accepts symbolic expressions as well, if the symbol is from the current section.
* x86-asm: Get rid of OPC_JMP and OPC_SHORTJMPMichael Matz2016-12-151-10/+10
| | | | | Those two insn types are nicer to handle as operand types, because the pressure for bits on instr_type is higher than for operands.
* x86-asm: Remove OPC_D16Michael Matz2016-12-151-2/+1
| | | | | Now that we can store prefixes even for 0x0fXX opcodes we can remove the OPC_D16 bit.
* x86-asm: Reorganize instr_typeMichael Matz2016-12-151-44/+63
| | | | | | | | | Disjoint instruction types don't need to be a bit field, so introduce an enumeration (3 bits). Also the 0x0f prefix can be expressed by a bit, doesn't need a byte in the opcode field. That enables to encode further prefixes still in 16 bit. To not have to touch all insns do some macro fiddling filtering out a 0x0f byte in the second position.
* x86-asm: move stats codeMichael Matz2016-12-151-0/+40
| | | | | The old place (tccasm.c) didn't have access to the variables anymore and was ifdefed out. Move it to i386-asm.c.
* x86-asm: Add more SSE2 instructionsMichael Matz2016-12-151-1/+18
| | | | | | | | In particular those that are extensions of existing mmx (or sse1) instructions by a simple 0x66 prefix. There's one caveat for x86-64: as we don't yet correctly handle the 0xf3 prefix the movq mem64->xmm is wrong (tested in asmtest.S). Needs some refactoring of the instr_type member.
* tccelf: introduce add32/64le()grischka2016-11-201-1/+1
|
* x86_64-asm: =m operand fixesgrischka2016-11-201-27/+48
| | | | | | | | | | | | | | | | | | | | | | The problem was with tcctest.c: unsigned set; __asm__("btsl %1,%0" : "=m"(set) : "Ir"(20) : "cc"); when with tcc compiled with the HAVE_SELINUX option, run with tcc -run, it would use large addresses far beyond the 32bits range when tcc did not use the pc-relative mode for accessing 'set' in global data memory. In fact the assembler did not know about %rip at all. Changes: - memory operands use (%rax) not (%eax) - conversion from VT_LLOCAL: use type VT_PTR - support 'k' modifier - support %rip register - support X(%rip) pc-relative addresses The test in tcctest.c is from Michael Matz.
* x86-asm: Reject some invalid arith imm8 instructionMichael Matz2016-05-161-0/+7
| | | | | | | There were two errors in the arithmetic imm8 instruction. They accept only REGW, and in case the user write a xxxb opcode that variant needs to be rejected as well (it's not automatically rejected by REGW in case the destination is memory).
* x86-asm: Fix signed constants and opcode orderMichael Matz2016-05-141-1/+3
| | | | | | | | Two things: negative constants were rejected (e.g. "add $-15,%eax"). Second the insn order was such that the arithmetic IM8S forms weren't used (always the IM32 ones). Switching them prefers those but requires a fix for size calculation in case the opcodes were OPC_ARITH and OPC_WLX (whose size starts with 1, not zero).
* x86-asm: Consolidate insn descriptionsMichael Matz2016-05-141-0/+2
| | | | | Use OPC_BWLX and OPC_WLX in i386-asm.h and x86_64-asm.h to reduce number of differences between both.
* x86-64-asm: Clean up 64bit immediate supportMichael Matz2016-05-111-18/+16
| | | | | | | | | Fix it to actually be able to parse 64bit immediates (enlarge operand value type). Then, generally there's no need for accepting IM64 anywhere, except in the 0xba+r mov opcodes, so OP_IM is unnecessary, as is OPT_IMNO64. Improve the generated code a bit by preferring the 0xc7 opcode for im32->reg64, instead of the im64->reg64 form (which we therefore hardcode).
* x86-asm: Get rid of is_short_jumpMichael Matz2016-05-111-7/+4
| | | | Can be implemented differently.
* x86-asm: Remove old ASM_16 codeMichael Matz2016-05-111-185/+6
| | | | | | This code was inactive since a long time (and was deactivated because it was wrong to start with) and just clutters the sources. Remove it.
* x86-64: Run asmtest as wellMichael Matz2016-05-111-0/+4
| | | | | This fixes and activates the asm test that's part of tcctest.c also on x86-64, requiring a small fix for the 'm' constraint.
* x86-64 asm: Remove useless jmp opcodeMichael Matz2016-05-111-7/+0
| | | | | Also remove the hacky mod/rm byte emission during disp/imm writing.
* x86: Improve cmov handlingMichael Matz2016-05-111-0/+5
| | | | | cmov can accept multi sizes, but is also a OPC_TEST opcode, deal with this.
* [x86] Fix some asm problemsMichael Matz2016-05-091-16/+71
| | | | | | | | | | | A bag of assembler fixes, to be either compatible with GAS (e.g. order of 'test' operands), accept more instructions, count correct foo{bwlq} variants on x86_64, fix modrm/sib bytes on x86_64 to not use %rip relative addressing mode, to not use invalid insns in tests/asmtest.S for x86_64. Result is that now output of GAS and of tcc on tests/asmtest.S is mostly the same.
* Improve hash performanceVlad Vissoultchev2016-04-171-5/+5
| | | | | | | | | | | | - better `TOK_HASH_FUNC` - increases `hash_ident` initial size to 16k (from 8k) - `cstr_cat` uses single `realloc` + `memcpy` - `cstr_cat` can append terminating zero - `tok_str_realloc` initial size to 16 (from 8) - `parse_define` uses static `tokstr_buf` - `next` uses static `tokstr_buf` - fixes two latent bugs (wrong deallocations in libtcc.c:482 and tccpp.c:2987)
* Change the way struct CStrings are handled.Edmund Grimley Evans2015-11-261-1/+1
| | | | | | | | | A CString used to be copied into a token string, which is an int array. On a 64-bit architecture the pointers were misaligned, so ASan gave lots of warnings. On a 64-bit architecture that required memory accesses to be correctly aligned it would not work at all. The CString is now included in CValue instead.
* Merge the integer members of union CValue into "uint64_t i".Edmund Grimley Evans2015-11-171-5/+5
|
* Revert all of my changes to directories & codingstyle.gus knight2015-07-291-0/+1502
|
* Reorganize the source tree.gus knight2015-07-271-1502/+0
| | | | | | | | | | * Documentation is now in "docs". * Source code is now in "src". * Misc. fixes here and there so that everything still works. I think I got everything in this commit, but I only tested this on Linux (Make) and Windows (CMake), so I might've messed something up on other platforms...
* Trim trailing spaces everywhere.gus knight2015-07-271-1/+1
|
* Convert some lines from ISO-8859-1 to UTF-8.Edmund Grimley Evans2015-03-111-1/+1
| | | | | | | | perl -i -pe 'use Text::Iconv; $c1 = Text::Iconv->new("utf-8", "utf-8"); $c2 = Text::Iconv->new("iso-8859-1", "utf-8"); if (!$c1->convert($_)) { $_ = $c2->convert($_); }' \ `find * -type f`
* Corrected spelling mistakes in comments and stringsVincent Lefevre2014-04-071-1/+1
|
* Detect correct instruction with incorrect operandsThomas Preud'homme2013-09-241-0/+4
| | | | | | Display a different warning when an instruction is recognized by tcc but the operands found do not correspond to the constraints of the instruction.
* add version number to manpageUrs Janssen2013-02-171-1/+1
| | | | | | | avoid c++/c99 style comments in preprocessor directives avoid leadings whitespaces in preprocessor directives mention implemented variable length arrays in documentation fixed ambiguous option in texi2html call (Austin English)
* rename error/warning -> tcc_(error/warning)grischka2011-08-111-26/+26
|
* tccasm: accept bracketed offset expressionsJoe Soroka2011-02-011-2/+14
|
* tccasm: allow one-line prefix+op things like "rep stosb"Joe Soroka2011-02-011-0/+5
|
* win64: add tiny unwind data for setjmp/longjmpgrischka2009-12-201-0/+4
| | | | | | | | | This enables native unwind semantics with longjmp on win64 by putting an entry into the .pdata section for each compiled fuction. Also, the function now use a fixed stack and store arguments into X(%rsp) rather than using push.
* allow tcc be build from separate objectsgrischka2009-12-201-9/+11
| | | | If you want that, run: make NOTALLINONE=1
* integrate x86_64-asm.c into i386-asm.cgrischka2009-12-191-248/+368
| | | | | Also, disable 16bit support for now as it causes bugs in 32bit mode. #define I386_ASM_16 if you want it.
* i386-asm: fix imulgrischka2009-12-061-1/+2
| | | | | | With imul the 3rd operand defaults to the 2nd on. The previous logic left 'op_type[2]' uninitialized which caused the bug to show up only sometimes.
* asm 32/64: replace (long)sym->next by sym->jnextgrischka2009-11-211-3/+3
|
* fix 32bit asmgrischka2009-11-141-25/+13
| | | | | | | The new 16bit code was causing wrong 0x66 prefixes in 32bit code. The fix possibly breaks the feature on 16bit asm.
* fix ambiguityBernhard Reutner-Fischer2009-11-131-1/+1
| | | | Signed-off-by: aldot <rep.dot.nop@gmail.com>
* Fixed compilation error in i386-asm.cFrederic Feret2009-11-131-3/+1
|
* added 16-bit x86 assembly supportFrederic Feret2009-11-131-31/+188
|
* get rid of a warning and fix .batgrischka2008-03-251-8/+7
|