Intel® Implicit SPMD Program Compiler (Intel® ISPC)  1.13.0
Public Types | Public Member Functions | Static Public Member Functions | Private Attributes | List of all members
Target Class Reference

Structure that defines a compilation target. More...

#include <ispc.h>

Collaboration diagram for Target:
Collaboration graph
[legend]

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
 

Detailed Description

Structure that defines a compilation target.

This structure defines a compilation target for the ispc compiler.

Definition at line 149 of file ispc.h.

Member Enumeration Documentation

◆ 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 

Definition at line 157 of file ispc.h.

Constructor & Destructor Documentation

◆ Target()

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.

Member Function Documentation

◆ getArch()

Arch Target::getArch ( ) const
inline

Definition at line 233 of file ispc.h.

Referenced by DefineStdlib(), Function::emitCode(), and FunctionEmitContext::MasksAllEqual().

◆ getCPU()

std::string Target::getCPU ( ) const
inline

Definition at line 237 of file ispc.h.

◆ getDataLayout()

const llvm::DataLayout* Target::getDataLayout ( ) const
inline

◆ getDataTypeWidth()

int Target::getDataTypeWidth ( ) const
inline

Definition at line 243 of file ispc.h.

Referenced by Module::execPreprocessor(), and VectorType::getVectorMemoryCount().

◆ getGeneratePIC()

bool Target::getGeneratePIC ( ) const
inline

Definition at line 247 of file ispc.h.

◆ getISA()

ISA Target::getISA ( ) const
inline

◆ GetISAString()

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().

◆ GetISATargetString()

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.

◆ getISPCTarget()

ISPCTarget Target::getISPCTarget ( ) const
inline

Definition at line 229 of file ispc.h.

Referenced by DefineStdlib().

◆ getMaskBitCount()

int Target::getMaskBitCount ( ) const
inline

◆ getMaskingIsFree()

bool Target::getMaskingIsFree ( ) const
inline

Definition at line 249 of file ispc.h.

Referenced by Function::emitCode().

◆ getNativeVectorAlignment()

int Target::getNativeVectorAlignment ( ) const
inline

◆ getNativeVectorWidth()

int Target::getNativeVectorWidth ( ) const
inline

Definition at line 239 of file ispc.h.

Referenced by FunctionEmitContext::LaunchInst().

◆ getTarget()

const llvm::Target* Target::getTarget ( ) const
inline

Definition at line 220 of file ispc.h.

◆ GetTargetMachine()

llvm::TargetMachine* Target::GetTargetMachine ( ) const
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().

◆ GetTripleString()

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().

◆ getVectorWidth()

int Target::getVectorWidth ( ) const
inline

◆ hasGather()

bool Target::hasGather ( ) const
inline

Definition at line 257 of file ispc.h.

Referenced by lGSBaseOffsetsGetMoreConst(), lGSToGSBaseOffsets(), and lGSToLoadStore().

◆ hasHalf()

bool Target::hasHalf ( ) const
inline

Definition at line 253 of file ispc.h.

Referenced by DefineStdlib(), and Module::execPreprocessor().

◆ hasRand()

bool Target::hasRand ( ) const
inline

Definition at line 255 of file ispc.h.

Referenced by DefineStdlib(), and Module::execPreprocessor().

◆ hasRcpd()

bool Target::hasRcpd ( ) const
inline

Definition at line 267 of file ispc.h.

Referenced by DefineStdlib().

◆ hasRsqrtd()

bool Target::hasRsqrtd ( ) const
inline

Definition at line 265 of file ispc.h.

Referenced by DefineStdlib().

◆ hasScatter()

bool Target::hasScatter ( ) const
inline

Definition at line 259 of file ispc.h.

Referenced by lGSBaseOffsetsGetMoreConst(), lGSToGSBaseOffsets(), and lGSToLoadStore().

◆ hasTranscendentals()

bool Target::hasTranscendentals ( ) const
inline

Definition at line 261 of file ispc.h.

Referenced by DefineStdlib(), and Module::execPreprocessor().

◆ hasTrigonometry()

bool Target::hasTrigonometry ( ) const
inline

Definition at line 263 of file ispc.h.

Referenced by DefineStdlib().

◆ hasVecPrefetch()

bool Target::hasVecPrefetch ( ) const
inline

Definition at line 269 of file ispc.h.

Referenced by lGSBaseOffsetsGetMoreConst(), and lGSToGSBaseOffsets().

◆ is32Bit()

bool Target::is32Bit ( ) const
inline

◆ ISAToString()

const char * Target::ISAToString ( Target::ISA  isa)
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().

◆ ISAToTargetString()

const char * Target::ISAToTargetString ( Target::ISA  isa)
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().

◆ IsGenericTypeLayoutIndeterminate()

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().

◆ isValid()

bool Target::isValid ( ) const
inline

Reports if Target object has valid state.

Definition at line 227 of file ispc.h.

Referenced by Module::CompileAndOutput().

◆ markFuncWithTargetAttr()

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().

◆ SizeOf()

llvm::Value * Target::SizeOf ( llvm::Type *  type,
llvm::BasicBlock *  insertAtEnd 
)

◆ StructOffset()

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().

◆ SupportedCPUs()

std::string Target::SupportedCPUs ( )
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().

Member Data Documentation

◆ m_arch

Arch Target::m_arch
private

Target system architecture. (e.g. "x86-64", "x86").

Definition at line 297 of file ispc.h.

Referenced by GetTripleString(), and Target().

◆ m_attributes

std::string Target::m_attributes
private

Target-specific attribute string to pass along to the LLVM backend

Definition at line 306 of file ispc.h.

◆ m_cpu

std::string Target::m_cpu
private

Target CPU. (e.g. "corei7", "corei7-avx", ..)

Definition at line 303 of file ispc.h.

Referenced by Target().

◆ m_dataLayout

llvm::DataLayout* Target::m_dataLayout
private

Definition at line 284 of file ispc.h.

Referenced by Target().

◆ m_dataTypeWidth

int Target::m_dataTypeWidth
private

Data type width in bits. Typically it's 32, but could be 8, 16 or 64. For generic it's -1, which means undefined.

Definition at line 330 of file ispc.h.

Referenced by Target().

◆ m_funcAttributes

std::vector<std::pair<std::string, std::string> > Target::m_funcAttributes
private

Target-specific function attributes

Definition at line 309 of file ispc.h.

Referenced by Target().

◆ m_generatePIC

bool Target::m_generatePIC
private

Indicates whether position independent code should be generated.

Definition at line 338 of file ispc.h.

Referenced by Target().

◆ m_hasGather

bool Target::m_hasGather
private

Indicates whether the target has a native gather instruction

Definition at line 359 of file ispc.h.

Referenced by Target().

◆ m_hasHalf

bool Target::m_hasHalf
private

Indicates whether the target has native support for float/half conversions.

Definition at line 353 of file ispc.h.

Referenced by Target().

◆ m_hasRand

bool Target::m_hasRand
private

Indicates whether there is an ISA random number instruction.

Definition at line 356 of file ispc.h.

Referenced by Target().

◆ m_hasRcpd

bool Target::m_hasRcpd
private

Indicates whether there is an ISA double precision rcp.

Definition at line 375 of file ispc.h.

Referenced by Target().

◆ m_hasRsqrtd

bool Target::m_hasRsqrtd
private

Indicates whether there is an ISA double precision rsqrt.

Definition at line 372 of file ispc.h.

Referenced by Target().

◆ m_hasScatter

bool Target::m_hasScatter
private

Indicates whether the target has a native scatter instruction

Definition at line 362 of file ispc.h.

Referenced by Target().

◆ m_hasTranscendentals

bool Target::m_hasTranscendentals
private

Indicates whether the target has support for transcendentals (beyond sqrt, which we assume that all of them handle).

Definition at line 366 of file ispc.h.

Referenced by Target().

◆ m_hasTrigonometry

bool Target::m_hasTrigonometry
private

Indicates whether the target has ISA support for trigonometry

Definition at line 369 of file ispc.h.

Referenced by Target().

◆ m_hasVecPrefetch

bool Target::m_hasVecPrefetch
private

Indicates whether the target has hardware instruction for vector prefetch.

Definition at line 378 of file ispc.h.

Referenced by Target().

◆ m_is32Bit

bool Target::m_is32Bit
private

Is the target architecture 32 or 64 bit

Definition at line 300 of file ispc.h.

Referenced by SizeOf(), StructOffset(), and Target().

◆ m_isa

ISA Target::m_isa
private

Instruction set being compiled to.

Definition at line 294 of file ispc.h.

Referenced by GetISAString(), GetISATargetString(), IsGenericTypeLayoutIndeterminate(), and Target().

◆ m_ispc_target

ISPCTarget Target::m_ispc_target
private

ISPC target being used

Definition at line 291 of file ispc.h.

Referenced by Target().

◆ m_maskBitCount

int Target::m_maskBitCount
private

How many bits are used to store each element of the mask: e.g. this is 32 on SSE/AVX, since that matches the HW better, but it's 1 for the generic target.

Definition at line 349 of file ispc.h.

Referenced by Target().

◆ m_maskingIsFree

bool Target::m_maskingIsFree
private

Is there overhead associated with masking on the target architecture; e.g. there is on SSE, due to extra blends and the like, but there isn't with an ISA that supports masking natively.

Definition at line 344 of file ispc.h.

Referenced by Target().

◆ m_nativeVectorAlignment

int Target::m_nativeVectorAlignment
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().

◆ m_nativeVectorWidth

int Target::m_nativeVectorWidth
private

Native vector width of the vector instruction set. Note that this value is directly derived from the ISA being used (e.g. it's 4 for SSE, 8 for AVX, etc.)

Definition at line 319 of file ispc.h.

Referenced by Target().

◆ m_target

const llvm::Target* Target::m_target
private

llvm Target object representing this target.

Definition at line 273 of file ispc.h.

Referenced by Target().

◆ m_targetMachine

llvm::TargetMachine* Target::m_targetMachine
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().

◆ m_tf_attributes

llvm::AttrBuilder* Target::m_tf_attributes
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().

◆ m_valid

bool Target::m_valid
private

flag to report invalid state after construction (due to bad parameters passed to constructor).

Definition at line 288 of file ispc.h.

Referenced by Target().

◆ m_vectorWidth

int Target::m_vectorWidth
private

Actual vector width currently being compiled to. This may be an integer multiple of the native vector width, for example if we're "doubling up" and compiling 8-wide on a 4-wide SSE system.

Definition at line 335 of file ispc.h.

Referenced by Target().


The documentation for this class was generated from the following files: