RFC: Adding Register Calling Convention Support

Hi All,

The Register Calling Convention (RegCall) was introduced by Intel to optimize parameter transfer on function call.

This calling convention ensures that as many values as possible are passed or returned in registers.

To use RegCall, place the keyword before a function declaration. For example:

__regcall int foo (int i, int j); // Windows OS

attribute((regcall)) foo (int I, int j); // Linux OS and Mac OS X)

The calling convention is described in more details here:

https://software.intel.com/en-us/node/693069

We are adding support for RegCall calling convention for Clang and LLVM IR.

The first step will include the implementation for LLVM IR.

I will appreciate your comments.

Thanks,

Oren

Seems technically straight forward form the LLVM perspective. The only complication is it looks like your callee saved register lists are influenced by the number of arguments to the functions. I’m not sure that’ll be easy to encode with the current infrastructure.

Philip

Thanks, Philip, for pointing it out.

You are correct. We have a task to add the relevant infrastructure.

Currently registers are statically defined as callee/caller saved.

In order to take into account which registers were passed as parameter we need to add relevant infrastructure.

Only then LLVM will ensure RegCall cross-compiler Interoperability.

Thanks again,

Oren