1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
|
// AsmJit - Complete JIT Assembler for C++ Language.
// Copyright (c) 2008-2010, Petr Kobalicek <kobalicek.petr@gmail.com>
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the "Software"), to deal in the Software without
// restriction, including without limitation the rights to use,
// copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following
// conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
// OTHER DEALINGS IN THE SOFTWARE.
// [Guard]
#ifndef _ASMJIT_OPERANDX86X64_H
#define _ASMJIT_OPERANDX86X64_H
#if !defined(_ASMJIT_OPERAND_H)
#warning "AsmJit/OperandX86X64.h can be only included by AsmJit/Operand.h"
#endif // _ASMJIT_OPERAND_H
// [Dependencies]
#include "Build.h"
#include "Defs.h"
namespace AsmJit {
// ============================================================================
// [AsmJit::Forward Declarations]
// ============================================================================
struct BaseReg;
struct BaseVar;
struct Compiler;
struct GPReg;
struct GPVar;
struct Imm;
struct Label;
struct Mem;
struct MMReg;
struct MMVar;
struct Operand;
struct X87Reg;
struct X87Var;
struct XMMReg;
struct XMMVar;
//! @addtogroup AsmJit_Core
//! @{
// ============================================================================
// [AsmJit::Operand]
// ============================================================================
//! @brief Operand, abstract class for register, memory location and immediate
//! value operands.
struct ASMJIT_HIDDEN Operand
{
// --------------------------------------------------------------------------
// [Construction / Destruction]
// --------------------------------------------------------------------------
//! @brief Create an uninitialized operand.
inline Operand() ASMJIT_NOTHROW
{
memset(this, 0, sizeof(Operand));
_base.id = INVALID_VALUE;
}
//! @brief Create a reference to @a other operand.
inline Operand(const Operand& other) ASMJIT_NOTHROW
{
_init(other);
}
#if !defined(ASMJIT_NODOC)
inline Operand(const _DontInitialize&) ASMJIT_NOTHROW
{
}
#endif // ASMJIT_NODOC
// --------------------------------------------------------------------------
// [Init & Copy]
// --------------------------------------------------------------------------
//! @internal
//!
//! @brief Initialize operand to @a other (used by constructors).
inline void _init(const Operand& other) ASMJIT_NOTHROW { memcpy(this, &other, sizeof(Operand)); }
//! @internal
//!
//! @brief Initialize operand to @a other (used by assign operators).
inline void _copy(const Operand& other) ASMJIT_NOTHROW { memcpy(this, &other, sizeof(Operand)); }
// --------------------------------------------------------------------------
// [Identification]
// --------------------------------------------------------------------------
//! @brief Get type of operand, see @c OPERAND_TYPE.
inline uint32_t getType() const ASMJIT_NOTHROW
{ return _base.op; }
//! @brief Get whether operand is none (@c OPERAND_NONE).
inline bool isNone() const ASMJIT_NOTHROW
{ return (_base.op == OPERAND_NONE); }
//! @brief Get whether operand is any (general purpose, mmx or sse) register (@c OPERAND_REG).
inline bool isReg() const ASMJIT_NOTHROW
{ return (_base.op == OPERAND_REG); }
//! @brief Get whether operand is memory address (@c OPERAND_MEM).
inline bool isMem() const ASMJIT_NOTHROW
{ return (_base.op == OPERAND_MEM); }
//! @brief Get whether operand is immediate (@c OPERAND_IMM).
inline bool isImm() const ASMJIT_NOTHROW
{ return (_base.op == OPERAND_IMM); }
//! @brief Get whether operand is label (@c OPERAND_LABEL).
inline bool isLabel() const ASMJIT_NOTHROW
{ return (_base.op == OPERAND_LABEL); }
//! @brief Get whether operand is variable (@c OPERAND_VAR).
inline bool isVar() const ASMJIT_NOTHROW
{ return (_base.op == OPERAND_VAR); }
//! @brief Get whether operand is variable or memory.
inline bool isVarMem() const ASMJIT_NOTHROW
{ return ((_base.op & (OPERAND_VAR | OPERAND_MEM)) != 0); }
//! @brief Get whether operand is register and type of register is @a regType.
inline bool isRegType(uint32_t regType) const ASMJIT_NOTHROW
{ return (_base.op == OPERAND_REG) & ((_reg.code & REG_TYPE_MASK) == regType); }
//! @brief Get whether operand is register and code of register is @a regCode.
inline bool isRegCode(uint32_t regCode) const ASMJIT_NOTHROW
{ return (_base.op == OPERAND_REG) & (_reg.code == regCode); }
//! @brief Get whether operand is register and index of register is @a regIndex.
inline bool isRegIndex(uint32_t regIndex) const ASMJIT_NOTHROW
{ return (_base.op == OPERAND_REG) & ((_reg.code & REG_INDEX_MASK) == (regIndex & REG_INDEX_MASK)); }
//! @brief Get whether operand is any register or memory.
inline bool isRegMem() const ASMJIT_NOTHROW
{ return ((_base.op & (OPERAND_REG | OPERAND_MEM)) != 0); }
//! @brief Get whether operand is register of @a regType type or memory.
inline bool isRegTypeMem(uint32_t regType) const ASMJIT_NOTHROW
{ return ((_base.op == OPERAND_REG) & ((_reg.code & REG_TYPE_MASK) == regType)) | (_base.op == OPERAND_MEM); }
// --------------------------------------------------------------------------
// [Operand Size]
// --------------------------------------------------------------------------
//! @brief Return size of operand in bytes.
inline uint32_t getSize() const ASMJIT_NOTHROW
{ return _base.size; }
// --------------------------------------------------------------------------
// [Operand Id]
// --------------------------------------------------------------------------
//! @brief Return operand Id (Operand Id's are used internally by
//! @c Assembler and @c Compiler classes).
//!
//! @note There is no way how to change or remove operand id. If you don't
//! need the operand just assign different operand to this one.
inline uint32_t getId() const ASMJIT_NOTHROW
{ return _base.id; }
// --------------------------------------------------------------------------
// [Extensions]
// --------------------------------------------------------------------------
//! @brief Get whether the extended register (additional eight registers
//! introduced by 64-bit mode) is used.
inline bool isExtendedRegisterUsed() const ASMJIT_NOTHROW
{
// Hacky, but correct.
// - If operand type is register then extended register is register with
// index 8 and greater (8 to 15 inclusive).
// - If operand type is memory operand then we need to take care about
// label (in _mem.base) and INVALID_VALUE, we just decrement the value
// by 8 and check if it's at interval 0 to 7 inclusive (if it's there
// then it's extended register.
return (isReg() && (_reg.code & REG_INDEX_MASK) >= 8) ||
(isMem() && ((((uint32_t)_mem.base - 8U) < 8U) ||
(((uint32_t)_mem.index - 8U) < 8U) ));
}
// --------------------------------------------------------------------------
// [Data Structures]
// --------------------------------------------------------------------------
//! @internal
//!
//! @brief Base operand data shared between all operands.
struct BaseData
{
//! @brief Type of operand, see @c OPERAND_TYPE.
uint8_t op;
//! @brief Size of operand (register, address, immediate or variable).
uint8_t size;
//! @brief Not used.
uint8_t reserved[2];
//! @brief Operand id (private variable for @c Assembler and @c Compiler classes).
//!
//! @note Uninitialized operands has id equal to zero.
uint32_t id;
};
//! @internal
//!
//! @brief Register data.
struct RegData
{
//! @brief Type of operand, see @c OPERAND_TYPE (in this case @c OPERAND_REG).
uint8_t op;
//! @brief Size of register.
uint8_t size;
//! @brief Not used.
uint8_t reserved[2];
//! @brief Operand id.
uint32_t id;
//! @brief Register code or variable, see @c REG and @c INVALID_VALUE.
uint32_t code;
};
//! @internal
//!
//! @brief Memory address data.
struct MemData
{
//! @brief Type of operand, see @c OPERAND_TYPE (in this case @c OPERAND_MEM).
uint8_t op;
//! @brief Size of pointer.
uint8_t size;
//! @brief Memory operand type, see @c OPERAND_MEM_TYPE.
uint8_t type;
//! @brief Segment override prefix, see @c SEGMENT_PREFIX.
uint8_t segmentPrefix : 4;
//! @brief Index register shift (0 to 3 inclusive).
uint8_t shift : 4;
//! @brief Operand ID.
uint32_t id;
//! @brief Base register index, variable or label id.
uint32_t base;
//! @brief Index register index or variable.
uint32_t index;
//! @brief Target (for 32-bit, absolute address).
void* target;
//! @brief Displacement.
sysint_t displacement;
};
//! @internal
//!
//! @brief Immediate value data.
struct ImmData
{
//! @brief Type of operand, see @c OPERAND_TYPE (in this case @c OPERAND_IMM)..
uint8_t op;
//! @brief Size of immediate (or 0 to autodetect).
uint8_t size;
//! @brief @c true if immediate is unsigned.
uint8_t isUnsigned;
//! @brief Not used.
uint8_t reserved;
//! @brief Operand ID.
uint32_t id;
//! @brief Immediate value.
sysint_t value;
};
//! @internal
//!
//! @brief Label data.
struct LblData
{
//! @brief Type of operand, see @c OPERAND_TYPE (in this case @c OPERAND_LABEL).
uint8_t op;
//! @brief Size of label, currently not used.
uint8_t size;
//! @brief Not used.
uint8_t reserved[2];
//! @brief Operand ID.
uint32_t id;
};
//! @internal
//!
//! @brief Variable data.
struct VarData
{
//! @brief Type of operand, see @c OPERAND_TYPE (in this case @c OPERAND_VAR).
uint8_t op;
//! @brief Size of variable (0 if don't known).
uint8_t size;
//! @brief Not used.
uint8_t reserved[2];
//! @brief Operand ID.
uint32_t id;
//! @brief Type (and later also code) of register, see @c REG_TYPE, @c REG_CODE.
//!
//! @note Register code and variable code are two different things. In most
//! cases registerCode is very related to variableType, but general purpose
//! registers are divided to 64-bit, 32-bit, 16-bit and 8-bit entities so
//! the registerCode can be used to access these, variableType remains
//! unchanged from the initialization state. Variable type describes mainly
//! variable type and home memory size.
uint32_t registerCode;
//! @brief Type of variable. See @c VARIABLE_TYPE enum.
uint32_t variableType;
};
// --------------------------------------------------------------------------
// [Members]
// --------------------------------------------------------------------------
union
{
//! @brief Generic operand data.
BaseData _base;
//! @brief Register operand data.
RegData _reg;
//! @brief Memory operand data.
MemData _mem;
//! @brief Immediate operand data.
ImmData _imm;
//! @brief Label data.
LblData _lbl;
//! @brief Variable data.
VarData _var;
};
};
// ============================================================================
// [AsmJit::BaseReg]
// ============================================================================
//! @brief Base class for all registers.
struct ASMJIT_HIDDEN BaseReg : public Operand
{
// --------------------------------------------------------------------------
// [Construction / Destruction]
// --------------------------------------------------------------------------
//! @brief Create a new base register.
inline BaseReg(uint32_t code, uint32_t size) ASMJIT_NOTHROW :
Operand(_DontInitialize())
{
_reg.op = OPERAND_REG;
_reg.size = (uint8_t)size;
_reg.id = INVALID_VALUE;
_reg.code = code;
}
//! @brief Create a new reference to @a other.
inline BaseReg(const BaseReg& other) ASMJIT_NOTHROW :
Operand(other)
{}
#if !defined(ASMJIT_NODOC)
inline BaseReg(const _DontInitialize& dontInitialize) ASMJIT_NOTHROW :
Operand(dontInitialize)
{}
#endif // ASMJIT_NODOC
// --------------------------------------------------------------------------
// [BaseReg Specific]
// --------------------------------------------------------------------------
//! @brief Get register code, see @c REG.
inline uint32_t getRegCode() const ASMJIT_NOTHROW
{ return (uint32_t)(_reg.code); }
//! @brief Get register type, see @c REG.
inline uint32_t getRegType() const ASMJIT_NOTHROW
{ return (uint32_t)(_reg.code & REG_TYPE_MASK); }
//! @brief Get register index (value from 0 to 7/15).
inline uint32_t getRegIndex() const ASMJIT_NOTHROW
{ return (uint32_t)(_reg.code & REG_INDEX_MASK); }
//! @brief Get whether register code is equal to @a code.
inline bool isRegCode(uint32_t code) const ASMJIT_NOTHROW
{ return _reg.code == code; }
//! @brief Get whether register code is equal to @a type.
inline bool isRegType(uint32_t type) const ASMJIT_NOTHROW
{ return (uint32_t)(_reg.code & REG_TYPE_MASK) == type; }
//! @brief Get whether register index is equal to @a index.
inline bool isRegIndex(uint32_t index) const ASMJIT_NOTHROW
{ return (uint32_t)(_reg.code & REG_INDEX_MASK) == index; }
//! @brief Set register code to @a code.
inline void setCode(uint32_t code) ASMJIT_NOTHROW
{ _reg.code = code; }
//! @brief Set register size to @a size.
inline void setSize(uint32_t size) ASMJIT_NOTHROW
{ _reg.size = (uint8_t)size; }
// --------------------------------------------------------------------------
// [Overloaded Operators]
// --------------------------------------------------------------------------
inline BaseReg& operator=(const BaseReg& other) ASMJIT_NOTHROW
{ _copy(other); return *this; }
inline bool operator==(const BaseReg& other) const ASMJIT_NOTHROW
{ return getRegCode() == other.getRegCode(); }
inline bool operator!=(const BaseReg& other) const ASMJIT_NOTHROW
{ return getRegCode() != other.getRegCode(); }
};
// ============================================================================
// [AsmJit::Reg]
// ============================================================================
//! @brief General purpose register.
//!
//! This class is for all general purpose registers (64, 32, 16 and 8-bit).
struct ASMJIT_HIDDEN GPReg : public BaseReg
{
// --------------------------------------------------------------------------
// [Construction / Destruction]
// --------------------------------------------------------------------------
//! @brief Create non-initialized general purpose register.
inline GPReg() ASMJIT_NOTHROW :
BaseReg(INVALID_VALUE, 0) {}
//! @brief Create a reference to @a other general purpose register.
inline GPReg(const GPReg& other) ASMJIT_NOTHROW :
BaseReg(other) {}
#if !defined(ASMJIT_NODOC)
inline GPReg(const _DontInitialize& dontInitialize) ASMJIT_NOTHROW :
BaseReg(dontInitialize) {}
inline GPReg(const _Initialize&, uint32_t code) ASMJIT_NOTHROW :
BaseReg(code, static_cast<uint32_t>(1U << ((code & REG_TYPE_MASK) >> 12))) {}
#endif // ASMJIT_NODOC
// --------------------------------------------------------------------------
// [GPReg Specific]
// --------------------------------------------------------------------------
//! @brief Get whether the general purpose register is BYTE (8-bit) type.
inline bool isGPB() const ASMJIT_NOTHROW { return (_reg.code & REG_TYPE_MASK) <= REG_TYPE_GPB_HI; }
//! @brief Get whether the general purpose register is LO-BYTE (8-bit) type.
inline bool isGPBLo() const ASMJIT_NOTHROW { return (_reg.code & REG_TYPE_MASK) == REG_TYPE_GPB_LO; }
//! @brief Get whether the general purpose register is HI-BYTE (8-bit) type.
inline bool isGPBHi() const ASMJIT_NOTHROW { return (_reg.code & REG_TYPE_MASK) == REG_TYPE_GPB_HI; }
//! @brief Get whether the general purpose register is WORD (16-bit) type.
inline bool isGPW() const ASMJIT_NOTHROW { return (_reg.code & REG_TYPE_MASK) == REG_TYPE_GPW; }
//! @brief Get whether the general purpose register is DWORD (32-bit) type.
//!
//! This is default type for 32-bit platforms.
inline bool isGPD() const ASMJIT_NOTHROW { return (_reg.code & REG_TYPE_MASK) == REG_TYPE_GPD; }
//! @brief Get whether the general purpose register is QWORD (64-bit) type.
//!
//! This is default type for 64-bit platforms.
inline bool isGPQ() const ASMJIT_NOTHROW { return (_reg.code & REG_TYPE_MASK) == REG_TYPE_GPQ; }
// --------------------------------------------------------------------------
// [Overloaded Operators]
// --------------------------------------------------------------------------
#if !defined(ASMJIT_NODOC)
inline GPReg& operator=(const GPReg& other) ASMJIT_NOTHROW { _copy(other); return *this; }
inline bool operator==(const GPReg& other) const ASMJIT_NOTHROW { return getRegCode() == other.getRegCode(); }
inline bool operator!=(const GPReg& other) const ASMJIT_NOTHROW { return getRegCode() != other.getRegCode(); }
#endif // ASMJIT_NODOC
};
// ============================================================================
// [AsmJit::X87Register]
// ============================================================================
//! @brief 80-bit x87 floating point register.
//!
//! To create instance of x87 register, use @c st() function.
struct ASMJIT_HIDDEN X87Reg : public BaseReg
{
// --------------------------------------------------------------------------
// [Construction / Destruction]
// --------------------------------------------------------------------------
//! @brief Create non-initialized x87 register.
inline X87Reg() ASMJIT_NOTHROW :
BaseReg(INVALID_VALUE, 10) {}
//! @brief Create a reference to @a other x87 register.
inline X87Reg(const X87Reg& other) ASMJIT_NOTHROW :
BaseReg(other) {}
#if !defined(ASMJIT_NODOC)
inline X87Reg(const _DontInitialize& dontInitialize) ASMJIT_NOTHROW :
BaseReg(dontInitialize) {}
inline X87Reg(const _Initialize&, uint32_t code) ASMJIT_NOTHROW :
BaseReg(code | REG_TYPE_X87, 10) {}
#endif // ASMJIT_NODOC
// --------------------------------------------------------------------------
// [Overloaded Operators]
// --------------------------------------------------------------------------
#if !defined(ASMJIT_NODOC)
inline X87Reg& operator=(const X87Reg& other) ASMJIT_NOTHROW { _copy(other); return *this; }
inline bool operator==(const X87Reg& other) const ASMJIT_NOTHROW { return getRegCode() == other.getRegCode(); }
inline bool operator!=(const X87Reg& other) const ASMJIT_NOTHROW { return getRegCode() != other.getRegCode(); }
#endif // ASMJIT_NODOC
};
// ============================================================================
// [AsmJit::MMReg]
// ============================================================================
//! @brief 64-bit MMX register.
struct ASMJIT_HIDDEN MMReg : public BaseReg
{
// --------------------------------------------------------------------------
// [Construction / Destruction]
// --------------------------------------------------------------------------
//! @brief Create non-initialized MM register.
inline MMReg() ASMJIT_NOTHROW :
BaseReg(INVALID_VALUE, 8) {}
//! @brief Create a reference to @a other MM register.
inline MMReg(const MMReg& other) ASMJIT_NOTHROW :
BaseReg(other) {}
#if !defined(ASMJIT_NODOC)
inline MMReg(const _DontInitialize& dontInitialize) ASMJIT_NOTHROW :
BaseReg(dontInitialize) {}
inline MMReg(const _Initialize&, uint32_t code) ASMJIT_NOTHROW :
BaseReg(code, 8) {}
#endif // ASMJIT_NODOC
// --------------------------------------------------------------------------
// [Overloaded Operators]
// --------------------------------------------------------------------------
#if !defined(ASMJIT_NODOC)
inline MMReg& operator=(const MMReg& other) ASMJIT_NOTHROW { _copy(other); return *this; }
inline bool operator==(const MMReg& other) const ASMJIT_NOTHROW { return getRegCode() == other.getRegCode(); }
inline bool operator!=(const MMReg& other) const ASMJIT_NOTHROW { return getRegCode() != other.getRegCode(); }
#endif // ASMJIT_NODOC
};
// ============================================================================
// [AsmJit::XMMReg]
// ============================================================================
//! @brief 128-bit SSE register.
struct ASMJIT_HIDDEN XMMReg : public BaseReg
{
// --------------------------------------------------------------------------
// [Construction / Destruction]
// --------------------------------------------------------------------------
//! @brief Create non-initialized XMM register.
inline XMMReg() ASMJIT_NOTHROW :
BaseReg(INVALID_VALUE, 16) {}
//! @brief Create a reference to @a other XMM register.
inline XMMReg(const _Initialize&, uint32_t code) ASMJIT_NOTHROW :
BaseReg(code, 16) {}
#if !defined(ASMJIT_NODOC)
inline XMMReg(const _DontInitialize& dontInitialize) ASMJIT_NOTHROW :
BaseReg(dontInitialize) {}
inline XMMReg(const XMMReg& other) ASMJIT_NOTHROW :
BaseReg(other) {}
#endif // ASMJIT_NODOC
// --------------------------------------------------------------------------
// [Overloaded Operators]
// --------------------------------------------------------------------------
#if !defined(ASMJIT_NODOC)
inline XMMReg& operator=(const XMMReg& other) ASMJIT_NOTHROW { _copy(other); return *this; }
inline bool operator==(const XMMReg& other) const ASMJIT_NOTHROW { return getRegCode() == other.getRegCode(); }
inline bool operator!=(const XMMReg& other) const ASMJIT_NOTHROW { return getRegCode() != other.getRegCode(); }
#endif // ASMJIT_NODOC
};
// ============================================================================
// [AsmJit::Registers - no_reg]
// ============================================================================
//! @brief No register, can be used only in @c Mem operand.
ASMJIT_VAR const GPReg no_reg;
// ============================================================================
// [AsmJit::Registers - 8-bit]
// ============================================================================
//! @brief 8-bit General purpose register.
ASMJIT_VAR const GPReg al;
//! @brief 8-bit General purpose register.
ASMJIT_VAR const GPReg cl;
//! @brief 8-bit General purpose register.
ASMJIT_VAR const GPReg dl;
//! @brief 8-bit General purpose register.
ASMJIT_VAR const GPReg bl;
#if defined(ASMJIT_X64)
//! @brief 8-bit General purpose register (64-bit mode only).
ASMJIT_VAR const GPReg spl;
//! @brief 8-bit General purpose register (64-bit mode only).
ASMJIT_VAR const GPReg bpl;
//! @brief 8-bit General purpose register (64-bit mode only).
ASMJIT_VAR const GPReg sil;
//! @brief 8-bit General purpose register (64-bit mode only).
ASMJIT_VAR const GPReg dil;
//! @brief 8-bit General purpose register (64-bit mode only).
ASMJIT_VAR const GPReg r8b;
//! @brief 8-bit General purpose register (64-bit mode only).
ASMJIT_VAR const GPReg r9b;
//! @brief 8-bit General purpose register (64-bit mode only).
ASMJIT_VAR const GPReg r10b;
//! @brief 8-bit General purpose register (64-bit mode only).
ASMJIT_VAR const GPReg r11b;
//! @brief 8-bit General purpose register (64-bit mode only).
ASMJIT_VAR const GPReg r12b;
//! @brief 8-bit General purpose register (64-bit mode only).
ASMJIT_VAR const GPReg r13b;
//! @brief 8-bit General purpose register (64-bit mode only).
ASMJIT_VAR const GPReg r14b;
//! @brief 8-bit General purpose register (64-bit mode only).
ASMJIT_VAR const GPReg r15b;
#endif // ASMJIT_X64
//! @brief 8-bit General purpose register.
ASMJIT_VAR const GPReg ah;
//! @brief 8-bit General purpose register.
ASMJIT_VAR const GPReg ch;
//! @brief 8-bit General purpose register.
ASMJIT_VAR const GPReg dh;
//! @brief 8-bit General purpose register.
ASMJIT_VAR const GPReg bh;
// ============================================================================
// [AsmJit::Registers - 16-bit]
// ============================================================================
//! @brief 16-bit General purpose register.
ASMJIT_VAR const GPReg ax;
//! @brief 16-bit General purpose register.
ASMJIT_VAR const GPReg cx;
//! @brief 16-bit General purpose register.
ASMJIT_VAR const GPReg dx;
//! @brief 16-bit General purpose register.
ASMJIT_VAR const GPReg bx;
//! @brief 16-bit General purpose register.
ASMJIT_VAR const GPReg sp;
//! @brief 16-bit General purpose register.
ASMJIT_VAR const GPReg bp;
//! @brief 16-bit General purpose register.
ASMJIT_VAR const GPReg si;
//! @brief 16-bit General purpose register.
ASMJIT_VAR const GPReg di;
#if defined(ASMJIT_X64)
//! @brief 16-bit General purpose register (64-bit mode only).
ASMJIT_VAR const GPReg r8w;
//! @brief 16-bit General purpose register (64-bit mode only).
ASMJIT_VAR const GPReg r9w;
//! @brief 16-bit General purpose register (64-bit mode only).
ASMJIT_VAR const GPReg r10w;
//! @brief 16-bit General purpose register (64-bit mode only).
ASMJIT_VAR const GPReg r11w;
//! @brief 16-bit General purpose register (64-bit mode only).
ASMJIT_VAR const GPReg r12w;
//! @brief 16-bit General purpose register (64-bit mode only).
ASMJIT_VAR const GPReg r13w;
//! @brief 16-bit General purpose register (64-bit mode only).
ASMJIT_VAR const GPReg r14w;
//! @brief 16-bit General purpose register (64-bit mode only).
ASMJIT_VAR const GPReg r15w;
#endif // ASMJIT_X64
// ============================================================================
// [AsmJit::Registers - 32-bit]
// ============================================================================
//! @brief 32-bit General purpose register.
ASMJIT_VAR const GPReg eax;
//! @brief 32-bit General purpose register.
ASMJIT_VAR const GPReg ecx;
//! @brief 32-bit General purpose register.
ASMJIT_VAR const GPReg edx;
//! @brief 32-bit General purpose register.
ASMJIT_VAR const GPReg ebx;
//! @brief 32-bit General purpose register.
ASMJIT_VAR const GPReg esp;
//! @brief 32-bit General purpose register.
ASMJIT_VAR const GPReg ebp;
//! @brief 32-bit General purpose register.
ASMJIT_VAR const GPReg esi;
//! @brief 32-bit General purpose register.
ASMJIT_VAR const GPReg edi;
#if defined(ASMJIT_X64)
//! @brief 32-bit General purpose register.
ASMJIT_VAR const GPReg r8d;
//! @brief 32-bit General purpose register.
ASMJIT_VAR const GPReg r9d;
//! @brief 32-bit General purpose register.
ASMJIT_VAR const GPReg r10d;
//! @brief 32-bit General purpose register.
ASMJIT_VAR const GPReg r11d;
//! @brief 32-bit General purpose register.
ASMJIT_VAR const GPReg r12d;
//! @brief 32-bit General purpose register.
ASMJIT_VAR const GPReg r13d;
//! @brief 32-bit General purpose register.
ASMJIT_VAR const GPReg r14d;
//! @brief 32-bit General purpose register.
ASMJIT_VAR const GPReg r15d;
#endif // ASMJIT_X64
// ============================================================================
// [AsmJit::Registers - 64-bit]
// ============================================================================
#if defined(ASMJIT_X64)
//! @brief 64-bit General purpose register (64-bit mode only).
ASMJIT_VAR const GPReg rax;
//! @brief 64-bit General purpose register (64-bit mode only).
ASMJIT_VAR const GPReg rcx;
//! @brief 64-bit General purpose register (64-bit mode only).
ASMJIT_VAR const GPReg rdx;
//! @brief 64-bit General purpose register (64-bit mode only).
ASMJIT_VAR const GPReg rbx;
//! @brief 64-bit General purpose register (64-bit mode only).
ASMJIT_VAR const GPReg rsp;
//! @brief 64-bit General purpose register (64-bit mode only).
ASMJIT_VAR const GPReg rbp;
//! @brief 64-bit General purpose register (64-bit mode only).
ASMJIT_VAR const GPReg rsi;
//! @brief 64-bit General purpose register (64-bit mode only).
ASMJIT_VAR const GPReg rdi;
//! @brief 64-bit General purpose register (64-bit mode only).
ASMJIT_VAR const GPReg r8;
//! @brief 64-bit General purpose register (64-bit mode only).
ASMJIT_VAR const GPReg r9;
//! @brief 64-bit General purpose register (64-bit mode only).
ASMJIT_VAR const GPReg r10;
//! @brief 64-bit General purpose register (64-bit mode only).
ASMJIT_VAR const GPReg r11;
//! @brief 64-bit General purpose register (64-bit mode only).
ASMJIT_VAR const GPReg r12;
//! @brief 64-bit General purpose register (64-bit mode only).
ASMJIT_VAR const GPReg r13;
//! @brief 64-bit General purpose register (64-bit mode only).
ASMJIT_VAR const GPReg r14;
//! @brief 64-bit General purpose register (64-bit mode only).
ASMJIT_VAR const GPReg r15;
#endif // ASMJIT_X64
// ============================================================================
// [AsmJit::Registers - Native (AsmJit extension)]
// ============================================================================
//! @brief 32-bit General purpose register.
ASMJIT_VAR const GPReg nax;
//! @brief 32-bit General purpose register.
ASMJIT_VAR const GPReg ncx;
//! @brief 32-bit General purpose register.
ASMJIT_VAR const GPReg ndx;
//! @brief 32-bit General purpose register.
ASMJIT_VAR const GPReg nbx;
//! @brief 32-bit General purpose register.
ASMJIT_VAR const GPReg nsp;
//! @brief 32-bit General purpose register.
ASMJIT_VAR const GPReg nbp;
//! @brief 32-bit General purpose register.
ASMJIT_VAR const GPReg nsi;
//! @brief 32-bit General purpose register.
ASMJIT_VAR const GPReg ndi;
// ============================================================================
// [AsmJit::Registers - MM]
// ============================================================================
//! @brief 64-bit MM register.
ASMJIT_VAR const MMReg mm0;
//! @brief 64-bit MM register.
ASMJIT_VAR const MMReg mm1;
//! @brief 64-bit MM register.
ASMJIT_VAR const MMReg mm2;
//! @brief 64-bit MM register.
ASMJIT_VAR const MMReg mm3;
//! @brief 64-bit MM register.
ASMJIT_VAR const MMReg mm4;
//! @brief 64-bit MM register.
ASMJIT_VAR const MMReg mm5;
//! @brief 64-bit MM register.
ASMJIT_VAR const MMReg mm6;
//! @brief 64-bit MM register.
ASMJIT_VAR const MMReg mm7;
// ============================================================================
// [AsmJit::Registers - XMM]
// ============================================================================
//! @brief 128-bit XMM register.
ASMJIT_VAR const XMMReg xmm0;
//! @brief 128-bit XMM register.
ASMJIT_VAR const XMMReg xmm1;
//! @brief 128-bit XMM register.
ASMJIT_VAR const XMMReg xmm2;
//! @brief 128-bit XMM register.
ASMJIT_VAR const XMMReg xmm3;
//! @brief 128-bit XMM register.
ASMJIT_VAR const XMMReg xmm4;
//! @brief 128-bit XMM register.
ASMJIT_VAR const XMMReg xmm5;
//! @brief 128-bit XMM register.
ASMJIT_VAR const XMMReg xmm6;
//! @brief 128-bit XMM register.
ASMJIT_VAR const XMMReg xmm7;
#if defined(ASMJIT_X64)
//! @brief 128-bit XMM register (64-bit mode only).
ASMJIT_VAR const XMMReg xmm8;
//! @brief 128-bit XMM register (64-bit mode only).
ASMJIT_VAR const XMMReg xmm9;
//! @brief 128-bit XMM register (64-bit mode only).
ASMJIT_VAR const XMMReg xmm10;
//! @brief 128-bit XMM register (64-bit mode only).
ASMJIT_VAR const XMMReg xmm11;
//! @brief 128-bit XMM register (64-bit mode only).
ASMJIT_VAR const XMMReg xmm12;
//! @brief 128-bit XMM register (64-bit mode only).
ASMJIT_VAR const XMMReg xmm13;
//! @brief 128-bit XMM register (64-bit mode only).
ASMJIT_VAR const XMMReg xmm14;
//! @brief 128-bit XMM register (64-bit mode only).
ASMJIT_VAR const XMMReg xmm15;
#endif // ASMJIT_X64
// ============================================================================
// [AsmJit::Registers - Register From Index]
// ============================================================================
//! @brief Get general purpose register of byte size.
static inline GPReg gpb_lo(uint32_t index) ASMJIT_NOTHROW
{ return GPReg(_Initialize(), static_cast<uint32_t>(index | REG_TYPE_GPB_LO)); }
//! @brief Get general purpose register of byte size.
static inline GPReg gpb_hi(uint32_t index) ASMJIT_NOTHROW
{ return GPReg(_Initialize(), static_cast<uint32_t>(index | REG_TYPE_GPB_HI)); }
//! @brief Get general purpose register of word size.
static inline GPReg gpw(uint32_t index) ASMJIT_NOTHROW
{ return GPReg(_Initialize(), static_cast<uint32_t>(index | REG_TYPE_GPW)); }
//! @brief Get general purpose register of dword size.
static inline GPReg gpd(uint32_t index) ASMJIT_NOTHROW
{ return GPReg(_Initialize(), static_cast<uint32_t>(index | REG_TYPE_GPD)); }
#if defined(ASMJIT_X64)
//! @brief Get general purpose register of qword size (64-bit only).
static inline GPReg gpq(uint32_t index) ASMJIT_NOTHROW
{ return GPReg(_Initialize(), static_cast<uint32_t>(index | REG_TYPE_GPQ)); }
#endif
//! @brief Get general purpose dword/qword register (depending to architecture).
static inline GPReg gpn(uint32_t index) ASMJIT_NOTHROW
{ return GPReg(_Initialize(), static_cast<uint32_t>(index | REG_TYPE_GPN)); }
//! @brief Get MMX (MM) register .
static inline MMReg mm(uint32_t index) ASMJIT_NOTHROW
{ return MMReg(_Initialize(), static_cast<uint32_t>(index | REG_TYPE_MM)); }
//! @brief Get SSE (XMM) register.
static inline XMMReg xmm(uint32_t index) ASMJIT_NOTHROW
{ return XMMReg(_Initialize(), static_cast<uint32_t>(index | REG_TYPE_XMM)); }
//! @brief Get x87 register with index @a i.
static inline X87Reg st(uint32_t i) ASMJIT_NOTHROW
{
ASMJIT_ASSERT(i < 8);
return X87Reg(_Initialize(), static_cast<uint32_t>(i));
}
// ============================================================================
// [AsmJit::Imm]
// ============================================================================
//! @brief Immediate operand.
//!
//! Immediate operand is part of instruction (it's inlined after it).
//!
//! To create immediate operand, use @c imm() and @c uimm() constructors
//! or constructors provided by @c Immediate class itself.
struct ASMJIT_HIDDEN Imm : public Operand
{
// --------------------------------------------------------------------------
// [Construction / Destruction]
// --------------------------------------------------------------------------
//! @brief Create a new immediate value (initial value is 0).
Imm() ASMJIT_NOTHROW :
Operand(_DontInitialize())
{
_imm.op = OPERAND_IMM;
_imm.size = 0;
_imm.isUnsigned = false;
_imm.reserved = 0;
_imm.id = INVALID_VALUE;
_imm.value = 0;
}
//! @brief Create a new signed immediate value, assigning the value to @a i.
Imm(sysint_t i) ASMJIT_NOTHROW :
Operand(_DontInitialize())
{
_imm.op = OPERAND_IMM;
_imm.size = 0;
_imm.isUnsigned = false;
_imm.reserved = 0;
_imm.id = INVALID_VALUE;
_imm.value = i;
}
//! @brief Create a new signed or unsigned immediate value, assigning the value to @a i.
Imm(sysint_t i, bool isUnsigned) ASMJIT_NOTHROW :
Operand(_DontInitialize())
{
_imm.op = OPERAND_IMM;
_imm.size = 0;
_imm.isUnsigned = isUnsigned;
_imm.reserved = 0;
_imm.id = INVALID_VALUE;
_imm.value = i;
}
//! @brief Create a new immediate value from @a other.
inline Imm(const Imm& other) ASMJIT_NOTHROW :
Operand(other) {}
// --------------------------------------------------------------------------
// [Immediate Specific]
// --------------------------------------------------------------------------
//! @brief Get whether an immediate is unsigned value.
inline bool isUnsigned() const ASMJIT_NOTHROW { return _imm.isUnsigned != 0; }
//! @brief Get signed immediate value.
inline sysint_t getValue() const ASMJIT_NOTHROW { return _imm.value; }
//! @brief Get unsigned immediate value.
inline sysuint_t getUValue() const ASMJIT_NOTHROW { return (sysuint_t)_imm.value; }
//! @brief Set immediate value as signed type to @a val.
inline void setValue(sysint_t val, bool isUnsigned = false) ASMJIT_NOTHROW
{
_imm.value = val;
_imm.isUnsigned = isUnsigned;
}
//! @brief Set immediate value as unsigned type to @a val.
inline void setUValue(sysuint_t val) ASMJIT_NOTHROW
{
_imm.value = (sysint_t)val;
_imm.isUnsigned = true;
}
// --------------------------------------------------------------------------
// [Overloaded Operators]
// --------------------------------------------------------------------------
//! @brief Assign a signed value @a val to the immediate operand.
inline Imm& operator=(sysint_t val) ASMJIT_NOTHROW
{ setValue(val); return *this; }
//! @brief Assign @a other to the immediate operand.
inline Imm& operator=(const Imm& other) ASMJIT_NOTHROW
{ _copy(other); return *this; }
};
//! @brief Create signed immediate value operand.
ASMJIT_API Imm imm(sysint_t i) ASMJIT_NOTHROW;
//! @brief Create unsigned immediate value operand.
ASMJIT_API Imm uimm(sysuint_t i) ASMJIT_NOTHROW;
// ============================================================================
// [AsmJit::Label]
// ============================================================================
//! @brief Label (jump target or data location).
//!
//! Label represents locations typically used as jump targets, but may be also
//! used as position where are stored constants or static variables. If you
//! want to use @c Label you need first to associate it with @c Assembler or
//! @c Compiler instance. To create new label use @c Assembler::newLabel() or
//! @c Compiler::newLabel().
//!
//! Example of using labels:
//!
//! @code
//! // Create Assembler or Compiler instance.
//! Assembler a;
//!
//! // Create Label instance.
//! Label L_1(a);
//!
//! // ... your code ...
//!
//! // Using label, see @c AsmJit::Assembler or @c AsmJit::Compiler.
//! a.jump(L_1);
//!
//! // ... your code ...
//!
//! // Bind label to current position, see @c AsmJit::Assembler::bind() or
//! // @c AsmJit::Compiler::bind().
//! a.bind(L_1);
//! @endcode
struct ASMJIT_HIDDEN Label : public Operand
{
// --------------------------------------------------------------------------
// [Construction / Destruction]
// --------------------------------------------------------------------------
//! @brief Create new, unassociated label.
inline Label() ASMJIT_NOTHROW :
Operand(_DontInitialize())
{
_lbl.op = OPERAND_LABEL;
_lbl.size = 0;
_lbl.id = INVALID_VALUE;
}
//! @brief Create reference to another label.
inline Label(const Label& other) ASMJIT_NOTHROW :
Operand(other)
{
}
//! @brief Destroy the label.
inline ~Label() ASMJIT_NOTHROW
{
}
// --------------------------------------------------------------------------
// [Overloaded Operators]
// --------------------------------------------------------------------------
#if !defined(ASMJIT_NODOC)
inline Label& operator=(const Label& other)
{ _copy(other); return *this; }
inline bool operator==(const Label& other) const ASMJIT_NOTHROW { return _base.id == other._base.id; }
inline bool operator!=(const Label& other) const ASMJIT_NOTHROW { return _base.id != other._base.id; }
#endif // ASMJIT_NODOC
};
// ============================================================================
// [AsmJit::Mem]
// ============================================================================
//! @brief Memory operand.
struct ASMJIT_HIDDEN Mem : public Operand
{
// --------------------------------------------------------------------------
// [Construction / Destruction]
// --------------------------------------------------------------------------
inline Mem() ASMJIT_NOTHROW :
Operand(_DontInitialize())
{
_mem.op = OPERAND_MEM;
_mem.size = 0;
_mem.type = OPERAND_MEM_NATIVE;
_mem.segmentPrefix = SEGMENT_NONE;
_mem.id = INVALID_VALUE;
_mem.base = INVALID_VALUE;
_mem.index = INVALID_VALUE;
_mem.shift = 0;
_mem.target = NULL;
_mem.displacement = 0;
}
inline Mem(const Label& label, sysint_t displacement, uint32_t size = 0) ASMJIT_NOTHROW :
Operand(_DontInitialize())
{
_mem.op = OPERAND_MEM;
_mem.size = (uint8_t)size;
_mem.type = OPERAND_MEM_LABEL;
_mem.segmentPrefix = SEGMENT_NONE;
_mem.id = INVALID_VALUE;
_mem.base = reinterpret_cast<const Operand&>(label)._base.id;
_mem.index = INVALID_VALUE;
_mem.shift = 0;
_mem.target = NULL;
_mem.displacement = displacement;
}
inline Mem(const GPReg& base, sysint_t displacement, uint32_t size = 0) ASMJIT_NOTHROW :
Operand(_DontInitialize())
{
_mem.op = OPERAND_MEM;
_mem.size = (uint8_t)size;
_mem.type = OPERAND_MEM_NATIVE;
_mem.segmentPrefix = SEGMENT_NONE;
_mem.id = INVALID_VALUE;
_mem.base = base.getRegCode() & REG_INDEX_MASK;
_mem.index = INVALID_VALUE;
_mem.shift = 0;
_mem.target = NULL;
_mem.displacement = displacement;
}
inline Mem(const GPVar& base, sysint_t displacement, uint32_t size = 0) ASMJIT_NOTHROW :
Operand(_DontInitialize())
{
_mem.op = OPERAND_MEM;
_mem.size = (uint8_t)size;
_mem.type = OPERAND_MEM_NATIVE;
_mem.segmentPrefix = SEGMENT_NONE;
_mem.id = INVALID_VALUE;
_mem.base = reinterpret_cast<const Operand&>(base).getId();
_mem.index = INVALID_VALUE;
_mem.shift = 0;
_mem.target = NULL;
_mem.displacement = displacement;
}
inline Mem(const GPReg& base, const GPReg& index, uint32_t shift, sysint_t displacement, uint32_t size = 0) ASMJIT_NOTHROW :
Operand(_DontInitialize())
{
ASMJIT_ASSERT(shift <= 3);
_mem.op = OPERAND_MEM;
_mem.size = (uint8_t)size;
_mem.type = OPERAND_MEM_NATIVE;
_mem.segmentPrefix = SEGMENT_NONE;
_mem.id = INVALID_VALUE;
_mem.base = base.getRegIndex();
_mem.index = index.getRegIndex();
_mem.shift = (uint8_t)shift;
_mem.target = NULL;
_mem.displacement = displacement;
}
inline Mem(const GPVar& base, const GPVar& index, uint32_t shift, sysint_t displacement, uint32_t size = 0) ASMJIT_NOTHROW :
Operand(_DontInitialize())
{
ASMJIT_ASSERT(shift <= 3);
_mem.op = OPERAND_MEM;
_mem.size = (uint8_t)size;
_mem.type = OPERAND_MEM_NATIVE;
_mem.segmentPrefix = SEGMENT_NONE;
_mem.id = INVALID_VALUE;
_mem.base = reinterpret_cast<const Operand&>(base).getId();
_mem.index = reinterpret_cast<const Operand&>(index).getId();
_mem.shift = (uint8_t)shift;
_mem.target = NULL;
_mem.displacement = displacement;
}
inline Mem(const Mem& other) ASMJIT_NOTHROW :
Operand(other)
{
}
inline Mem(const _DontInitialize& dontInitialize) ASMJIT_NOTHROW :
Operand(dontInitialize)
{
}
// --------------------------------------------------------------------------
// [Mem Specific]
// --------------------------------------------------------------------------
//! @brief Get type of memory operand, see @c OPERAND_MEM_TYPE enum.
inline uint32_t getMemType() const ASMJIT_NOTHROW
{ return _mem.type; }
//! @brief Get memory operand segment prefix, see @c SEGMENT_PREFIX enum.
inline uint32_t getSegmentPrefix() const ASMJIT_NOTHROW
{ return _mem.segmentPrefix; }
//! @brief Get whether the memory operand has base register.
inline bool hasBase() const ASMJIT_NOTHROW
{ return _mem.base != INVALID_VALUE; }
//! @brief Get whether the memory operand has index.
inline bool hasIndex() const ASMJIT_NOTHROW
{ return _mem.index != INVALID_VALUE; }
//! @brief Get whether the memory operand has shift used.
inline bool hasShift() const ASMJIT_NOTHROW
{ return _mem.shift != 0; }
//! @brief Get memory operand base register or @c INVALID_VALUE.
inline uint32_t getBase() const ASMJIT_NOTHROW
{ return _mem.base; }
//! @brief Get memory operand index register or @c INVALID_VALUE.
inline uint32_t getIndex() const ASMJIT_NOTHROW
{ return _mem.index; }
//! @brief Get memory operand index scale (0, 1, 2 or 3).
inline uint32_t getShift() const ASMJIT_NOTHROW
{ return _mem.shift; }
//! @brief Get absolute target address.
//!
//! @note You should always check if operand contains address by @c getMemType().
inline void* getTarget() const ASMJIT_NOTHROW
{ return _mem.target; }
//! @brief Set memory operand size.
inline void setSize(uint32_t size) ASMJIT_NOTHROW
{ _mem.size = size; }
//! @brief Set absolute target address.
inline void setTarget(void* target) ASMJIT_NOTHROW
{ _mem.target = target; }
//! @brief Get memory operand relative displacement.
inline sysint_t getDisplacement() const ASMJIT_NOTHROW
{ return _mem.displacement; }
//! @brief Set memory operand relative displacement.
inline void setDisplacement(sysint_t displacement) ASMJIT_NOTHROW
{ _mem.displacement = displacement; }
//! @brief Adjust memory operand relative displacement by @a displacement.
inline void adjust(sysint_t displacement) ASMJIT_NOTHROW
{
_mem.displacement += displacement;
}
//! @brief Return new memory operand adjusted by @a displacement.
inline Mem adjusted(sysint_t displacement) ASMJIT_NOTHROW
{
Mem result(*this);
result.adjust(displacement);
return result;
}
// --------------------------------------------------------------------------
// [Overloaded Operators]
// --------------------------------------------------------------------------
#if !defined(ASMJIT_NODOC)
inline Mem& operator=(const Mem& other) ASMJIT_NOTHROW { _copy(other); return *this; }
inline bool operator==(const Mem& other) const ASMJIT_NOTHROW
{
return
_mem.size == other._mem.size &&
_mem.type == other._mem.type &&
_mem.segmentPrefix == other._mem.segmentPrefix &&
_mem.base == other._mem.base &&
_mem.index == other._mem.index &&
_mem.shift == other._mem.shift &&
_mem.target == other._mem.target &&
_mem.displacement == other._mem.displacement;
}
inline bool operator!=(const Mem& other) const ASMJIT_NOTHROW { return *this == other; }
#endif // ASMJIT_NODOC
};
// ============================================================================
// [AsmJit::BaseVar]
// ============================================================================
//! @internal
ASMJIT_API Mem _baseVarMem(const BaseVar& var, uint32_t ptrSize) ASMJIT_NOTHROW;
//! @internal
ASMJIT_API Mem _baseVarMem(const BaseVar& var, uint32_t ptrSize, sysint_t disp) ASMJIT_NOTHROW;
//! @internal
ASMJIT_API Mem _baseVarMem(const BaseVar& var, uint32_t ptrSize, const GPVar& index, uint32_t shift, sysint_t disp) ASMJIT_NOTHROW;
//! @brief Base class for all variables.
struct ASMJIT_HIDDEN BaseVar : public Operand
{
// --------------------------------------------------------------------------
// [Construction / Destruction]
// --------------------------------------------------------------------------
#if !defined(ASMJIT_NODOC)
inline BaseVar(const _DontInitialize& dontInitialize) ASMJIT_NOTHROW :
Operand(dontInitialize)
{
}
#endif // ASMJIT_NODOC
inline BaseVar() ASMJIT_NOTHROW :
Operand(_DontInitialize())
{
_var.op = OPERAND_VAR;
_var.size = 0;
_var.registerCode = INVALID_VALUE;
_var.variableType = INVALID_VALUE;
_var.id = INVALID_VALUE;
}
inline BaseVar(const BaseVar& other) ASMJIT_NOTHROW :
Operand(other)
{
}
// --------------------------------------------------------------------------
// [Type]
// --------------------------------------------------------------------------
inline uint32_t getVariableType() const ASMJIT_NOTHROW
{ return _var.variableType; }
inline bool isGPVar() const ASMJIT_NOTHROW
{ return _var.variableType <= VARIABLE_TYPE_GPQ; }
inline bool isX87Var() const ASMJIT_NOTHROW
{ return _var.variableType >= VARIABLE_TYPE_X87 && _var.variableType <= VARIABLE_TYPE_X87_1D; }
inline bool isMMVar() const ASMJIT_NOTHROW
{ return _var.variableType == VARIABLE_TYPE_MM; }
inline bool isXMMVar() const ASMJIT_NOTHROW
{ return _var.variableType >= VARIABLE_TYPE_XMM && _var.variableType <= VARIABLE_TYPE_XMM_2D; }
// --------------------------------------------------------------------------
// [Memory Cast]
// --------------------------------------------------------------------------
//! @brief Cast this variable to memory operand.
//!
//! @note Size of operand depends to native variable type, you can use other
//! variants if you want specific one.
inline Mem m() const ASMJIT_NOTHROW
{ return _baseVarMem(*this, INVALID_VALUE); }
//! @overload.
inline Mem m(sysint_t disp) const ASMJIT_NOTHROW
{ return _baseVarMem(*this, INVALID_VALUE, disp); }
//! @overload.
inline Mem m(const GPVar& index, uint32_t shift = 0, sysint_t disp = 0) const ASMJIT_NOTHROW
{ return _baseVarMem(*this, INVALID_VALUE, index, shift, disp); }
//! @brief Cast this variable to 8-bit memory operand.
inline Mem m8() const ASMJIT_NOTHROW
{ return _baseVarMem(*this, 1); }
//! @overload.
inline Mem m8(sysint_t disp) const ASMJIT_NOTHROW
{ return _baseVarMem(*this, 1, disp); }
//! @overload.
inline Mem m8(const GPVar& index, uint32_t shift = 0, sysint_t disp = 0) const ASMJIT_NOTHROW
{ return _baseVarMem(*this, 1, index, shift, disp); }
//! @brief Cast this variable to 16-bit memory operand.
inline Mem m16() const ASMJIT_NOTHROW
{ return _baseVarMem(*this, 2); }
//! @overload.
inline Mem m16(sysint_t disp) const ASMJIT_NOTHROW
{ return _baseVarMem(*this, 2, disp); }
//! @overload.
inline Mem m16(const GPVar& index, uint32_t shift = 0, sysint_t disp = 0) const ASMJIT_NOTHROW
{ return _baseVarMem(*this, 2, index, shift, disp); }
//! @brief Cast this variable to 32-bit memory operand.
inline Mem m32() const ASMJIT_NOTHROW
{ return _baseVarMem(*this, 4); }
//! @overload.
inline Mem m32(sysint_t disp) const ASMJIT_NOTHROW
{ return _baseVarMem(*this, 4, disp); }
//! @overload.
inline Mem m32(const GPVar& index, uint32_t shift = 0, sysint_t disp = 0) const ASMJIT_NOTHROW
{ return _baseVarMem(*this, 4, index, shift, disp); }
//! @brief Cast this variable to 64-bit memory operand.
inline Mem m64() const ASMJIT_NOTHROW
{ return _baseVarMem(*this, 8); }
//! @overload.
inline Mem m64(sysint_t disp) const ASMJIT_NOTHROW
{ return _baseVarMem(*this, 8, disp); }
//! @overload.
inline Mem m64(const GPVar& index, uint32_t shift = 0, sysint_t disp = 0) const ASMJIT_NOTHROW
{ return _baseVarMem(*this, 8, index, shift, disp); }
//! @brief Cast this variable to 80-bit memory operand (long double).
inline Mem m80() const ASMJIT_NOTHROW
{ return _baseVarMem(*this, 10); }
//! @overload.
inline Mem m80(sysint_t disp) const ASMJIT_NOTHROW
{ return _baseVarMem(*this, 10, disp); }
//! @overload.
inline Mem m80(const GPVar& index, uint32_t shift = 0, sysint_t disp = 0) const ASMJIT_NOTHROW
{ return _baseVarMem(*this, 10, index, shift, disp); }
//! @brief Cast this variable to 128-bit memory operand.
inline Mem m128() const ASMJIT_NOTHROW
{ return _baseVarMem(*this, 16); }
//! @overload.
inline Mem m128(sysint_t disp) const ASMJIT_NOTHROW
{ return _baseVarMem(*this, 16, disp); }
//! @overload.
inline Mem m128(const GPVar& index, uint32_t shift = 0, sysint_t disp = 0) const ASMJIT_NOTHROW
{ return _baseVarMem(*this, 16, index, shift, disp); }
// --------------------------------------------------------------------------
// [Overloaded Operators]
// --------------------------------------------------------------------------
#if !defined(ASMJIT_NODOC)
inline BaseVar& operator=(const BaseVar& other) ASMJIT_NOTHROW
{ _copy(other); return *this; }
inline bool operator==(const BaseVar& other) const ASMJIT_NOTHROW { return _base.id == other._base.id && _var.registerCode == other._var.registerCode; }
inline bool operator!=(const BaseVar& other) const ASMJIT_NOTHROW { return _base.id != other._base.id || _var.registerCode != other._var.registerCode; }
#endif // ASMJIT_NODOC
// --------------------------------------------------------------------------
// [Private]
// --------------------------------------------------------------------------
protected:
inline BaseVar(const BaseVar& other, uint32_t registerCode, uint32_t size) ASMJIT_NOTHROW :
Operand(_DontInitialize())
{
_var.op = OPERAND_VAR;
_var.size = (uint8_t)size;
_var.id = other._base.id;
_var.registerCode = registerCode;
_var.variableType = other._var.variableType;
}
};
// ============================================================================
// [AsmJit::X87Var]
// ============================================================================
//! @brief X87 Variable operand.
struct ASMJIT_HIDDEN X87Var : public BaseVar
{
// --------------------------------------------------------------------------
// [Construction / Destruction]
// --------------------------------------------------------------------------
inline X87Var(const _DontInitialize& dontInitialize) ASMJIT_NOTHROW :
BaseVar(dontInitialize)
{
}
inline X87Var() ASMJIT_NOTHROW :
BaseVar(_DontInitialize())
{
_var.op = OPERAND_VAR;
_var.size = 12;
_var.id = INVALID_VALUE;
_var.registerCode = REG_TYPE_X87;
_var.variableType = VARIABLE_TYPE_X87;
}
inline X87Var(const X87Var& other) ASMJIT_NOTHROW :
BaseVar(other) {}
// --------------------------------------------------------------------------
// [Overloaded Operators]
// --------------------------------------------------------------------------
#if !defined(ASMJIT_NODOC)
inline X87Var& operator=(const X87Var& other) ASMJIT_NOTHROW
{ _copy(other); return *this; }
inline bool operator==(const X87Var& other) const ASMJIT_NOTHROW { return _base.id == other._base.id; }
inline bool operator!=(const X87Var& other) const ASMJIT_NOTHROW { return _base.id != other._base.id; }
#endif // ASMJIT_NODOC
};
// ============================================================================
// [AsmJit::GPVar]
// ============================================================================
//! @brief GP variable operand.
struct ASMJIT_HIDDEN GPVar : public BaseVar
{
// --------------------------------------------------------------------------
// [Construction / Destruction]
// --------------------------------------------------------------------------
//! @brief Create new uninitialized @c GPVar instance (internal constructor).
inline GPVar(const _DontInitialize& dontInitialize) ASMJIT_NOTHROW :
BaseVar(dontInitialize)
{
}
//! @brief Create new uninitialized @c GPVar instance.
inline GPVar() ASMJIT_NOTHROW :
BaseVar(_DontInitialize())
{
_var.op = OPERAND_VAR;
_var.size = sizeof(sysint_t);
_var.id = INVALID_VALUE;
_var.registerCode = REG_TYPE_GPN;
_var.variableType = VARIABLE_TYPE_GPN;
}
//! @brief Create new @c GPVar instance using @a other.
//!
//! Note this will not create a different variable, use @c Compiler::newGP()
//! if you want to do so. This is only copy-constructor that allows to store
//! the same variable in different places.
inline GPVar(const GPVar& other) ASMJIT_NOTHROW :
BaseVar(other) {}
// --------------------------------------------------------------------------
// [GPVar Specific]
// --------------------------------------------------------------------------
//! @brief Get whether this variable is general purpose BYTE register.
inline bool isGPB() const ASMJIT_NOTHROW { return (_var.registerCode & REG_TYPE_MASK) <= REG_TYPE_GPB_HI; }
//! @brief Get whether this variable is general purpose BYTE.LO register.
inline bool isGPBLo() const ASMJIT_NOTHROW { return (_var.registerCode & REG_TYPE_MASK) == REG_TYPE_GPB_LO; }
//! @brief Get whether this variable is general purpose BYTE.HI register.
inline bool isGPBHi() const ASMJIT_NOTHROW { return (_var.registerCode & REG_TYPE_MASK) == REG_TYPE_GPB_HI; }
//! @brief Get whether this variable is general purpose WORD register.
inline bool isGPW() const ASMJIT_NOTHROW { return (_var.registerCode & REG_TYPE_MASK) == REG_TYPE_GPW; }
//! @brief Get whether this variable is general purpose DWORD register.
inline bool isGPD() const ASMJIT_NOTHROW { return (_var.registerCode & REG_TYPE_MASK) == REG_TYPE_GPD; }
//! @brief Get whether this variable is general purpose QWORD (only 64-bit) register.
inline bool isGPQ() const ASMJIT_NOTHROW { return (_var.registerCode & REG_TYPE_MASK) == REG_TYPE_GPQ; }
// --------------------------------------------------------------------------
// [GPVar Cast]
// --------------------------------------------------------------------------
//! @brief Cast this variable to 8-bit (LO) part of variable
inline GPVar r8() const { return GPVar(*this, REG_TYPE_GPB_LO, 1); }
//! @brief Cast this variable to 8-bit (LO) part of variable
inline GPVar r8Lo() const { return GPVar(*this, REG_TYPE_GPB_LO, 1); }
//! @brief Cast this variable to 8-bit (HI) part of variable
inline GPVar r8Hi() const { return GPVar(*this, REG_TYPE_GPB_HI, 1); }
//! @brief Cast this variable to 16-bit part of variable
inline GPVar r16() const { return GPVar(*this, REG_TYPE_GPW, 2); }
//! @brief Cast this variable to 32-bit part of variable
inline GPVar r32() const { return GPVar(*this, REG_TYPE_GPD, 4); }
#if defined(ASMJIT_X64)
//! @brief Cast this variable to 64-bit part of variable
inline GPVar r64() const { return GPVar(*this, REG_TYPE_GPQ, 8); }
#endif // ASMJIT_X64
// --------------------------------------------------------------------------
// [Overloaded Operators]
// --------------------------------------------------------------------------
#if !defined(ASMJIT_NODOC)
inline GPVar& operator=(const GPVar& other) ASMJIT_NOTHROW
{ _copy(other); return *this; }
inline bool operator==(const GPVar& other) const ASMJIT_NOTHROW { return _base.id == other._base.id && _var.registerCode == other._var.registerCode; }
inline bool operator!=(const GPVar& other) const ASMJIT_NOTHROW { return _base.id != other._base.id || _var.registerCode != other._var.registerCode; }
#endif // ASMJIT_NODOC
// --------------------------------------------------------------------------
// [Private]
// --------------------------------------------------------------------------
protected:
inline GPVar(const GPVar& other, uint32_t registerCode, uint32_t size) ASMJIT_NOTHROW :
BaseVar(other, registerCode, size)
{
}
};
// ============================================================================
// [AsmJit::MMVar]
// ============================================================================
//! @brief MM variable operand.
struct ASMJIT_HIDDEN MMVar : public BaseVar
{
// --------------------------------------------------------------------------
// [Construction / Destruction]
// --------------------------------------------------------------------------
//! @brief Create new uninitialized @c MMVar instance (internal constructor).
inline MMVar(const _DontInitialize& dontInitialize) ASMJIT_NOTHROW :
BaseVar(dontInitialize)
{
}
//! @brief Create new uninitialized @c MMVar instance.
inline MMVar() ASMJIT_NOTHROW :
BaseVar(_DontInitialize())
{
_var.op = OPERAND_VAR;
_var.size = 8;
_var.id = INVALID_VALUE;
_var.registerCode = REG_TYPE_MM;
_var.variableType = VARIABLE_TYPE_MM;
}
//! @brief Create new @c MMVar instance using @a other.
//!
//! Note this will not create a different variable, use @c Compiler::newMM()
//! if you want to do so. This is only copy-constructor that allows to store
//! the same variable in different places.
inline MMVar(const MMVar& other) ASMJIT_NOTHROW :
BaseVar(other) {}
// --------------------------------------------------------------------------
// [MMVar Cast]
// --------------------------------------------------------------------------
// --------------------------------------------------------------------------
// [Overloaded Operators]
// --------------------------------------------------------------------------
#if !defined(ASMJIT_NODOC)
inline MMVar& operator=(const MMVar& other) ASMJIT_NOTHROW
{ _copy(other); return *this; }
inline bool operator==(const MMVar& other) const ASMJIT_NOTHROW { return _base.id == other._base.id; }
inline bool operator!=(const MMVar& other) const ASMJIT_NOTHROW { return _base.id != other._base.id; }
#endif // ASMJIT_NODOC
};
// ============================================================================
// [AsmJit::XMMVar]
// ============================================================================
//! @brief XMM Variable operand.
struct ASMJIT_HIDDEN XMMVar : public BaseVar
{
// --------------------------------------------------------------------------
// [Construction / Destruction]
// --------------------------------------------------------------------------
inline XMMVar(const _DontInitialize& dontInitialize) ASMJIT_NOTHROW :
BaseVar(dontInitialize)
{
}
inline XMMVar() ASMJIT_NOTHROW :
BaseVar(_DontInitialize())
{
_var.op = OPERAND_VAR;
_var.size = 16;
_var.id = INVALID_VALUE;
_var.registerCode = REG_TYPE_XMM;
_var.variableType = VARIABLE_TYPE_XMM;
}
inline XMMVar(const XMMVar& other) ASMJIT_NOTHROW :
BaseVar(other) {}
// --------------------------------------------------------------------------
// [XMMVar Access]
// --------------------------------------------------------------------------
// --------------------------------------------------------------------------
// [Overloaded Operators]
// --------------------------------------------------------------------------
#if !defined(ASMJIT_NODOC)
inline XMMVar& operator=(const XMMVar& other) ASMJIT_NOTHROW
{ _copy(other); return *this; }
inline bool operator==(const XMMVar& other) const ASMJIT_NOTHROW { return _base.id == other._base.id; }
inline bool operator!=(const XMMVar& other) const ASMJIT_NOTHROW { return _base.id != other._base.id; }
#endif // ASMJIT_NODOC
};
// ============================================================================
// [AsmJit::Mem - ptr[displacement]]
// ============================================================================
//! @internal
ASMJIT_API Mem _MemPtrBuild(const Label& label, sysint_t disp, uint32_t ptrSize) ASMJIT_NOTHROW;
//! @internal
ASMJIT_API Mem _MemPtrBuild(const Label& label, const GPReg& index, uint32_t shift, sysint_t disp, uint32_t ptrSize) ASMJIT_NOTHROW;
//! @internal
ASMJIT_API Mem _MemPtrBuild(const Label& label, const GPVar& index, uint32_t shift, sysint_t disp, uint32_t ptrSize) ASMJIT_NOTHROW;
//! @brief Create pointer operand with not specified size.
static inline Mem ptr(const Label& label, sysint_t disp = 0) ASMJIT_NOTHROW
{ return _MemPtrBuild(label, disp, 0); }
//! @brief Create byte pointer operand.
static inline Mem byte_ptr(const Label& label, sysint_t disp = 0) ASMJIT_NOTHROW
{ return _MemPtrBuild(label, disp, SIZE_BYTE); }
//! @brief Create word (2 Bytes) pointer operand.
static inline Mem word_ptr(const Label& label, sysint_t disp = 0) ASMJIT_NOTHROW
{ return _MemPtrBuild(label, disp, SIZE_WORD); }
//! @brief Create dword (4 Bytes) pointer operand.
static inline Mem dword_ptr(const Label& label, sysint_t disp = 0) ASMJIT_NOTHROW
{ return _MemPtrBuild(label, disp, SIZE_DWORD); }
//! @brief Create qword (8 Bytes) pointer operand.
static inline Mem qword_ptr(const Label& label, sysint_t disp = 0) ASMJIT_NOTHROW
{ return _MemPtrBuild(label, disp, SIZE_QWORD); }
//! @brief Create tword (10 Bytes) pointer operand (used for 80-bit floating points).
static inline Mem tword_ptr(const Label& label, sysint_t disp = 0) ASMJIT_NOTHROW
{ return _MemPtrBuild(label, disp, SIZE_TWORD); }
//! @brief Create dqword (16 Bytes) pointer operand.
static inline Mem dqword_ptr(const Label& label, sysint_t disp = 0) ASMJIT_NOTHROW
{ return _MemPtrBuild(label, disp, SIZE_DQWORD); }
//! @brief Create mmword (8 bytes) pointer operand
//!
//! @note This constructor is provided only for convenience for mmx programming.
static inline Mem mmword_ptr(const Label& label, sysint_t disp = 0) ASMJIT_NOTHROW
{ return _MemPtrBuild(label, disp, SIZE_QWORD); }
//! @brief Create xmmword (16 bytes) pointer operand
//!
//! @note This constructor is provided only for convenience for sse programming.
static inline Mem xmmword_ptr(const Label& label, sysint_t disp = 0) ASMJIT_NOTHROW
{ return _MemPtrBuild(label, disp, SIZE_DQWORD); }
//! @brief Create system dependent pointer operand (32-bit or 64-bit).
static inline Mem sysint_ptr(const Label& label, sysint_t disp = 0) ASMJIT_NOTHROW
{ return _MemPtrBuild(label, disp, sizeof(sysint_t)); }
//! @brief Create pointer operand with not specified size.
static inline Mem ptr(const Label& label, const GPReg& index, uint32_t shift, sysint_t disp = 0) ASMJIT_NOTHROW
{ return _MemPtrBuild(label, index, shift, disp, 0); }
//! @brief Create byte pointer operand.
static inline Mem byte_ptr(const Label& label, const GPReg& index, uint32_t shift, sysint_t disp = 0) ASMJIT_NOTHROW
{ return _MemPtrBuild(label, index, shift, disp, SIZE_BYTE); }
//! @brief Create word (2 Bytes) pointer operand.
static inline Mem word_ptr(const Label& label, const GPReg& index, uint32_t shift, sysint_t disp = 0) ASMJIT_NOTHROW
{ return _MemPtrBuild(label, index, shift, disp, SIZE_WORD); }
//! @brief Create dword (4 Bytes) pointer operand.
static inline Mem dword_ptr(const Label& label, const GPReg& index, uint32_t shift, sysint_t disp = 0) ASMJIT_NOTHROW
{ return _MemPtrBuild(label, index, shift, disp, SIZE_DWORD); }
//! @brief Create qword (8 Bytes) pointer operand.
static inline Mem qword_ptr(const Label& label, const GPReg& index, uint32_t shift, sysint_t disp = 0) ASMJIT_NOTHROW
{ return _MemPtrBuild(label, index, shift, disp, SIZE_QWORD); }
//! @brief Create tword (10 Bytes) pointer operand (used for 80-bit floating points).
static inline Mem tword_ptr(const Label& label, const GPReg& index, uint32_t shift, sysint_t disp = 0) ASMJIT_NOTHROW
{ return _MemPtrBuild(label, index, shift, disp, SIZE_TWORD); }
//! @brief Create dqword (16 Bytes) pointer operand.
static inline Mem dqword_ptr(const Label& label, const GPReg& index, uint32_t shift, sysint_t disp = 0) ASMJIT_NOTHROW
{ return _MemPtrBuild(label, index, shift, disp, SIZE_DQWORD); }
//! @brief Create mmword (8 bytes) pointer operand
//!
//! @note This constructor is provided only for convenience for mmx programming.
static inline Mem mmword_ptr(const Label& label, const GPReg& index, uint32_t shift, sysint_t disp = 0) ASMJIT_NOTHROW
{ return _MemPtrBuild(label, index, shift, disp, SIZE_QWORD); }
//! @brief Create xmmword (16 bytes) pointer operand
//!
//! @note This constructor is provided only for convenience for sse programming.
static inline Mem xmmword_ptr(const Label& label, const GPReg& index, uint32_t shift, sysint_t disp = 0) ASMJIT_NOTHROW
{ return _MemPtrBuild(label, index, shift, disp, SIZE_DQWORD); }
//! @brief Create system dependent pointer operand (32-bit or 64-bit).
static inline Mem sysint_ptr(const Label& label, const GPReg& index, uint32_t shift, sysint_t disp = 0) ASMJIT_NOTHROW
{ return _MemPtrBuild(label, index, shift, disp, sizeof(sysint_t)); }
//! @brief Create pointer operand with not specified size.
static inline Mem ptr(const Label& label, const GPVar& index, uint32_t shift, sysint_t disp = 0) ASMJIT_NOTHROW
{ return _MemPtrBuild(label, index, shift, disp, 0); }
//! @brief Create byte pointer operand.
static inline Mem byte_ptr(const Label& label, const GPVar& index, uint32_t shift, sysint_t disp = 0) ASMJIT_NOTHROW
{ return _MemPtrBuild(label, index, shift, disp, SIZE_BYTE); }
//! @brief Create word (2 Bytes) pointer operand.
static inline Mem word_ptr(const Label& label, const GPVar& index, uint32_t shift, sysint_t disp = 0) ASMJIT_NOTHROW
{ return _MemPtrBuild(label, index, shift, disp, SIZE_WORD); }
//! @brief Create dword (4 Bytes) pointer operand.
static inline Mem dword_ptr(const Label& label, const GPVar& index, uint32_t shift, sysint_t disp = 0) ASMJIT_NOTHROW
{ return _MemPtrBuild(label, index, shift, disp, SIZE_DWORD); }
//! @brief Create qword (8 Bytes) pointer operand.
static inline Mem qword_ptr(const Label& label, const GPVar& index, uint32_t shift, sysint_t disp = 0) ASMJIT_NOTHROW
{ return _MemPtrBuild(label, index, shift, disp, SIZE_QWORD); }
//! @brief Create tword (10 Bytes) pointer operand (used for 80-bit floating points).
static inline Mem tword_ptr(const Label& label, const GPVar& index, uint32_t shift, sysint_t disp = 0) ASMJIT_NOTHROW
{ return _MemPtrBuild(label, index, shift, disp, SIZE_TWORD); }
//! @brief Create dqword (16 Bytes) pointer operand.
static inline Mem dqword_ptr(const Label& label, const GPVar& index, uint32_t shift, sysint_t disp = 0) ASMJIT_NOTHROW
{ return _MemPtrBuild(label, index, shift, disp, SIZE_DQWORD); }
//! @brief Create mmword (8 bytes) pointer operand
//!
//! @note This constructor is provided only for convenience for mmx programming.
static inline Mem mmword_ptr(const Label& label, const GPVar& index, uint32_t shift, sysint_t disp = 0) ASMJIT_NOTHROW
{ return _MemPtrBuild(label, index, shift, disp, SIZE_QWORD); }
//! @brief Create xmmword (16 bytes) pointer operand
//!
//! @note This constructor is provided only for convenience for sse programming.
static inline Mem xmmword_ptr(const Label& label, const GPVar& index, uint32_t shift, sysint_t disp = 0) ASMJIT_NOTHROW
{ return _MemPtrBuild(label, index, shift, disp, SIZE_DQWORD); }
//! @brief Create system dependent pointer operand (32-bit or 64-bit).
static inline Mem sysint_ptr(const Label& label, const GPVar& index, uint32_t shift, sysint_t disp = 0) ASMJIT_NOTHROW
{ return _MemPtrBuild(label, index, shift, disp, sizeof(sysint_t)); }
// ============================================================================
// [AsmJit::Mem - Absolute Addressing]
// ============================================================================
//! @internal
ASMJIT_API Mem _MemPtrAbs(
void* target,
sysint_t disp,
uint32_t segmentPrefix, uint32_t ptrSize) ASMJIT_NOTHROW;
//! @internal
ASMJIT_API Mem _MemPtrAbs(
void* target,
const GPReg& index, uint32_t shift, sysint_t disp,
uint32_t segmentPrefix, uint32_t ptrSize) ASMJIT_NOTHROW;
//! @internal
ASMJIT_API Mem _MemPtrAbs(
void* target,
const GPVar& index, uint32_t shift, sysint_t disp,
uint32_t segmentPrefix, uint32_t ptrSize) ASMJIT_NOTHROW;
//! @brief Create pointer operand with not specified size.
static inline Mem ptr_abs(void* target, sysint_t disp = 0, uint32_t segmentPrefix = SEGMENT_NONE) ASMJIT_NOTHROW
{ return _MemPtrAbs(target, disp, segmentPrefix, 0); }
//! @brief Create byte pointer operand.
static inline Mem byte_ptr_abs(void* target, sysint_t disp = 0, uint32_t segmentPrefix = SEGMENT_NONE) ASMJIT_NOTHROW
{ return _MemPtrAbs(target, disp, segmentPrefix, SIZE_BYTE); }
//! @brief Create word (2 Bytes) pointer operand.
static inline Mem word_ptr_abs(void* target, sysint_t disp = 0, uint32_t segmentPrefix = SEGMENT_NONE) ASMJIT_NOTHROW
{ return _MemPtrAbs(target, disp, segmentPrefix, SIZE_WORD); }
//! @brief Create dword (4 Bytes) pointer operand.
static inline Mem dword_ptr_abs(void* target, sysint_t disp = 0, uint32_t segmentPrefix = SEGMENT_NONE) ASMJIT_NOTHROW
{ return _MemPtrAbs(target, disp, segmentPrefix, SIZE_DWORD); }
//! @brief Create qword (8 Bytes) pointer operand.
static inline Mem qword_ptr_abs(void* target, sysint_t disp = 0, uint32_t segmentPrefix = SEGMENT_NONE) ASMJIT_NOTHROW
{ return _MemPtrAbs(target, disp, segmentPrefix, SIZE_QWORD); }
//! @brief Create tword (10 Bytes) pointer operand (used for 80-bit floating points).
static inline Mem tword_ptr_abs(void* target, sysint_t disp = 0, uint32_t segmentPrefix = SEGMENT_NONE) ASMJIT_NOTHROW
{ return _MemPtrAbs(target, disp, segmentPrefix, SIZE_TWORD); }
//! @brief Create dqword (16 Bytes) pointer operand.
static inline Mem dqword_ptr_abs(void* target, sysint_t disp = 0, uint32_t segmentPrefix = SEGMENT_NONE) ASMJIT_NOTHROW
{ return _MemPtrAbs(target, disp, segmentPrefix, SIZE_DQWORD); }
//! @brief Create mmword (8 bytes) pointer operand
//!
//! @note This constructor is provided only for convenience for mmx programming.
static inline Mem mmword_ptr_abs(void* target, sysint_t disp = 0, uint32_t segmentPrefix = SEGMENT_NONE) ASMJIT_NOTHROW
{ return _MemPtrAbs(target, disp, segmentPrefix, SIZE_QWORD); }
//! @brief Create xmmword (16 bytes) pointer operand
//!
//! @note This constructor is provided only for convenience for sse programming.
static inline Mem xmmword_ptr_abs(void* target, sysint_t disp = 0, uint32_t segmentPrefix = SEGMENT_NONE) ASMJIT_NOTHROW
{ return _MemPtrAbs(target, disp, segmentPrefix, SIZE_DQWORD); }
//! @brief Create system dependent pointer operand (32-bit or 64-bit).
static inline Mem sysint_ptr_abs(void* target, sysint_t disp = 0, uint32_t segmentPrefix = SEGMENT_NONE) ASMJIT_NOTHROW
{ return _MemPtrAbs(target, disp, segmentPrefix, sizeof(sysint_t)); }
//! @brief Create pointer operand with not specified size.
static inline Mem ptr_abs(void* target, const GPReg& index, uint32_t shift, sysint_t disp = 0, uint32_t segmentPrefix = SEGMENT_NONE) ASMJIT_NOTHROW
{ return _MemPtrAbs(target, index, shift, disp, segmentPrefix, 0); }
//! @brief Create byte pointer operand.
static inline Mem byte_ptr_abs(void* target, const GPReg& index, uint32_t shift, sysint_t disp = 0, uint32_t segmentPrefix = SEGMENT_NONE) ASMJIT_NOTHROW
{ return _MemPtrAbs(target, index, shift, disp, segmentPrefix, SIZE_BYTE); }
//! @brief Create word (2 Bytes) pointer operand.
static inline Mem word_ptr_abs(void* target, const GPReg& index, uint32_t shift, sysint_t disp = 0, uint32_t segmentPrefix = SEGMENT_NONE) ASMJIT_NOTHROW
{ return _MemPtrAbs(target, index, shift, disp, segmentPrefix, SIZE_WORD); }
//! @brief Create dword (4 Bytes) pointer operand.
static inline Mem dword_ptr_abs(void* target, const GPReg& index, uint32_t shift, sysint_t disp = 0, uint32_t segmentPrefix = SEGMENT_NONE) ASMJIT_NOTHROW
{ return _MemPtrAbs(target, index, shift, disp, segmentPrefix, SIZE_DWORD); }
//! @brief Create qword (8 Bytes) pointer operand.
static inline Mem qword_ptr_abs(void* target, const GPReg& index, uint32_t shift, sysint_t disp = 0, uint32_t segmentPrefix = SEGMENT_NONE) ASMJIT_NOTHROW
{ return _MemPtrAbs(target, index, shift, disp, segmentPrefix, SIZE_QWORD); }
//! @brief Create tword (10 Bytes) pointer operand (used for 80-bit floating points).
static inline Mem tword_ptr_abs(void* target, const GPReg& index, uint32_t shift, sysint_t disp = 0, uint32_t segmentPrefix = SEGMENT_NONE) ASMJIT_NOTHROW
{ return _MemPtrAbs(target, index, shift, disp, segmentPrefix, SIZE_TWORD); }
//! @brief Create dqword (16 Bytes) pointer operand.
static inline Mem dqword_ptr_abs(void* target, const GPReg& index, uint32_t shift, sysint_t disp = 0, uint32_t segmentPrefix = SEGMENT_NONE) ASMJIT_NOTHROW
{ return _MemPtrAbs(target, index, shift, disp, segmentPrefix, SIZE_DQWORD); }
//! @brief Create mmword (8 bytes) pointer operand
//!
//! @note This constructor is provided only for convenience for mmx programming.
static inline Mem mmword_ptr_abs(void* target, const GPReg& index, uint32_t shift, sysint_t disp = 0, uint32_t segmentPrefix = SEGMENT_NONE) ASMJIT_NOTHROW
{ return _MemPtrAbs(target, index, shift, disp, segmentPrefix, SIZE_QWORD); }
//! @brief Create xmmword (16 bytes) pointer operand
//!
//! @note This constructor is provided only for convenience for sse programming.
static inline Mem xmmword_ptr_abs(void* target, const GPReg& index, uint32_t shift, sysint_t disp = 0, uint32_t segmentPrefix = SEGMENT_NONE) ASMJIT_NOTHROW
{ return _MemPtrAbs(target, index, shift, disp, segmentPrefix, SIZE_DQWORD); }
//! @brief Create system dependent pointer operand (32-bit or 64-bit).
static inline Mem sysint_ptr_abs(void* target, const GPReg& index, uint32_t shift, sysint_t disp = 0, uint32_t segmentPrefix = SEGMENT_NONE) ASMJIT_NOTHROW
{ return _MemPtrAbs(target, index, shift, disp, segmentPrefix, sizeof(sysint_t)); }
//! @brief Create pointer operand with not specified size.
static inline Mem ptr_abs(void* target, const GPVar& index, uint32_t shift, sysint_t disp = 0, uint32_t segmentPrefix = SEGMENT_NONE) ASMJIT_NOTHROW
{ return _MemPtrAbs(target, index, shift, disp, segmentPrefix, 0); }
//! @brief Create byte pointer operand.
static inline Mem byte_ptr_abs(void* target, const GPVar& index, uint32_t shift, sysint_t disp = 0, uint32_t segmentPrefix = SEGMENT_NONE) ASMJIT_NOTHROW
{ return _MemPtrAbs(target, index, shift, disp, segmentPrefix, SIZE_BYTE); }
//! @brief Create word (2 Bytes) pointer operand.
static inline Mem word_ptr_abs(void* target, const GPVar& index, uint32_t shift, sysint_t disp = 0, uint32_t segmentPrefix = SEGMENT_NONE) ASMJIT_NOTHROW
{ return _MemPtrAbs(target, index, shift, disp, segmentPrefix, SIZE_WORD); }
//! @brief Create dword (4 Bytes) pointer operand.
static inline Mem dword_ptr_abs(void* target, const GPVar& index, uint32_t shift, sysint_t disp = 0, uint32_t segmentPrefix = SEGMENT_NONE) ASMJIT_NOTHROW
{ return _MemPtrAbs(target, index, shift, disp, segmentPrefix, SIZE_DWORD); }
//! @brief Create qword (8 Bytes) pointer operand.
static inline Mem qword_ptr_abs(void* target, const GPVar& index, uint32_t shift, sysint_t disp = 0, uint32_t segmentPrefix = SEGMENT_NONE) ASMJIT_NOTHROW
{ return _MemPtrAbs(target, index, shift, disp, segmentPrefix, SIZE_QWORD); }
//! @brief Create tword (10 Bytes) pointer operand (used for 80-bit floating points).
static inline Mem tword_ptr_abs(void* target, const GPVar& index, uint32_t shift, sysint_t disp = 0, uint32_t segmentPrefix = SEGMENT_NONE) ASMJIT_NOTHROW
{ return _MemPtrAbs(target, index, shift, disp, segmentPrefix, SIZE_TWORD); }
//! @brief Create dqword (16 Bytes) pointer operand.
static inline Mem dqword_ptr_abs(void* target, const GPVar& index, uint32_t shift, sysint_t disp = 0, uint32_t segmentPrefix = SEGMENT_NONE) ASMJIT_NOTHROW
{ return _MemPtrAbs(target, index, shift, disp, segmentPrefix, SIZE_DQWORD); }
//! @brief Create mmword (8 bytes) pointer operand
//!
//! @note This constructor is provided only for convenience for mmx programming.
static inline Mem mmword_ptr_abs(void* target, const GPVar& index, uint32_t shift, sysint_t disp = 0, uint32_t segmentPrefix = SEGMENT_NONE) ASMJIT_NOTHROW
{ return _MemPtrAbs(target, index, shift, disp, segmentPrefix, SIZE_QWORD); }
//! @brief Create xmmword (16 bytes) pointer operand
//!
//! @note This constructor is provided only for convenience for sse programming.
static inline Mem xmmword_ptr_abs(void* target, const GPVar& index, uint32_t shift, sysint_t disp = 0, uint32_t segmentPrefix = SEGMENT_NONE) ASMJIT_NOTHROW
{ return _MemPtrAbs(target, index, shift, disp, segmentPrefix, SIZE_DQWORD); }
//! @brief Create system dependent pointer operand (32-bit or 64-bit).
static inline Mem sysint_ptr_abs(void* target, const GPVar& index, uint32_t shift, sysint_t disp = 0, uint32_t segmentPrefix = SEGMENT_NONE) ASMJIT_NOTHROW
{ return _MemPtrAbs(target, index, shift, disp, segmentPrefix, sizeof(sysint_t)); }
// ============================================================================
// [AsmJit::Mem - ptr[base + displacement]]
// ============================================================================
//! @internal
ASMJIT_API Mem _MemPtrBuild(const GPReg& base, sysint_t disp, uint32_t ptrSize) ASMJIT_NOTHROW;
//! @internal
ASMJIT_API Mem _MemPtrBuild(const GPVar& base, sysint_t disp, uint32_t ptrSize) ASMJIT_NOTHROW;
//! @brief Create pointer operand with not specified size.
static inline Mem ptr(const GPReg& base, sysint_t disp = 0) ASMJIT_NOTHROW
{ return _MemPtrBuild(base, disp, 0); }
//! @brief Create byte pointer operand.
static inline Mem byte_ptr(const GPReg& base, sysint_t disp = 0) ASMJIT_NOTHROW
{ return _MemPtrBuild(base, disp, SIZE_BYTE); }
//! @brief Create word (2 Bytes) pointer operand.
static inline Mem word_ptr(const GPReg& base, sysint_t disp = 0) ASMJIT_NOTHROW
{ return _MemPtrBuild(base, disp, SIZE_WORD); }
//! @brief Create dword (4 Bytes) pointer operand.
static inline Mem dword_ptr(const GPReg& base, sysint_t disp = 0) ASMJIT_NOTHROW
{ return _MemPtrBuild(base, disp, SIZE_DWORD); }
//! @brief Create qword (8 Bytes) pointer operand.
static inline Mem qword_ptr(const GPReg& base, sysint_t disp = 0) ASMJIT_NOTHROW
{ return _MemPtrBuild(base, disp, SIZE_QWORD); }
//! @brief Create tword (10 Bytes) pointer operand (used for 80-bit floating points).
static inline Mem tword_ptr(const GPReg& base, sysint_t disp = 0) ASMJIT_NOTHROW
{ return _MemPtrBuild(base, disp, SIZE_TWORD); }
//! @brief Create dqword (16 Bytes) pointer operand.
static inline Mem dqword_ptr(const GPReg& base, sysint_t disp = 0) ASMJIT_NOTHROW
{ return _MemPtrBuild(base, disp, SIZE_DQWORD); }
//! @brief Create mmword (8 bytes) pointer operand
//!
//! @note This constructor is provided only for convenience for mmx programming.
static inline Mem mmword_ptr(const GPReg& base, sysint_t disp = 0) ASMJIT_NOTHROW
{ return _MemPtrBuild(base, disp, SIZE_QWORD); }
//! @brief Create xmmword (16 bytes) pointer operand
//!
//! @note This constructor is provided only for convenience for sse programming.
static inline Mem xmmword_ptr(const GPReg& base, sysint_t disp = 0) ASMJIT_NOTHROW
{ return _MemPtrBuild(base, disp, SIZE_DQWORD); }
//! @brief Create system dependent pointer operand (32-bit or 64-bit).
static inline Mem sysint_ptr(const GPReg& base, sysint_t disp = 0) ASMJIT_NOTHROW
{ return _MemPtrBuild(base, disp, sizeof(sysint_t)); }
//! @brief Create pointer operand with not specified size.
static inline Mem ptr(const GPVar& base, sysint_t disp = 0) ASMJIT_NOTHROW
{ return _MemPtrBuild(base, disp, 0); }
//! @brief Create byte pointer operand.
static inline Mem byte_ptr(const GPVar& base, sysint_t disp = 0) ASMJIT_NOTHROW
{ return _MemPtrBuild(base, disp, SIZE_BYTE); }
//! @brief Create word (2 Bytes) pointer operand.
static inline Mem word_ptr(const GPVar& base, sysint_t disp = 0) ASMJIT_NOTHROW
{ return _MemPtrBuild(base, disp, SIZE_WORD); }
//! @brief Create dword (4 Bytes) pointer operand.
static inline Mem dword_ptr(const GPVar& base, sysint_t disp = 0) ASMJIT_NOTHROW
{ return _MemPtrBuild(base, disp, SIZE_DWORD); }
//! @brief Create qword (8 Bytes) pointer operand.
static inline Mem qword_ptr(const GPVar& base, sysint_t disp = 0) ASMJIT_NOTHROW
{ return _MemPtrBuild(base, disp, SIZE_QWORD); }
//! @brief Create tword (10 Bytes) pointer operand (used for 80-bit floating points).
static inline Mem tword_ptr(const GPVar& base, sysint_t disp = 0) ASMJIT_NOTHROW
{ return _MemPtrBuild(base, disp, SIZE_TWORD); }
//! @brief Create dqword (16 Bytes) pointer operand.
static inline Mem dqword_ptr(const GPVar& base, sysint_t disp = 0) ASMJIT_NOTHROW
{ return _MemPtrBuild(base, disp, SIZE_DQWORD); }
//! @brief Create mmword (8 bytes) pointer operand
//!
//! @note This constructor is provided only for convenience for mmx programming.
static inline Mem mmword_ptr(const GPVar& base, sysint_t disp = 0) ASMJIT_NOTHROW
{ return _MemPtrBuild(base, disp, SIZE_QWORD); }
//! @brief Create xmmword (16 bytes) pointer operand
//!
//! @note This constructor is provided only for convenience for sse programming.
static inline Mem xmmword_ptr(const GPVar& base, sysint_t disp = 0) ASMJIT_NOTHROW
{ return _MemPtrBuild(base, disp, SIZE_DQWORD); }
//! @brief Create system dependent pointer operand (32-bit or 64-bit).
static inline Mem sysint_ptr(const GPVar& base, sysint_t disp = 0) ASMJIT_NOTHROW
{ return _MemPtrBuild(base, disp, sizeof(sysint_t)); }
// ============================================================================
// [AsmJit::Mem - ptr[base + (index << shift) + displacement]]
// ============================================================================
//! @internal
ASMJIT_API Mem _MemPtrBuild(const GPReg& base, const GPReg& index, uint32_t shift, sysint_t disp, uint32_t ptrSize) ASMJIT_NOTHROW;
//! @internal
ASMJIT_API Mem _MemPtrBuild(const GPVar& base, const GPVar& index, uint32_t shift, sysint_t disp, uint32_t ptrSize) ASMJIT_NOTHROW;
//! @brief Create pointer operand with not specified size.
static inline Mem ptr(const GPReg& base, const GPReg& index, uint32_t shift = 0, sysint_t disp = 0) ASMJIT_NOTHROW
{ return _MemPtrBuild(base, index, shift, disp, 0); }
//! @brief Create byte pointer operand.
static inline Mem byte_ptr(const GPReg& base, const GPReg& index, uint32_t shift = 0, sysint_t disp = 0) ASMJIT_NOTHROW
{ return _MemPtrBuild(base, index, shift, disp, SIZE_BYTE); }
//! @brief Create word (2 Bytes) pointer operand.
static inline Mem word_ptr(const GPReg& base, const GPReg& index, uint32_t shift = 0, sysint_t disp = 0) ASMJIT_NOTHROW
{ return _MemPtrBuild(base, index, shift, disp, SIZE_WORD); }
//! @brief Create dword (4 Bytes) pointer operand.
static inline Mem dword_ptr(const GPReg& base, const GPReg& index, uint32_t shift = 0, sysint_t disp = 0) ASMJIT_NOTHROW
{ return _MemPtrBuild(base, index, shift, disp, SIZE_DWORD); }
//! @brief Create qword (8 Bytes) pointer operand.
static inline Mem qword_ptr(const GPReg& base, const GPReg& index, uint32_t shift = 0, sysint_t disp = 0) ASMJIT_NOTHROW
{ return _MemPtrBuild(base, index, shift, disp, SIZE_QWORD); }
//! @brief Create tword (10 Bytes) pointer operand (used for 80-bit floating points).
static inline Mem tword_ptr(const GPReg& base, const GPReg& index, uint32_t shift = 0, sysint_t disp = 0) ASMJIT_NOTHROW
{ return _MemPtrBuild(base, index, shift, disp, SIZE_TWORD); }
//! @brief Create dqword (16 Bytes) pointer operand.
static inline Mem dqword_ptr(const GPReg& base, const GPReg& index, uint32_t shift = 0, sysint_t disp = 0) ASMJIT_NOTHROW
{ return _MemPtrBuild(base, index, shift, disp, SIZE_DQWORD); }
//! @brief Create mmword (8 Bytes) pointer operand).
//!
//! @note This constructor is provided only for convenience for mmx programming.
static inline Mem mmword_ptr(const GPReg& base, const GPReg& index, uint32_t shift = 0, sysint_t disp = 0) ASMJIT_NOTHROW
{ return _MemPtrBuild(base, index, shift, disp, SIZE_QWORD); }
//! @brief Create xmmword (16 Bytes) pointer operand.
//!
//! @note This constructor is provided only for convenience for sse programming.
static inline Mem xmmword_ptr(const GPReg& base, const GPReg& index, uint32_t shift = 0, sysint_t disp = 0) ASMJIT_NOTHROW
{ return _MemPtrBuild(base, index, shift, disp, SIZE_DQWORD); }
//! @brief Create system dependent pointer operand (32-bit or 64-bit).
static inline Mem sysint_ptr(const GPReg& base, const GPReg& index, uint32_t shift = 0, sysint_t disp = 0) ASMJIT_NOTHROW
{ return _MemPtrBuild(base, index, shift, disp, sizeof(sysint_t)); }
//! @brief Create pointer operand with not specified size.
static inline Mem ptr(const GPVar& base, const GPVar& index, uint32_t shift = 0, sysint_t disp = 0) ASMJIT_NOTHROW
{ return _MemPtrBuild(base, index, shift, disp, 0); }
//! @brief Create byte pointer operand.
static inline Mem byte_ptr(const GPVar& base, const GPVar& index, uint32_t shift = 0, sysint_t disp = 0) ASMJIT_NOTHROW
{ return _MemPtrBuild(base, index, shift, disp, SIZE_BYTE); }
//! @brief Create word (2 Bytes) pointer operand.
static inline Mem word_ptr(const GPVar& base, const GPVar& index, uint32_t shift = 0, sysint_t disp = 0) ASMJIT_NOTHROW
{ return _MemPtrBuild(base, index, shift, disp, SIZE_WORD); }
//! @brief Create dword (4 Bytes) pointer operand.
static inline Mem dword_ptr(const GPVar& base, const GPVar& index, uint32_t shift = 0, sysint_t disp = 0) ASMJIT_NOTHROW
{ return _MemPtrBuild(base, index, shift, disp, SIZE_DWORD); }
//! @brief Create qword (8 Bytes) pointer operand.
static inline Mem qword_ptr(const GPVar& base, const GPVar& index, uint32_t shift = 0, sysint_t disp = 0) ASMJIT_NOTHROW
{ return _MemPtrBuild(base, index, shift, disp, SIZE_QWORD); }
//! @brief Create tword (10 Bytes) pointer operand (used for 80-bit floating points).
static inline Mem tword_ptr(const GPVar& base, const GPVar& index, uint32_t shift = 0, sysint_t disp = 0) ASMJIT_NOTHROW
{ return _MemPtrBuild(base, index, shift, disp, SIZE_TWORD); }
//! @brief Create dqword (16 Bytes) pointer operand.
static inline Mem dqword_ptr(const GPVar& base, const GPVar& index, uint32_t shift = 0, sysint_t disp = 0) ASMJIT_NOTHROW
{ return _MemPtrBuild(base, index, shift, disp, SIZE_DQWORD); }
//! @brief Create mmword (8 Bytes) pointer operand).
//!
//! @note This constructor is provided only for convenience for mmx programming.
static inline Mem mmword_ptr(const GPVar& base, const GPVar& index, uint32_t shift = 0, sysint_t disp = 0) ASMJIT_NOTHROW
{ return _MemPtrBuild(base, index, shift, disp, SIZE_QWORD); }
//! @brief Create xmmword (16 Bytes) pointer operand.
//!
//! @note This constructor is provided only for convenience for sse programming.
static inline Mem xmmword_ptr(const GPVar& base, const GPVar& index, uint32_t shift = 0, sysint_t disp = 0) ASMJIT_NOTHROW
{ return _MemPtrBuild(base, index, shift, disp, SIZE_DQWORD); }
//! @brief Create system dependent pointer operand (32-bit or 64-bit).
static inline Mem sysint_ptr(const GPVar& base, const GPVar& index, uint32_t shift = 0, sysint_t disp = 0) ASMJIT_NOTHROW
{ return _MemPtrBuild(base, index, shift, disp, sizeof(sysint_t)); }
// ============================================================================
// [AsmJit::Macros]
// ============================================================================
//! @brief Create Shuffle Constant for MMX/SSE shuffle instrutions.
//! @param z First component position, number at interval [0, 3] inclusive.
//! @param x Second component position, number at interval [0, 3] inclusive.
//! @param y Third component position, number at interval [0, 3] inclusive.
//! @param w Fourth component position, number at interval [0, 3] inclusive.
//!
//! Shuffle constants can be used to make immediate value for these intrinsics:
//! - @c AsmJit::AssemblerIntrinsics::pshufw()
//! - @c AsmJit::AssemblerIntrinsics::pshufd()
//! - @c AsmJit::AssemblerIntrinsics::pshufhw()
//! - @c AsmJit::AssemblerIntrinsics::pshuflw()
//! - @c AsmJit::AssemblerIntrinsics::shufps()
static inline uint8_t mm_shuffle(uint8_t z, uint8_t y, uint8_t x, uint8_t w) ASMJIT_NOTHROW
{ return (z << 6) | (y << 4) | (x << 2) | w; }
//! @}
} // AsmJit namespace
// [Guard]
#endif // _ASMJIT_OPERANDX86X64_H
|