Intel SPMD Program Compiler  1.9.1
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, AVX11 = 3,
  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 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
 
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 181 of file ispc.h.

Member Enumeration Documentation

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 
AVX11 
AVX2 
KNL_AVX512 
SKX_AVX512 
GENERIC 
NUM_ISAS 

Definition at line 189 of file ispc.h.

Constructor & Destructor Documentation

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

Member Function Documentation

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

Definition at line 271 of file ispc.h.

References m_arch.

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

Definition at line 275 of file ispc.h.

References m_cpu.

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

Definition at line 281 of file ispc.h.

References m_dataTypeWidth.

Referenced by DefineStdlib().

bool Target::getGeneratePIC ( ) const
inline

Definition at line 285 of file ispc.h.

References m_generatePIC.

ISA Target::getISA ( ) const
inline
const char * Target::GetISAString ( ) const

Returns a string like "avx" encoding the target. Good for mangling.

Definition at line 1307 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 "avx1.1-i32x8" encoding the target. This may be used for Target initialization.

Definition at line 1358 of file ispc.cpp.

References ISAToString(), and m_isa.

int Target::getMaskBitCount ( ) const
inline
bool Target::getMaskingIsFree ( ) const
inline

Definition at line 287 of file ispc.h.

References m_maskingIsFree.

Referenced by Function::emitCode().

int Target::getNativeVectorAlignment ( ) const
inline
int Target::getNativeVectorWidth ( ) const
inline
const llvm::Target* Target::getTarget ( ) const
inline

Definition at line 258 of file ispc.h.

References m_target.

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

Returns the LLVM TargetMachine object corresponding to this target.

Definition at line 230 of file ispc.h.

References m_targetMachine.

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

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

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

Definition at line 1230 of file ispc.cpp.

References m_arch.

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

int Target::getVectorWidth ( ) const
inline
bool Target::hasGather ( ) const
inline

Definition at line 295 of file ispc.h.

References m_hasGather.

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

bool Target::hasHalf ( ) const
inline

Definition at line 291 of file ispc.h.

References m_hasHalf.

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

bool Target::hasRand ( ) const
inline

Definition at line 293 of file ispc.h.

References m_hasRand.

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

bool Target::hasRcpd ( ) const
inline

Definition at line 305 of file ispc.h.

References m_hasRcpd.

Referenced by DefineStdlib().

bool Target::hasRsqrtd ( ) const
inline

Definition at line 303 of file ispc.h.

References m_hasRsqrtd.

Referenced by DefineStdlib().

bool Target::hasScatter ( ) const
inline

Definition at line 297 of file ispc.h.

References m_hasScatter.

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

bool Target::hasTranscendentals ( ) const
inline

Definition at line 299 of file ispc.h.

References m_hasTranscendentals.

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

bool Target::hasTrigonometry ( ) const
inline

Definition at line 301 of file ispc.h.

References m_hasTrigonometry.

Referenced by DefineStdlib().

bool Target::hasVecPrefetch ( ) const
inline

Definition at line 307 of file ispc.h.

References m_hasVecPrefetch.

Referenced by lGSBaseOffsetsGetMoreConst(), and lGSToGSBaseOffsets().

bool Target::is32Bit ( ) const
inline
const char * Target::ISAToString ( Target::ISA  isa)
static

Convert ISA enum to string

Definition at line 1266 of file ispc.cpp.

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

Referenced by GetISAString(), and GetISATargetString().

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

Convert ISA enum to string

Definition at line 1316 of file ispc.cpp.

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

Referenced by Module::CompileAndOutput().

bool Target::isValid ( ) const
inline

Reports if Target object has valid state.

Definition at line 265 of file ispc.h.

References m_valid.

Referenced by Module::CompileAndOutput().

void Target::markFuncWithTargetAttr ( llvm::Function *  func)

Mark LLVM function with target specific attribute, if required.

Definition at line 1477 of file ispc.cpp.

Referenced by Module::AddFunctionDeclaration(), Function::GenerateIR(), and lSetInternalFunctions().

llvm::Value * Target::SizeOf ( llvm::Type *  type,
llvm::BasicBlock *  insertAtEnd 
)
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 1434 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().

const char * Target::SupportedArchs ( )
static

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

Definition at line 1192 of file ispc.cpp.

Referenced by usage().

std::string Target::SupportedCPUs ( )
static

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

Definition at line 1185 of file ispc.cpp.

References AllCPUs::HumanReadableListOfNames().

Referenced by usage().

const char * Target::SupportedTargets ( )
static

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

Definition at line 1202 of file ispc.cpp.

Referenced by Target(), and usage().

Member Data Documentation

std::string Target::m_arch
private

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

Definition at line 336 of file ispc.h.

Referenced by getArch(), GetTripleString(), and Target().

std::string Target::m_attributes
private

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

Definition at line 345 of file ispc.h.

Referenced by Target().

std::string Target::m_cpu
private

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

Definition at line 342 of file ispc.h.

Referenced by getCPU(), and Target().

llvm::DataLayout* Target::m_dataLayout
private

Definition at line 323 of file ispc.h.

Referenced by getDataLayout(), and Target().

int Target::m_dataTypeWidth
private

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

Definition at line 368 of file ispc.h.

Referenced by getDataTypeWidth(), and Target().

bool Target::m_generatePIC
private

Indicates whether position independent code should be generated.

Definition at line 376 of file ispc.h.

Referenced by getGeneratePIC(), and Target().

bool Target::m_hasGather
private

Indicates whether the target has a native gather instruction

Definition at line 397 of file ispc.h.

Referenced by hasGather(), and Target().

bool Target::m_hasHalf
private

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

Definition at line 391 of file ispc.h.

Referenced by hasHalf(), and Target().

bool Target::m_hasRand
private

Indicates whether there is an ISA random number instruction.

Definition at line 394 of file ispc.h.

Referenced by hasRand(), and Target().

bool Target::m_hasRcpd
private

Indicates whether there is an ISA double precision rcp.

Definition at line 413 of file ispc.h.

Referenced by hasRcpd(), and Target().

bool Target::m_hasRsqrtd
private

Indicates whether there is an ISA double precision rsqrt.

Definition at line 410 of file ispc.h.

Referenced by hasRsqrtd(), and Target().

bool Target::m_hasScatter
private

Indicates whether the target has a native scatter instruction

Definition at line 400 of file ispc.h.

Referenced by hasScatter(), and Target().

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 404 of file ispc.h.

Referenced by hasTranscendentals(), and Target().

bool Target::m_hasTrigonometry
private

Indicates whether the target has ISA support for trigonometry

Definition at line 407 of file ispc.h.

Referenced by hasTrigonometry(), and Target().

bool Target::m_hasVecPrefetch
private

Indicates whether the target has hardware instruction for vector prefetch.

Definition at line 416 of file ispc.h.

Referenced by hasVecPrefetch(), and Target().

bool Target::m_is32Bit
private

Is the target architecture 32 or 64 bit

Definition at line 339 of file ispc.h.

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

ISA Target::m_isa
private

Instruction set being compiled to.

Definition at line 330 of file ispc.h.

Referenced by getISA(), GetISAString(), GetISATargetString(), SizeOf(), StructOffset(), and Target().

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 387 of file ispc.h.

Referenced by getMaskBitCount(), and Target().

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 382 of file ispc.h.

Referenced by getMaskingIsFree(), and Target().

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 364 of file ispc.h.

Referenced by getNativeVectorAlignment(), and Target().

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 357 of file ispc.h.

Referenced by getNativeVectorWidth(), and Target().

const llvm::Target* Target::m_target
private

llvm Target object representing this target.

Definition at line 312 of file ispc.h.

Referenced by getTarget(), and Target().

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

Referenced by GetTargetMachine(), and Target().

std::string Target::m_treatGenericAsSmth
private

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

Definition at line 333 of file ispc.h.

Referenced by getTreatGenericAsSmth(), and Target().

bool Target::m_valid
private

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

Definition at line 327 of file ispc.h.

Referenced by isValid(), and Target().

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 373 of file ispc.h.

Referenced by getVectorWidth(), and Target().


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