Skip to content

Instantly share code, notes, and snippets.

@kunalspathak
Last active June 25, 2024 22:25
Show Gist options
  • Save kunalspathak/e236e00d74594b7ea4bdecfd6b7cc8fc to your computer and use it in GitHub Desktop.
Save kunalspathak/e236e00d74594b7ea4bdecfd6b7cc8fc to your computer and use it in GitHub Desktop.
sve_calling_convention
sve1()
{
   ; prolog - save z8-z23, p0-p3

     ...      
   ; save v0-v7                                 - LIVE-ONLY
   ; save v24-v31                               - LIVE-ONLY
   ; save p0-p3                                 - LIVE-ONLY
   
   sve2();
   
   ; restore p0-p3                              - LIVE-ONLY
   ; restore v24-v31                            - LIVE-ONLY
   ; restore v0-v7                              - LIVE-ONLY
     ...

   ; epilog - restore  z8-z23, p0-p3
}
------------------------------
sve2()
{
   ; prolog - save z8-z23, p0-p3

     ...
   ; save v0-v7                                 - LIVE-ONLY
   ; save v8-v15 (top only)                     - LIVE-ONLY
   ; save v16-v23                               - ALWAYS
   ; save v24-v31                               - LIVE-ONLY
   ; save p0-p3                                 - LIVE-ONLY
   ; save p4-p15                                - ALWAYS
   
   regular();
   
   ; restore p4-p15                             - ALWAYS   
   ; restore p0-p3                              - LIVE-ONLY
   ; restore v24-v31                            - LIVE-ONLY
   ; restore v16-v23                            - ALWAYS   
   ; restore v8-v15 (top only)                  - LIVE-ONLY
   ; restore v0-v7                              - LIVE-ONLY    
     ...

   ; epilog - restore  z8-z23, p0-p3
}

------------------------------
regular1()
{
   ; prolog - save bottom 64-bits v8-v15

     ...    
   ; save v0-v7                                 - LIVE-ONLY
   ; save v8-v15 (top only)                     - LIVE-ONLY
   ; save v16-v31                               - LIVE-ONLY
    
    regular2();

   ; restore v16-v31                            - LIVE-ONLY
   ; restore v8-v15 (top only)                  - LIVE-ONLY
   ; restore v0-v7                              - LIVE-ONLY    
     ...    

    ; epilog - restore bottom 64-bits v8-v15
}

------------------------------

regular1()
{
   ; prolog - save bottom 64-bits v8-v15

     ...
   ; save v0-v7                                 - LIVE-ONLY
   ; save v24-v31                               - LIVE-ONLY
   ; save p0-p3                                 - LIVE-ONLY   

    sve()    

   ; restore p0-p3                              - LIVE-ONLY
   ; restore v24-v31                            - LIVE-ONLY
   ; restore v0-v7                              - LIVE-ONLY
     ...    

   ; epilog - restore bottom 64-bits v8-v15    
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment