[PATCH] D125419: [Arm64EC 7/?] clang side of Arm64EC varargs ABI.

Eli Friedman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 5 23:04:43 PDT 2022


efriedma planned changes to this revision.
efriedma added a comment.

Just realized I forgot to add tests for va_arg.



================
Comment at: clang/lib/CodeGen/TargetInfo.cpp:2457
+                    /*IsVectorCall=*/false, /*IsRegCall=*/false);
+  }
+
----------------
rjmccall wrote:
> efriedma wrote:
> > rjmccall wrote:
> > > Hmm.  Doesn't EC ABI lowering need to preserve this same state, or else you'll get incompatibilities when you exhaust SSE registers?
> > > 
> > > Should you just be calling over to this at a higher-level point, like in `computeInfo`?
> > If both IsVectorCall and IsRegCall are false, WinX86_64ABIInfo doesn't use FreeSSERegs, so we don't need to preserve its state.  There isn't any other relevant state to preserve.
> > 
> > Return values follow the Arm64 ABI rules, not the x64 rules, so using computeInfo() as an entry point doesn't really make sense.
> That's odd.  I assume this whole thing is about matching the CC you would get from an instruction-by-instruction translation of x86_64 assembly so that arm64-compiled code can call / be called from translated assembly as long as it uses this special CC.  Are there just no functions with interesting return types that anybody happens to care about calling across such a boundary?  I would be amazed if the standard arm64 and x64 return rules just happily match for all types.
Normally, arm64ec code uses the arm64 calling convention, and x64 code in the same process uses the x64 calling convention.  When there are calls between the two, a thunk translates the calling convention.  (See D126811 etc.)

For varargs, things work slightly differently.  It's impossible to translate an arbitrary arm64 varargs call to an x64 varargs call, or vice versa, because then thunk doesn't know how the varargs arguments are laid out.  (Also, va_list has to be ABI-compatible.)  So varargs calls use a special calling convention that ensures varargs arguments in arm64ec calls are laid out exactly the same way as x64 varargs arguments.

There are still thunks for varargs calls, though; among other things, they translates the return value.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D125419/new/

https://reviews.llvm.org/D125419



More information about the cfe-commits mailing list