Intel SPMD Program Compiler  1.12.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 = 4,
  KNL_AVX512 = 5, SKX_AVX512 = 6, GENERIC = 7, NUM_ISAS
}
 

Public Member Functions

 Target (const char *arch, const char *cpu, const char *isa, bool pic, bool printTarget, std::string genenricAsSmth="")
 
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)
 
const llvm::Target * getTarget () const
 
const llvm::DataLayout * getDataLayout () const
 
bool isValid () const
 
ISA getISA () const
 
std::string getTreatGenericAsSmth () const
 
std::string 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 const char * SupportedTargets ()
 
static const char * SupportedOSes ()
 
static std::string SupportedCPUs ()
 
static const char * SupportedArchs ()
 
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
 
ISA m_isa
 
std::string m_treatGenericAsSmth
 
std::string m_arch
 
bool m_is32Bit
 
std::string m_cpu
 
std::string m_attributes
 
std::vector< std::pair< std::string, std::string > > m_funcAttributes
 
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 171 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 179 of file ispc.h.

Constructor & Destructor Documentation

◆ Target()

Target::Target ( const char *  arch,
const char *  cpu,
const char *  isa,
bool  pic,
bool  printTarget,
std::string  genenricAsSmth = "" 
)

Member Function Documentation

◆ getArch()

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

Definition at line 267 of file ispc.h.

Referenced by DefineStdlib().

◆ getCPU()

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

Definition at line 271 of file ispc.h.

◆ getDataLayout()

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

◆ getDataTypeWidth()

int Target::getDataTypeWidth ( ) const
inline

◆ getGeneratePIC()

bool Target::getGeneratePIC ( ) const
inline

Definition at line 281 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 1402 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 1445 of file ispc.cpp.

References ISAToString(), and m_isa.

◆ getMaskBitCount()

int Target::getMaskBitCount ( ) const
inline

◆ getMaskingIsFree()

bool Target::getMaskingIsFree ( ) const
inline

Definition at line 283 of file ispc.h.

Referenced by Function::emitCode().

◆ getNativeVectorAlignment()

int Target::getNativeVectorAlignment ( ) const
inline

◆ getNativeVectorWidth()

int Target::getNativeVectorWidth ( ) const
inline

Definition at line 273 of file ispc.h.

Referenced by FunctionEmitContext::LaunchInst().

◆ getTarget()

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

Definition at line 254 of file ispc.h.

◆ GetTargetMachine()

llvm::TargetMachine* Target::GetTargetMachine ( ) const
inline

Returns the LLVM TargetMachine object corresponding to this target.

Definition at line 228 of file ispc.h.

Referenced by Module::CompileAndOutput(), lGetMask(), Optimize(), and Module::writeObjectFileOrAssembly().

◆ getTreatGenericAsSmth()

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

◆ GetTripleString()

std::string Target::GetTripleString ( ) const

Returns a triple string specifying the target architecture, vendor, and environment.

Definition at line 1264 of file ispc.cpp.

References Error(), m_arch, OS_ANDROID, OS_IOS, OS_LINUX, OS_MAC, OS_PS4, OS_WINDOWS, and Globals::target_os.

Referenced by lInitDispatchModule(), Module::Module(), and Target().

◆ getVectorWidth()

int Target::getVectorWidth ( ) const
inline

◆ hasGather()

bool Target::hasGather ( ) const
inline

Definition at line 291 of file ispc.h.

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

◆ hasHalf()

bool Target::hasHalf ( ) const
inline

Definition at line 287 of file ispc.h.

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

◆ hasRand()

bool Target::hasRand ( ) const
inline

Definition at line 289 of file ispc.h.

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

◆ hasRcpd()

bool Target::hasRcpd ( ) const
inline

Definition at line 301 of file ispc.h.

Referenced by DefineStdlib().

◆ hasRsqrtd()

bool Target::hasRsqrtd ( ) const
inline

Definition at line 299 of file ispc.h.

Referenced by DefineStdlib().

◆ hasScatter()

bool Target::hasScatter ( ) const
inline

Definition at line 293 of file ispc.h.

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

◆ hasTranscendentals()

bool Target::hasTranscendentals ( ) const
inline

Definition at line 295 of file ispc.h.

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

◆ hasTrigonometry()

bool Target::hasTrigonometry ( ) const
inline

Definition at line 297 of file ispc.h.

Referenced by DefineStdlib().

◆ hasVecPrefetch()

bool Target::hasVecPrefetch ( ) const
inline

Definition at line 303 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 1364 of file ispc.cpp.

References AVX, AVX2, FATAL, GENERIC, KNL_AVX512, SKX_AVX512, SSE2, and SSE4.

Referenced by GetISAString(), and GetISATargetString().

◆ ISAToTargetString()

const char * Target::ISAToTargetString ( Target::ISA  isa)
static

Convert ISA enum to string

Definition at line 1407 of file ispc.cpp.

References AVX, AVX2, FATAL, GENERIC, KNL_AVX512, SKX_AVX512, SSE2, and SSE4.

Referenced by Module::CompileAndOutput().

◆ isValid()

bool Target::isValid ( ) const
inline

Reports if Target object has valid state.

Definition at line 261 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 1534 of file ispc.cpp.

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 1500 of file ispc.cpp.

References Assert, Module::errorCount, Opt::force32BitAddressing, GENERIC, getDataLayout(), LLVMTypes::Int32Type, LLVMTypes::Int64Type, lGenericTypeLayoutIndeterminate(), LLVMInt32(), LLVMInt64(), m_is32Bit, m_isa, Globals::opt, and PTYPE.

Referenced by FunctionEmitContext::AddElementOffset().

◆ SupportedArchs()

const char * Target::SupportedArchs ( )
static

Returns a comma-delimited string giving the names of the currently supported architectures.

Definition at line 1204 of file ispc.cpp.

Referenced by usage().

◆ SupportedCPUs()

std::string Target::SupportedCPUs ( )
static

Returns a comma-delimited string giving the names of the currently supported CPUs.

Definition at line 1199 of file ispc.cpp.

References AllCPUs::HumanReadableListOfNames().

Referenced by usage().

◆ SupportedOSes()

const char * Target::SupportedOSes ( )
static

Returns a comma-delimited string giving the names of the currently supported target OSes

Definition at line 1238 of file ispc.cpp.

Referenced by main(), StringToOS(), and usage().

◆ SupportedTargets()

const char * Target::SupportedTargets ( )
static

Returns a comma-delimited string giving the names of the currently supported compilation targets.

Definition at line 1212 of file ispc.cpp.

Referenced by Target(), and usage().

Member Data Documentation

◆ m_arch

std::string Target::m_arch
private

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

Definition at line 331 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 340 of file ispc.h.

◆ m_cpu

std::string Target::m_cpu
private

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

Definition at line 337 of file ispc.h.

Referenced by Target().

◆ m_dataLayout

llvm::DataLayout* Target::m_dataLayout
private

Definition at line 318 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 370 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 343 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 378 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 399 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 393 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 396 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 415 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 412 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 402 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 406 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 409 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 418 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 334 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 325 of file ispc.h.

Referenced by GetISAString(), GetISATargetString(), SizeOf(), StructOffset(), and 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 389 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 384 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 366 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 359 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 307 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 317 of file ispc.h.

Referenced by Target().

◆ m_treatGenericAsSmth

std::string Target::m_treatGenericAsSmth
private

The variable shows if we use special mangling with generic target.

Definition at line 328 of file ispc.h.

Referenced by 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 322 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 375 of file ispc.h.

Referenced by Target().


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