History

int main() { struct st { int aa:16; int bb:16; } s; s.aa = 1; s.bb = 2; return 0; } objdump -d: elf64-x86-64 Disassembly of section .text:

0000000000000000 <main>: 0: 55 push %rbp 1: 48 89 e5 mov %rsp,%rbp 4: 48 81 ec 10 00 00 00 sub $0x10,%rsp b: b8 01 00 00 00 mov $0x1,%eax 10: 48 89 c1 mov %rax,%rcx 13: 81 e1 ff ff 00 00 and $0xffff,%ecx 19: 8b 55 fc mov -0x4(%rbp),%edx 1c: 81 e2 00 00 ff ff and $0xffff0000,%edx 22: 09 d1 or %edx,%ecx 24: 89 4d fc mov %ecx,-0x4(%rbp) 27: b8 02 00 00 00 mov $0x2,%eax 2c: 48 89 c1 mov %rax,%rcx 2f: 81 e1 ff ff 00 00 and $0xffff,%ecx 35: c1 e1 10 shl $0x10,%ecx 38: 8b 55 fc mov -0x4(%rbp),%edx 3b: 81 e2 ff ff 00 00 and $0xffff,%edx 41: 09 d1 or %edx,%ecx 43: 89 4d fc mov %ecx,-0x4(%rbp) 46: b8 00 00 00 00 mov $0x0,%eax 4b: e9 00 00 00 00 jmpq 50 <main+0x50> 50: c9 leaveq 51: c3 retq After the patch Disassembly of section .text: 0000000000000000 <main>: 0: 55 push %rbp 1: 48 89 e5 mov %rsp,%rbp 4: 48 81 ec 10 00 00 00 sub $0x10,%rsp b: 8b 45 fc mov -0x4(%rbp),%eax e: 81 e0 00 00 ff ff and $0xffff0000,%eax 14: 83 c8 01 or $0x1,%eax 17: 89 45 fc mov %eax,-0x4(%rbp) 1a: 8b 45 fc mov -0x4(%rbp),%eax 1d: 81 e0 ff ff 00 00 and $0xffff,%eax 23: 81 c8 00 00 02 00 or $0x20000,%eax 29: 89 45 fc mov %eax,-0x4(%rbp) 2c: b8 00 00 00 00 mov $0x0,%eax 31: e9 00 00 00 00 jmpq 36 <main+0x36> 36: c9 leaveq 37: c3 retq

jiang committed 12 years ago

Commit e5e7f481 parent a94ed431 file · +10 −17Browse files

Unified · Split

tccgen.c+10−17
@@ -1019,6 +1019,7 @@ ST_FUNC void lexpand_nr(void) · 1018 unmodified lines
10191019 }
10201020 #endif
10211021
1022+#ifndef TCC_TARGET_X86_64
10221023 /* build a long long from two ints */
10231024 static void lbuild(int t)
10241025 {
@@ -1027,6 +1028,7 @@ static void lbuild(int t) · 2 unmodified lines
10271028 vtop[-1].type.t = t;
10281029 vpop();
10291030 }
1031+#endif
10301032
10311033 /* rotate n first stack elements to the bottom
10321034 I1 ... In -> I2 ... In I1 [top is right]
@@ -1088,8 +1090,8 @@ static void gv_dup(void) · 55 unmodified lines
10881090 {
10891091 int rc, t, r, r1;
10901092 SValue sv;
1091−
10921093 t = vtop->type.t;
1094+#ifndef TCC_TARGET_X86_64
10931095 if ((t & VT_BTYPE) == VT_LLONG) {
10941096 lexpand();
10951097 gv_dup();
@@ -1099,15 +1101,14 @@ static void gv_dup(void) · 3 unmodified lines
10991101 vrotb(4);
11001102 /* stack: H L L1 H1 */
11011103 lbuild(t);
1102− vrotb(3);
1103− vrotb(3);
1104+ vrott(3);
11041105 vswap();
11051106 lbuild(t);
11061107 vswap();
1107− } else {
1108+ } else
1109+#endif
1110+ {
11081111 /* duplicate value */
1109− rc = RC_INT;
1110− sv.type.t = VT_INT;
11111112 if (is_float(t)) {
11121113 rc = RC_FLOAT;
11131114 #ifdef TCC_TARGET_X86_64
@@ -1115,8 +1116,9 @@ static void gv_dup(void) · 1 unmodified line
11151116 rc = RC_ST0;
11161117 }
11171118 #endif
1118− sv.type.t = t;
1119− }
1119+ }else
1120+ rc = RC_INT;
1121+ sv.type.t = t;
11201122 r = gv(rc);
11211123 r1 = get_reg(rc);
11221124 sv.r = r;
@@ -2549,11 +2551,6 @@ ST_FUNC void vstore(void) · 1426 unmodified lines
25492551 /* remove bit field info to avoid loops */
25502552 vtop[-1].type.t = ft & ~(VT_BITFIELD | (-1 << VT_STRUCT_SHIFT));
25512553
2552− /* duplicate source into other register */
2553− gv_dup();
2554− vswap();
2555− vrott(3);
2556−
25572554 if((ft & VT_BTYPE) == VT_BOOL) {
25582555 gen_cast(&vtop[-1].type);
25592556 vtop[-1].type.t = (vtop[-1].type.t & ~VT_BTYPE) | (VT_BYTE | VT_UNSIGNED);
@@ -2585,10 +2582,6 @@ ST_FUNC void vstore(void) · 25 unmodified lines
25852582 gen_op('|');
25862583 /* store result */
25872584 vstore();
2588−
2589− /* pop off shifted source from "duplicate source..." above */
2590− vpop();
2591−
25922585 } else {
25932586 #ifdef CONFIG_TCC_BCHECK
25942587 /* bound check case */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t