PyNerva 0.0.7__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.
- nervapy/__init__.py +50 -0
- nervapy/abi.py +91 -0
- nervapy/arm/__init__.py +124 -0
- nervapy/arm/__main__.py +0 -0
- nervapy/arm/abi.py +138 -0
- nervapy/arm/formats.py +49 -0
- nervapy/arm/function.py +2465 -0
- nervapy/arm/generic.py +10796 -0
- nervapy/arm/instructions.py +519 -0
- nervapy/arm/isa.py +409 -0
- nervapy/arm/literal_pool.py +331 -0
- nervapy/arm/microarchitecture.py +211 -0
- nervapy/arm/pseudo.py +652 -0
- nervapy/arm/registers.py +1458 -0
- nervapy/arm/vfpneon.py +4092 -0
- nervapy/arm.py +13 -0
- nervapy/c/__init__.py +1 -0
- nervapy/c/types.py +436 -0
- nervapy/codegen.py +99 -0
- nervapy/common/__init__.py +4 -0
- nervapy/common/function.py +5 -0
- nervapy/common/regalloc.py +121 -0
- nervapy/constant_data.py +282 -0
- nervapy/encoder.py +246 -0
- nervapy/formats/__init__.py +2 -0
- nervapy/formats/elf/__init__.py +4 -0
- nervapy/formats/elf/file.py +178 -0
- nervapy/formats/elf/image.py +106 -0
- nervapy/formats/elf/section.py +422 -0
- nervapy/formats/elf/symbol.py +281 -0
- nervapy/formats/macho/__init__.py +2 -0
- nervapy/formats/macho/file.py +123 -0
- nervapy/formats/macho/image.py +143 -0
- nervapy/formats/macho/section.py +322 -0
- nervapy/formats/macho/symbol.py +158 -0
- nervapy/formats/mscoff/__init__.py +8 -0
- nervapy/formats/mscoff/image.py +132 -0
- nervapy/formats/mscoff/section.py +181 -0
- nervapy/formats/mscoff/symbol.py +148 -0
- nervapy/function.py +136 -0
- nervapy/literal.py +731 -0
- nervapy/loader.py +188 -0
- nervapy/name.py +159 -0
- nervapy/parse.py +52 -0
- nervapy/stream.py +58 -0
- nervapy/util.py +126 -0
- nervapy/writer.py +518 -0
- nervapy/x86_64/__init__.py +324 -0
- nervapy/x86_64/__main__.py +407 -0
- nervapy/x86_64/abi.py +517 -0
- nervapy/x86_64/amd.py +6464 -0
- nervapy/x86_64/avx.py +102029 -0
- nervapy/x86_64/crypto.py +1533 -0
- nervapy/x86_64/encoding.py +424 -0
- nervapy/x86_64/fma.py +19138 -0
- nervapy/x86_64/function.py +2707 -0
- nervapy/x86_64/generic.py +23384 -0
- nervapy/x86_64/instructions.py +500 -0
- nervapy/x86_64/isa.py +476 -0
- nervapy/x86_64/lower.py +126 -0
- nervapy/x86_64/mask.py +2593 -0
- nervapy/x86_64/meta.py +143 -0
- nervapy/x86_64/mmxsse.py +17265 -0
- nervapy/x86_64/nacl.py +327 -0
- nervapy/x86_64/operand.py +1204 -0
- nervapy/x86_64/options.py +21 -0
- nervapy/x86_64/pseudo.py +686 -0
- nervapy/x86_64/registers.py +1225 -0
- nervapy/x86_64/types.py +17 -0
- nervapy/x86_64/uarch.py +580 -0
- pynerva-0.0.7.dist-info/METADATA +310 -0
- pynerva-0.0.7.dist-info/RECORD +74 -0
- pynerva-0.0.7.dist-info/WHEEL +4 -0
- pynerva-0.0.7.dist-info/licenses/LICENSE.rst +15 -0
nervapy/__init__.py
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# This file is part of NervaPy package and is licensed under the Simplified BSD license.
|
|
2
|
+
# See license.rst for the full text of the license.
|
|
3
|
+
|
|
4
|
+
__version_info__ = (0, 2, 0)
|
|
5
|
+
__version__ = ".".join(map(str, __version_info__))
|
|
6
|
+
|
|
7
|
+
from nervapy.c.types import (Float16, Float32, Float64, Type, Yep8s, Yep8u,
|
|
8
|
+
Yep16f, Yep16s, Yep16u, Yep32f, Yep32s, Yep32u,
|
|
9
|
+
Yep64f, Yep64s, Yep64u, YepSize, char, const_char,
|
|
10
|
+
const_double_, const_Float16, const_Float32,
|
|
11
|
+
const_Float64, const_float_, const_int8_t,
|
|
12
|
+
const_int16_t, const_int32_t, const_int64_t,
|
|
13
|
+
const_intptr_t, const_ptr, const_ptrdiff_t,
|
|
14
|
+
const_signed_char, const_signed_int,
|
|
15
|
+
const_signed_long, const_signed_long_long,
|
|
16
|
+
const_signed_short, const_size_t, const_uint8_t,
|
|
17
|
+
const_uint16_t, const_uint32_t, const_uint64_t,
|
|
18
|
+
const_uintptr_t, const_unsigned_char,
|
|
19
|
+
const_unsigned_int, const_unsigned_long,
|
|
20
|
+
const_unsigned_long_long, const_unsigned_short,
|
|
21
|
+
const_wchar_t, const_Yep8s, const_Yep8u,
|
|
22
|
+
const_Yep16f, const_Yep16s, const_Yep16u,
|
|
23
|
+
const_Yep32f, const_Yep32s, const_Yep32u,
|
|
24
|
+
const_Yep64f, const_Yep64s, const_Yep64u,
|
|
25
|
+
const_YepSize, double_, float_, int8_t, int16_t,
|
|
26
|
+
int32_t, int64_t, intptr_t, ptr, ptrdiff_t,
|
|
27
|
+
signed_char, signed_int, signed_long,
|
|
28
|
+
signed_long_long, signed_short, size_t, uint8_t,
|
|
29
|
+
uint16_t, uint32_t, uint64_t, uintptr_t,
|
|
30
|
+
unsigned_char, unsigned_int, unsigned_long,
|
|
31
|
+
unsigned_long_long, unsigned_short, wchar_t)
|
|
32
|
+
from nervapy.function import Argument
|
|
33
|
+
from nervapy.literal import Constant
|
|
34
|
+
from nervapy.stream import InstructionStream
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
class ConstantBucket:
|
|
38
|
+
def __init__(self, capacity):
|
|
39
|
+
self.capacity = capacity
|
|
40
|
+
self.constants = []
|
|
41
|
+
|
|
42
|
+
def add(self, constant):
|
|
43
|
+
self.constants.append(constant)
|
|
44
|
+
|
|
45
|
+
def is_full(self):
|
|
46
|
+
return False # Simple implementation for now
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
class RegisterAllocationError(Exception):
|
|
50
|
+
pass
|
nervapy/abi.py
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
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
|
+
|
|
5
|
+
class Endianness:
|
|
6
|
+
Big, Little = "Big-Endian", "Little-Endian"
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class ABI(object):
|
|
10
|
+
def __init__(
|
|
11
|
+
self,
|
|
12
|
+
name,
|
|
13
|
+
endianness,
|
|
14
|
+
bool_size,
|
|
15
|
+
wchar_size,
|
|
16
|
+
short_size,
|
|
17
|
+
int_size,
|
|
18
|
+
long_size,
|
|
19
|
+
longlong_size,
|
|
20
|
+
pointer_size,
|
|
21
|
+
index_size,
|
|
22
|
+
stack_alignment,
|
|
23
|
+
red_zone,
|
|
24
|
+
callee_save_registers,
|
|
25
|
+
argument_registers,
|
|
26
|
+
volatile_registers,
|
|
27
|
+
restricted_registers=[],
|
|
28
|
+
elf_class=None,
|
|
29
|
+
elf_data_encoding=None,
|
|
30
|
+
elf_machine_type=None,
|
|
31
|
+
mscoff_machine_type=None,
|
|
32
|
+
):
|
|
33
|
+
super(ABI, self).__init__()
|
|
34
|
+
self.name = name
|
|
35
|
+
self.endianness = endianness
|
|
36
|
+
self.bool_size = bool_size
|
|
37
|
+
self.wchar_size = wchar_size
|
|
38
|
+
self.short_size = short_size
|
|
39
|
+
self.int_size = int_size
|
|
40
|
+
self.long_size = long_size
|
|
41
|
+
self.longlong_size = longlong_size
|
|
42
|
+
self.pointer_size = pointer_size
|
|
43
|
+
self.index_size = index_size
|
|
44
|
+
self.stack_alignment = stack_alignment
|
|
45
|
+
self.red_zone = red_zone
|
|
46
|
+
self.callee_save_registers = callee_save_registers
|
|
47
|
+
self.argument_registers = argument_registers
|
|
48
|
+
self.volatile_registers = volatile_registers
|
|
49
|
+
self.restricted_registers = restricted_registers
|
|
50
|
+
self.elf_class = elf_class
|
|
51
|
+
self.elf_data_encoding = elf_data_encoding
|
|
52
|
+
self.elf_machine_type = elf_machine_type
|
|
53
|
+
self.mscoff_machine_type = mscoff_machine_type
|
|
54
|
+
|
|
55
|
+
def __eq__(self, other):
|
|
56
|
+
return isinstance(other, ABI) and self.name == other.name
|
|
57
|
+
|
|
58
|
+
def __ne__(self, other):
|
|
59
|
+
return not isinstance(other, ABI) or self.name != other.name
|
|
60
|
+
|
|
61
|
+
def __hash__(self):
|
|
62
|
+
return hash(self.name)
|
|
63
|
+
|
|
64
|
+
def __str__(self):
|
|
65
|
+
return self.name
|
|
66
|
+
|
|
67
|
+
def __repr__(self):
|
|
68
|
+
return str(self)
|
|
69
|
+
|
|
70
|
+
@property
|
|
71
|
+
def is_elf_compatible(self):
|
|
72
|
+
return (
|
|
73
|
+
self.elf_class is not None
|
|
74
|
+
and self.elf_data_encoding is not None
|
|
75
|
+
and self.elf_machine_type is not None
|
|
76
|
+
)
|
|
77
|
+
|
|
78
|
+
@property
|
|
79
|
+
def is_mscoff_compatible(self):
|
|
80
|
+
return self.mscoff_machine_type is not None
|
|
81
|
+
|
|
82
|
+
@property
|
|
83
|
+
def is_macho_compatible(self):
|
|
84
|
+
return False
|
|
85
|
+
|
|
86
|
+
@property
|
|
87
|
+
def elf_bitness(self):
|
|
88
|
+
if self.elf_class is not None:
|
|
89
|
+
from nervapy.formats.elf.file import ElfClass
|
|
90
|
+
|
|
91
|
+
return {ElfClass.class32: 32, ElfClass.class64: 64}[self.elf_class]
|
nervapy/arm/__init__.py
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
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
|
+
import nervapy
|
|
5
|
+
import nervapy.arm.abi
|
|
6
|
+
import nervapy.arm.isa
|
|
7
|
+
from nervapy.arm.formats import AssemblyFormat, HighRegisterStrategy
|
|
8
|
+
from nervapy.arm.function import Function, print_live_registers
|
|
9
|
+
from nervapy.arm.generic import (ADC, ADCCC, ADCCS, ADCEQ, ADCGE, ADCGT, ADCHI,
|
|
10
|
+
ADCHS, ADCLE, ADCLO, ADCLS, ADCLT, ADCMI,
|
|
11
|
+
ADCNE, ADCPL, ADCS, ADCSCC, ADCSCS, ADCSEQ,
|
|
12
|
+
ADCSGE, ADCSGT, ADCSHI, ADCSHS, ADCSLE,
|
|
13
|
+
ADCSLO, ADCSLS, ADCSLT, ADCSMI, ADCSNE,
|
|
14
|
+
ADCSPL, ADCSVC, ADCSVS, ADCVC, ADCVS, ADD,
|
|
15
|
+
ADDCC, ADDCS, ADDEQ, ADDGE, ADDGT, ADDHI,
|
|
16
|
+
ADDHS, ADDLE, ADDLO, ADDLS, ADDLT, ADDMI,
|
|
17
|
+
ADDNE, ADDPL, ADDS, ADDSCC, ADDSCS, ADDSEQ,
|
|
18
|
+
ADDSGE, ADDSGT, ADDSHI, ADDSHS, ADDSLE,
|
|
19
|
+
ADDSLO, ADDSLS, ADDSLT, ADDSMI, ADDSNE,
|
|
20
|
+
ADDSPL, ADDSVC, ADDSVS, ADDVC, ADDVS, ADR,
|
|
21
|
+
AND, AND_W, ANDCC, ANDCS, ANDEQ, ANDGE, ANDGT,
|
|
22
|
+
ANDHI, ANDHS, ANDLE, ANDLO, ANDLS, ANDLT,
|
|
23
|
+
ANDMI, ANDNE, ANDPL, ANDS, ANDSCC, ANDSCS,
|
|
24
|
+
ANDSEQ, ANDSGE, ANDSGT, ANDSHI, ANDSHS,
|
|
25
|
+
ANDSLE, ANDSLO, ANDSLS, ANDSLT, ANDSMI,
|
|
26
|
+
ANDSNE, ANDSPL, ANDSVC, ANDSVS, ANDVC, ANDVS,
|
|
27
|
+
ASR, BCC, BCS, BEQ, BFC, BFI, BGE, BGT, BHI,
|
|
28
|
+
BHS, BIC, BICCC, BICCS, BICEQ, BICGE, BICGT,
|
|
29
|
+
BICHI, BICHS, BICLE, BICLO, BICLS, BICLT,
|
|
30
|
+
BICMI, BICNE, BICPL, BICS, BICSCC, BICSCS,
|
|
31
|
+
BICSEQ, BICSGE, BICSGT, BICSHI, BICSHS,
|
|
32
|
+
BICSLE, BICSLO, BICSLS, BICSLT, BICSMI,
|
|
33
|
+
BICSNE, BICSPL, BICSVC, BICSVS, BICVC, BICVS,
|
|
34
|
+
BKPT, BL, BLE, BLO, BLS, BLT, BLX, BLXNS, BMI,
|
|
35
|
+
BNE, BPL, BVC, BVS, BX, BXNS, CBNZ, CBZ, CMP,
|
|
36
|
+
CMPCC, CMPCS, CMPEQ, CMPGE, CMPGT, CMPHI,
|
|
37
|
+
CMPHS, CMPLE, CMPLO, CMPLS, CMPLT, CMPMI,
|
|
38
|
+
CMPNE, CMPPL, CMPVC, CMPVS, EOR, EOR_W, EORCC,
|
|
39
|
+
EORCS, EOREQ, EORGE, EORGT, EORHI, EORHS,
|
|
40
|
+
EORLE, EORLO, EORLS, EORLT, EORMI, EORNE,
|
|
41
|
+
EORPL, EORS, EORSCC, EORSCS, EORSEQ, EORSGE,
|
|
42
|
+
EORSGT, EORSHI, EORSHS, EORSLE, EORSLO,
|
|
43
|
+
EORSLS, EORSLT, EORSMI, EORSNE, EORSPL,
|
|
44
|
+
EORSVC, EORSVS, EORVC, EORVS, LDMDB, LDMIA,
|
|
45
|
+
LDR, LDR_W, LDRB, LDRB_W, LDRD, LDRH, LDRH_W,
|
|
46
|
+
LDRSB, LDRSB_W, LDRSH, LDRSH_W, LSL, LSR, MIA,
|
|
47
|
+
MIAPH, MLA, MLS, MOV, MOV_W, MOVCC, MOVCS,
|
|
48
|
+
MOVEQ, MOVGE, MOVGT, MOVHI, MOVHS, MOVLE,
|
|
49
|
+
MOVLO, MOVLS, MOVLT, MOVMI, MOVNE, MOVPL,
|
|
50
|
+
MOVS, MOVSCC, MOVSCS, MOVSEQ, MOVSGE, MOVSGT,
|
|
51
|
+
MOVSHI, MOVSHS, MOVSLE, MOVSLO, MOVSLS,
|
|
52
|
+
MOVSLT, MOVSMI, MOVSNE, MOVSPL, MOVSVC,
|
|
53
|
+
MOVSVS, MOVT, MOVVC, MOVVS, MUL, MVN, ORR,
|
|
54
|
+
ORRCC, ORRCS, ORREQ, ORRGE, ORRGT, ORRHI,
|
|
55
|
+
ORRHS, ORRLE, ORRLO, ORRLS, ORRLT, ORRMI,
|
|
56
|
+
ORRNE, ORRPL, ORRS, ORRSCC, ORRSCS, ORRSEQ,
|
|
57
|
+
ORRSGE, ORRSGT, ORRSHI, ORRSHS, ORRSLE,
|
|
58
|
+
ORRSLO, ORRSLS, ORRSLT, ORRSMI, ORRSNE,
|
|
59
|
+
ORRSPL, ORRSVC, ORRSVS, ORRVC, ORRVS, POP,
|
|
60
|
+
POP_W, PUSH, PUSH_W, ROR, RSB, RSBCC, RSBCS,
|
|
61
|
+
RSBEQ, RSBGE, RSBGT, RSBHI, RSBHS, RSBLE,
|
|
62
|
+
RSBLO, RSBLS, RSBLT, RSBMI, RSBNE, RSBPL,
|
|
63
|
+
RSBS, RSBSCC, RSBSCS, RSBSEQ, RSBSGE, RSBSGT,
|
|
64
|
+
RSBSHI, RSBSHS, RSBSLE, RSBSLO, RSBSLS,
|
|
65
|
+
RSBSLT, RSBSMI, RSBSNE, RSBSPL, RSBSVC,
|
|
66
|
+
RSBSVS, RSBVC, RSBVS, RSC, RSCCC, RSCCS,
|
|
67
|
+
RSCEQ, RSCGE, RSCGT, RSCHI, RSCHS, RSCLE,
|
|
68
|
+
RSCLO, RSCLS, RSCLT, RSCMI, RSCNE, RSCPL,
|
|
69
|
+
RSCS, RSCSCC, RSCSCS, RSCSEQ, RSCSGE, RSCSGT,
|
|
70
|
+
RSCSHI, RSCSHS, RSCSLE, RSCSLO, RSCSLS,
|
|
71
|
+
RSCSLT, RSCSMI, RSCSNE, RSCSPL, RSCSVC,
|
|
72
|
+
RSCSVS, RSCVC, RSCVS, SBC, SBCCC, SBCCS,
|
|
73
|
+
SBCEQ, SBCGE, SBCGT, SBCHI, SBCHS, SBCLE,
|
|
74
|
+
SBCLO, SBCLS, SBCLT, SBCMI, SBCNE, SBCPL,
|
|
75
|
+
SBCS, SBCSCC, SBCSCS, SBCSEQ, SBCSGE, SBCSGT,
|
|
76
|
+
SBCSHI, SBCSHS, SBCSLE, SBCSLO, SBCSLS,
|
|
77
|
+
SBCSLT, SBCSMI, SBCSNE, SBCSPL, SBCSVC,
|
|
78
|
+
SBCSVS, SBCVC, SBCVS, SG, SMLABBNE, SMLABT,
|
|
79
|
+
SMLAD, SMLAL, SMLALBB, SMLALBT, SMLALD,
|
|
80
|
+
SMLALTB, SMLALTT, SMLAWB, SMLAWT, SMLSD,
|
|
81
|
+
SMLSLD, SMMLA, SMMLS, SMMUL, SMUAD, SMULL,
|
|
82
|
+
SMULTBEQ, SMULWB, SMULWT, SMUSD, SMUSDXNE,
|
|
83
|
+
STMDB, STMIA, STR, STR_W, STRB, STRB_W, STRD,
|
|
84
|
+
STRH, STRH_W, SUB, SUBCC, SUBCS, SUBEQ, SUBGE,
|
|
85
|
+
SUBGT, SUBHI, SUBHS, SUBLE, SUBLO, SUBLS,
|
|
86
|
+
SUBLT, SUBMI, SUBNE, SUBPL, SUBS, SUBSCC,
|
|
87
|
+
SUBSCS, SUBSEQ, SUBSGE, SUBSGT, SUBSHI,
|
|
88
|
+
SUBSHS, SUBSLE, SUBSLO, SUBSLS, SUBSLT,
|
|
89
|
+
SUBSMI, SUBSNE, SUBSPL, SUBSVC, SUBSVS, SUBVC,
|
|
90
|
+
SUBVS, TEQ, TEQCC, TEQCS, TEQEQ, TEQGE, TEQGT,
|
|
91
|
+
TEQHI, TEQHS, TEQLE, TEQLO, TEQLS, TEQLT,
|
|
92
|
+
TEQMI, TEQNE, TEQPL, TEQVC, TEQVS, TST, TSTCC,
|
|
93
|
+
TSTCS, TSTEQ, TSTGE, TSTGT, TSTHI, TSTHS,
|
|
94
|
+
TSTLE, TSTLO, TSTLS, TSTLT, TSTMI, TSTNE,
|
|
95
|
+
TSTPL, TSTVC, TSTVS, TT, TTA, TTAT, TTT,
|
|
96
|
+
UMAAL, UMAALGE, UMLAL, UMULL, B)
|
|
97
|
+
from nervapy.arm.literal_pool import LDR_LITERAL, LDRL
|
|
98
|
+
from nervapy.arm.microarchitecture import Microarchitecture
|
|
99
|
+
from nervapy.arm.pseudo import (ALIGN, ASSUME, IMPORT, INIT, LABEL, LOAD,
|
|
100
|
+
REDUCE, RETURN, STORE, SWAP, ExternalFunction,
|
|
101
|
+
Label, Loop)
|
|
102
|
+
from nervapy.arm.registers import (DRegister, GeneralPurposeRegister,
|
|
103
|
+
PRegister, QRegister, SRegister,
|
|
104
|
+
VPRRegister, WMMXRegister, d0, d1, d2, d3,
|
|
105
|
+
d4, d5, d6, d7, d8, d9, d10, d11, d12, d13,
|
|
106
|
+
d14, d15, lr, p0, p1, p2, p3, p4, p5, p6,
|
|
107
|
+
p7, pc, q0, q1, q2, q3, q4, q5, q6, q7, r0,
|
|
108
|
+
r1, r2, r3, r4, r5, r6, r7, r8, r9, r10,
|
|
109
|
+
r11, r12, s0, s1, s2, s3, s4, s5, s6, s7,
|
|
110
|
+
s8, s9, s10, s11, s12, s13, s14, s15, s16,
|
|
111
|
+
s17, s18, s19, s20, s21, s22, s23, s24, s25,
|
|
112
|
+
s26, s27, s28, s29, s30, s31, vpr, wr0, wr1,
|
|
113
|
+
wr2, wr3, wr4, wr5, wr6, wr7, wr8, wr9,
|
|
114
|
+
wr10, wr11, wr12, wr13, wr14, wr15)
|
|
115
|
+
from nervapy.arm.vfpneon import (VABD, VABS, VACGE, VACGT, VACLE, VACLT, VADD,
|
|
116
|
+
VADDL, VAND, VBIC, VDIV, VEOR, VFMA, VFMS,
|
|
117
|
+
VFNMA, VFNMS, VHADD, VHSUB, VLD1, VLDM,
|
|
118
|
+
VLDMDB, VLDMIA, VLDR, VMAX, VMIN, VMLA, VMLS,
|
|
119
|
+
VMOV, VMUL, VMULL, VNEG, VNMLA, VNMLS, VNMUL,
|
|
120
|
+
VORN, VORR, VPADD, VPMAX, VPMIN, VQADD, VQSUB,
|
|
121
|
+
VRECPS, VRHADD, VRSQRTS, VSQRT, VST1, VSTM,
|
|
122
|
+
VSTMDB, VSTMIA, VSTR, VSUB, VSUBL, VTST)
|
|
123
|
+
|
|
124
|
+
__m64 = nervapy.Type("__m64", size=8, is_vector=True, header="mmintrin.h")
|
nervapy/arm/__main__.py
ADDED
|
File without changes
|
nervapy/arm/abi.py
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
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.abi import ABI, Endianness
|
|
5
|
+
from nervapy.arm.registers import (d0, d1, d2, d3, d4, d5, d6, d7, d8, d9, d10,
|
|
6
|
+
d11, d12, d13, d14, d15, d16, d17, d18, d19,
|
|
7
|
+
d20, d21, d22, d23, d24, d25, d26, d27, d28,
|
|
8
|
+
d29, d30, d31, r0, r1, r2, r3, r4, r5, r6,
|
|
9
|
+
r7, r8, r9, r10, r11, r12)
|
|
10
|
+
from nervapy.formats.elf.file import DataEncoding, ElfClass, MachineType
|
|
11
|
+
|
|
12
|
+
arm_gnueabi = ABI(
|
|
13
|
+
"GNU Soft-Float ARM EABI",
|
|
14
|
+
endianness=Endianness.Little,
|
|
15
|
+
bool_size=1,
|
|
16
|
+
wchar_size=2,
|
|
17
|
+
short_size=2,
|
|
18
|
+
int_size=4,
|
|
19
|
+
long_size=4,
|
|
20
|
+
longlong_size=8,
|
|
21
|
+
pointer_size=4,
|
|
22
|
+
index_size=4,
|
|
23
|
+
stack_alignment=8,
|
|
24
|
+
red_zone=0,
|
|
25
|
+
callee_save_registers=[
|
|
26
|
+
r4,
|
|
27
|
+
r5,
|
|
28
|
+
r6,
|
|
29
|
+
r7,
|
|
30
|
+
r8,
|
|
31
|
+
r9,
|
|
32
|
+
r10,
|
|
33
|
+
r11,
|
|
34
|
+
d8,
|
|
35
|
+
d9,
|
|
36
|
+
d10,
|
|
37
|
+
d11,
|
|
38
|
+
d12,
|
|
39
|
+
d13,
|
|
40
|
+
d14,
|
|
41
|
+
d15,
|
|
42
|
+
],
|
|
43
|
+
argument_registers=[r0, r1, r2, r3],
|
|
44
|
+
volatile_registers=[
|
|
45
|
+
r12,
|
|
46
|
+
d0,
|
|
47
|
+
d1,
|
|
48
|
+
d2,
|
|
49
|
+
d3,
|
|
50
|
+
d4,
|
|
51
|
+
d5,
|
|
52
|
+
d6,
|
|
53
|
+
d7,
|
|
54
|
+
d16,
|
|
55
|
+
d17,
|
|
56
|
+
d18,
|
|
57
|
+
d19,
|
|
58
|
+
d20,
|
|
59
|
+
d21,
|
|
60
|
+
d22,
|
|
61
|
+
d23,
|
|
62
|
+
d24,
|
|
63
|
+
d25,
|
|
64
|
+
d26,
|
|
65
|
+
d27,
|
|
66
|
+
d28,
|
|
67
|
+
d29,
|
|
68
|
+
d30,
|
|
69
|
+
d31,
|
|
70
|
+
],
|
|
71
|
+
elf_class=ElfClass.class32,
|
|
72
|
+
elf_data_encoding=DataEncoding.little_endian,
|
|
73
|
+
elf_machine_type=MachineType.arm,
|
|
74
|
+
)
|
|
75
|
+
|
|
76
|
+
arm_gnueabihf = ABI(
|
|
77
|
+
"GNU Hard-Float ARM EABI",
|
|
78
|
+
endianness=Endianness.Little,
|
|
79
|
+
bool_size=1,
|
|
80
|
+
wchar_size=2,
|
|
81
|
+
short_size=2,
|
|
82
|
+
int_size=4,
|
|
83
|
+
long_size=4,
|
|
84
|
+
longlong_size=8,
|
|
85
|
+
pointer_size=4,
|
|
86
|
+
index_size=4,
|
|
87
|
+
stack_alignment=8,
|
|
88
|
+
red_zone=0,
|
|
89
|
+
callee_save_registers=[
|
|
90
|
+
r4,
|
|
91
|
+
r5,
|
|
92
|
+
r6,
|
|
93
|
+
r7,
|
|
94
|
+
r8,
|
|
95
|
+
r9,
|
|
96
|
+
r10,
|
|
97
|
+
r11,
|
|
98
|
+
d8,
|
|
99
|
+
d9,
|
|
100
|
+
d10,
|
|
101
|
+
d11,
|
|
102
|
+
d12,
|
|
103
|
+
d13,
|
|
104
|
+
d14,
|
|
105
|
+
d15,
|
|
106
|
+
],
|
|
107
|
+
argument_registers=[r0, r1, r2, r3],
|
|
108
|
+
volatile_registers=[
|
|
109
|
+
r12,
|
|
110
|
+
d0,
|
|
111
|
+
d1,
|
|
112
|
+
d2,
|
|
113
|
+
d3,
|
|
114
|
+
d4,
|
|
115
|
+
d5,
|
|
116
|
+
d6,
|
|
117
|
+
d7,
|
|
118
|
+
d16,
|
|
119
|
+
d17,
|
|
120
|
+
d18,
|
|
121
|
+
d19,
|
|
122
|
+
d20,
|
|
123
|
+
d21,
|
|
124
|
+
d22,
|
|
125
|
+
d23,
|
|
126
|
+
d24,
|
|
127
|
+
d25,
|
|
128
|
+
d26,
|
|
129
|
+
d27,
|
|
130
|
+
d28,
|
|
131
|
+
d29,
|
|
132
|
+
d30,
|
|
133
|
+
d31,
|
|
134
|
+
],
|
|
135
|
+
elf_class=ElfClass.class32,
|
|
136
|
+
elf_data_encoding=DataEncoding.little_endian,
|
|
137
|
+
elf_machine_type=MachineType.arm,
|
|
138
|
+
)
|
nervapy/arm/formats.py
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
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 typing import Optional
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class AssemblyFormat:
|
|
8
|
+
"""Defines different assembly output formats for ARM processors."""
|
|
9
|
+
|
|
10
|
+
def __init__(self, name):
|
|
11
|
+
self.name = name
|
|
12
|
+
|
|
13
|
+
def __str__(self):
|
|
14
|
+
return self.name
|
|
15
|
+
|
|
16
|
+
def __eq__(self, other):
|
|
17
|
+
return self.name == other.name
|
|
18
|
+
|
|
19
|
+
# Assembly format constants
|
|
20
|
+
GAS: Optional["AssemblyFormat"] = None # GNU Assembler (default)
|
|
21
|
+
ARMCC: Optional["AssemblyFormat"] = None # ARM Compiler armasm
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class HighRegisterStrategy:
|
|
25
|
+
"""Defines strategies for handling high registers (r8-r15) in ARMv7-M."""
|
|
26
|
+
|
|
27
|
+
def __init__(self, name):
|
|
28
|
+
self.name = name
|
|
29
|
+
|
|
30
|
+
def __str__(self):
|
|
31
|
+
return self.name
|
|
32
|
+
|
|
33
|
+
def __eq__(self, other):
|
|
34
|
+
return self.name == other.name
|
|
35
|
+
|
|
36
|
+
# High register handling strategies
|
|
37
|
+
PUSH_W: Optional["HighRegisterStrategy"] = None # Use PUSH.W/POP.W for high registers (modern, efficient)
|
|
38
|
+
STMDB: Optional["HighRegisterStrategy"] = None # Use STMDB sp!/LDMIA sp! for high registers (compatible)
|
|
39
|
+
AUTO: Optional["HighRegisterStrategy"] = None # Automatically choose based on target and assembler
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
# Initialize format constants
|
|
43
|
+
AssemblyFormat.GAS = AssemblyFormat("GAS")
|
|
44
|
+
AssemblyFormat.ARMCC = AssemblyFormat("ARMCC")
|
|
45
|
+
|
|
46
|
+
# Initialize strategy constants
|
|
47
|
+
HighRegisterStrategy.PUSH_W = HighRegisterStrategy("PUSH_W")
|
|
48
|
+
HighRegisterStrategy.STMDB = HighRegisterStrategy("STMDB")
|
|
49
|
+
HighRegisterStrategy.AUTO = HighRegisterStrategy("AUTO")
|