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 namespace AMDGPU { 31 32 struct AMDGPUMCKernelCodeT { 33 AMDGPUMCKernelCodeT() = default; 34 35 // Names of most (if not all) members should match the ones used for table 36 // driven (array) generation in AMDKernelCodeTInfo.h. 37 uint32_t amd_kernel_code_version_major = 0; 38 uint32_t amd_kernel_code_version_minor = 0; 39 uint16_t amd_machine_kind = 0; 40 uint16_t amd_machine_version_major = 0; 41 uint16_t amd_machine_version_minor = 0; 42 uint16_t amd_machine_version_stepping = 0; 43 int64_t kernel_code_entry_byte_offset = 0; 44 int64_t kernel_code_prefetch_byte_offset = 0; 45 uint64_t kernel_code_prefetch_byte_size = 0; 46 uint64_t reserved0 = 0; 47 uint64_t compute_pgm_resource_registers = 0; 48 uint32_t code_properties = 0; 49 uint32_t workgroup_group_segment_byte_size = 0; 50 uint32_t gds_segment_byte_size = 0; 51 uint64_t kernarg_segment_byte_size = 0; 52 uint32_t workgroup_fbarrier_count = 0; 53 uint16_t reserved_vgpr_first = 0; 54 uint16_t reserved_vgpr_count = 0; 55 uint16_t reserved_sgpr_first = 0; 56 uint16_t reserved_sgpr_count = 0; 57 uint16_t debug_wavefront_private_segment_offset_sgpr = 0; 58 uint16_t debug_private_segment_buffer_sgpr = 0; 59 uint8_t kernarg_segment_alignment = 0; 60 uint8_t group_segment_alignment = 0; 61 uint8_t private_segment_alignment = 0; 62 uint8_t wavefront_size = 0; 63 int32_t call_convention = 0; 64 uint8_t reserved3[12] = {0}; 65 uint64_t runtime_loader_kernel_symbol = 0; 66 uint64_t control_directives[16] = {0}; 67 68 const MCExpr *compute_pgm_resource1_registers = nullptr; 69 const MCExpr *compute_pgm_resource2_registers = nullptr; 70 71 const MCExpr *is_dynamic_callstack = nullptr; 72 const MCExpr *wavefront_sgpr_count = nullptr; 73 const MCExpr *workitem_vgpr_count = nullptr; 74 const MCExpr *workitem_private_segment_byte_size = nullptr; 75 76 void initDefault(const MCSubtargetInfo *STI, MCContext &Ctx, 77 bool InitMCExpr = true); 78 void validate(const MCSubtargetInfo *STI, MCContext &Ctx); 79 80 const MCExpr *&getMCExprForIndex(int Index); 81 82 bool ParseKernelCodeT(StringRef ID, MCAsmParser &MCParser, raw_ostream &Err); 83 void EmitKernelCodeT(raw_ostream &OS, MCContext &Ctx); 84 void EmitKernelCodeT(MCStreamer &OS, MCContext &Ctx); 85 }; 86 87 } // end namespace AMDGPU 88 } // end namespace llvm 89 90 #endif // LLVM_LIB_TARGET_AMDGPU_MCTARGETDESC_AMDGPUMCKERNELCODET_H 91