llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

[AIX] support builtin_cpu_support

Open diggerlin opened this issue 2 years ago • 5 comments

Lowering of intrinsic __builtin_cpu_is and __builtin_cpu_support into AIX platform-specific code.

The runtime external variable _system_configuration in /usr/include/sys/systemcfg.h provides all the information needed for functions __builtin_cpu_is() and __builtin_cpu_support().

diggerlin avatar Jan 30 '24 18:01 diggerlin

@llvm/issue-subscribers-backend-powerpc

Author: zhijian lin (diggerlin)

Add the lowering of intrinsic `__builtin_cpu_is` and `__builtin_cpu_support` into AIX platform-specific code to determine the CPU.

runtime external variable _system_configuration.version of /usr/include/sys/systemcfg.h provide all the information we need the function __builtin_cpu_is() and

it has structure like

 extern struct _system_conf {
        int architecture;       /* processor architecture */
        int implementation;     /* processor implementation */
        int version;            /* processor version */
        .....
        }
        

it has some define as

We use the value of the implementation for the aix builtin_cpu_is()

#define POWER_7 0x8000 /* 7 class CPU /
#define POWER_8 0x10000 / 8 class CPU /
#define POWER_9 0x20000 / 9 class CPU */

llvmbot avatar Jan 30 '24 18:01 llvmbot

It is not clear what the proposed code generation is. Is the plan to simply emit a reference to an external symbol that provides the information? If so, is there any safety if the binary is executed on a system that doesn't provide this definition in the library?

nemanjai avatar Jan 30 '24 20:01 nemanjai

Is the plan to simply emit a reference to an external symbol that provides the information?

yes.

If so, is there any safety if the binary is executed on a system that doesn't provide this definition in the library?

I think _system_configuration is kernel variable , It do not need any library support. would like you help to double confirm? @stephenpeckham

diggerlin avatar Jan 31 '24 15:01 diggerlin

Seems we are done for this issue? @diggerlin

chenzheng1030 avatar May 23 '24 05:05 chenzheng1030