1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178
|
/*========================== begin_copyright_notice ============================
Copyright (C) 2020-2022 Intel Corporation
SPDX-License-Identifier: MIT
============================= end_copyright_notice ===========================*/
#pragma once
#include "vc/GenXCodeGen/GenXOCLRuntimeInfo.h"
#include "vc/Support/BackendConfig.h"
#include "vc/Support/ShaderDump.h"
#include "vc/Support/ShaderOverride.h"
#include <JitterDataStruct.h>
#include <RelocationInfo.h>
#include <inc/common/sku_wa.h>
#include <llvm/ADT/ArrayRef.h>
#include <llvm/ADT/Optional.h>
#include <llvm/Support/Error.h>
#include <llvm/Support/MemoryBuffer.h>
#include <llvm/Target/TargetOptions.h>
#include <memory>
#include <string>
#include <variant>
#include <vector>
namespace vc {
namespace ocl {
using CompileOutput = llvm::GenXOCLRuntimeInfo::CompiledModuleT;
} // namespace ocl
namespace cm {
struct CompileOutput {
std::string IsaBinary;
};
} // namespace cm
using CompileOutput = std::variant<cm::CompileOutput, ocl::CompileOutput>;
enum class FileType { SPIRV, LLVM_TEXT, LLVM_BINARY };
enum class OptimizerLevel { None, Full };
enum class GlobalsLocalizationMode { All, No, Vector, Partial };
enum class DisableLRCoalescingControl { Default, Disable, Enable };
enum class DisableExtraCoalescingControl { Default, Disable, Enable };
enum class NoOptFinalizerControl { Default, Disable, Enable };
enum class DebugInfoStripControl { None, All, NonLine };
struct CompileOptions {
FileType FType = FileType::SPIRV;
std::string CPUStr;
int RevId = -1;
// Non-owning pointer to WA table.
const WA_TABLE *WATable = nullptr;
// Optional shader dumper.
std::unique_ptr<ShaderDumper> Dumper = nullptr;
// Optional Shader Overrider
std::unique_ptr<vc::ShaderOverrider> ShaderOverrider = nullptr;
// Output binary format
// API options:
// -[cl,ze]-enable-zebin
/// -[cl,ze]-disable-zebin
// Internal options:
// -[cl,ze]-allow-zebin
// -[cl,ze]-disable-zebin
// -binary-format=[ocl,ze,cm]
// Debug keys:
// IGC_EnableZEBinary=[0,1]
BinaryKind Binary = BinaryKind::Default;
// Api accessible options.
// -ze-no-vector-decomposition
bool NoVecDecomp = false;
// -g
bool ExtendedDebuggingSupport = false;
// emit kernels that can interact with debugger, can be disabled by
// -vc-disable-debuggable-kernels internal option
bool EmitDebuggableKernels = true;
// -fno-jump-tables
bool NoJumpTables = false;
// -ftranslate-legacy-memory-intrinsics
bool TranslateLegacyMemoryIntrinsics = false;
// -disable-finalizer-msg
bool DisableFinalizerMsg = false;
// -fno-struct-splitting
bool DisableStructSplitting = false;
// IGC_DisableEuFusion
bool DisableEUFusion = false;
// IGC_VCSaveStackCallLinkage, -vc-save-stack-call-linkage
bool SaveStackCallLinkage = false;
OptimizerLevel IROptLevel = OptimizerLevel::Full;
OptimizerLevel CodegenOptLevel = OptimizerLevel::Full;
llvm::Optional<unsigned> StackMemSize;
bool ForceLiveRangesLocalizationForAccUsage = false;
bool ForceDisableNonOverlappingRegionOpt = false;
bool IsLargeGRFMode = false;
DisableLRCoalescingControl DisableLRCoalescingMode =
DisableLRCoalescingControl::Default;
DisableExtraCoalescingControl DisableExtraCoalescingMode =
DisableExtraCoalescingControl::Default;
NoOptFinalizerControl NoOptFinalizerMode = NoOptFinalizerControl::Default;
bool ForceDebugInfoValidation = false;
bool EnablePreemption = false;
llvm::FPOpFusion::FPOpFusionMode AllowFPOpFusion = llvm::FPOpFusion::Standard;
bool UsePlain2DImages = false;
// Internal options.
std::string FeaturesString; // format is: [+-]<feature1>,[+-]<feature2>,...
bool DumpIsa = false;
bool DumpIR = false;
bool DumpAsm = false;
bool DumpDebugInfo = false;
bool TimePasses = false;
bool ShowStats = false;
bool ResetTimePasses = false;
bool ResetLLVMStats = false;
std::string StatsFile;
std::string LLVMOptions;
bool UseBindlessBuffers = false;
bool EmitZebinVisaSections = false;
bool HasL1ReadOnlyCache = false;
bool HasLocalMemFenceSupress = false;
bool HasMultiTile = false;
bool HasL3CacheCoherentCrossTiles = false;
bool HasL3FlushOnGPUScopeInvalidate = false;
bool HasL3FlushForGlobal = false;
bool HasGPUFenceScopeOnSingleTileGPUs = false;
bool HasHalfSIMDLSC = false;
// from IGC_XXX env
FunctionControl FCtrl = FunctionControl::Default;
bool DirectCallsOnly = false;
DebugInfoStripControl StripDebugInfoCtrl = DebugInfoStripControl::None;
unsigned ForceLoopUnrollThreshold = 0;
bool IgnoreLoopUnrollThresholdOnPragma = false;
unsigned InteropSubgroupSize = 16;
};
struct ExternalData {
std::unique_ptr<llvm::MemoryBuffer> OCLGenericBIFModule;
std::unique_ptr<llvm::MemoryBuffer> VCPrintf32BIFModule;
std::unique_ptr<llvm::MemoryBuffer> VCPrintf64BIFModule;
std::unique_ptr<llvm::MemoryBuffer> VCEmulationBIFModule;
std::unique_ptr<llvm::MemoryBuffer> VCSPIRVBuiltinsBIFModule;
llvm::ArrayRef<const char*> VISALTOStrings;
llvm::ArrayRef<const char*> DirectCallFunctions;
};
llvm::Expected<CompileOutput> Compile(llvm::ArrayRef<char> Input,
const CompileOptions &Opts,
const ExternalData &ExtData,
llvm::ArrayRef<uint32_t> SpecConstIds,
llvm::ArrayRef<uint64_t> SpecConstValues);
llvm::Expected<CompileOptions> ParseOptions(llvm::StringRef ApiOptions,
llvm::StringRef InternalOptions,
bool IsStrictMode);
} // namespace vc
|