|
Intel SPMD Program Compiler
1.3.0
|
Implementations of various LLVM utility types and classes. More...
#include "llvmutil.h"#include "ispc.h"#include "type.h"#include <llvm/Instructions.h>#include <llvm/BasicBlock.h>#include <set>#include <map>
Go to the source code of this file.
Functions | |
| void | InitLLVMUtil (llvm::LLVMContext *ctx, Target target) |
| llvm::ConstantInt * | LLVMInt8 (int8_t ival) |
| llvm::ConstantInt * | LLVMUInt8 (uint8_t ival) |
| llvm::ConstantInt * | LLVMInt16 (int16_t ival) |
| llvm::ConstantInt * | LLVMUInt16 (uint16_t ival) |
| llvm::ConstantInt * | LLVMInt32 (int32_t ival) |
| llvm::ConstantInt * | LLVMUInt32 (uint32_t ival) |
| llvm::ConstantInt * | LLVMInt64 (int64_t ival) |
| llvm::ConstantInt * | LLVMUInt64 (uint64_t ival) |
| llvm::Constant * | LLVMFloat (float fval) |
| llvm::Constant * | LLVMDouble (double dval) |
| llvm::Constant * | LLVMInt8Vector (int8_t ival) |
| llvm::Constant * | LLVMInt8Vector (const int8_t *ivec) |
| llvm::Constant * | LLVMUInt8Vector (uint8_t ival) |
| llvm::Constant * | LLVMUInt8Vector (const uint8_t *ivec) |
| llvm::Constant * | LLVMInt16Vector (int16_t ival) |
| llvm::Constant * | LLVMInt16Vector (const int16_t *ivec) |
| llvm::Constant * | LLVMUInt16Vector (uint16_t ival) |
| llvm::Constant * | LLVMUInt16Vector (const uint16_t *ivec) |
| llvm::Constant * | LLVMInt32Vector (int32_t ival) |
| llvm::Constant * | LLVMInt32Vector (const int32_t *ivec) |
| llvm::Constant * | LLVMUInt32Vector (uint32_t ival) |
| llvm::Constant * | LLVMUInt32Vector (const uint32_t *ivec) |
| llvm::Constant * | LLVMFloatVector (float fval) |
| llvm::Constant * | LLVMFloatVector (const float *fvec) |
| llvm::Constant * | LLVMDoubleVector (double dval) |
| llvm::Constant * | LLVMDoubleVector (const double *dvec) |
| llvm::Constant * | LLVMInt64Vector (int64_t ival) |
| llvm::Constant * | LLVMInt64Vector (const int64_t *ivec) |
| llvm::Constant * | LLVMUInt64Vector (uint64_t ival) |
| llvm::Constant * | LLVMUInt64Vector (const uint64_t *ivec) |
| llvm::Constant * | LLVMBoolVector (bool b) |
| llvm::Constant * | LLVMBoolVector (const bool *bvec) |
| llvm::Constant * | LLVMIntAsType (int64_t val, llvm::Type *type) |
| llvm::Constant * | LLVMUIntAsType (uint64_t val, llvm::Type *type) |
| static bool | lValuesAreEqual (llvm::Value *v0, llvm::Value *v1, std::vector< llvm::PHINode * > &seenPhi0, std::vector< llvm::PHINode * > &seenPhi1) |
| static int64_t | lGetIntValue (llvm::Value *offset) |
| void | LLVMFlattenInsertChain (llvm::InsertElementInst *ie, int vectorWidth, llvm::Value **elements) |
| bool | LLVMExtractVectorInts (llvm::Value *v, int64_t ret[], int *nElts) |
| static bool | lVectorValuesAllEqual (llvm::Value *v, int vectorLength, std::vector< llvm::PHINode * > &seenPhis) |
| static bool | lIsExactMultiple (llvm::Value *val, int baseValue, int vectorLength, std::vector< llvm::PHINode * > &seenPhis) |
| static int | lRoundUpPow2 (int v) |
| static bool | lAllDivBaseEqual (llvm::Value *val, int64_t baseValue, int vectorLength, std::vector< llvm::PHINode * > &seenPhis, bool &canAdd) |
| static bool | lVectorShiftRightAllEqual (llvm::Value *val, llvm::Value *shift, int vectorLength) |
| bool | LLVMVectorValuesAllEqual (llvm::Value *v) |
| static bool | lVectorIsLinear (llvm::Value *v, int vectorLength, int stride, std::vector< llvm::PHINode * > &seenPhis) |
| static bool | lVectorIsLinearConstantInts (llvm::ConstantDataVector *cv, int vectorLength, int stride) |
| static bool | lCheckMulForLinear (llvm::Value *op0, llvm::Value *op1, int vectorLength, int stride, std::vector< llvm::PHINode * > &seenPhis) |
| static bool | lCheckAndForLinear (llvm::Value *op0, llvm::Value *op1, int vectorLength, int stride, std::vector< llvm::PHINode * > &seenPhis) |
| bool | LLVMVectorIsLinear (llvm::Value *v, int stride) |
| static void | lDumpValue (llvm::Value *v, std::set< llvm::Value * > &done) |
| void | LLVMDumpValue (llvm::Value *v) |
| static llvm::Value * | lExtractFirstVectorElement (llvm::Value *v, std::map< llvm::PHINode *, llvm::PHINode * > &phiMap) |
| llvm::Value * | LLVMExtractFirstVectorElement (llvm::Value *v) |
| llvm::Value * | LLVMConcatVectors (llvm::Value *v1, llvm::Value *v2, llvm::Instruction *insertBefore) |
| llvm::Value * | LLVMShuffleVectors (llvm::Value *v1, llvm::Value *v2, int32_t shuf[], int shufSize, llvm::Instruction *insertBefore) |
| const char * | LLVMGetName (llvm::Value *v, const char *s) |
| const char * | LLVMGetName (const char *op, llvm::Value *v1, llvm::Value *v2) |
Variables | |
| llvm::Constant * | LLVMTrue = NULL |
| llvm::Constant * | LLVMFalse = NULL |
| llvm::Constant * | LLVMMaskAllOn = NULL |
| llvm::Constant * | LLVMMaskAllOff = NULL |
Implementations of various LLVM utility types and classes.
Definition in file llvmutil.cpp.
| void InitLLVMUtil | ( | llvm::LLVMContext * | ctx, |
| Target | target | ||
| ) |
Definition at line 92 of file llvmutil.cpp.
References Assert, LLVMTypes::BoolType, LLVMTypes::BoolVectorType, LLVMTypes::DoublePointerType, LLVMTypes::DoubleType, LLVMTypes::DoubleVectorPointerType, LLVMTypes::DoubleVectorType, LLVMTypes::FloatPointerType, LLVMTypes::FloatType, LLVMTypes::FloatVectorPointerType, LLVMTypes::FloatVectorType, g, LLVMTypes::Int16PointerType, LLVMTypes::Int16Type, LLVMTypes::Int16VectorPointerType, LLVMTypes::Int16VectorType, LLVMTypes::Int1VectorType, LLVMTypes::Int32PointerType, LLVMTypes::Int32Type, LLVMTypes::Int32VectorPointerType, LLVMTypes::Int32VectorType, LLVMTypes::Int64PointerType, LLVMTypes::Int64Type, LLVMTypes::Int64VectorPointerType, LLVMTypes::Int64VectorType, LLVMTypes::Int8PointerType, LLVMTypes::Int8Type, LLVMTypes::Int8VectorPointerType, LLVMTypes::Int8VectorType, Target::is32Bit, LLVMFalse, LLVMMaskAllOff, LLVMMaskAllOn, LLVMTrue, Target::maskBitCount, LLVMTypes::MaskType, NULL, LLVMTypes::PointerIntType, Globals::target, Target::vectorWidth, LLVMTypes::VoidPointerType, LLVMTypes::VoidPointerVectorType, and LLVMTypes::VoidType.
Referenced by Module::Module().
| static bool lAllDivBaseEqual | ( | llvm::Value * | val, |
| int64_t | baseValue, | ||
| int | vectorLength, | ||
| std::vector< llvm::PHINode * > & | seenPhis, | ||
| bool & | canAdd | ||
| ) | [static] |
Try to determine if all of the elements of the given vector value have the same value when divided by the given baseValue. The function returns true if this can be determined to be the case, and false otherwise. (This function may fail to identify some cases where it does in fact have this property, but should never report a given value as being a multiple if it isn't!)
Definition at line 780 of file llvmutil.cpp.
References Assert, ISPC_MAX_NVEC, lIsExactMultiple(), LLVMExtractVectorInts(), lRoundUpPow2(), lVectorValuesAllEqual(), and NULL.
Referenced by lCheckAndForLinear(), and lVectorShiftRightAllEqual().
| static bool lCheckAndForLinear | ( | llvm::Value * | op0, |
| llvm::Value * | op1, | ||
| int | vectorLength, | ||
| int | stride, | ||
| std::vector< llvm::PHINode * > & | seenPhis | ||
| ) | [static] |
Given (op0 AND op1), try and see if we can determine if the result is a linear sequence with a step of "stride" between values. Returns true if so and false otherwise. This pattern comes up when accessing SOA data.
Definition at line 1191 of file llvmutil.cpp.
References Assert, ISPC_MAX_NVEC, lAllDivBaseEqual(), LLVMExtractVectorInts(), and lVectorIsLinear().
Referenced by lVectorIsLinear().
| static bool lCheckMulForLinear | ( | llvm::Value * | op0, |
| llvm::Value * | op1, | ||
| int | vectorLength, | ||
| int | stride, | ||
| std::vector< llvm::PHINode * > & | seenPhis | ||
| ) | [static] |
Checks to see if (op0 * op1) is a linear vector where the result is a vector with values that increase by stride.
Definition at line 1151 of file llvmutil.cpp.
References lVectorIsLinear(), and NULL.
Referenced by lVectorIsLinear().
| static void lDumpValue | ( | llvm::Value * | v, |
| std::set< llvm::Value * > & | done | ||
| ) | [static] |
Definition at line 1364 of file llvmutil.cpp.
Referenced by LLVMDumpValue().
| static llvm::Value* lExtractFirstVectorElement | ( | llvm::Value * | v, |
| std::map< llvm::PHINode *, llvm::PHINode * > & | phiMap | ||
| ) | [static] |
Definition at line 1393 of file llvmutil.cpp.
References Assert, ISPC_MAX_NVEC, LLVMFlattenInsertChain(), LLVMInt32(), and NULL.
Referenced by LLVMExtractFirstVectorElement().
| static int64_t lGetIntValue | ( | llvm::Value * | offset | ) | [static] |
Given an llvm::Value known to be an integer, return its value as an int64_t.
Definition at line 590 of file llvmutil.cpp.
References Assert.
Referenced by LLVMFlattenInsertChain().
| static bool lIsExactMultiple | ( | llvm::Value * | val, |
| int | baseValue, | ||
| int | vectorLength, | ||
| std::vector< llvm::PHINode * > & | seenPhis | ||
| ) | [static] |
This function checks to see if the given (scalar or vector) value is an exact multiple of baseValue. It returns true if so, and false if not (or if it's not able to determine if it is). Any vector value passed in is required to have the same value in all elements (so that we can just check the first element to be a multiple of the given value.)
Definition at line 697 of file llvmutil.cpp.
References Assert, g, ISPC_MAX_NVEC, LLVMFlattenInsertChain(), LLVMVectorValuesAllEqual(), NULL, Globals::target, and Target::vectorWidth.
Referenced by lAllDivBaseEqual().
| llvm::Constant* LLVMBoolVector | ( | bool | v | ) |
Returns an LLVM boolean vector constant of the given value smeared across all elements
Definition at line 437 of file llvmutil.cpp.
References Assert, LLVMTypes::BoolVectorType, Globals::ctx, g, LLVMTypes::Int32Type, LLVMTypes::Int32VectorType, LLVMFalse, LLVMTrue, Globals::target, and Target::vectorWidth.
Referenced by ForStmt::EmitCode(), ConstExpr::GetConstant(), ConstExpr::GetValue(), and lLLVMConstantValue().
| llvm::Constant* LLVMBoolVector | ( | const bool * | v | ) |
Returns an LLVM boolean vector based on the given array of values. The array should have g->target.vectorWidth elements.
Definition at line 456 of file llvmutil.cpp.
References Assert, LLVMTypes::BoolVectorType, Globals::ctx, g, LLVMTypes::Int32Type, LLVMTypes::Int32VectorType, LLVMFalse, LLVMTrue, Globals::target, and Target::vectorWidth.
| llvm::Value* LLVMConcatVectors | ( | llvm::Value * | v1, |
| llvm::Value * | v2, | ||
| llvm::Instruction * | insertBefore | ||
| ) |
Given two vectors of the same type, concatenate them into a vector that has twice as many elements, where the first half has the elements from the first vector and the second half has the elements from the second vector.
Definition at line 1517 of file llvmutil.cpp.
References Assert, int32_t, ISPC_MAX_NVEC, LLVMShuffleVectors(), and NULL.
Referenced by lAssembleResultVectors().
| llvm::Constant* LLVMDouble | ( | double | f | ) |
Returns an LLVM double constant of the given value
Definition at line 241 of file llvmutil.cpp.
References Globals::ctx, and g.
Referenced by ConstExpr::GetConstant(), ConstExpr::GetValue(), lLLVMConstantValue(), LLVMDoubleVector(), and lTypeConvAtomic().
| llvm::Constant* LLVMDoubleVector | ( | double | f | ) |
Returns an LLVM double vector constant of the given value smeared across all elements
Definition at line 380 of file llvmutil.cpp.
References g, LLVMDouble(), Globals::target, and Target::vectorWidth.
Referenced by ConstExpr::GetConstant(), ConstExpr::GetValue(), lLLVMConstantValue(), and lTypeConvAtomic().
| llvm::Constant* LLVMDoubleVector | ( | const double * | f | ) |
Returns an LLVM double vector based on the given array of values. The array should have g->target.vectorWidth elements.
Definition at line 390 of file llvmutil.cpp.
References g, LLVMDouble(), Globals::target, and Target::vectorWidth.
| void LLVMDumpValue | ( | llvm::Value * | v | ) |
This is a utility routine for debugging that dumps out the given LLVM value as well as (recursively) all of the other values that it depends on.
Definition at line 1385 of file llvmutil.cpp.
References lDumpValue(), and stderr.
Referenced by lGetBasePtrAndOffsets(), LLVMVectorIsLinear(), LLVMVectorValuesAllEqual(), lVectorShiftRightAllEqual(), and GatherCoalescePass::runOnBasicBlock().
| llvm::Value* LLVMExtractFirstVectorElement | ( | llvm::Value * | v | ) |
Given a vector-typed value, this function returns the value of its first element. Rather than just doing the straightforward thing of using a single extractelement instruction to do this, this function tries to rewrite the computation for the first element in scalar form; this is generally more efficient than computing the entire vector's worth of values just to extract the first element, in cases where only the first element's value is needed.
Definition at line 1504 of file llvmutil.cpp.
References lExtractFirstVectorElement().
Referenced by lComputeBasePtr(), and lComputeCommonPointer().
| bool LLVMExtractVectorInts | ( | llvm::Value * | v, |
| int64_t | ret[], | ||
| int * | nElts | ||
| ) |
Given a vector-typed value v, if the vector is a vector with constant element values, this function extracts those element values into the ret[] array and returns the number of elements (i.e. the vector type's width) in *nElts. It returns true if successful and false if the given vector is not in fact a vector of constants.
Definition at line 643 of file llvmutil.cpp.
Referenced by lAllDivBaseEqual(), lCheckAndForLinear(), lExtractConstOffsets(), lVectorIs32BitInts(), and lVectorShiftRightAllEqual().
| void LLVMFlattenInsertChain | ( | llvm::InsertElementInst * | ie, |
| int | vectorWidth, | ||
| llvm::Value ** | elements | ||
| ) |
This function takes chains of InsertElement instructions along the lines of:
v0 = insertelement undef, value_0, i32 index_0 v1 = insertelement v1, value_1, i32 index_1 ... vn = insertelement vn-1, value_n-1, i32 index_n-1
and initializes the provided elements array such that the i'th llvm::Value * in the array is the element that was inserted into the i'th element of the vector.
When the chain of insertelement instruction comes to an end, the only base case that this function handles is the initial value being a constant vector. For anything more complex (e.g. some other arbitrary value, it doesn't try to extract element values into the returned array.
Definition at line 599 of file llvmutil.cpp.
References Assert, int32_t, lGetIntValue(), and NULL.
Referenced by lExtractFirstVectorElement(), lGetBasePointer(), lIsExactMultiple(), and lVectorValuesAllEqual().
| llvm::Constant* LLVMFloat | ( | float | f | ) |
Returns an LLVM float constant of the given value
Definition at line 235 of file llvmutil.cpp.
References Globals::ctx, and g.
Referenced by ConstExpr::GetConstant(), ConstExpr::GetValue(), lLLVMConstantValue(), LLVMFloatVector(), and lTypeConvAtomic().
| llvm::Constant* LLVMFloatVector | ( | float | f | ) |
Returns an LLVM float vector constant of the given value smeared across all elements
Definition at line 361 of file llvmutil.cpp.
References g, LLVMFloat(), Globals::target, and Target::vectorWidth.
Referenced by ConstExpr::GetConstant(), ConstExpr::GetValue(), lLLVMConstantValue(), and lTypeConvAtomic().
| llvm::Constant* LLVMFloatVector | ( | const float * | f | ) |
Returns an LLVM float vector based on the given array of values. The array should have g->target.vectorWidth elements.
Definition at line 371 of file llvmutil.cpp.
References g, LLVMFloat(), Globals::target, and Target::vectorWidth.
| const char* LLVMGetName | ( | llvm::Value * | v, |
| const char * | |||
| ) |
Utility routines to concat strings with the names of existing values to create meaningful new names for instruction values.
Definition at line 1558 of file llvmutil.cpp.
Referenced by FunctionEmitContext::All(), FunctionEmitContext::Any(), FunctionEmitContext::applyVaryingGEP(), FunctionEmitContext::BitCastInst(), FunctionEmitContext::CastInst(), FunctionEmitContext::ExtractInst(), FunctionEmitContext::FPCastInst(), IndexExpr::GetLValue(), UnaryExpr::GetValue(), MemberExpr::GetValue(), NewExpr::GetValue(), VectorMemberExpr::GetValue(), FunctionEmitContext::I1VecToBoolVec(), FunctionEmitContext::InsertInst(), FunctionEmitContext::IntToPtrInst(), FunctionEmitContext::LaneMask(), lConvertToSlicePointer(), lEmitBinaryArith(), lEmitBinaryCmp(), lEmitNegate(), lExtractConstantOffset(), lFinalSliceOffset(), lGSToGSBaseOffsets(), lGSToLoadStore(), FunctionEmitContext::LoadInst(), lOffsets32BitSafe(), lTypeConvAtomic(), FunctionEmitContext::MakeSlicePointer(), FunctionEmitContext::MasksAllEqual(), FunctionEmitContext::None(), FunctionEmitContext::PtrToIntInst(), IntrinsicsOpt::runOnBasicBlock(), FunctionEmitContext::SelectInst(), FunctionEmitContext::SExtInst(), FunctionEmitContext::TruncInst(), and FunctionEmitContext::ZExtInst().
| const char* LLVMGetName | ( | const char * | op, |
| llvm::Value * | v1, | ||
| llvm::Value * | v2 | ||
| ) |
Definition at line 1567 of file llvmutil.cpp.
| llvm::ConstantInt* LLVMInt16 | ( | int16_t | i | ) |
Returns an LLVM i16 constant of the given value
Definition at line 193 of file llvmutil.cpp.
References Globals::ctx, and g.
Referenced by ConstExpr::GetConstant(), ConstExpr::GetValue(), lLLVMConstantValue(), LLVMInt16Vector(), and lTypeConvAtomic().
| llvm::Constant* LLVMInt16Vector | ( | int16_t | i | ) |
Returns an LLVM i16 vector constant of the given value smeared across all elements
Definition at line 285 of file llvmutil.cpp.
References g, LLVMInt16(), Globals::target, and Target::vectorWidth.
Referenced by ConstExpr::GetConstant(), ConstExpr::GetValue(), lLLVMConstantValue(), and lTypeConvAtomic().
| llvm::Constant* LLVMInt16Vector | ( | const int16_t * | i | ) |
Returns an LLVM i16 vector based on the given array of values. The array should have g->target.vectorWidth elements.
Definition at line 295 of file llvmutil.cpp.
References g, LLVMInt16(), Globals::target, and Target::vectorWidth.
| llvm::ConstantInt* LLVMInt32 | ( | int32_t | i | ) |
Returns an LLVM i32 constant of the given value
Definition at line 207 of file llvmutil.cpp.
References Globals::ctx, and g.
Referenced by FunctionEmitContext::AddElementOffset(), FunctionEmitContext::addGSMetadata(), FunctionEmitContext::AddInstrumentationPoint(), FunctionEmitContext::addVaryingOffsetsIfNeeded(), ForeachStmt::EmitCode(), ForeachActiveStmt::EmitCode(), PrintStmt::EmitCode(), FunctionEmitContext::ExtractInst(), ConstExpr::GetConstant(), IndexExpr::GetLValue(), IndexExpr::GetValue(), ConstExpr::GetValue(), TypeCastExpr::GetValue(), NewExpr::GetValue(), InitSymbol(), FunctionEmitContext::InsertInst(), lAddVaryingOffsetsIfNeeded(), lApplyLoad1(), lApplyLoad2(), FunctionEmitContext::LaunchInst(), lDefineConstantInt(), lDefineConstantIntFunc(), lExtract248Scale(), lExtractFirstVectorElement(), lExtractOffsetVector248Scale(), lGetBasePtrAndOffsets(), lGetStringAsValue(), lGSToLoadStore(), lLLVMConstantValue(), LLVMInt32Vector(), LLVMShuffleVectors(), lTypeConvAtomic(), FunctionEmitContext::MemcpyInst(), IntrinsicsOpt::runOnBasicBlock(), Target::SizeOf(), Target::StructOffset(), and FunctionEmitContext::SwitchInst().
| llvm::Constant* LLVMInt32Vector | ( | int32_t | i | ) |
Returns an LLVM i32 vector constant of the given value smeared across all elements
Definition at line 323 of file llvmutil.cpp.
References g, LLVMInt32(), Globals::target, and Target::vectorWidth.
Referenced by FunctionEmitContext::EmitCaseLabel(), FunctionEmitContext::EmitDefaultLabel(), ConstExpr::GetConstant(), ConstExpr::GetValue(), TypeCastExpr::GetValue(), NewExpr::GetValue(), lDefineProgramIndex(), lExtract248Scale(), lGetBasePtrAndOffsets(), lGSBaseOffsetsGetMoreConst(), lLLVMConstantValue(), lTypeConvAtomic(), and lUpdateVaryingCounter().
| llvm::Constant* LLVMInt32Vector | ( | const int32_t * | i | ) |
Returns an LLVM i32 vector based on the given array of values. The array should have g->target.vectorWidth elements.
Definition at line 333 of file llvmutil.cpp.
References g, LLVMInt32(), Globals::target, and Target::vectorWidth.
| llvm::ConstantInt* LLVMInt64 | ( | int64_t | i | ) |
Returns an LLVM i64 constant of the given value
Definition at line 221 of file llvmutil.cpp.
References Globals::ctx, and g.
Referenced by FunctionEmitContext::AddElementOffset(), FunctionEmitContext::addVaryingOffsetsIfNeeded(), FunctionEmitContext::All(), FunctionEmitContext::Any(), ForeachActiveStmt::EmitCode(), ForeachUniqueStmt::EmitCode(), ConstExpr::GetConstant(), ConstExpr::GetValue(), NewExpr::GetValue(), lEmitLoads(), lGEPAndLoad(), lGetBasePtrAndOffsets(), lGSToLoadStore(), lLLVMConstantValue(), LLVMInt64Vector(), lTypeConvAtomic(), FunctionEmitContext::None(), IntrinsicsOpt::runOnBasicBlock(), VSelMovmskOpt::runOnBasicBlock(), Target::SizeOf(), Target::StructOffset(), and FunctionEmitContext::SwitchInst().
| llvm::Constant* LLVMInt64Vector | ( | int64_t | i | ) |
Returns an LLVM i64 vector constant of the given value smeared across all elements
Definition at line 399 of file llvmutil.cpp.
References g, LLVMInt64(), Globals::target, and Target::vectorWidth.
Referenced by FunctionEmitContext::EmitCaseLabel(), FunctionEmitContext::EmitDefaultLabel(), ConstExpr::GetConstant(), ConstExpr::GetValue(), NewExpr::GetValue(), lExtract248Scale(), lGetBasePtrAndOffsets(), lGSBaseOffsetsGetMoreConst(), lLLVMConstantValue(), and lTypeConvAtomic().
| llvm::Constant* LLVMInt64Vector | ( | const int64_t * | i | ) |
Returns an LLVM i64 vector based on the given array of values. The array should have g->target.vectorWidth elements.
Definition at line 409 of file llvmutil.cpp.
References g, LLVMInt64(), Globals::target, and Target::vectorWidth.
| llvm::ConstantInt* LLVMInt8 | ( | int8_t | i | ) |
Returns an LLVM i8 constant of the given value
Definition at line 179 of file llvmutil.cpp.
References Globals::ctx, and g.
Referenced by ConstExpr::GetConstant(), ConstExpr::GetValue(), lLLVMConstantValue(), LLVMInt8Vector(), and lTypeConvAtomic().
| llvm::Constant* LLVMInt8Vector | ( | int8_t | i | ) |
Returns an LLVM i8 vector constant of the given value smeared across all elements
Definition at line 247 of file llvmutil.cpp.
References g, LLVMInt8(), Globals::target, and Target::vectorWidth.
Referenced by ConstExpr::GetConstant(), ConstExpr::GetValue(), lLLVMConstantValue(), and lTypeConvAtomic().
| llvm::Constant* LLVMInt8Vector | ( | const int8_t * | i | ) |
Returns an LLVM i8 vector based on the given array of values. The array should have g->target.vectorWidth elements.
Definition at line 257 of file llvmutil.cpp.
References g, LLVMInt8(), Globals::target, and Target::vectorWidth.
| llvm::Constant* LLVMIntAsType | ( | int64_t | , |
| llvm::Type * | t | ||
| ) |
Returns a constant integer or vector (according to the given type) of the given signed integer value.
Definition at line 476 of file llvmutil.cpp.
References NULL.
Referenced by lComputeSliceIndex(), lEmitBinaryPointerArith(), lGSBaseOffsetsGetMoreConst(), and lGSToGSBaseOffsets().
| llvm::Value* LLVMShuffleVectors | ( | llvm::Value * | v1, |
| llvm::Value * | v2, | ||
| int32_t | shuf[], | ||
| int | shufSize, | ||
| llvm::Instruction * | insertBefore | ||
| ) |
Shuffle two vectors together with a ShuffleVectorInst, returning a vector with shufSize elements, where the shuf[] array offsets are used to determine which element from the two given vectors is used for each result element.
Definition at line 1540 of file llvmutil.cpp.
References LLVMTypes::Int32Type, and LLVMInt32().
Referenced by lApplyLoad4(), LLVMConcatVectors(), and lSplit8WideLoads().
| llvm::ConstantInt* LLVMUInt16 | ( | uint16_t | i | ) |
Returns an LLVM i16 constant of the given value
Definition at line 200 of file llvmutil.cpp.
References Globals::ctx, and g.
Referenced by ConstExpr::GetConstant(), ConstExpr::GetValue(), lLLVMConstantValue(), and LLVMUInt16Vector().
| llvm::Constant* LLVMUInt16Vector | ( | uint16_t | i | ) |
Returns an LLVM i16 vector constant of the given value smeared across all elements
Definition at line 304 of file llvmutil.cpp.
References g, LLVMUInt16(), Globals::target, and Target::vectorWidth.
Referenced by ConstExpr::GetConstant(), ConstExpr::GetValue(), and lLLVMConstantValue().
| llvm::Constant* LLVMUInt16Vector | ( | const uint16_t * | i | ) |
Returns an LLVM i16 vector based on the given array of values. The array should have g->target.vectorWidth elements.
Definition at line 314 of file llvmutil.cpp.
References g, LLVMUInt16(), Globals::target, and Target::vectorWidth.
| llvm::ConstantInt* LLVMUInt32 | ( | uint32_t | i | ) |
Returns an LLVM i32 constant of the given value
Definition at line 214 of file llvmutil.cpp.
References Globals::ctx, and g.
Referenced by ConstExpr::GetConstant(), ConstExpr::GetValue(), lLLVMConstantValue(), and LLVMUInt32Vector().
| llvm::Constant* LLVMUInt32Vector | ( | uint32_t | i | ) |
Returns an LLVM i32 vector constant of the given value smeared across all elements
Definition at line 342 of file llvmutil.cpp.
References g, LLVMUInt32(), Globals::target, and Target::vectorWidth.
Referenced by ConstExpr::GetConstant(), ConstExpr::GetValue(), and lLLVMConstantValue().
| llvm::Constant* LLVMUInt32Vector | ( | const uint32_t * | i | ) |
Returns an LLVM i32 vector based on the given array of values. The array should have g->target.vectorWidth elements.
Definition at line 352 of file llvmutil.cpp.
References g, LLVMUInt32(), Globals::target, and Target::vectorWidth.
| llvm::ConstantInt* LLVMUInt64 | ( | uint64_t | i | ) |
Returns an LLVM i64 constant of the given value
Definition at line 228 of file llvmutil.cpp.
References Globals::ctx, and g.
Referenced by ConstExpr::GetConstant(), ConstExpr::GetValue(), lLLVMConstantValue(), and LLVMUInt64Vector().
| llvm::Constant* LLVMUInt64Vector | ( | uint64_t | i | ) |
Returns an LLVM i64 vector constant of the given value smeared across all elements
Definition at line 418 of file llvmutil.cpp.
References g, LLVMUInt64(), Globals::target, and Target::vectorWidth.
Referenced by ConstExpr::GetConstant(), ConstExpr::GetValue(), and lLLVMConstantValue().
| llvm::Constant* LLVMUInt64Vector | ( | const uint64_t * | i | ) |
Returns an LLVM i64 vector based on the given array of values. The array should have g->target.vectorWidth elements.
Definition at line 428 of file llvmutil.cpp.
References g, LLVMUInt64(), Globals::target, and Target::vectorWidth.
| llvm::ConstantInt* LLVMUInt8 | ( | uint8_t | i | ) |
Returns an LLVM i8 constant of the given value
Definition at line 186 of file llvmutil.cpp.
References Globals::ctx, and g.
Referenced by ConstExpr::GetConstant(), ConstExpr::GetValue(), lLLVMConstantValue(), and LLVMUInt8Vector().
| llvm::Constant* LLVMUInt8Vector | ( | uint8_t | i | ) |
Returns an LLVM i8 vector constant of the given value smeared across all elements
Definition at line 266 of file llvmutil.cpp.
References g, LLVMUInt8(), Globals::target, and Target::vectorWidth.
Referenced by ConstExpr::GetConstant(), ConstExpr::GetValue(), and lLLVMConstantValue().
| llvm::Constant* LLVMUInt8Vector | ( | const uint8_t * | i | ) |
Returns an LLVM i8 vector based on the given array of values. The array should have g->target.vectorWidth elements.
Definition at line 276 of file llvmutil.cpp.
References g, LLVMUInt8(), Globals::target, and Target::vectorWidth.
| llvm::Constant* LLVMUIntAsType | ( | uint64_t | , |
| llvm::Type * | t | ||
| ) |
Returns a constant integer or vector (according to the given type) of the given unsigned integer value.
Definition at line 494 of file llvmutil.cpp.
References NULL.
| bool LLVMVectorIsLinear | ( | llvm::Value * | v, |
| int | stride | ||
| ) |
Given vector of integer-typed values, see if the elements of the array have a step of 'stride' between their values. This function tries to handle as many possibilities as possible, including things like all elements equal to some non-constant value plus an integer offset, etc.
Definition at line 1346 of file llvmutil.cpp.
References Assert, Debug(), Globals::debugPrint, g, LLVMDumpValue(), lVectorIsLinear(), and NULL.
Referenced by lGSToLoadStore().
| bool LLVMVectorValuesAllEqual | ( | llvm::Value * | v | ) |
Tests to see if all of the elements of the vector in the 'v' parameter are equal. This is a conservative test and may return false for arrays where the values are actually all equal.
Definition at line 1076 of file llvmutil.cpp.
References Assert, Debug(), Globals::debugPrint, g, LLVMDumpValue(), lVectorValuesAllEqual(), and NULL.
Referenced by lGSToLoadStore(), lIsExactMultiple(), and GatherCoalescePass::runOnBasicBlock().
| static int lRoundUpPow2 | ( | int | v | ) | [static] |
Returns the next power of two greater than or equal to the given value.
Definition at line 761 of file llvmutil.cpp.
Referenced by lAllDivBaseEqual().
| static bool lValuesAreEqual | ( | llvm::Value * | v0, |
| llvm::Value * | v1, | ||
| std::vector< llvm::PHINode * > & | seenPhi0, | ||
| std::vector< llvm::PHINode * > & | seenPhi1 | ||
| ) | [static] |
Conservative test to see if two llvm::Values are equal. There are (potentially many) cases where the two values actually are equal but this will return false. However, if it does return true, the two vectors definitely are equal.
Definition at line 517 of file llvmutil.cpp.
Referenced by lVectorValuesAllEqual().
| static bool lVectorIsLinear | ( | llvm::Value * | v, |
| int | vectorLength, | ||
| int | stride, | ||
| std::vector< llvm::PHINode * > & | seenPhis | ||
| ) | [static] |
Definition at line 1225 of file llvmutil.cpp.
References lCheckAndForLinear(), lCheckMulForLinear(), lVectorIsLinearConstantInts(), lVectorValuesAllEqual(), NULL, and stderr.
Referenced by lCheckAndForLinear(), lCheckMulForLinear(), and LLVMVectorIsLinear().
| static bool lVectorIsLinearConstantInts | ( | llvm::ConstantDataVector * | cv, |
| int | vectorLength, | ||
| int | stride | ||
| ) | [static] |
Given a vector of compile-time constant integer values, test to see if they are a linear sequence of constant integers starting from an arbirary value but then having a step of value "stride" between elements.
Definition at line 1104 of file llvmutil.cpp.
Referenced by lVectorIsLinear().
| static bool lVectorShiftRightAllEqual | ( | llvm::Value * | val, |
| llvm::Value * | shift, | ||
| int | vectorLength | ||
| ) | [static] |
Given a vector shift right of some value by some amount, try to determine if all of the elements of the final result have the same value (i.e. whether the high bits are all equal, disregarding the low bits that are shifted out.) Returns true if so, and false otherwise.
Definition at line 906 of file llvmutil.cpp.
References Assert, ISPC_MAX_NVEC, lAllDivBaseEqual(), LLVMDumpValue(), LLVMExtractVectorInts(), and stderr.
Referenced by lVectorValuesAllEqual().
| static bool lVectorValuesAllEqual | ( | llvm::Value * | v, |
| int | vectorLength, | ||
| std::vector< llvm::PHINode * > & | seenPhis | ||
| ) | [static] |
Definition at line 938 of file llvmutil.cpp.
References Assert, ISPC_MAX_NVEC, LLVMFlattenInsertChain(), lValuesAreEqual(), lVectorShiftRightAllEqual(), NULL, and stderr.
Referenced by lAllDivBaseEqual(), LLVMVectorValuesAllEqual(), and lVectorIsLinear().
| llvm::Constant* LLVMFalse = NULL |
Definition at line 86 of file llvmutil.cpp.
Referenced by ForeachStmt::EmitCode(), ConstExpr::GetConstant(), ConstExpr::GetValue(), InitLLVMUtil(), lEmitLogicalOp(), lLLVMConstantValue(), LLVMBoolVector(), FunctionEmitContext::MemcpyInst(), and IsCompileTimeConstantPass::runOnBasicBlock().
| llvm::Constant* LLVMMaskAllOff = NULL |
LLVM constant value representing an 'all off' SIMD lane mask
Definition at line 88 of file llvmutil.cpp.
Referenced by FunctionEmitContext::Break(), FunctionEmitContext::Continue(), FunctionEmitContext::CurrentLanesReturned(), ForeachStmt::EmitCode(), FunctionEmitContext::EndIf(), FunctionEmitContext::FunctionEmitContext(), InitLLVMUtil(), lEmitLogicalOp(), FunctionEmitContext::RestoreContinuedLanes(), FunctionEmitContext::StartForeach(), FunctionEmitContext::StartLoop(), FunctionEmitContext::StartSwitch(), and FunctionEmitContext::SwitchInst().
| llvm::Constant* LLVMMaskAllOn = NULL |
LLVM constant value representing an 'all on' SIMD lane mask
Definition at line 87 of file llvmutil.cpp.
Referenced by FunctionEmitContext::CallInst(), DoStmt::EmitCode(), ForStmt::EmitCode(), ForeachStmt::EmitCode(), UnmaskedStmt::EmitCode(), IfStmt::emitMaskAllOn(), FunctionEmitContext::FunctionEmitContext(), IndexExpr::GetValue(), MemberExpr::GetValue(), InitLLVMUtil(), lEmitLogicalOp(), lStoreAssignResult(), FunctionEmitContext::maskedStore(), FunctionEmitContext::SetInternalMaskAndNot(), and FunctionEmitContext::StoreInst().
| llvm::Constant* LLVMTrue = NULL |
These variables hold the corresponding LLVM constant values as a convenience to code elsewhere in the system.
Definition at line 85 of file llvmutil.cpp.
Referenced by ForStmt::EmitCode(), ForeachStmt::EmitCode(), ConstExpr::GetConstant(), ConstExpr::GetValue(), InitLLVMUtil(), lEmitLogicalOp(), lLLVMConstantValue(), LLVMBoolVector(), and IsCompileTimeConstantPass::runOnBasicBlock().
1.7.5.1