Rev 7983 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 7983 | Rev 8097 | ||
---|---|---|---|
Line 6... | Line 6... | ||
6 | *) |
6 | *) |
Line 7... | Line 7... | ||
7 | 7 | ||
Line 8... | Line 8... | ||
8 | MODULE AMD64; |
8 | MODULE AMD64; |
9 | 9 | ||
Line 10... | Line 10... | ||
10 | IMPORT IL, BIN, WR := WRITER, CHL := CHUNKLISTS, LISTS, PATHS, PROG, TARGETS, |
10 | IMPORT IL, BIN, WR := WRITER, CHL := CHUNKLISTS, LISTS, PATHS, PROG, TARGETS, |
Line 11... | Line 11... | ||
11 | REG, C := CONSOLE, UTILS, S := STRINGS, PE32, ELF, X86; |
11 | REG, UTILS, S := STRINGS, PE32, ELF, X86, ERRORS; |
Line 25... | Line 25... | ||
25 | rsp = 4; |
25 | rsp = 4; |
26 | rbp = 5; |
26 | rbp = 5; |
27 | rsi = 6; |
27 | rsi = 6; |
28 | rdi = 7; |
28 | rdi = 7; |
Line -... | Line 29... | ||
- | 29 | ||
- | 30 | MAX_XMM = 5; |
|
29 | 31 | ||
Line 30... | Line 32... | ||
30 | je = 84H; jne = 85H; jl = 8CH; jge = 8DH; jle = 8EH; jg = 8FH; jb = 82H; |
32 | je = 84H; jne = 85H; jl = 8CH; jge = 8DH; jle = 8EH; jg = 8FH; jb = 82H; |
Line 31... | Line 33... | ||
31 | 33 | ||
Line 36... | Line 38... | ||
36 | sCODE = BIN.PICCODE; |
38 | sCODE = BIN.PICCODE; |
37 | sDATA = BIN.PICDATA; |
39 | sDATA = BIN.PICDATA; |
38 | sBSS = BIN.PICBSS; |
40 | sBSS = BIN.PICBSS; |
39 | sIMP = BIN.PICIMP; |
41 | sIMP = BIN.PICIMP; |
Line -... | Line 42... | ||
- | 42 | ||
- | 43 | FPR_ERR = 41; |
|
Line 40... | Line 44... | ||
40 | 44 | ||
Line 41... | Line 45... | ||
41 | 45 | ||
Line 63... | Line 67... | ||
63 | dllret, sofinit: INTEGER; |
67 | dllret, sofinit: INTEGER; |
Line 64... | Line 68... | ||
64 | 68 | ||
65 | Win64RegPar: ARRAY 4 OF INTEGER; |
69 | Win64RegPar: ARRAY 4 OF INTEGER; |
Line -... | Line 70... | ||
- | 70 | SystemVRegPar: ARRAY 6 OF INTEGER; |
|
- | 71 | ||
- | 72 | Xmm: ARRAY 1000 OF INTEGER; |
|
- | 73 | ||
Line 66... | Line 74... | ||
66 | SystemVRegPar: ARRAY 6 OF INTEGER; |
74 | fname: PATHS.PATH; |
67 | 75 | ||
68 | 76 | ||
69 | PROCEDURE OutByte (b: BYTE); |
77 | PROCEDURE OutByte (b: BYTE); |
Line 94... | Line 102... | ||
94 | X86.OutByte(UTILS.Byte(n, 2)); |
102 | X86.OutByte(UTILS.Byte(n, 2)); |
95 | X86.OutByte(UTILS.Byte(n, 3)) |
103 | X86.OutByte(UTILS.Byte(n, 3)) |
96 | END OutInt; |
104 | END OutInt; |
Line 97... | Line -... | ||
97 | - | ||
98 | - | ||
99 | PROCEDURE isByte (n: INTEGER): BOOLEAN; |
- | |
100 | RETURN (-128 <= n) & (n <= 127) |
- | |
101 | END isByte; |
- | |
102 | 105 | ||
103 | 106 | ||
104 | PROCEDURE short (n: INTEGER): INTEGER; |
107 | PROCEDURE short (n: INTEGER): INTEGER; |
Line 105... | Line 108... | ||
105 | RETURN 2 * ORD(isByte(n)) |
108 | RETURN 2 * ORD(X86.isByte(n)) |
106 | END short; |
109 | END short; |
107 | 110 | ||
Line 108... | Line 111... | ||
108 | 111 | ||
109 | PROCEDURE long (n: INTEGER): INTEGER; |
112 | PROCEDURE long (n: INTEGER): INTEGER; |
110 | RETURN 40H * ORD(~isByte(n)) |
113 | RETURN 40H * ORD(~X86.isByte(n)) |
111 | END long; |
114 | END long; |
112 | 115 | ||
113 | 116 | ||
114 | PROCEDURE OutIntByte (n: INTEGER); |
117 | PROCEDURE OutIntByte (n: INTEGER); |
115 | BEGIN |
118 | BEGIN |
Line 189... | Line 192... | ||
189 | BEGIN |
192 | BEGIN |
190 | oprr(21H, reg1, reg2) |
193 | oprr(21H, reg1, reg2) |
191 | END and; |
194 | END and; |
Line 192... | Line 195... | ||
192 | 195 | ||
193 | 196 | ||
194 | PROCEDURE or (reg1, reg2: INTEGER); (* or reg1, reg2 *) |
197 | PROCEDURE _or (reg1, reg2: INTEGER); (* or reg1, reg2 *) |
195 | BEGIN |
198 | BEGIN |
Line 196... | Line 199... | ||
196 | oprr(09H, reg1, reg2) |
199 | oprr(09H, reg1, reg2) |
197 | END or; |
200 | END _or; |
198 | 201 | ||
Line 209... | Line 212... | ||
209 | END sub; |
212 | END sub; |
Line 210... | Line 213... | ||
210 | 213 | ||
211 | 214 | ||
- | 215 | PROCEDURE xchg (reg1, reg2: INTEGER); (* xchg reg1, reg2 *) |
|
- | 216 | BEGIN |
|
- | 217 | IF rax IN {reg1, reg2} THEN |
|
- | 218 | Rex(reg1 + reg2, 0); |
|
212 | PROCEDURE xchg (reg1, reg2: INTEGER); (* xchg reg1, reg2 *) |
219 | OutByte(90H + (reg1 + reg2) MOD 8) |
- | 220 | ELSE |
|
213 | BEGIN |
221 | oprr(87H, reg1, reg2) |
Line 214... | Line 222... | ||
214 | oprr(87H, reg1, reg2) |
222 | END |
215 | END xchg; |
223 | END xchg; |
Line 268... | Line 276... | ||
268 | RETURN REG.GetVarReg(R, offs) |
276 | RETURN REG.GetVarReg(R, offs) |
269 | END GetVarReg; |
277 | END GetVarReg; |
Line 270... | Line 278... | ||
270 | 278 | ||
271 | - | ||
272 | PROCEDURE callimp (label: INTEGER); |
- | |
273 | VAR |
- | |
274 | reg: INTEGER; |
279 | |
275 | - | ||
276 | BEGIN |
- | |
277 | reg := GetAnyReg(); |
280 | PROCEDURE callimp (label: INTEGER); |
278 | lea(reg, label, sIMP); |
281 | BEGIN |
279 | IF reg >= 8 THEN (* call qword[reg] *) |
- | |
280 | OutByte(41H) |
- | |
281 | END; |
- | |
282 | OutByte2(0FFH, 10H + reg MOD 8); |
282 | OutByte2(0FFH, 15H); (* call qword[rip + label + IMP] *) |
Line 283... | Line 283... | ||
283 | drop |
283 | X86.Reloc(sIMP, label) |
284 | END callimp; |
284 | END callimp; |
Line 381... | Line 381... | ||
381 | BEGIN |
381 | BEGIN |
382 | IF isLong(n) THEN |
382 | IF isLong(n) THEN |
383 | oprlongc(reg, n, oprr) |
383 | oprlongc(reg, n, oprr) |
384 | ELSE |
384 | ELSE |
385 | Rex(reg, 0); |
385 | Rex(reg, 0); |
386 | OutByte2(81H + short(n), op + reg MOD 8); |
- | |
387 | OutIntByte(n) |
386 | X86.oprc(op, reg, n) |
388 | END |
387 | END |
389 | END oprc; |
388 | END oprc; |
Line 390... | Line 389... | ||
390 | 389 | ||
Line 417... | Line 416... | ||
417 | END andrc; |
416 | END andrc; |
Line 418... | Line 417... | ||
418 | 417 | ||
419 | 418 | ||
420 | PROCEDURE orrc (reg, n: INTEGER); (* or reg, n *) |
419 | PROCEDURE orrc (reg, n: INTEGER); (* or reg, n *) |
421 | BEGIN |
420 | BEGIN |
Line 422... | Line 421... | ||
422 | oprc(0C8H, reg, n, or) |
421 | oprc(0C8H, reg, n, _or) |
423 | END orrc; |
422 | END orrc; |
Line 438... | Line 437... | ||
438 | reg2 := GetAnyReg(); |
437 | reg2 := GetAnyReg(); |
439 | movabs(reg2, n); |
438 | movabs(reg2, n); |
440 | push(reg2); |
439 | push(reg2); |
441 | drop |
440 | drop |
442 | ELSE |
441 | ELSE |
443 | OutByte(68H + short(n)); OutIntByte(n) (* push n *) |
442 | X86.pushc(n) |
444 | END |
443 | END |
445 | END pushc; |
444 | END pushc; |
Line 446... | Line 445... | ||
446 | 445 | ||
Line 551... | Line 550... | ||
551 | BEGIN |
550 | BEGIN |
552 | X86.jcc(cc, label) |
551 | X86.jcc(cc, label) |
553 | END jcc; |
552 | END jcc; |
Line 554... | Line -... | ||
554 | - | ||
555 | - | ||
556 | PROCEDURE jmp (label: INTEGER); (* jmp label *) |
- | |
557 | BEGIN |
- | |
558 | X86.jmp(label) |
- | |
559 | END jmp; |
- | |
560 | - | ||
561 | - | ||
562 | PROCEDURE setcc (cc, reg: INTEGER); (* setcc reg8 *) |
- | |
563 | BEGIN |
- | |
564 | IF reg >= 8 THEN |
- | |
565 | OutByte(41H) |
- | |
566 | END; |
- | |
567 | OutByte3(0FH, cc, 0C0H + reg MOD 8) |
- | |
568 | END setcc; |
- | |
569 | 553 | ||
570 | 554 | ||
571 | PROCEDURE shiftrc (op, reg, n: INTEGER); |
555 | PROCEDURE shiftrc (op, reg, n: INTEGER); |
572 | BEGIN |
556 | BEGIN |
573 | Rex(reg, 0); |
557 | Rex(reg, 0); |
Line 827... | Line 811... | ||
827 | |IL.opGEF: |
811 | |IL.opGEF: |
828 | comisd(xmm - 1, xmm); |
812 | comisd(xmm - 1, xmm); |
829 | cc := setnc |
813 | cc := setnc |
830 | END; |
814 | END; |
831 | OutByte2(7AH, 3 + reg DIV 8); (* jp L *) |
815 | OutByte2(7AH, 3 + reg DIV 8); (* jp L *) |
832 | setcc(cc, reg); |
816 | X86.setcc(cc, reg) |
833 | (* L: *) |
817 | (* L: *) |
834 | END fcmp; |
818 | END fcmp; |
Line 835... | Line 819... | ||
835 | 819 | ||
Line 857... | Line 841... | ||
857 | opcode := cmd.opcode; |
841 | opcode := cmd.opcode; |
Line 858... | Line 842... | ||
858 | 842 | ||
Line 859... | Line 843... | ||
859 | CASE opcode OF |
843 | CASE opcode OF |
860 | 844 | ||
Line 861... | Line 845... | ||
861 | |IL.opJMP: |
845 | |IL.opJMP: |
862 | jmp(param1) |
846 | X86.jmp(param1) |
863 | 847 | ||
864 | |IL.opCALL, IL.opWIN64CALL, IL.opSYSVCALL: |
848 | |IL.opCALL, IL.opWIN64CALL, IL.opSYSVCALL: |
Line 905... | Line 889... | ||
905 | |IL.opERR: |
889 | |IL.opERR: |
906 | CallRTL(IL._error) |
890 | CallRTL(IL._error) |
Line 907... | Line 891... | ||
907 | 891 | ||
908 | |IL.opONERR: |
892 | |IL.opONERR: |
909 | pushc(param2); |
893 | pushc(param2); |
Line 910... | Line 894... | ||
910 | jmp(param1) |
894 | X86.jmp(param1) |
911 | 895 | ||
Line 912... | Line 896... | ||
912 | |IL.opPUSHC: |
896 | |IL.opPUSHC: |
913 | pushc(param2) |
897 | pushc(param2) |
914 | 898 | ||
915 | |IL.opPRECALL: |
899 | |IL.opPRECALL: |
916 | n := param2; |
900 | PushAll(0); |
- | 901 | IF (param2 # 0) & (xmm >= 0) THEN |
|
- | 902 | subrc(rsp, 8) |
|
917 | IF (param1 # 0) & (n # 0) THEN |
903 | END; |
918 | subrc(rsp, 8) |
904 | INC(Xmm[0]); |
919 | END; |
905 | Xmm[Xmm[0]] := xmm + 1; |
920 | WHILE n > 0 DO |
906 | WHILE xmm >= 0 DO |
921 | subrc(rsp, 8); |
- | |
922 | movsdmr(rsp, 0, xmm); |
907 | subrc(rsp, 8); |
923 | DEC(xmm); |
908 | movsdmr(rsp, 0, xmm); |
924 | DEC(n) |
- | |
Line 925... | Line 909... | ||
925 | END; |
909 | DEC(xmm) |
926 | ASSERT(xmm = -1); |
910 | END; |
927 | PushAll(0) |
911 | ASSERT(xmm = -1) |
928 | 912 | ||
Line 940... | Line 924... | ||
940 | push(rax); |
924 | push(rax); |
941 | IF ~ODD(param2) THEN |
925 | IF ~ODD(param2) THEN |
942 | push(rax) |
926 | push(rax) |
943 | END |
927 | END |
Line 944... | Line 928... | ||
944 | 928 | ||
- | 929 | |IL.opRESF, IL.opRES: |
|
945 | |IL.opRESF: |
930 | ASSERT(R.top = -1); |
- | 931 | ASSERT(xmm = -1); |
|
- | 932 | n := Xmm[Xmm[0]]; DEC(Xmm[0]); |
|
- | 933 | ||
946 | ASSERT(xmm = -1); |
934 | IF opcode = IL.opRESF THEN |
947 | INC(xmm); |
- | |
948 | n := param2; |
935 | INC(xmm); |
949 | IF n > 0 THEN |
936 | IF n > 0 THEN |
950 | movsdmr(rsp, n * 8, xmm); |
937 | movsdmr(rsp, n * 8, 0); |
951 | DEC(xmm); |
938 | DEC(xmm); |
952 | INC(n) |
939 | INC(n) |
Line 953... | Line 940... | ||
953 | END; |
940 | END; |
954 | - | ||
955 | WHILE n > 0 DO |
941 | |
956 | INC(xmm); |
- | |
957 | movsdrm(xmm, rsp, 0); |
- | |
958 | addrc(rsp, 8); |
942 | IF xmm + n > MAX_XMM THEN |
- | 943 | ERRORS.ErrorMsg(fname, param1, param2, FPR_ERR) |
|
- | 944 | END |
|
- | 945 | ELSE |
|
Line 959... | Line -... | ||
959 | DEC(n) |
- | |
960 | END |
- | |
961 | - | ||
962 | |IL.opRES: |
- | |
963 | ASSERT(R.top = -1); |
946 | GetRegA |
964 | GetRegA; |
947 | END; |
965 | n := param2; |
948 | |
966 | WHILE n > 0 DO |
949 | WHILE n > 0 DO |
967 | INC(xmm); |
950 | INC(xmm); |
Line 1135... | Line 1118... | ||
1135 | reg1 := GetAnyReg(); |
1118 | reg1 := GetAnyReg(); |
1136 | reg2 := GetVarReg(param2); |
1119 | reg2 := GetVarReg(param2); |
1137 | IF reg2 # -1 THEN |
1120 | IF reg2 # -1 THEN |
1138 | mov(reg1, reg2) |
1121 | mov(reg1, reg2) |
1139 | ELSE |
1122 | ELSE |
1140 | n := param2 * 8; |
1123 | movrm32(reg1, rbp, param2 * 8) |
1141 | xor(reg1, reg1); |
1124 | END; |
1142 | movrm32(reg1, rbp, n) |
1125 | shiftrc(shl, reg1, 32); |
1143 | END |
1126 | shiftrc(shr, reg1, 32) |
Line 1144... | Line 1127... | ||
1144 | 1127 | ||
1145 | |IL.opGLOAD64: |
1128 | |IL.opGLOAD64: |
1146 | reg1 := GetAnyReg(); |
1129 | reg1 := GetAnyReg(); |
1147 | lea(reg1, param2, sBSS); |
1130 | Rex(0, reg1); (* mov reg1, qword[rip + param2 + BSS] *) |
1148 | movrm(reg1, reg1, 0) |
- | |
1149 | - | ||
1150 | |IL.opGLOAD8: |
- | |
1151 | reg1 := GetAnyReg(); |
1131 | OutByte2(8BH, 05H + 8 * (reg1 MOD 8)); |
1152 | lea(reg1, param2, sBSS); |
- | |
1153 | movzx(reg1, reg1, 0, FALSE) |
1132 | X86.Reloc(sBSS, param2) |
1154 | 1133 | ||
1155 | |IL.opGLOAD16: |
1134 | |IL.opGLOAD8, IL.opGLOAD16: |
1156 | reg1 := GetAnyReg(); |
1135 | reg1 := GetAnyReg(); |
- | 1136 | Rex(0, reg1); (* movzx reg1, byte/word[rip + param2 + BSS] *) |
|
1157 | lea(reg1, param2, sBSS); |
1137 | OutByte3(0FH, 0B6H + ORD(opcode = IL.opGLOAD16), 05H + 8 * (reg1 MOD 8)); |
Line 1158... | Line 1138... | ||
1158 | movzx(reg1, reg1, 0, TRUE) |
1138 | X86.Reloc(sBSS, param2) |
1159 | 1139 | ||
1160 | |IL.opGLOAD32: |
- | |
1161 | reg1 := GetAnyReg(); |
1140 | |IL.opGLOAD32: |
1162 | xor(reg1, reg1); |
1141 | reg1 := GetAnyReg(); |
- | 1142 | lea(reg1, param2, sBSS); |
|
- | 1143 | movrm32(reg1, reg1, 0); |
|
Line 1163... | Line 1144... | ||
1163 | lea(reg1, param2, sBSS); |
1144 | shiftrc(shl, reg1, 32); |
1164 | movrm32(reg1, reg1, 0) |
1145 | shiftrc(shr, reg1, 32) |
1165 | 1146 | ||
1166 | |IL.opVLOAD64: |
1147 | |IL.opVLOAD64: |
Line 1175... | Line 1156... | ||
1175 | movzx(reg1, reg1, 0, opcode = IL.opVLOAD16) |
1156 | movzx(reg1, reg1, 0, opcode = IL.opVLOAD16) |
Line 1176... | Line 1157... | ||
1176 | 1157 | ||
1177 | |IL.opVLOAD32: |
1158 | |IL.opVLOAD32: |
1178 | reg1 := GetAnyReg(); |
1159 | reg1 := GetAnyReg(); |
1179 | reg2 := GetAnyReg(); |
- | |
1180 | xor(reg1, reg1); |
1160 | reg2 := GetAnyReg(); |
1181 | movrm(reg2, rbp, param2 * 8); |
1161 | movrm(reg2, rbp, param2 * 8); |
- | 1162 | movrm32(reg1, reg2, 0); |
|
- | 1163 | shiftrc(shl, reg1, 32); |
|
1182 | movrm32(reg1, reg2, 0); |
1164 | shiftrc(shr, reg1, 32); |
Line 1183... | Line 1165... | ||
1183 | drop |
1165 | drop |
1184 | 1166 | ||
1185 | |IL.opLADR: |
1167 | |IL.opLADR: |
1186 | n := param2 * 8; |
1168 | n := param2 * 8; |
- | 1169 | next := cmd.next(COMMAND); |
|
1187 | next := cmd.next(COMMAND); |
1170 | IF (next.opcode = IL.opSAVEF) OR (next.opcode = IL.opSAVEFI) THEN |
1188 | IF (next.opcode = IL.opSAVEF) OR (next.opcode = IL.opSAVEFI) THEN |
1171 | ASSERT(xmm >= 0); |
1189 | movsdmr(rbp, n, xmm); |
1172 | movsdmr(rbp, n, xmm); |
1190 | DEC(xmm); |
1173 | DEC(xmm); |
1191 | cmd := next |
1174 | cmd := next |
- | 1175 | ELSIF next.opcode = IL.opLOADF THEN |
|
- | 1176 | INC(xmm); |
|
- | 1177 | IF xmm > MAX_XMM THEN |
|
1192 | ELSIF next.opcode = IL.opLOADF THEN |
1178 | ERRORS.ErrorMsg(fname, next.param1, next.param2, FPR_ERR) |
1193 | INC(xmm); |
1179 | END; |
1194 | movsdrm(xmm, rbp, n); |
1180 | movsdrm(xmm, rbp, n); |
- | 1181 | cmd := next |
|
- | 1182 | ELSE |
|
- | 1183 | IF (next.opcode = IL.opADDC) & ~isLong(n + next.param2) THEN |
|
- | 1184 | INC(n, next.param2); |
|
1195 | cmd := next |
1185 | cmd := next |
1196 | ELSE |
1186 | END; |
1197 | reg1 := GetAnyReg(); |
1187 | reg1 := GetAnyReg(); |
1198 | Rex(0, reg1); |
1188 | Rex(0, reg1); |
1199 | OutByte2(8DH, 45H + long(n) + (reg1 MOD 8) * 8); (* lea reg1, qword[rbp+n] *) |
1189 | OutByte2(8DH, 45H + long(n) + (reg1 MOD 8) * 8); (* lea reg1, qword[rbp+n] *) |
Line 1200... | Line 1190... | ||
1200 | OutIntByte(n) |
1190 | OutIntByte(n) |
- | 1191 | END |
|
- | 1192 | ||
- | 1193 | |IL.opGADR: |
|
- | 1194 | next := cmd.next(COMMAND); |
|
- | 1195 | IF (next.opcode = IL.opADDC) & ~isLong(param2 + next.param2) THEN |
|
1201 | END |
1196 | INC(param2, next.param2); |
Line 1202... | Line 1197... | ||
1202 | 1197 | cmd := next |
|
1203 | |IL.opGADR: |
1198 | END; |
Line 1309... | Line 1304... | ||
1309 | 1304 | ||
1310 | drop; |
1305 | drop; |
Line 1311... | Line 1306... | ||
1311 | cc := X86.cond(opcode); |
1306 | cc := X86.cond(opcode); |
1312 | 1307 | ||
1313 | next := cmd.next(COMMAND); |
1308 | next := cmd.next(COMMAND); |
1314 | IF next.opcode = IL.opJE THEN |
1309 | IF next.opcode = IL.opJNZ THEN |
1315 | jcc(cc, next.param1); |
1310 | jcc(cc, next.param1); |
1316 | cmd := next |
1311 | cmd := next |
1317 | ELSIF next.opcode = IL.opJNE THEN |
1312 | ELSIF next.opcode = IL.opJZ THEN |
1318 | jcc(X86.inv0(cc), next.param1); |
1313 | jcc(X86.inv0(cc), next.param1); |
1319 | cmd := next |
1314 | cmd := next |
1320 | ELSE |
1315 | ELSE |
1321 | reg1 := GetAnyReg(); |
1316 | reg1 := GetAnyReg(); |
1322 | setcc(cc + 16, reg1); |
1317 | X86.setcc(cc + 16, reg1); |
Line 1323... | Line 1318... | ||
1323 | andrc(reg1, 1) |
1318 | andrc(reg1, 1) |
1324 | END |
1319 | END |
Line 1340... | Line 1335... | ||
1340 | ELSE |
1335 | ELSE |
1341 | ASSERT(R.top + 1 <= n); |
1336 | ASSERT(R.top + 1 <= n); |
1342 | PushAll(n) |
1337 | PushAll(n) |
1343 | END |
1338 | END |
Line 1344... | Line -... | ||
1344 | - | ||
1345 | |IL.opACC: |
- | |
1346 | IF (R.top # 0) OR (R.stk[0] # rax) THEN |
- | |
1347 | PushAll(0); |
- | |
1348 | GetRegA; |
- | |
1349 | pop(rax); |
- | |
1350 | DEC(R.pushed) |
- | |
1351 | END |
- | |
1352 | 1339 | ||
1353 | |IL.opJNZ: |
1340 | |IL.opJNZ1: |
1354 | UnOp(reg1); |
1341 | UnOp(reg1); |
1355 | test(reg1); |
1342 | test(reg1); |
Line 1356... | Line -... | ||
1356 | jcc(jne, param1) |
- | |
1357 | - | ||
1358 | |IL.opJZ: |
- | |
1359 | UnOp(reg1); |
- | |
1360 | test(reg1); |
- | |
1361 | jcc(je, param1) |
1343 | jcc(jne, param1) |
1362 | 1344 | ||
1363 | |IL.opJG: |
1345 | |IL.opJG: |
1364 | UnOp(reg1); |
1346 | UnOp(reg1); |
Line 1365... | Line 1347... | ||
1365 | test(reg1); |
1347 | test(reg1); |
1366 | jcc(jg, param1) |
1348 | jcc(jg, param1) |
1367 | 1349 | ||
1368 | |IL.opJE: |
1350 | |IL.opJNZ: |
1369 | UnOp(reg1); |
1351 | UnOp(reg1); |
Line 1370... | Line 1352... | ||
1370 | test(reg1); |
1352 | test(reg1); |
1371 | jcc(jne, param1); |
1353 | jcc(jne, param1); |
1372 | drop |
1354 | drop |
1373 | 1355 | ||
1374 | |IL.opJNE: |
1356 | |IL.opJZ: |
Line 1386... | Line 1368... | ||
1386 | L := NewLabel(); |
1368 | L := NewLabel(); |
1387 | BinOp(reg1, reg2); |
1369 | BinOp(reg1, reg2); |
1388 | cmprc(reg1, 64); |
1370 | cmprc(reg1, 64); |
1389 | jcc(jb, L); |
1371 | jcc(jb, L); |
1390 | xor(reg1, reg1); |
1372 | xor(reg1, reg1); |
1391 | jmp(label); |
1373 | X86.jmp(label); |
1392 | X86.SetLabel(L); |
1374 | X86.SetLabel(L); |
1393 | Rex(reg2, reg1); |
1375 | Rex(reg2, reg1); |
1394 | OutByte3(0FH, 0A3H, 0C0H + 8 * (reg1 MOD 8) + reg2 MOD 8); (* bt reg2, reg1 *) |
1376 | OutByte3(0FH, 0A3H, 0C0H + 8 * (reg1 MOD 8) + reg2 MOD 8); (* bt reg2, reg1 *) |
1395 | setcc(setc, reg1); |
1377 | X86.setcc(setc, reg1); |
1396 | andrc(reg1, 1); |
1378 | andrc(reg1, 1); |
1397 | X86.SetLabel(label); |
1379 | X86.SetLabel(label); |
1398 | drop |
1380 | drop |
Line 1399... | Line 1381... | ||
1399 | 1381 | ||
1400 | |IL.opINL: |
1382 | |IL.opINL: |
1401 | UnOp(reg1); |
1383 | UnOp(reg1); |
1402 | Rex(reg1, 0); |
1384 | Rex(reg1, 0); |
1403 | OutByte2(0FH, 0BAH); (* bt reg1, param2 *) |
1385 | OutByte2(0FH, 0BAH); (* bt reg1, param2 *) |
1404 | OutByte2(0E0H + reg1 MOD 8, param2); |
1386 | OutByte2(0E0H + reg1 MOD 8, param2); |
1405 | setcc(setc, reg1); |
1387 | X86.setcc(setc, reg1); |
Line 1406... | Line 1388... | ||
1406 | andrc(reg1, 1) |
1388 | andrc(reg1, 1) |
1407 | 1389 | ||
1408 | |IL.opNOT: |
1390 | |IL.opNOT: |
1409 | UnOp(reg1); |
1391 | UnOp(reg1); |
1410 | test(reg1); |
1392 | test(reg1); |
Line 1411... | Line 1393... | ||
1411 | setcc(sete, reg1); |
1393 | X86.setcc(sete, reg1); |
1412 | andrc(reg1, 1) |
1394 | andrc(reg1, 1) |
1413 | 1395 | ||
1414 | |IL.opORD: |
1396 | |IL.opORD: |
1415 | UnOp(reg1); |
1397 | UnOp(reg1); |
Line 1416... | Line 1398... | ||
1416 | test(reg1); |
1398 | test(reg1); |
1417 | setcc(setne, reg1); |
1399 | X86.setcc(setne, reg1); |
1418 | andrc(reg1, 1) |
1400 | andrc(reg1, 1) |
Line 1437... | Line 1419... | ||
1437 | jcc(je, label); |
1419 | jcc(je, label); |
1438 | movrc(reg2, 1); |
1420 | movrc(reg2, 1); |
1439 | X86.SetLabel(label); |
1421 | X86.SetLabel(label); |
1440 | cmprr(reg1, reg2); |
1422 | cmprr(reg1, reg2); |
1441 | IF opcode = IL.opEQB THEN |
1423 | IF opcode = IL.opEQB THEN |
1442 | setcc(sete, reg1) |
1424 | X86.setcc(sete, reg1) |
1443 | ELSE |
1425 | ELSE |
1444 | setcc(setne, reg1) |
1426 | X86.setcc(setne, reg1) |
1445 | END; |
1427 | END; |
1446 | andrc(reg1, 1) |
1428 | andrc(reg1, 1) |
Line 1447... | Line 1429... | ||
1447 | 1429 | ||
1448 | |IL.opMULSC: |
1430 | |IL.opMULSC: |
Line 1451... | Line 1433... | ||
1451 | 1433 | ||
1452 | |IL.opDIVSC: |
1434 | |IL.opDIVSC: |
1453 | UnOp(reg1); |
1435 | UnOp(reg1); |
Line 1454... | Line 1436... | ||
1454 | xorrc(reg1, param2) |
1436 | xorrc(reg1, param2) |
1455 | 1437 | ||
1456 | |IL.opADDSL, IL.opADDSR: |
1438 | |IL.opADDSC: |
Line 1457... | Line 1439... | ||
1457 | UnOp(reg1); |
1439 | UnOp(reg1); |
1458 | orrc(reg1, param2) |
1440 | orrc(reg1, param2) |
Line 1686... | Line 1668... | ||
1686 | sub(reg1, reg2); |
1668 | sub(reg1, reg2); |
1687 | drop |
1669 | drop |
Line 1688... | Line 1670... | ||
1688 | 1670 | ||
1689 | |IL.opSUBR, IL.opSUBL: |
1671 | |IL.opSUBR, IL.opSUBL: |
1690 | UnOp(reg1); |
- | |
1691 | n := param2; |
1672 | UnOp(reg1); |
1692 | IF n = 1 THEN |
1673 | IF param2 = 1 THEN |
1693 | decr(reg1) |
1674 | decr(reg1) |
1694 | ELSIF n = -1 THEN |
1675 | ELSIF param2 = -1 THEN |
1695 | incr(reg1) |
1676 | incr(reg1) |
1696 | ELSIF n # 0 THEN |
1677 | ELSIF param2 # 0 THEN |
1697 | subrc(reg1, n) |
1678 | subrc(reg1, param2) |
1698 | END; |
1679 | END; |
1699 | IF opcode = IL.opSUBL THEN |
1680 | IF opcode = IL.opSUBL THEN |
1700 | neg(reg1) |
1681 | neg(reg1) |
Line 1701... | Line 1682... | ||
1701 | END |
1682 | END |
1702 | 1683 | ||
1703 | |IL.opADDL, IL.opADDR: |
1684 | |IL.opADDC: |
1704 | IF (param2 # 0) & ~isLong(param2) THEN |
1685 | IF (param2 # 0) & ~isLong(param2) THEN |
1705 | UnOp(reg1); |
1686 | UnOp(reg1); |
1706 | next := cmd.next(COMMAND); |
1687 | next := cmd.next(COMMAND); |
Line 1849... | Line 1830... | ||
1849 | END |
1830 | END |
1850 | END |
1831 | END |
Line 1851... | Line 1832... | ||
1851 | 1832 | ||
1852 | |IL.opADDS: |
1833 | |IL.opADDS: |
1853 | BinOp(reg1, reg2); |
1834 | BinOp(reg1, reg2); |
1854 | or(reg1, reg2); |
1835 | _or(reg1, reg2); |
Line 1855... | Line 1836... | ||
1855 | drop |
1836 | drop |
1856 | 1837 | ||
1857 | |IL.opSUBS: |
1838 | |IL.opSUBS: |
1858 | BinOp(reg1, reg2); |
1839 | BinOp(reg1, reg2); |
1859 | not(reg2); |
1840 | not(reg2); |
Line 1860... | Line 1841... | ||
1860 | and(reg1, reg2); |
1841 | and(reg1, reg2); |
Line 1861... | Line 1842... | ||
1861 | drop |
1842 | drop |
1862 | 1843 | ||
1863 | |IL.opNOP: |
1844 | |IL.opNOP, IL.opAND, IL.opOR: |
1864 | 1845 | ||
Line 2006... | Line 1987... | ||
2006 | drop; |
1987 | drop; |
2007 | drop; |
1988 | drop; |
2008 | reg1 := GetAnyReg(); |
1989 | reg1 := GetAnyReg(); |
Line 2009... | Line 1990... | ||
2009 | 1990 | ||
2010 | CASE opcode OF |
1991 | CASE opcode OF |
2011 | |IL.opEQP, IL.opEQIP: setcc(sete, reg1) |
1992 | |IL.opEQP, IL.opEQIP: X86.setcc(sete, reg1) |
2012 | |IL.opNEP, IL.opNEIP: setcc(setne, reg1) |
1993 | |IL.opNEP, IL.opNEIP: X86.setcc(setne, reg1) |
Line 2013... | Line 1994... | ||
2013 | END; |
1994 | END; |
Line 2014... | Line 1995... | ||
2014 | 1995 | ||
Line 2043... | Line 2024... | ||
2043 | END; |
2024 | END; |
2044 | OutByte2(8FH, reg1 MOD 8); (* pop qword[reg1] *) |
2025 | OutByte2(8FH, reg1 MOD 8); (* pop qword[reg1] *) |
2045 | drop |
2026 | drop |
Line 2046... | Line 2027... | ||
2046 | 2027 | ||
2047 | |IL.opCLEANUP: |
- | |
2048 | n := param2 * 8; |
2028 | |IL.opCLEANUP: |
2049 | IF n # 0 THEN |
2029 | IF param2 # 0 THEN |
2050 | addrc(rsp, n) |
2030 | addrc(rsp, param2 * 8) |
Line 2051... | Line 2031... | ||
2051 | END |
2031 | END |
2052 | 2032 | ||
Line 2053... | Line 2033... | ||
2053 | |IL.opPOPSP: |
2033 | |IL.opPOPSP: |
2054 | pop(rsp) |
2034 | pop(rsp) |
2055 | 2035 | ||
- | 2036 | |IL.opLOADF: |
|
- | 2037 | UnOp(reg1); |
|
- | 2038 | INC(xmm); |
|
2056 | |IL.opLOADF: |
2039 | IF xmm > MAX_XMM THEN |
2057 | UnOp(reg1); |
2040 | ERRORS.ErrorMsg(fname, param1, param2, FPR_ERR) |
Line 2058... | Line 2041... | ||
2058 | INC(xmm); |
2041 | END; |
- | 2042 | movsdrm(xmm, reg1, 0); |
|
2059 | movsdrm(xmm, reg1, 0); |
2043 | drop |
2060 | drop |
2044 | |
2061 | 2045 | |IL.opPUSHF: |
|
Line 2062... | Line 2046... | ||
2062 | |IL.opPUSHF: |
2046 | ASSERT(xmm >= 0); |
2063 | subrc(rsp, 8); |
2047 | subrc(rsp, 8); |
2064 | movsdmr(rsp, 0, xmm); |
2048 | movsdmr(rsp, 0, xmm); |
2065 | DEC(xmm) |
2049 | DEC(xmm) |
- | 2050 | ||
- | 2051 | |IL.opCONSTF: |
|
2066 | 2052 | float := cmd.float; |
|
- | 2053 | INC(xmm); |
|
2067 | |IL.opCONSTF: |
2054 | IF xmm > MAX_XMM THEN |
- | 2055 | ERRORS.ErrorMsg(fname, param1, param2, FPR_ERR) |
|
2068 | float := cmd.float; |
2056 | END; |
- | 2057 | (* movsd xmm, qword ptr [rip + Numbers_Offs + Numbers_Count * 8 + DATA] *) |
|
- | 2058 | OutByte(0F2H); |
|
2069 | INC(xmm); |
2059 | IF xmm >= 8 THEN |
Line 2070... | Line 2060... | ||
2070 | reg1 := GetAnyReg(); |
2060 | OutByte(44H) |
- | 2061 | END; |
|
2071 | lea(reg1, Numbers_Offs + Numbers_Count * 8, sDATA); |
2062 | OutByte3(0FH, 10H, 05H + 8 * (xmm MOD 8)); |
2072 | movsdrm(xmm, reg1, 0); |
2063 | X86.Reloc(sDATA, Numbers_Offs + Numbers_Count * 8); |
2073 | drop; |
2064 | NewNumber(UTILS.splitf(float, a, b)) |
2074 | NewNumber(UTILS.splitf(float, a, b)) |
2065 | |
Line 2075... | Line 2066... | ||
2075 | 2066 | |IL.opSAVEF, IL.opSAVEFI: |
|
- | 2067 | ASSERT(xmm >= 0); |
|
2076 | |IL.opSAVEF, IL.opSAVEFI: |
2068 | UnOp(reg1); |
2077 | UnOp(reg1); |
2069 | movsdmr(reg1, 0, xmm); |
Line 2078... | Line 2070... | ||
2078 | movsdmr(reg1, 0, xmm); |
2070 | DEC(xmm); |
- | 2071 | drop |
|
2079 | DEC(xmm); |
2072 | |
2080 | drop |
2073 | |IL.opADDF: |
Line 2081... | Line 2074... | ||
2081 | 2074 | ASSERT(xmm >= 1); |
|
- | 2075 | opxx(58H, xmm - 1, xmm); |
|
2082 | |IL.opADDF, IL.opADDFI: |
2076 | DEC(xmm) |
2083 | opxx(58H, xmm - 1, xmm); |
2077 | |
2084 | DEC(xmm) |
2078 | |IL.opSUBF: |
Line 2085... | Line 2079... | ||
2085 | 2079 | ASSERT(xmm >= 1); |
|
- | 2080 | opxx(5CH, xmm - 1, xmm); |
|
2086 | |IL.opSUBF: |
2081 | DEC(xmm) |
2087 | opxx(5CH, xmm - 1, xmm); |
2082 | |
Line 2088... | Line 2083... | ||
2088 | DEC(xmm) |
2083 | |IL.opSUBFI: |
- | 2084 | ASSERT(xmm >= 1); |
|
2089 | 2085 | opxx(5CH, xmm, xmm - 1); |
|
2090 | |IL.opSUBFI: |
2086 | opxx(10H, xmm - 1, xmm); |
Line 2091... | Line 2087... | ||
2091 | opxx(5CH, xmm, xmm - 1); |
2087 | DEC(xmm) |
- | 2088 | ||
2092 | opxx(10H, xmm - 1, xmm); |
2089 | |IL.opMULF: |
2093 | DEC(xmm) |
2090 | ASSERT(xmm >= 1); |
2094 | 2091 | opxx(59H, xmm - 1, xmm); |
|
Line 2095... | Line -... | ||
2095 | |IL.opMULF: |
- | |
2096 | opxx(59H, xmm - 1, xmm); |
- | |
2097 | DEC(xmm) |
- | |
2098 | 2092 | DEC(xmm) |
|
2099 | |IL.opDIVF: |
2093 | |
2100 | opxx(5EH, xmm - 1, xmm); |
2094 | |IL.opDIVF: |
2101 | DEC(xmm) |
- | |
2102 | 2095 | ASSERT(xmm >= 1); |
|
2103 | |IL.opDIVFI: |
2096 | opxx(5EH, xmm - 1, xmm); |
2104 | opxx(5EH, xmm, xmm - 1); |
2097 | DEC(xmm) |
2105 | opxx(10H, xmm - 1, xmm); |
2098 | |
2106 | DEC(xmm) |
2099 | |IL.opDIVFI: |
2107 | - | ||
Line 2108... | Line 2100... | ||
2108 | |IL.opUMINF: |
2100 | ASSERT(xmm >= 1); |
2109 | reg1 := GetAnyReg(); |
2101 | opxx(5EH, xmm, xmm - 1); |
2110 | lea(reg1, Numbers_Offs, sDATA); |
2102 | opxx(10H, xmm - 1, xmm); |
- | 2103 | DEC(xmm) |
|
- | 2104 | ||
- | 2105 | |IL.opFABS, IL.opUMINF: (* andpd/xorpd xmm, xmmword[rip + Numbers_Offs + (16) + DATA] *) |
|
2111 | OutByte3(66H, 40H + reg1 DIV 8 + (xmm DIV 8) * 4, 0FH); (* xorpd xmm, xmmword[reg1] *) |
2106 | ASSERT(xmm >= 0); |
2112 | OutByte2(57H, reg1 MOD 8 + (xmm MOD 8) * 8); |
2107 | OutByte(66H); |
2113 | drop |
2108 | IF xmm >= 8 THEN |
Line 2114... | Line 2109... | ||
2114 | 2109 | OutByte(44H) |
|
- | 2110 | END; |
|
2115 | |IL.opFABS: |
2111 | OutByte3(0FH, 54H + 3 * ORD(opcode = IL.opUMINF), 05H + (xmm MOD 8) * 8); |
2116 | reg1 := GetAnyReg(); |
2112 | X86.Reloc(sDATA, Numbers_Offs + 16 * ORD(opcode = IL.opFABS)) |
2117 | lea(reg1, Numbers_Offs + 16, sDATA); |
2113 | |
2118 | OutByte3(66H, 40H + reg1 DIV 8 + (xmm DIV 8) * 4, 0FH); (* andpd xmm, xmmword[reg1] *) |
2114 | |IL.opFLT: |
2119 | OutByte2(54H, reg1 MOD 8 + (xmm MOD 8) * 8); |
2115 | UnOp(reg1); |
Line 2139... | Line 2135... | ||
2139 | OutByte3(00FH, 0AEH, 054H); OutByte2(024H, 004H); (* ldmxcsr dword[rsp+4]; *) |
2135 | OutByte3(00FH, 0AEH, 054H); OutByte2(024H, 004H); (* ldmxcsr dword[rsp+4]; *) |
2140 | addrc(rsp, 8); |
2136 | addrc(rsp, 8); |
2141 | DEC(xmm) |
2137 | DEC(xmm) |
Line 2142... | Line 2138... | ||
2142 | 2138 | ||
- | 2139 | |IL.opEQF .. IL.opGEF: |
|
2143 | |IL.opEQF .. IL.opGEF: |
2140 | ASSERT(xmm >= 1); |
2144 | fcmp(opcode, xmm); |
2141 | fcmp(opcode, xmm); |
Line 2145... | Line 2142... | ||
2145 | DEC(xmm, 2) |
2142 | DEC(xmm, 2) |
2146 | 2143 | ||
2147 | |IL.opINF: |
2144 | |IL.opINF: |
- | 2145 | INC(xmm); |
|
- | 2146 | IF xmm > MAX_XMM THEN |
|
2148 | INC(xmm); |
2147 | ERRORS.ErrorMsg(fname, param1, param2, FPR_ERR) |
- | 2148 | END; |
|
2149 | reg1 := GetAnyReg(); |
2149 | (* movsd xmm, qword ptr [rip + Numbers_Offs + 32 + DATA] *) |
- | 2150 | OutByte(0F2H); |
|
2150 | lea(reg1, Numbers_Offs + 32, sDATA); |
2151 | IF xmm >= 8 THEN |
- | 2152 | OutByte(44H) |
|
- | 2153 | END; |
|
Line 2151... | Line 2154... | ||
2151 | movsdrm(xmm, reg1, 0); |
2154 | OutByte3(0FH, 10H, 05H + 8 * (xmm MOD 8)); |
2152 | drop |
2155 | X86.Reloc(sDATA, Numbers_Offs + 32) |
2153 | 2156 | ||
2154 | |IL.opPACK, IL.opPACKC: |
2157 | |IL.opPACK, IL.opPACKC: |
Line 2173... | Line 2176... | ||
2173 | lea(reg1, Numbers_Offs + 40, sDATA); (* {0..51, 63} *) |
2176 | lea(reg1, Numbers_Offs + 40, sDATA); (* {0..51, 63} *) |
2174 | movrm(reg1, reg1, 0); |
2177 | movrm(reg1, reg1, 0); |
2175 | and(reg2, reg1); |
2178 | and(reg2, reg1); |
2176 | pop(reg1); |
2179 | pop(reg1); |
Line 2177... | Line 2180... | ||
2177 | 2180 | ||
2178 | or(reg2, reg1); |
2181 | _or(reg2, reg1); |
2179 | pop(reg1); |
2182 | pop(reg1); |
2180 | movmr(reg1, 0, reg2); |
2183 | movmr(reg1, 0, reg2); |
2181 | drop; |
2184 | drop; |
Line 2216... | Line 2219... | ||
2216 | movrm(reg1, reg2, 0); |
2219 | movrm(reg1, reg2, 0); |
Line 2217... | Line 2220... | ||
2217 | 2220 | ||
2218 | push(reg2); |
2221 | push(reg2); |
2219 | lea(reg2, Numbers_Offs + 48, sDATA); (* {52..61} *) |
2222 | lea(reg2, Numbers_Offs + 48, sDATA); (* {52..61} *) |
2220 | movrm(reg2, reg2, 0); |
2223 | movrm(reg2, reg2, 0); |
2221 | or(reg1, reg2); |
2224 | _or(reg1, reg2); |
Line 2222... | Line 2225... | ||
2222 | pop(reg2); |
2225 | pop(reg2); |
2223 | 2226 | ||
2224 | Rex(reg1, 0); |
2227 | Rex(reg1, 0); |
Line 2246... | Line 2249... | ||
2246 | ELSE |
2249 | ELSE |
2247 | X86.pushm(rbp, param2 * 8) |
2250 | X86.pushm(rbp, param2 * 8) |
2248 | END |
2251 | END |
Line 2249... | Line 2252... | ||
2249 | 2252 | ||
2250 | |IL.opGLOAD64_PARAM: |
- | |
2251 | reg2 := GetAnyReg(); |
2253 | |IL.opGLOAD64_PARAM: |
2252 | lea(reg2, param2, sBSS); |
2254 | OutByte2(0FFH, 35H); (* push qword[rip + param2 + BSS] *) |
2253 | movrm(reg2, reg2, 0); |
- | |
2254 | push(reg2); |
- | |
Line 2255... | Line 2255... | ||
2255 | drop |
2255 | X86.Reloc(sBSS, param2) |
2256 | 2256 | ||
Line 2257... | Line 2257... | ||
2257 | |IL.opCONST_PARAM: |
2257 | |IL.opCONST_PARAM: |
- | 2258 | pushc(param2) |
|
2258 | pushc(param2) |
2259 | |
2259 | - | ||
2260 | |IL.opGLOAD32_PARAM: |
2260 | |IL.opGLOAD32_PARAM, IL.opLOAD32_PARAM: |
2261 | reg1 := GetAnyReg(); |
- | |
2262 | xor(reg1, reg1); |
- | |
2263 | lea(reg1, param2, sBSS); |
2261 | IF opcode = IL.opGLOAD32_PARAM THEN |
2264 | movrm32(reg1, reg1, 0); |
- | |
2265 | push(reg1); |
2262 | reg1 := GetAnyReg(); |
2266 | drop |
2263 | lea(reg1, param2, sBSS) |
2267 | 2264 | ELSE |
|
2268 | |IL.opLOAD32_PARAM: |
2265 | UnOp(reg1) |
2269 | UnOp(reg1); |
2266 | END; |
2270 | movrm32(reg1, reg1, 0); |
2267 | movrm32(reg1, reg1, 0); |
2271 | shiftrc(shl, reg1, 32); |
2268 | shiftrc(shl, reg1, 32); |
Line 2272... | Line 2269... | ||
2272 | shiftrc(shr, reg1, 32); |
2269 | shiftrc(shr, reg1, 32); |
2273 | push(reg1); |
2270 | push(reg1); |
2274 | drop |
- | |
2275 | 2271 | drop |
|
2276 | |IL.opLLOAD32_PARAM: |
2272 | |
2277 | reg1 := GetAnyReg(); |
2273 | |IL.opLLOAD32_PARAM: |
2278 | xor(reg1, reg1); |
2274 | reg1 := GetAnyReg(); |
2279 | reg2 := GetVarReg(param2); |
2275 | reg2 := GetVarReg(param2); |
2280 | IF reg2 # -1 THEN |
2276 | IF reg2 # -1 THEN |
- | 2277 | mov(reg1, reg2) |
|
- | 2278 | ELSE |
|
2281 | mov(reg1, reg2) |
2279 | movrm32(reg1, rbp, param2 * 8) |
2282 | ELSE |
2280 | END; |
Line 2283... | Line 2281... | ||
2283 | movrm32(reg1, rbp, param2 * 8) |
2281 | shiftrc(shl, reg1, 32); |
2284 | END; |
2282 | shiftrc(shr, reg1, 32); |
Line 2311... | Line 2309... | ||
2311 | lea(reg2, param1, sBSS); |
2309 | lea(reg2, param1, sBSS); |
2312 | movmr(reg2, 0, reg1); |
2310 | movmr(reg2, 0, reg1); |
2313 | drop; |
2311 | drop; |
2314 | drop |
2312 | drop |
2315 | ELSE |
2313 | ELSE |
2316 | reg2 := GetAnyReg(); |
2314 | (* mov qword[rip + param1 - 4 + BSS], param2 *) |
2317 | lea(reg2, param1, sBSS); |
2315 | OutByte3(48H, 0C7H, 05H); |
2318 | Rex(reg2, 0); |
2316 | X86.Reloc(sBSS, param1 - 4); |
2319 | OutByte2(0C7H, reg2 MOD 8); (* mov qword[reg2], param2 *) |
- | |
2320 | OutInt(param2); |
2317 | OutInt(param2) |
2321 | drop |
- | |
2322 | END |
2318 | END |
Line 2323... | Line 2319... | ||
2323 | 2319 | ||
2324 | |IL.opLADR_SAVE: |
2320 | |IL.opLADR_SAVE: |
2325 | UnOp(reg1); |
2321 | UnOp(reg1); |
Line 2429... | Line 2425... | ||
2429 | IF reg2 # -1 THEN |
2425 | IF reg2 # -1 THEN |
2430 | OutByte2(73H, 4); (* jnb L *) |
2426 | OutByte2(73H, 4); (* jnb L *) |
2431 | oprr2(0FH, 0ABH + 8 * ORD(opcode = IL.opLADR_EXCL), reg2, reg1) (* bts/btr reg2, reg1 *) |
2427 | oprr2(0FH, 0ABH + 8 * ORD(opcode = IL.opLADR_EXCL), reg2, reg1) (* bts/btr reg2, reg1 *) |
2432 | ELSE |
2428 | ELSE |
2433 | n := param2 * 8; |
2429 | n := param2 * 8; |
2434 | OutByte2(73H, 5 + 3 * ORD(~isByte(n))); (* jnb L *) |
2430 | OutByte2(73H, 5 + 3 * ORD(~X86.isByte(n))); (* jnb L *) |
2435 | Rex(0, reg1); |
2431 | Rex(0, reg1); |
2436 | OutByte3(0FH, 0ABH + 8 * ORD(opcode = IL.opLADR_EXCL), 45H + long(n) + 8 * (reg1 MOD 8)); |
2432 | OutByte3(0FH, 0ABH + 8 * ORD(opcode = IL.opLADR_EXCL), 45H + long(n) + 8 * (reg1 MOD 8)); |
2437 | OutIntByte(n) (* bts/btr qword[rbp+n], reg1 *) |
2433 | OutIntByte(n) (* bts/btr qword[rbp+n], reg1 *) |
2438 | END; |
2434 | END; |
2439 | (* L: *) |
2435 | (* L: *) |
Line 2451... | Line 2447... | ||
2451 | OutByte(6DH + long(n) + 8 * ORD(opcode = IL.opLADR_EXCLC)); |
2447 | OutByte(6DH + long(n) + 8 * ORD(opcode = IL.opLADR_EXCLC)); |
2452 | OutIntByte(n); |
2448 | OutIntByte(n); |
2453 | OutByte(param2) |
2449 | OutByte(param2) |
2454 | END |
2450 | END |
Line -... | Line 2451... | ||
- | 2451 | ||
- | 2452 | |IL.opFNAME: |
|
- | 2453 | fname := cmd(IL.FNAMECMD).fname |
|
2455 | 2454 | ||
Line 2456... | Line 2455... | ||
2456 | |IL.opLOOP, IL.opENDLOOP: |
2455 | |IL.opLOOP, IL.opENDLOOP: |
Line 2457... | Line 2456... | ||
2457 | 2456 | ||
Line 2483... | Line 2482... | ||
2483 | push(r8); |
2482 | push(r8); |
2484 | push(rdx); |
2483 | push(rdx); |
2485 | push(rcx); |
2484 | push(rcx); |
2486 | CallRTL(IL._dllentry); |
2485 | CallRTL(IL._dllentry); |
2487 | test(rax); |
2486 | test(rax); |
2488 | jcc(je, dllret) |
2487 | jcc(je, dllret); |
2489 | END; |
2488 | pushc(0) |
2490 | - | ||
2491 | IF target = TARGETS.Linux64 THEN |
2489 | ELSIF target = TARGETS.Linux64 THEN |
2492 | push(rsp) |
2490 | push(rsp) |
2493 | ELSE |
2491 | ELSE |
2494 | pushc(0) |
2492 | pushc(0) |
2495 | END; |
2493 | END; |
Line 2525... | Line 2523... | ||
2525 | i, n: INTEGER; |
2523 | i, n: INTEGER; |
2526 | number: Number; |
2524 | number: Number; |
2527 | exp: IL.EXPORT_PROC; |
2525 | exp: IL.EXPORT_PROC; |
Line 2528... | Line 2526... | ||
2528 | 2526 | ||
2529 | 2527 | ||
2530 | PROCEDURE import (imp: LISTS.LIST); |
2528 | PROCEDURE _import (imp: LISTS.LIST); |
2531 | VAR |
2529 | VAR |
Line 2532... | Line 2530... | ||
2532 | lib: IL.IMPORT_LIB; |
2530 | lib: IL.IMPORT_LIB; |
Line 2543... | Line 2541... | ||
2543 | proc := proc.next(IL.IMPORT_PROC) |
2541 | proc := proc.next(IL.IMPORT_PROC) |
2544 | END; |
2542 | END; |
2545 | lib := lib.next(IL.IMPORT_LIB) |
2543 | lib := lib.next(IL.IMPORT_LIB) |
2546 | END |
2544 | END |
Line 2547... | Line 2545... | ||
2547 | 2545 | ||
Line 2548... | Line 2546... | ||
2548 | END import; |
2546 | END _import; |
2549 | 2547 | ||
2550 | 2548 | ||
Line 2596... | Line 2594... | ||
2596 | WHILE exp # NIL DO |
2594 | WHILE exp # NIL DO |
2597 | BIN.Export(prog, exp.name, exp.label); |
2595 | BIN.Export(prog, exp.name, exp.label); |
2598 | exp := exp.next(IL.EXPORT_PROC) |
2596 | exp := exp.next(IL.EXPORT_PROC) |
2599 | END; |
2597 | END; |
Line 2600... | Line 2598... | ||
2600 | 2598 | ||
2601 | import(IL.codes.import) |
2599 | _import(IL.codes._import) |
Line 2602... | Line 2600... | ||
2602 | END epilog; |
2600 | END epilog; |
2603 | 2601 | ||
Line 2629... | Line 2627... | ||
2629 | PROCEDURE CodeGen* (outname: ARRAY OF CHAR; target: INTEGER; options: PROG.OPTIONS); |
2627 | PROCEDURE CodeGen* (outname: ARRAY OF CHAR; target: INTEGER; options: PROG.OPTIONS); |
2630 | VAR |
2628 | VAR |
2631 | path, modname, ext: PATHS.PATH; |
2629 | path, modname, ext: PATHS.PATH; |
Line 2632... | Line 2630... | ||
2632 | 2630 | ||
- | 2631 | BEGIN |
|
2633 | BEGIN |
2632 | Xmm[0] := 0; |
Line 2634... | Line 2633... | ||
2634 | tcount := CHL.Length(IL.codes.types); |
2633 | tcount := CHL.Length(IL.codes.types); |
2635 | 2634 | ||
2636 | Win64RegPar[0] := rcx; |
2635 | Win64RegPar[0] := rcx; |