Intel® Implicit SPMD Program Compiler (Intel® ISPC)
1.13.0
|
Structure that defines a compilation target. More...
#include <ispc.h>
Public Types | |
enum | ISA { SSE2 = 0, SSE4 = 1, AVX = 2, AVX2 = 3, KNL_AVX512 = 4, SKX_AVX512 = 5, GENERIC = 6, NUM_ISAS } |
Public Member Functions | |
Target (Arch arch, const char *cpu, ISPCTarget isa, bool pic, bool printTarget) | |
std::string | GetTripleString () const |
llvm::TargetMachine * | GetTargetMachine () const |
const char * | GetISAString () const |
const char * | GetISATargetString () const |
llvm::Value * | SizeOf (llvm::Type *type, llvm::BasicBlock *insertAtEnd) |
llvm::Value * | StructOffset (llvm::Type *type, int element, llvm::BasicBlock *insertAtEnd) |
void | markFuncWithTargetAttr (llvm::Function *func) |
bool | IsGenericTypeLayoutIndeterminate (llvm::Type *type) |
const llvm::Target * | getTarget () const |
const llvm::DataLayout * | getDataLayout () const |
bool | isValid () const |
ISPCTarget | getISPCTarget () const |
ISA | getISA () const |
Arch | getArch () const |
bool | is32Bit () const |
std::string | getCPU () const |
int | getNativeVectorWidth () const |
int | getNativeVectorAlignment () const |
int | getDataTypeWidth () const |
int | getVectorWidth () const |
bool | getGeneratePIC () const |
bool | getMaskingIsFree () const |
int | getMaskBitCount () const |
bool | hasHalf () const |
bool | hasRand () const |
bool | hasGather () const |
bool | hasScatter () const |
bool | hasTranscendentals () const |
bool | hasTrigonometry () const |
bool | hasRsqrtd () const |
bool | hasRcpd () const |
bool | hasVecPrefetch () const |
Static Public Member Functions | |
static std::string | SupportedCPUs () |
static const char * | ISAToString (Target::ISA isa) |
static const char * | ISAToTargetString (Target::ISA isa) |
Private Attributes | |
const llvm::Target * | m_target |
llvm::TargetMachine * | m_targetMachine |
llvm::DataLayout * | m_dataLayout |
bool | m_valid |
ISPCTarget | m_ispc_target |
ISA | m_isa |
Arch | m_arch |
bool | m_is32Bit |
std::string | m_cpu |
std::string | m_attributes |
std::vector< std::pair< std::string, std::string > > | m_funcAttributes |
llvm::AttrBuilder * | m_tf_attributes |
int | m_nativeVectorWidth |
int | m_nativeVectorAlignment |
int | m_dataTypeWidth |
int | m_vectorWidth |
bool | m_generatePIC |
bool | m_maskingIsFree |
int | m_maskBitCount |
bool | m_hasHalf |
bool | m_hasRand |
bool | m_hasGather |
bool | m_hasScatter |
bool | m_hasTranscendentals |
bool | m_hasTrigonometry |
bool | m_hasRsqrtd |
bool | m_hasRcpd |
bool | m_hasVecPrefetch |
Structure that defines a compilation target.
This structure defines a compilation target for the ispc compiler.
enum Target::ISA |
Enumerator giving the instruction sets that the compiler can target. These should be ordered from "worse" to "better" in that if a processor supports multiple target ISAs, then the most flexible/performant of them will apear last in the enumerant. Note also that __best_available_isa() needs to be updated if ISAs are added or the enumerant values are reordered.
Enumerator | |
---|---|
SSE2 | |
SSE4 | |
AVX | |
AVX2 | |
KNL_AVX512 | |
SKX_AVX512 | |
GENERIC | |
NUM_ISAS |
Target::Target | ( | Arch | arch, |
const char * | cpu, | ||
ISPCTarget | isa, | ||
bool | pic, | ||
bool | printTarget | ||
) |
Initializes the given Target pointer for a target of the given name, if the name is a known target. Returns true if the target was initialized and false if the name is unknown.
Definition at line 443 of file ispc.cpp.
References aarch64, ArchToString(), arm, Assert, AVX, avx1_i32x16, avx1_i32x4, avx1_i32x8, avx1_i64x4, AVX2, avx2_i32x16, avx2_i32x4, avx2_i32x8, avx2_i64x4, avx512knl_i32x16, avx512skx_i32x16, avx512skx_i32x8, AllCPUs::BackwardCompatible(), Globals::codegenOptLevel, CPU_Broadwell, CPU_Core2, CPU_Generic, CPU_Haswell, CPU_IvyBridge, CPU_KNL, CPU_Nehalem, CPU_None, CPU_Penryn, CPU_PS4, CPU_SandyBridge, CPU_Silvermont, CPU_SKX, CPU_x86_64, custom_linux, Opt::disableFMA, Opt::disableZMM, error, Error(), FATAL, Globals::generateDWARFVersion, GENERIC, generic_1, generic_16, generic_32, generic_4, generic_64, generic_8, getDataLayout(), AllCPUs::GetDefaultNameFromType(), GetTripleString(), AllCPUs::GetTypeFromName(), host, AllCPUs::HumanReadableListOfNames(), ISPC_MAX_NVEC, ISPCTargetIsNeon(), ISPCTargetToString(), KNL_AVX512, lGetSystemISA(), lIsTargetValidforArch(), m_arch, m_cpu, m_dataLayout, m_dataTypeWidth, m_funcAttributes, m_generatePIC, m_hasGather, m_hasHalf, m_hasRand, m_hasRcpd, m_hasRsqrtd, m_hasScatter, m_hasTranscendentals, m_hasTrigonometry, m_hasVecPrefetch, m_is32Bit, m_isa, m_ispc_target, m_maskBitCount, m_maskingIsFree, m_nativeVectorAlignment, m_nativeVectorWidth, m_target, m_targetMachine, m_tf_attributes, m_valid, m_vectorWidth, neon_i16x8, neon_i32x4, neon_i32x8, neon_i8x16, none, Globals::opt, SKX_AVX512, SSE2, sse2_i32x4, sse2_i32x8, SSE4, sse4_i16x8, sse4_i32x4, sse4_i32x8, sse4_i8x16, Globals::target_os, Warning(), wasm_i32x4, and x86_64.
|
inline |
Definition at line 233 of file ispc.h.
Referenced by DefineStdlib(), Function::emitCode(), and FunctionEmitContext::MasksAllEqual().
|
inline |
Definition at line 224 of file ispc.h.
Referenced by FunctionEmitContext::gather(), SizeOfExpr::GetConstant(), VectorType::GetDIType(), lEmitStructDecl(), lEmitVectorTypedefs(), lInitDispatchModule(), Module::Module(), SizeOf(), StructOffset(), FunctionEmitContext::SwitchBoolSize(), and Target().
|
inline |
Definition at line 243 of file ispc.h.
Referenced by Module::execPreprocessor(), and VectorType::getVectorMemoryCount().
|
inline |
Definition at line 231 of file ispc.h.
Referenced by Module::CompileAndOutput(), DefineStdlib(), lGetExportedFunctions(), lTypeConvAtomic(), Optimize(), and Module::writeOutput().
const char * Target::GetISAString | ( | ) | const |
Returns a string like "avx" encoding the target. Good for mangling.
Definition at line 1287 of file ispc.cpp.
References ISAToString(), and m_isa.
Referenced by Module::AddFunctionDeclaration(), Module::CompileAndOutput(), Module::execPreprocessor(), FunctionEmitContext::FunctionEmitContext(), and Function::GenerateIR().
const char * Target::GetISATargetString | ( | ) | const |
Returns a string like "avx2-i32x8" encoding the target. This may be used for Target initialization.
Definition at line 1322 of file ispc.cpp.
References ISAToTargetString(), and m_isa.
|
inline |
Definition at line 229 of file ispc.h.
Referenced by DefineStdlib().
|
inline |
Definition at line 251 of file ispc.h.
Referenced by FunctionEmitContext::All(), FunctionEmitContext::Any(), DefineStdlib(), AtomicType::GetAsUniformType(), FunctionEmitContext::I1VecToBoolVec(), InitLLVMUtil(), FunctionEmitContext::LaneMask(), lCreateISPCSymbol(), FunctionEmitContext::LoadInst(), and FunctionEmitContext::None().
|
inline |
Definition at line 249 of file ispc.h.
Referenced by Function::emitCode().
|
inline |
Definition at line 241 of file ispc.h.
Referenced by FunctionEmitContext::AllocaInst(), FunctionEmitContext::FunctionEmitContext(), lEmitLoads(), lImproveMaskedLoad(), lImproveMaskedStore(), FunctionEmitContext::LoadInst(), IntrinsicsOpt::runOnBasicBlock(), and FunctionEmitContext::StoreInst().
|
inline |
Definition at line 239 of file ispc.h.
Referenced by FunctionEmitContext::LaunchInst().
|
inline |
Returns the LLVM TargetMachine object corresponding to this target.
Definition at line 191 of file ispc.h.
Referenced by Module::CompileAndOutput(), lGetMask(), Optimize(), and Module::writeObjectFileOrAssembly().
std::string Target::GetTripleString | ( | ) | const |
Returns a triple string specifying the target architecture, vendor, and environment.
Definition at line 1124 of file ispc.cpp.
References aarch64, android, arm, custom_linux, error, Error(), freebsd, ios, linux, m_arch, macos, ps4, Globals::target_os, wasm32, web, windows, x86, and x86_64.
Referenced by lInitDispatchModule(), Module::Module(), and Target().
|
inline |
Definition at line 245 of file ispc.h.
Referenced by ConstExpr::Count(), DefineStdlib(), ForeachStmt::EmitCode(), PrintStmt::EmitCode(), Module::execPreprocessor(), DeclSpecs::GetBaseType(), EnumType::GetCDeclaration(), PointerType::GetCDeclaration(), ArrayType::GetCDeclaration(), AtomicType::GetDIType(), EnumType::GetDIType(), PointerType::GetDIType(), NewExpr::GetValue(), InitLLVMUtil(), InitSymbol(), lArrayVectorWidth(), lAssembleResultVectors(), lConvert(), lConvertPointerConstant(), lDefineProgramIndex(), lEmitStructDecl(), lExtractConstOffsets(), lGetBasePointer(), lGetExprListConstant(), lGetMaskStatus(), lGetMatchingBoolVectorType(), lGetOffsetScaleVec(), lGSToLoadStore(), lIsExactMultiple(), lIsSafeToBlend(), LLVMBoolVector(), LLVMBoolVectorInStorage(), LLVMDoubleVector(), LLVMFloatVector(), LLVMInt16Vector(), LLVMInt32Vector(), LLVMInt64Vector(), LLVMInt8Vector(), LLVMUInt16Vector(), LLVMUInt32Vector(), LLVMUInt64Vector(), LLVMUInt8Vector(), lMangleStructName(), lReplacePseudoGS(), lUpdateVaryingCounter(), Optimize(), FunctionEmitContext::ProgramIndexVector(), ReplaceStdlibShiftPass::runOnBasicBlock(), FunctionEmitContext::SmearUniform(), Module::writeDispatchHeader(), and Module::writeOutput().
|
inline |
Definition at line 257 of file ispc.h.
Referenced by lGSBaseOffsetsGetMoreConst(), lGSToGSBaseOffsets(), and lGSToLoadStore().
|
inline |
Definition at line 253 of file ispc.h.
Referenced by DefineStdlib(), and Module::execPreprocessor().
|
inline |
Definition at line 255 of file ispc.h.
Referenced by DefineStdlib(), and Module::execPreprocessor().
|
inline |
Definition at line 267 of file ispc.h.
Referenced by DefineStdlib().
|
inline |
Definition at line 265 of file ispc.h.
Referenced by DefineStdlib().
|
inline |
Definition at line 259 of file ispc.h.
Referenced by lGSBaseOffsetsGetMoreConst(), lGSToGSBaseOffsets(), and lGSToLoadStore().
|
inline |
Definition at line 261 of file ispc.h.
Referenced by DefineStdlib(), and Module::execPreprocessor().
|
inline |
Definition at line 263 of file ispc.h.
Referenced by DefineStdlib().
|
inline |
Definition at line 269 of file ispc.h.
Referenced by lGSBaseOffsetsGetMoreConst(), and lGSToGSBaseOffsets().
|
inline |
Definition at line 235 of file ispc.h.
Referenced by FunctionEmitContext::AddElementOffset(), FunctionEmitContext::addVaryingOffsetsIfNeeded(), FunctionEmitContext::applyVaryingGEP(), DeleteStmt::EmitCode(), Module::execPreprocessor(), FunctionEmitContext::gather(), PointerType::GetDIType(), BinaryExpr::GetType(), SizeOfExpr::GetType(), NewExpr::GetValue(), InitLLVMUtil(), lDeclareSizeAndPtrIntTypes(), lEmitBinaryPointerArith(), lGetBasePtrAndOffsets(), FunctionEmitContext::maskedStore(), FunctionEmitContext::scatter(), BinaryExpr::TypeCheck(), AssignExpr::TypeCheck(), IndexExpr::TypeCheck(), TypeCastExpr::TypeCheck(), and NewExpr::TypeCheck().
|
static |
Convert ISA enum to string
Definition at line 1257 of file ispc.cpp.
References AVX, AVX2, FATAL, GENERIC, KNL_AVX512, SKX_AVX512, SSE2, and SSE4.
Referenced by GetISAString().
|
static |
Convert ISA enum to string
Definition at line 1292 of file ispc.cpp.
References AVX, AVX2, FATAL, GENERIC, KNL_AVX512, SKX_AVX512, SSE2, and SSE4.
Referenced by Module::CompileAndOutput(), and GetISATargetString().
bool Target::IsGenericTypeLayoutIndeterminate | ( | llvm::Type * | type | ) |
Definition at line 1352 of file ispc.cpp.
References GENERIC, lGenericTypeLayoutIndeterminate(), and m_isa.
Referenced by SizeOfExpr::GetConstant(), SizeOf(), and StructOffset().
|
inline |
Reports if Target object has valid state.
Definition at line 227 of file ispc.h.
Referenced by Module::CompileAndOutput().
void Target::markFuncWithTargetAttr | ( | llvm::Function * | func | ) |
Mark LLVM function with target specific attribute, if required.
Definition at line 1410 of file ispc.cpp.
References m_tf_attributes.
Referenced by Module::AddFunctionDeclaration(), Module::CompileFile(), Function::emitCode(), and Function::GenerateIR().
llvm::Value * Target::SizeOf | ( | llvm::Type * | type, |
llvm::BasicBlock * | insertAtEnd | ||
) |
Returns the size of the given type
Definition at line 1359 of file ispc.cpp.
References Opt::force32BitAddressing, getDataLayout(), LLVMTypes::Int32Type, LLVMTypes::Int64Type, IsGenericTypeLayoutIndeterminate(), LLVMInt32(), LLVMInt64(), m_is32Bit, Globals::opt, and PTYPE.
Referenced by FunctionEmitContext::AddElementOffset(), FunctionEmitContext::addVaryingOffsetsIfNeeded(), FunctionEmitContext::applyVaryingGEP(), SizeOfExpr::GetValue(), NewExpr::GetValue(), InitSymbol(), FunctionEmitContext::LaunchInst(), and lEmitBinaryPointerArith().
llvm::Value * Target::StructOffset | ( | llvm::Type * | type, |
int | element, | ||
llvm::BasicBlock * | insertAtEnd | ||
) |
Given a structure type and an element number in the structure, returns a value corresponding to the number of bytes from the start of the structure where the element is located.
Definition at line 1380 of file ispc.cpp.
References Assert, Module::errorCount, Opt::force32BitAddressing, getDataLayout(), LLVMTypes::Int32Type, LLVMTypes::Int64Type, IsGenericTypeLayoutIndeterminate(), LLVMInt32(), LLVMInt64(), m_is32Bit, Globals::opt, and PTYPE.
Referenced by FunctionEmitContext::AddElementOffset().
|
static |
Returns a comma-delimited string giving the names of the currently supported CPUs.
Definition at line 1119 of file ispc.cpp.
References AllCPUs::HumanReadableListOfNames().
Referenced by usage().
|
private |
Target system architecture. (e.g. "x86-64", "x86").
Definition at line 297 of file ispc.h.
Referenced by GetTripleString(), and Target().
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
Is the target architecture 32 or 64 bit
Definition at line 300 of file ispc.h.
Referenced by SizeOf(), StructOffset(), and Target().
|
private |
Instruction set being compiled to.
Definition at line 294 of file ispc.h.
Referenced by GetISAString(), GetISATargetString(), IsGenericTypeLayoutIndeterminate(), and Target().
|
private |
|
private |
|
private |
|
private |
Native vector alignment in bytes. Theoretically this may be derived from the vector size, but it's better to manage directly the alignement. It allows easier experimenting and better fine tuning for particular platform. This information is primatily used when –opt=force-aligned-memory is used.
Definition at line 326 of file ispc.h.
Referenced by Target().
|
private |
|
private |
|
private |
llvm TargetMachine. Note that it's not destroyed during Target destruction, as Module::CompileAndOutput() uses TargetMachines after Target is destroyed. This needs to be changed. It's also worth noticing, that DataLayout of TargetMachine cannot be modified and for generic targets it's not what we really need, so it must not be used.
Definition at line 283 of file ispc.h.
Referenced by Target().
|
private |
Target-specific LLVM attribute, which has to be attached to every function to ensure that it is generated for correct target architecture. This is requirement was introduced in LLVM 3.3
Definition at line 314 of file ispc.h.
Referenced by markFuncWithTargetAttr(), and Target().
|
private |
|
private |