summary refs log tree commit diff stats
path: root/compiler/sizealignoffsetimpl.nim
Commit message (Expand)AuthorAgeFilesLines
* cString => cSourceString; tyCString => tyCstring so that error msgs show cstr...Timothee Cour2021-04-171-1/+1
* Fix #12636 (#15850)cooldome2020-11-051-2/+6
* fix #15752 (#15754)cooldome2020-10-281-4/+4
* fixes view types for sizeof() and --gc:orc (#15680)Andreas Rumpf2020-10-221-1/+1
* fix #15516 (#15518)cooldome2020-10-081-4/+6
* allow packed union (#14868)Clyybber2020-07-011-9/+7
* sizeof for empty objects/tuples should be 1; fixes #14690 (#14751)Andreas Rumpf2020-06-211-2/+2
* `nim doc --backend:js`, `nim doc --doccmd:-d:foo`, `nim r --backend:js`, `--d...Timothee Cour2020-05-111-1/+1
* CT sizeof(+friends) for {.importc, completeStruct.} types, enable ABI static ...Timothee Cour2020-04-231-1/+2
* catchable defects (#13626)Andreas Rumpf2020-03-121-1/+1
* make case-object transitions explicit, make unknownLineInfo a const, replace ...Jasper Jenkins2020-01-171-2/+2
* Cosmetic compiler cleanup (#12718)Clyybber2019-11-281-28/+28
* implemented alignas pragma (#12643)Arne Döring2019-11-131-0/+4
* refactoring: use the new strings and seqs when optSeqDestructors is activeAraq2019-10-201-2/+2
* fixes #12264 [backport] (#12302)Andreas Rumpf2019-09-301-5/+6
* Fix spellings (#12277) [backport]Federico Ceratto2019-09-271-1/+1
* Small ast.nim cleanup (#12156)Clyybber2019-09-091-4/+4
* refactor sizealignoffset (#12077)Andreas Rumpf2019-08-281-201/+142
* int128 on firstOrd, lastOrd and lengthOrd (#11701)Arne Döring2019-08-071-4/+4
* fixes #11792 (#11793)cooldome2019-07-211-1/+1
* there is only one style -- my styleAraq2019-07-101-4/+4
* Offsetof fixes (#11690)Arne Döring2019-07-091-18/+123
* [backport] fix #11320 (#11538)Arne Döring2019-07-031-1/+1
* Replace countup(x, y-1) with x ..< yClyybber2019-05-071-1/+1
* newruntime: progressAraq2019-04-011-1/+1
* Size ptr tuple (#10846)Arne Döring2019-03-181-8/+0
* sizealign of union type (#10780)Arne Döring2019-03-041-2/+52
* Fix for sizeof bitsize combination (#10227)Arne Döring2019-01-071-3/+8
* fixes #10082Andreas Rumpf2018-12-301-25/+11
* fixes #9868Araq2018-12-051-1/+2
* gc:destructors: more progressAndreas Rumpf2018-11-291-2/+2
* fixes #9794: sizeof tuple is incorrect if contains imported object (#9795)cooldome2018-11-261-3/+3
* Fixes multiple bugs with sink arguments (#9802)cooldome2018-11-261-4/+4
* bitsize respected in size calculation. (#9756)Arne Döring2018-11-191-3/+8
* make tsizeof run on C++ backend (#9734)Arne Döring2018-11-181-10/+18
* Merge pull request #9511 from krux02/krux02-develArne Döring2018-10-311-0/+9
|\
| * set code ownerArne Döring2018-10-301-0/+9
* | Sizeof alignof fixes (#9568)Arne Döring2018-10-301-1/+1
|/
* sizeof(UncheckedArray) should be invalid; fixed the formating of sizealignoff...Araq2018-10-141-87/+34
* implement sizeof and alignof operator (manually squashed #5664) (#9356)Timothee Cour2018-10-141-0/+447
span>, "run") << "effective address is initially 0x" << HEXWORD << addr << " (" << rname(base) << ")" << end(); } else { // base == EBP && mod == 0 addr = next32(); // ignore base trace(Callstack_depth+1, "run") << "effective address is initially 0x" << HEXWORD << addr << " (disp32)" << end(); } const uint8_t index = (sib>>3)&0x7; if (index == ESP) { // ignore index and scale trace(Callstack_depth+1, "run") << "effective address is 0x" << HEXWORD << addr << end(); } else { const uint8_t scale = (1 << (sib>>6)); addr += Reg[index].i*scale; // treat index register as signed. Maybe base as well? But we'll always ensure it's non-negative. trace(Callstack_depth+1, "run") << "effective address is 0x" << HEXWORD << addr << " (after adding " << rname(index) << "*" << NUM(scale) << ")" << end(); } return addr; } :(code) void test_add_r32_to_mem_at_base_r32_index_r32() { Reg[EBX].i = 0x10; // source Reg[EAX].i = 0x1ffe; // dest base Reg[ECX].i = 0x2; // dest index run( "== code 0x1\n" // op ModR/M SIB displacement immediate " 01 1c 08 \n" // add EBX to *(EAX+ECX) // ModR/M in binary: 00 (indirect mode) 011 (src EBX) 100 (dest in SIB) // SIB in binary: 00 (scale 1) 001 (index ECX) 000 (base EAX) "== data 0x2000\n" "01 00 00 00\n" // 0x00000001 ); CHECK_TRACE_CONTENTS( "run: add EBX to r/m32\n" "run: effective address is initially 0x00001ffe (EAX)\n" "run: effective address is 0x00002000 (after adding ECX*1)\n" "run: storing 0x00000011\n" ); } :(code) void test_add_r32_to_mem_at_displacement_using_sib() { Reg[EBX].i = 0x10; // source run( "== code 0x1\n" // op ModR/M SIB displacement immediate " 01 1c 25 00 20 00 00 \n" // add EBX to *0x2000 // ModR/M in binary: 00 (indirect mode) 011 (src EBX) 100 (dest in SIB) // SIB in binary: 00 (scale 1) 100 (no index) 101 (not EBP but disp32) "== data 0x2000\n" "01 00 00 00\n" // 0x00000001 ); CHECK_TRACE_CONTENTS( "run: add EBX to r/m32\n" "run: effective address is initially 0x00002000 (disp32)\n" "run: effective address is 0x00002000\n" "run: storing 0x00000011\n" ); } //: :(code) void test_add_r32_to_mem_at_base_r32_index_r32_plus_disp8() { Reg[EBX].i = 0x10; // source Reg[EAX].i = 0x1ff9; // dest base Reg[ECX].i = 0x5; // dest index run( "== code 0x1\n" // op ModR/M SIB displacement immediate " 01 5c 08 02 \n" // add EBX to *(EAX+ECX+2) // ModR/M in binary: 01 (indirect+disp8 mode) 011 (src EBX) 100 (dest in SIB) // SIB in binary: 00 (scale 1) 001 (index ECX) 000 (base EAX) "== data 0x2000\n" "01 00 00 00\n" // 0x00000001 ); CHECK_TRACE_CONTENTS( "run: add EBX to r/m32\n" "run: effective address is initially 0x00001ff9 (EAX)\n" "run: effective address is 0x00001ffe (after adding ECX*1)\n" "run: effective address is 0x00002000 (after adding disp8)\n" "run: storing 0x00000011\n" ); } :(before "End Mod 1 Special-cases(addr)") case 4: // exception: mod 0b01 rm 0b100 => incoming SIB (scale-index-base) byte addr = effective_address_from_sib(mod); break; //: :(code) void test_add_r32_to_mem_at_base_r32_index_r32_plus_disp32() { Reg[EBX].i = 0x10; // source Reg[EAX].i = 0x1ff9; // dest base Reg[ECX].i = 0x5; // dest index run( "== code 0x1\n" // op ModR/M SIB displacement immediate " 01 9c 08 02 00 00 00 \n" // add EBX to *(EAX+ECX+2) // ModR/M in binary: 10 (indirect+disp32 mode) 011 (src EBX) 100 (dest in SIB) // SIB in binary: 00 (scale 1) 001 (index ECX) 000 (base EAX) "== data 0x2000\n" "01 00 00 00\n" // 0x00000001 ); CHECK_TRACE_CONTENTS( "run: add EBX to r/m32\n" "run: effective address is initially 0x00001ff9 (EAX)\n" "run: effective address is 0x00001ffe (after adding ECX*1)\n" "run: effective address is 0x00002000 (after adding disp32)\n" "run: storing 0x00000011\n" ); } :(before "End Mod 2 Special-cases(addr)") case 4: // exception: mod 0b10 rm 0b100 => incoming SIB (scale-index-base) byte addr = effective_address_from_sib(mod); break;