1 //===- AMDGPUKernelCodeTUtils.h - helpers for amd_kernel_code_t -*- C++ -*-===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 // 9 /// \file AMDKernelCodeTUtils.h 10 /// MC layer struct for AMDGPUMCKernelCodeT, provides MCExpr functionality where 11 /// required. 12 /// 13 // 14 //===----------------------------------------------------------------------===// 15 16 #ifndef LLVM_LIB_TARGET_AMDGPU_MCTARGETDESC_AMDGPUMCKERNELCODET_H 17 #define LLVM_LIB_TARGET_AMDGPU_MCTARGETDESC_AMDGPUMCKERNELCODET_H 18 19 #include "AMDKernelCodeT.h" 20 #include "llvm/ADT/ArrayRef.h" 21 #include "llvm/ADT/StringRef.h" 22 23 namespace llvm { 24 class MCAsmParser; 25 class MCContext; 26 class MCExpr; 27 class MCStreamer; 28 class MCSubtargetInfo; 29 class raw_ostream; 30 class MCAsmInfo; 31 namespace AMDGPU { 32 33 struct AMDGPUMCKernelCodeT { 34 AMDGPUMCKernelCodeT() = default; 35 36 // Names of most (if not all) members should match the ones used for table 37 // driven (array) generation in AMDKernelCodeTInfo.h. 38 uint32_t amd_kernel_code_version_major = 0; 39 uint32_t amd_kernel_code_version_minor = 0; 40 uint16_t amd_machine_kind = 0; 41 uint16_t amd_machine_version_major = 0; 42 uint16_t amd_machine_version_minor = 0; 43 uint16_t amd_machine_version_stepping = 0; 44 int64_t kernel_code_entry_byte_offset = 0; 45 int64_t kernel_code_prefetch_byte_offset = 0; 46 uint64_t kernel_code_prefetch_byte_size = 0; 47 uint64_t reserved0 = 0; 48 uint64_t compute_pgm_resource_registers = 0; 49 uint32_t code_properties = 0; 50 uint32_t workgroup_group_segment_byte_size = 0; 51 uint32_t gds_segment_byte_size = 0; 52 uint64_t kernarg_segment_byte_size = 0; 53 uint32_t workgroup_fbarrier_count = 0; 54 uint16_t reserved_vgpr_first = 0; 55 uint16_t reserved_vgpr_count = 0; 56 uint16_t reserved_sgpr_first = 0; 57 uint16_t reserved_sgpr_count = 0; 58 uint16_t debug_wavefront_private_segment_offset_sgpr = 0; 59 uint16_t debug_private_segment_buffer_sgpr = 0; 60 uint8_t kernarg_segment_alignment = 0; 61 uint8_t group_segment_alignment = 0; 62 uint8_t private_segment_alignment = 0; 63 uint8_t wavefront_size = 0; 64 int32_t call_convention = 0; 65 uint8_t reserved3[12] = {0}; 66 uint64_t runtime_loader_kernel_symbol = 0; 67 uint64_t control_directives[16] = {0}; 68 69 const MCExpr *compute_pgm_resource1_registers = nullptr; 70 const MCExpr *compute_pgm_resource2_registers = nullptr; 71 72 const MCExpr *is_dynamic_callstack = nullptr; 73 const MCExpr *wavefront_sgpr_count = nullptr; 74 const MCExpr *workitem_vgpr_count = nullptr; 75 const MCExpr *workitem_private_segment_byte_size = nullptr; 76 77 void initDefault(const MCSubtargetInfo *STI, MCContext &Ctx, 78 bool InitMCExpr = true); 79 void validate(const MCSubtargetInfo *STI, MCContext &Ctx); 80 81 const MCExpr *&getMCExprForIndex(int Index); 82 83 using PrintHelper = 84 function_ref<void(const MCExpr *, raw_ostream &, const MCAsmInfo *)>; 85 bool ParseKernelCodeT(StringRef ID, MCAsmParser &MCParser, raw_ostream &Err); 86 void EmitKernelCodeT(raw_ostream &OS, MCContext &Ctx, PrintHelper Helper); 87 void EmitKernelCodeT(MCStreamer &OS, MCContext &Ctx); 88 }; 89 90 } // end namespace AMDGPU 91 } // end namespace llvm 92 93 #endif // LLVM_LIB_TARGET_AMDGPU_MCTARGETDESC_AMDGPUMCKERNELCODET_H 94