def gen_prologue_amd64_systemv()

in scripts/symcryptasm_processor.py [0:0]


def gen_prologue_amd64_systemv(self, arg_count, reg_count, mul_fixup="", nested=False):
    # push volatile registers onto the stack
    prologue = "\n"
    if reg_count > self.volatile_registers:
        for i in range(self.volatile_registers, reg_count):
            prologue += "push Q%s\n" % i

    # If we are a nested function, we need to align the stack to 16B, and allocate space for up to 4
    # memory slots not in the redzone. We can use the same logic as on the MSFT x64 side to allocate
    # our own space for 32B of local variables (whereas on the MSFT side, we use this for allocating
    # space for a function we are about to call)
    if nested:
        allocation_size = calc_amd64_shadow_space_allocation_size(self, reg_count)
        prologue += "sub rsp, %d // allocate memslot space and align stack\n\n" % allocation_size

    prologue += mul_fixup

    # do not support more than 6 arguments for now
    # # put additional arguments into Q7-Qn
    # # stack_offset to get the 7th argument is:
    # # 8B for return address
    # stack_offset = 8
    # for i in range(self.argument_registers+1, arg_count+1):
    #     prologue += "mov Q%s, [rsp + %d]\n" % (i, stack_offset)
    #     stack_offset += 8

    return prologue