Skip to content

calling_convention

Calling conventions

ARM64CC

Bases: CallingConvention

AAPCS calling convention for Aarch64

Source code in quokka/analysis/calling_convention.py
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
class ARM64CC(CallingConvention):
    """AAPCS calling convention for Aarch64"""

    name = "aapcs"
    argument_registers = [
        ArchARM64.regs.X0,
        ArchARM64.regs.X1,
        ArchARM64.regs.X2,
        ArchARM64.regs.X3,
        ArchARM64.regs.X4,
        ArchARM64.regs.X5,
        ArchARM64.regs.X6,
        ArchARM64.regs.X7,
    ]

    floating_point_registers: List[RegType] = []  # TODO
    caller_saved_registers: List[RegType] = []
    return_value = ArchARM64.regs.X0

ARMCC

Bases: CallingConvention

AAPCS calling convention for ARM

Source code in quokka/analysis/calling_convention.py
132
133
134
135
136
137
138
139
140
141
142
143
144
class ARMCC(CallingConvention):
    """AAPCS calling convention for ARM"""

    name = "aapcs"
    argument_registers = [
        ArchARM.regs.R0,
        ArchARM.regs.R1,
        ArchARM.regs.R2,
        ArchARM.regs.R3,
    ]
    floating_point_registers: List[RegType] = []  # TODO
    caller_saved_registers: List[RegType] = []
    return_value = ArchARM.regs.R0

CCdecl

Bases: CallingConvention

Cdecl calling convention

Source code in quokka/analysis/calling_convention.py
36
37
38
39
40
41
42
43
44
45
46
47
48
49
class CCdecl(CallingConvention):
    """Cdecl calling convention"""

    name = "cdecl"
    argument_registers: List[RegType] = []  # All arguments are on the stack
    floating_point_registers: List[RegType] = []  # Same
    caller_saved_registers = [
        ArchX86.regs.EAX,
        ArchX86.regs.ECX,
        ArchX86.regs.EDX,
    ]

    return_value = ArchX86.regs.EAX
    overflow_return = ArchX86.regs.EDX

CallingConvention

Base class for a calling convention

Source code in quokka/analysis/calling_convention.py
23
24
25
26
27
28
29
30
31
32
33
class CallingConvention:
    """Base class for a calling convention"""

    name: str
    argument_registers: List[RegType]
    floating_point_registers: List[RegType]
    caller_saved_registers: List[RegType]
    callee_saved: bool = False

    return_value: RegType
    overflow_return: RegType

Fastcall

Bases: CallingConvention

Fastcall calling convention

Source code in quokka/analysis/calling_convention.py
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
class Fastcall(CallingConvention):
    """Fastcall calling convention"""

    name = "fastcall"
    argument_registers = [ArchX86.regs.ECX, ArchX86.regs.EDX]
    floating_point_registers = [ArchX86.regs.ST0, ArchX86.regs.ST1]  # TODO(dm) check
    caller_saved_registers = [
        ArchX86.regs.EBX,
        ArchX86.regs.EBX,
        ArchX86.regs.ESI,
        ArchX86.regs.EDI,
    ]

    return_value = ArchX86.regs.EAX
    overflow_return = ArchX86.regs.EDX

MicrosoftAMD64

Bases: CallingConvention

Microsoft 64 calling convention

Source code in quokka/analysis/calling_convention.py
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
class MicrosoftAMD64(CallingConvention):
    """Microsoft 64 calling convention"""

    name = "ms"
    argument_registers = [
        ArchX64.regs.RCX,
        ArchX64.regs.RDX,
        ArchX64.regs.R8,
        ArchX64.regs.R9,
    ]

    floating_point_registers = [
        ArchX64.regs.XMM0,
        ArchX64.regs.XMM1,
        ArchX64.regs.XMM2,
        ArchX64.regs.XMM3,
    ]

    return_value = ArchX64.regs.RAX
    overflow_return = ArchX64.regs.RDX

Stdcall

Bases: CCdecl

Stdcall calling convention

Source code in quokka/analysis/calling_convention.py
52
53
54
55
56
class Stdcall(CCdecl):
    """Stdcall calling convention"""

    name = "stdcall"
    callee_saved = True

SystemVAMD

Bases: CallingConvention

SysV calling convention

Source code in quokka/analysis/calling_convention.py
 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
class SystemVAMD(CallingConvention):
    """SysV calling convention"""

    name = "sysv"
    argument_registers = [
        ArchX64.regs.RDI,
        ArchX64.regs.RSI,
        ArchX64.regs.RDX,
        ArchX64.regs.RCX,
        ArchX64.regs.R8,
        ArchX64.regs.R9,
    ]

    floating_point_registers = [
        ArchX64.regs.XMM0,
        ArchX64.regs.XMM1,
        ArchX64.regs.XMM2,
        ArchX64.regs.XMM3,
        ArchX64.regs.XMM4,
        ArchX64.regs.XMM5,
        ArchX64.regs.XMM6,
        ArchX64.regs.XMM7,
    ]

    caller_saved_registers = argument_registers + [
        ArchX64.regs.R10,
        ArchX64.regs.R11,
        ArchX64.regs.RAX,
    ]

    return_value = ArchX64.regs.RAX
    overflow_return = ArchX64.regs.RDX