Target ID is a module flag metadata needed by HIP language. Its key is 'target-id'
Its format is a list of strings delimited by ':', e.g. amdgcn-amd-amdhsa--gfx908:xnack+:sramecc-. The first string is
triple-cpu. The other strings are called feature string which may or may not be target features.
Except for the id string, all feature strings end with '+' or '-'.
A new module flag behavior is needed for merging module flags in this format.
The rule is:
- module with target-id module flag can only link with module with target-id module flag
- empty target ID can merge with any target ID
- If neither target ID is empty, the triple-cpu must match
- the triple-cpu string and existing features of the destination target ID are kept
- If a feature is in both source and destination target ID, they must have the same sign, otherwise it results in a conflict module flag error.
- If a feature is in source target ID but not in destination target ID, it is added to destination target ID
Do we have a canonical definition of "TargetID" somewhere? I know it isn't updated yet, but would https://llvm.org/docs/AMDGPUUsage.html#code-object-target-identification be a reasonable place?
The format is general enough for any target to use, so maybe it should be described somewhere else and linked to from AMDGPUUsage?