[llvm] [AMDGPU] Add an asm directive to track code_object_version (PR #76267)
Konstantin Zhuravlyov via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 4 12:45:21 PST 2024
================
@@ -123,45 +124,32 @@ bool isHsaAbi(const MCSubtargetInfo &STI) {
return STI.getTargetTriple().getOS() == Triple::AMDHSA;
}
-std::optional<uint8_t> getHsaAbiVersion(const MCSubtargetInfo *STI) {
- if (STI && STI->getTargetTriple().getOS() != Triple::AMDHSA)
- return std::nullopt;
-
- switch (AmdhsaCodeObjectVersion) {
- case 4:
- return ELF::ELFABIVERSION_AMDGPU_HSA_V4;
- case 5:
- return ELF::ELFABIVERSION_AMDGPU_HSA_V5;
- default:
- report_fatal_error(Twine("Unsupported AMDHSA Code Object Version ") +
- Twine(AmdhsaCodeObjectVersion));
+unsigned getCodeObjectVersion(const Module &M) {
+ if (auto Ver = mdconst::extract_or_null<ConstantInt>(
+ M.getModuleFlag("amdgpu_code_object_version"))) {
----------------
kzhuravl wrote:
This is HSA-specific version only used with ELFOSABI_AMDGPU_HSA. See e_ident[EI_ABIVERSION] row in https://llvm.org/docs/AMDGPUUsage.html#amdgpu-elf-header-table. So I think it would be good to clean this up and have consistent naming, with amdhsa prefix in LLVM IR and ASM directive.
https://github.com/llvm/llvm-project/pull/76267
More information about the llvm-commits
mailing list