PyNerva 0.0.5__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of PyNerva might be problematic. Click here for more details.

Files changed (74) hide show
  1. nervapy/__init__.py +50 -0
  2. nervapy/abi.py +91 -0
  3. nervapy/arm/__init__.py +124 -0
  4. nervapy/arm/__main__.py +0 -0
  5. nervapy/arm/abi.py +138 -0
  6. nervapy/arm/formats.py +49 -0
  7. nervapy/arm/function.py +2405 -0
  8. nervapy/arm/generic.py +10797 -0
  9. nervapy/arm/instructions.py +519 -0
  10. nervapy/arm/isa.py +409 -0
  11. nervapy/arm/literal_pool.py +331 -0
  12. nervapy/arm/microarchitecture.py +211 -0
  13. nervapy/arm/pseudo.py +652 -0
  14. nervapy/arm/registers.py +1458 -0
  15. nervapy/arm/vfpneon.py +4092 -0
  16. nervapy/arm.py +13 -0
  17. nervapy/c/__init__.py +1 -0
  18. nervapy/c/types.py +436 -0
  19. nervapy/codegen.py +99 -0
  20. nervapy/common/__init__.py +4 -0
  21. nervapy/common/function.py +5 -0
  22. nervapy/common/regalloc.py +121 -0
  23. nervapy/constant_data.py +282 -0
  24. nervapy/encoder.py +246 -0
  25. nervapy/formats/__init__.py +2 -0
  26. nervapy/formats/elf/__init__.py +4 -0
  27. nervapy/formats/elf/file.py +178 -0
  28. nervapy/formats/elf/image.py +106 -0
  29. nervapy/formats/elf/section.py +422 -0
  30. nervapy/formats/elf/symbol.py +281 -0
  31. nervapy/formats/macho/__init__.py +2 -0
  32. nervapy/formats/macho/file.py +123 -0
  33. nervapy/formats/macho/image.py +143 -0
  34. nervapy/formats/macho/section.py +322 -0
  35. nervapy/formats/macho/symbol.py +158 -0
  36. nervapy/formats/mscoff/__init__.py +8 -0
  37. nervapy/formats/mscoff/image.py +132 -0
  38. nervapy/formats/mscoff/section.py +181 -0
  39. nervapy/formats/mscoff/symbol.py +148 -0
  40. nervapy/function.py +136 -0
  41. nervapy/literal.py +731 -0
  42. nervapy/loader.py +188 -0
  43. nervapy/name.py +159 -0
  44. nervapy/parse.py +52 -0
  45. nervapy/stream.py +58 -0
  46. nervapy/util.py +126 -0
  47. nervapy/writer.py +518 -0
  48. nervapy/x86_64/__init__.py +324 -0
  49. nervapy/x86_64/__main__.py +407 -0
  50. nervapy/x86_64/abi.py +517 -0
  51. nervapy/x86_64/amd.py +6464 -0
  52. nervapy/x86_64/avx.py +102029 -0
  53. nervapy/x86_64/crypto.py +1533 -0
  54. nervapy/x86_64/encoding.py +424 -0
  55. nervapy/x86_64/fma.py +19138 -0
  56. nervapy/x86_64/function.py +2707 -0
  57. nervapy/x86_64/generic.py +23384 -0
  58. nervapy/x86_64/instructions.py +500 -0
  59. nervapy/x86_64/isa.py +476 -0
  60. nervapy/x86_64/lower.py +126 -0
  61. nervapy/x86_64/mask.py +2593 -0
  62. nervapy/x86_64/meta.py +143 -0
  63. nervapy/x86_64/mmxsse.py +17265 -0
  64. nervapy/x86_64/nacl.py +327 -0
  65. nervapy/x86_64/operand.py +1204 -0
  66. nervapy/x86_64/options.py +21 -0
  67. nervapy/x86_64/pseudo.py +686 -0
  68. nervapy/x86_64/registers.py +1225 -0
  69. nervapy/x86_64/types.py +17 -0
  70. nervapy/x86_64/uarch.py +580 -0
  71. pynerva-0.0.5.dist-info/METADATA +310 -0
  72. pynerva-0.0.5.dist-info/RECORD +74 -0
  73. pynerva-0.0.5.dist-info/WHEEL +4 -0
  74. pynerva-0.0.5.dist-info/licenses/LICENSE.rst +15 -0
@@ -0,0 +1,17 @@
1
+ # This file is part of PeachPy package and is licensed under the Simplified BSD license.
2
+ # See license.rst for the full text of the license.
3
+
4
+ from nervapy import Type
5
+
6
+ m64 = Type("__m64", size=8, is_vector=True, header="mmintrin.h")
7
+ m128 = Type("__m128", size=16, is_vector=True, header="xmmintrin.h")
8
+ m128d = Type("__m128d", size=16, is_vector=True, header="emmintrin.h")
9
+ m128i = Type("__m128i", size=16, is_vector=True, header="emmintrin.h")
10
+ m256 = Type("__m256", size=32, is_vector=True, header="immintrin.h")
11
+ m256d = Type("__m256d", size=32, is_vector=True, header="immintrin.h")
12
+ m256i = Type("__m256i", size=32, is_vector=True, header="immintrin.h")
13
+ m512 = Type("__m512", size=64, is_vector=True, header="immintrin.h")
14
+ m512d = Type("__m512d", size=64, is_vector=True, header="immintrin.h")
15
+ m512i = Type("__m512i", size=64, is_vector=True, header="immintrin.h")
16
+ mmask8 = Type("__mmask8", size=1, is_mask=True, header="immintrin.h")
17
+ mmask16 = Type("__mmask16", size=2, is_mask=True, header="immintrin.h")
@@ -0,0 +1,580 @@
1
+ # This file is part of PeachPy package and is licensed under the Simplified BSD license.
2
+ # See license.rst for the full text of the license.
3
+
4
+ from nervapy.x86_64 import isa
5
+
6
+
7
+ class Microarchitecture:
8
+ def __init__(self, name, extensions, alu_width, fpu_width, load_with, store_width):
9
+ self.name = name
10
+ self.extensions = isa.Extensions(
11
+ *[
12
+ prerequisite
13
+ for extension in extensions
14
+ for prerequisite in extension.prerequisites
15
+ ]
16
+ )
17
+ self.alu_width = alu_width
18
+ self.fpu_width = fpu_width
19
+ self.load_width = load_with
20
+ self.store_width = store_width
21
+
22
+ def is_supported(self, extension):
23
+ return extension in self.extensions
24
+
25
+ @property
26
+ def id(self):
27
+ return self.name.replace(" ", "")
28
+
29
+ @property
30
+ def has_sse3(self):
31
+ return isa.sse3 in self.extensions
32
+
33
+ @property
34
+ def has_ssse3(self):
35
+ return isa.ssse3 in self.extensions
36
+
37
+ @property
38
+ def has_sse4_1(self):
39
+ return isa.sse4_1 in self.extensions
40
+
41
+ @property
42
+ def has_sse4_2(self):
43
+ return isa.sse4_2 in self.extensions
44
+
45
+ @property
46
+ def has_avx(self):
47
+ return isa.avx in self.extensions
48
+
49
+ @property
50
+ def has_avx2(self):
51
+ return isa.avx2 in self.extensions
52
+
53
+ @property
54
+ def has_fma3(self):
55
+ return isa.fma3 in self.extensions
56
+
57
+ @property
58
+ def has_fma4(self):
59
+ return isa.fma4 in self.extensions
60
+
61
+ @property
62
+ def has_fma(self):
63
+ return self.has_fma3 or self.has_fma4
64
+
65
+ @property
66
+ def has_avx512f(self):
67
+ return isa.avx512f in self.extensions
68
+
69
+ def __add__(self, extension):
70
+ return Microarchitecture(
71
+ self.name,
72
+ self.extensions + extension,
73
+ self.alu_width,
74
+ self.fpu_width,
75
+ self.load_width,
76
+ self.store_width,
77
+ )
78
+
79
+ def __sub__(self, extension):
80
+ return Microarchitecture(
81
+ self.name,
82
+ self.extensions - extension,
83
+ self.alu_width,
84
+ self.fpu_width,
85
+ self.load_width,
86
+ self.store_width,
87
+ )
88
+
89
+ def __hash__(self):
90
+ return hash(self.name)
91
+
92
+ def __eq__(self, other):
93
+ return isinstance(other, Microarchitecture) and self.name == other.name
94
+
95
+ def __ne__(self, other):
96
+ return not isinstance(other, Microarchitecture) or self.name != other.name
97
+
98
+ def __str__(self):
99
+ return self.name
100
+
101
+ def __repr__(self):
102
+ return str(self)
103
+
104
+
105
+ default = Microarchitecture(
106
+ "Default", isa.default, alu_width=128, fpu_width=128, load_with=128, store_width=128
107
+ )
108
+ prescott = Microarchitecture(
109
+ "Prescott",
110
+ (isa.cmov, isa.sse3, isa.clflush),
111
+ alu_width=64,
112
+ fpu_width=64,
113
+ load_with=64,
114
+ store_width=64,
115
+ )
116
+ conroe = Microarchitecture(
117
+ "Conroe",
118
+ (isa.cmov, isa.mmx_plus, isa.ssse3, isa.clflush),
119
+ alu_width=128,
120
+ fpu_width=128,
121
+ load_with=128,
122
+ store_width=128,
123
+ )
124
+ penryn = Microarchitecture(
125
+ "Penryn",
126
+ (isa.cmov, isa.mmx_plus, isa.sse4_1, isa.clflush),
127
+ alu_width=128,
128
+ fpu_width=128,
129
+ load_with=128,
130
+ store_width=128,
131
+ )
132
+ nehalem = Microarchitecture(
133
+ "Nehalem",
134
+ (isa.cmov, isa.mmx_plus, isa.sse4_2, isa.popcnt, isa.clflush),
135
+ alu_width=128,
136
+ fpu_width=128,
137
+ load_with=128,
138
+ store_width=128,
139
+ )
140
+ sandy_bridge = Microarchitecture(
141
+ "Sandy Bridge",
142
+ (isa.cmov, isa.mmx_plus, isa.sse4_2, isa.popcnt, isa.avx),
143
+ alu_width=128,
144
+ fpu_width=256,
145
+ load_with=256,
146
+ store_width=128,
147
+ )
148
+ ivy_bridge = Microarchitecture(
149
+ "Ivy Bridge",
150
+ (isa.cmov, isa.mmx_plus, isa.sse4_2, isa.popcnt, isa.avx, isa.f16c),
151
+ alu_width=128,
152
+ fpu_width=256,
153
+ load_with=256,
154
+ store_width=128,
155
+ )
156
+ haswell = Microarchitecture(
157
+ "Haswell",
158
+ (
159
+ isa.cmov,
160
+ isa.mmx_plus,
161
+ isa.sse4_2,
162
+ isa.popcnt,
163
+ isa.avx,
164
+ isa.f16c,
165
+ isa.fma3,
166
+ isa.avx2,
167
+ isa.lzcnt,
168
+ isa.prefetchw,
169
+ isa.movbe,
170
+ isa.bmi2,
171
+ ),
172
+ alu_width=256,
173
+ fpu_width=256,
174
+ load_with=256,
175
+ store_width=256,
176
+ )
177
+ broadwell = Microarchitecture(
178
+ "Broadwell",
179
+ (
180
+ isa.cmov,
181
+ isa.mmx_plus,
182
+ isa.sse4_2,
183
+ isa.popcnt,
184
+ isa.f16c,
185
+ isa.fma3,
186
+ isa.avx2,
187
+ isa.lzcnt,
188
+ isa.prefetchw,
189
+ isa.movbe,
190
+ isa.bmi2,
191
+ isa.adx,
192
+ isa.rdseed,
193
+ ),
194
+ alu_width=256,
195
+ fpu_width=256,
196
+ load_with=256,
197
+ store_width=256,
198
+ )
199
+ skylake = Microarchitecture(
200
+ "Skylake",
201
+ (
202
+ isa.cmov,
203
+ isa.mmx_plus,
204
+ isa.sse4_2,
205
+ isa.popcnt,
206
+ isa.f16c,
207
+ isa.fma3,
208
+ isa.avx2,
209
+ isa.lzcnt,
210
+ isa.prefetchw,
211
+ isa.clflushopt,
212
+ isa.movbe,
213
+ isa.bmi2,
214
+ isa.adx,
215
+ isa.rdseed,
216
+ ),
217
+ alu_width=256,
218
+ fpu_width=256,
219
+ load_with=256,
220
+ store_width=256,
221
+ )
222
+ skylake_xeon = Microarchitecture(
223
+ "Skylake Xeon",
224
+ (
225
+ isa.cmov,
226
+ isa.mmx_plus,
227
+ isa.sse4_2,
228
+ isa.popcnt,
229
+ isa.f16c,
230
+ isa.fma3,
231
+ isa.lzcnt,
232
+ isa.prefetchw,
233
+ isa.clflushopt,
234
+ isa.movbe,
235
+ isa.bmi2,
236
+ isa.adx,
237
+ isa.avx512bw,
238
+ isa.avx512dq,
239
+ isa.avx512vl,
240
+ isa.avx512cd,
241
+ isa.rdseed,
242
+ ),
243
+ alu_width=512,
244
+ fpu_width=512,
245
+ load_with=512,
246
+ store_width=512,
247
+ )
248
+ cannonlake = Microarchitecture(
249
+ "Cannonlake",
250
+ (
251
+ isa.cmov,
252
+ isa.mmx_plus,
253
+ isa.sse4_2,
254
+ isa.popcnt,
255
+ isa.f16c,
256
+ isa.fma3,
257
+ isa.lzcnt,
258
+ isa.prefetchw,
259
+ isa.clflushopt,
260
+ isa.movbe,
261
+ isa.bmi2,
262
+ isa.adx,
263
+ isa.avx512bw,
264
+ isa.avx512dq,
265
+ isa.avx512vl,
266
+ isa.avx512cd,
267
+ isa.avx512ifma,
268
+ isa.avx512vbmi,
269
+ isa.rdseed,
270
+ ),
271
+ # TODO: update EU width when CNL is out
272
+ alu_width=512,
273
+ fpu_width=512,
274
+ load_with=512,
275
+ store_width=512,
276
+ )
277
+ knights_landing = Microarchitecture(
278
+ "Knights Landing",
279
+ (
280
+ isa.cmov,
281
+ isa.mmx_plus,
282
+ isa.sse4_2,
283
+ isa.popcnt,
284
+ isa.f16c,
285
+ isa.fma3,
286
+ isa.lzcnt,
287
+ isa.prefetchw,
288
+ isa.movbe,
289
+ isa.bmi2,
290
+ isa.adx,
291
+ isa.avx512cd,
292
+ isa.avx512cd,
293
+ isa.avx512er,
294
+ ),
295
+ alu_width=512,
296
+ fpu_width=512,
297
+ load_with=512,
298
+ store_width=512,
299
+ )
300
+ k8 = Microarchitecture(
301
+ "K8",
302
+ (
303
+ isa.cmov,
304
+ isa.mmx_plus,
305
+ isa.three_d_now_plus,
306
+ isa.sse2,
307
+ isa.prefetch,
308
+ isa.prefetchw,
309
+ isa.clflush,
310
+ ),
311
+ alu_width=64,
312
+ fpu_width=64,
313
+ load_with=64,
314
+ store_width=64,
315
+ )
316
+ k10 = Microarchitecture(
317
+ "K10",
318
+ (
319
+ isa.cmov,
320
+ isa.mmx_plus,
321
+ isa.three_d_now_plus,
322
+ isa.sse4a,
323
+ isa.prefetch,
324
+ isa.prefetchw,
325
+ isa.clflush,
326
+ isa.popcnt,
327
+ isa.lzcnt,
328
+ ),
329
+ alu_width=128,
330
+ fpu_width=128,
331
+ load_with=128,
332
+ store_width=64,
333
+ )
334
+ bulldozer = Microarchitecture(
335
+ "Bulldozer",
336
+ (
337
+ isa.cmov,
338
+ isa.mmx_plus,
339
+ isa.sse4a,
340
+ isa.avx,
341
+ isa.xop,
342
+ isa.fma4,
343
+ isa.prefetch,
344
+ isa.prefetchw,
345
+ isa.clflush,
346
+ isa.aes,
347
+ isa.pclmulqdq,
348
+ isa.lzcnt,
349
+ isa.popcnt,
350
+ ),
351
+ alu_width=128,
352
+ fpu_width=128,
353
+ load_with=128,
354
+ store_width=128,
355
+ )
356
+ piledriver = Microarchitecture(
357
+ "Piledriver",
358
+ (
359
+ isa.cmov,
360
+ isa.mmx_plus,
361
+ isa.sse4a,
362
+ isa.sse4_2,
363
+ isa.avx,
364
+ isa.xop,
365
+ isa.fma4,
366
+ isa.fma3,
367
+ isa.f16c,
368
+ isa.aes,
369
+ isa.pclmulqdq,
370
+ isa.prefetch,
371
+ isa.prefetchw,
372
+ isa.clflush,
373
+ isa.lzcnt,
374
+ isa.popcnt,
375
+ isa.bmi,
376
+ isa.tbm,
377
+ ),
378
+ alu_width=128,
379
+ fpu_width=128,
380
+ load_with=128,
381
+ store_width=128,
382
+ )
383
+ steamroller = Microarchitecture(
384
+ "Steamroller",
385
+ (
386
+ isa.cmov,
387
+ isa.mmx_plus,
388
+ isa.sse4a,
389
+ isa.sse4_2,
390
+ isa.avx,
391
+ isa.xop,
392
+ isa.fma4,
393
+ isa.fma3,
394
+ isa.f16c,
395
+ isa.aes,
396
+ isa.pclmulqdq,
397
+ isa.prefetch,
398
+ isa.prefetchw,
399
+ isa.clflush,
400
+ isa.lzcnt,
401
+ isa.popcnt,
402
+ isa.bmi,
403
+ isa.tbm,
404
+ ),
405
+ alu_width=128,
406
+ fpu_width=256,
407
+ load_with=256,
408
+ store_width=128,
409
+ )
410
+ excavator = Microarchitecture(
411
+ "Excavator",
412
+ (
413
+ isa.cmov,
414
+ isa.mmx_plus,
415
+ isa.sse4a,
416
+ isa.xop,
417
+ isa.fma4,
418
+ isa.fma3,
419
+ isa.f16c,
420
+ isa.avx2,
421
+ isa.aes,
422
+ isa.pclmulqdq,
423
+ isa.rdrand,
424
+ isa.prefetch,
425
+ isa.prefetchw,
426
+ isa.clflush,
427
+ isa.lzcnt,
428
+ isa.popcnt,
429
+ isa.bmi2,
430
+ isa.tbm,
431
+ ),
432
+ alu_width=256,
433
+ fpu_width=256,
434
+ load_with=256,
435
+ store_width=128,
436
+ )
437
+ zen = Microarchitecture(
438
+ "Zen",
439
+ (
440
+ isa.cmov,
441
+ isa.mmx_plus,
442
+ isa.fma4,
443
+ isa.fma3,
444
+ isa.f16c,
445
+ isa.avx2,
446
+ isa.aes,
447
+ isa.pclmulqdq,
448
+ isa.rdseed,
449
+ isa.sha,
450
+ isa.prefetch,
451
+ isa.prefetchw,
452
+ isa.clflushopt,
453
+ isa.clzero,
454
+ isa.lzcnt,
455
+ isa.popcnt,
456
+ isa.bmi2,
457
+ isa.adx,
458
+ isa.rdseed,
459
+ ),
460
+ alu_width=256,
461
+ fpu_width=256,
462
+ load_with=256,
463
+ store_width=256,
464
+ )
465
+ bonnell = Microarchitecture(
466
+ "Bonnell",
467
+ (isa.cmov, isa.movbe, isa.mmx_plus, isa.ssse3, isa.clflush),
468
+ alu_width=128,
469
+ fpu_width=64,
470
+ load_with=128,
471
+ store_width=128,
472
+ )
473
+ saltwell = Microarchitecture(
474
+ "Saltwell",
475
+ (isa.cmov, isa.movbe, isa.mmx_plus, isa.ssse3, isa.clflush),
476
+ alu_width=128,
477
+ fpu_width=64,
478
+ load_with=128,
479
+ store_width=128,
480
+ )
481
+ silvermont = Microarchitecture(
482
+ "Silvermont",
483
+ (
484
+ isa.cmov,
485
+ isa.movbe,
486
+ isa.popcnt,
487
+ isa.clflush,
488
+ isa.mmx_plus,
489
+ isa.sse4_2,
490
+ isa.aes,
491
+ isa.pclmulqdq,
492
+ ),
493
+ alu_width=128,
494
+ fpu_width=64,
495
+ load_with=128,
496
+ store_width=128,
497
+ )
498
+ airmont = Microarchitecture(
499
+ "Airmont",
500
+ (
501
+ isa.cmov,
502
+ isa.movbe,
503
+ isa.popcnt,
504
+ isa.mmx_plus,
505
+ isa.sse4_2,
506
+ isa.aes,
507
+ isa.pclmulqdq,
508
+ isa.rdrand,
509
+ isa.prefetchw,
510
+ isa.clflush,
511
+ isa.rdtscp,
512
+ ),
513
+ alu_width=128,
514
+ fpu_width=64,
515
+ load_with=128,
516
+ store_width=128,
517
+ )
518
+ goldmont = Microarchitecture(
519
+ "Goldmont",
520
+ (
521
+ isa.cmov,
522
+ isa.movbe,
523
+ isa.popcnt,
524
+ isa.adx,
525
+ isa.mmx_plus,
526
+ isa.sse4_2,
527
+ isa.prefetchw,
528
+ isa.clflushopt,
529
+ isa.aes,
530
+ isa.pclmulqdq,
531
+ isa.rdseed,
532
+ isa.sha,
533
+ isa.rdtscp,
534
+ ),
535
+ alu_width=128,
536
+ fpu_width=64,
537
+ load_with=128,
538
+ store_width=128,
539
+ )
540
+ bobcat = Microarchitecture(
541
+ "Bobcat",
542
+ (
543
+ isa.cmov,
544
+ isa.mmx_plus,
545
+ isa.ssse3,
546
+ isa.sse4a,
547
+ isa.prefetch,
548
+ isa.prefetchw,
549
+ isa.clflush,
550
+ isa.lzcnt,
551
+ isa.popcnt,
552
+ ),
553
+ alu_width=64,
554
+ fpu_width=64,
555
+ load_with=64,
556
+ store_width=64,
557
+ )
558
+ jaguar = Microarchitecture(
559
+ "Jaguar",
560
+ (
561
+ isa.cmov,
562
+ isa.mmx_plus,
563
+ isa.sse4_2,
564
+ isa.sse4a,
565
+ isa.avx,
566
+ isa.f16c,
567
+ isa.prefetch,
568
+ isa.prefetchw,
569
+ isa.clflush,
570
+ isa.lzcnt,
571
+ isa.popcnt,
572
+ isa.movbe,
573
+ isa.aes,
574
+ isa.pclmulqdq,
575
+ ),
576
+ alu_width=128,
577
+ fpu_width=128,
578
+ load_with=128,
579
+ store_width=128,
580
+ )