Intel® Implicit SPMD Program Compiler (Intel® ISPC)  1.13.0
Classes | Macros | Functions
expr.cpp File Reference

Implementations of expression classes. More...

#include "expr.h"
#include "ast.h"
#include "ctx.h"
#include "llvmutil.h"
#include "module.h"
#include "sym.h"
#include "type.h"
#include "util.h"
#include <inttypes.h>
#include <list>
#include <set>
#include <stdio.h>
#include <llvm/ExecutionEngine/GenericValue.h>
#include <llvm/IR/CallingConv.h>
#include <llvm/IR/DerivedTypes.h>
#include <llvm/IR/Function.h>
#include <llvm/IR/InstIterator.h>
#include <llvm/IR/Instructions.h>
#include <llvm/IR/LLVMContext.h>
#include <llvm/IR/Module.h>
#include <llvm/IR/Type.h>
Include dependency graph for expr.cpp:

Go to the source code of this file.

Classes

class  StructMemberExpr
 
class  VectorMemberExpr
 

Macros

#define FOLD_OP(O, E)
 
#define FOLD_OP_REF(O, E, TRef)
 

Functions

static ExprlArrayToPointer (Expr *expr)
 
static bool lIsAllIntZeros (Expr *expr)
 
static bool lDoTypeConv (const Type *fromType, const Type *toType, Expr **expr, bool failureOk, const char *errorMsgBase, SourcePos pos)
 
bool CanConvertTypes (const Type *fromType, const Type *toType, const char *errorMsgBase, SourcePos pos)
 
ExprTypeConvertExpr (Expr *expr, const Type *toType, const char *errorMsgBase)
 
bool PossiblyResolveFunctionOverloads (Expr *expr, const Type *type)
 
void InitSymbol (llvm::Value *ptr, const Type *symType, Expr *initExpr, FunctionEmitContext *ctx, SourcePos pos)
 
static const TypelMatchingBoolType (const Type *type)
 
static llvm::Constant * lLLVMConstantValue (const Type *type, llvm::LLVMContext *ctx, double value)
 
static llvm::Value * lMaskForSymbol (Symbol *baseSym, FunctionEmitContext *ctx)
 
static void lStoreAssignResult (llvm::Value *value, llvm::Value *ptr, const Type *valueType, const Type *ptrType, FunctionEmitContext *ctx, Symbol *baseSym)
 
static llvm::Value * lEmitPrePostIncDec (UnaryExpr::Op op, Expr *expr, SourcePos pos, FunctionEmitContext *ctx)
 
static llvm::Value * lEmitNegate (Expr *arg, SourcePos pos, FunctionEmitContext *ctx)
 
template<typename T >
static ExprlOptimizeBitNot (ConstExpr *constExpr, const Type *type, SourcePos pos)
 
template<typename T >
static ExprlOptimizeNegate (ConstExpr *constExpr, const Type *type, SourcePos pos)
 
static const char * lOpString (BinaryExpr::Op op)
 
static llvm::Value * lEmitBinaryBitOp (BinaryExpr::Op op, llvm::Value *arg0Val, llvm::Value *arg1Val, bool isUnsigned, FunctionEmitContext *ctx)
 
static llvm::Value * lEmitBinaryPointerArith (BinaryExpr::Op op, llvm::Value *value0, llvm::Value *value1, const Type *type0, const Type *type1, FunctionEmitContext *ctx, SourcePos pos)
 
static llvm::Value * lEmitBinaryArith (BinaryExpr::Op op, llvm::Value *value0, llvm::Value *value1, const Type *type0, const Type *type1, FunctionEmitContext *ctx, SourcePos pos)
 
static llvm::Value * lEmitBinaryCmp (BinaryExpr::Op op, llvm::Value *e0Val, llvm::Value *e1Val, const Type *type, FunctionEmitContext *ctx, SourcePos pos)
 
ExprlCreateBinaryOperatorCall (const BinaryExpr::Op bop, Expr *a0, Expr *a1, const SourcePos &sp)
 
ExprMakeBinaryExpr (BinaryExpr::Op o, Expr *a, Expr *b, SourcePos p)
 
llvm::Value * lEmitLogicalOp (BinaryExpr::Op op, Expr *arg0, Expr *arg1, FunctionEmitContext *ctx, SourcePos pos)
 
static bool lIsDifficultShiftAmount (Expr *expr)
 
template<typename T , typename TRef >
static ConstExprlConstFoldBinaryIntOp (BinaryExpr::Op op, const T *v0, const T *v1, ConstExpr *carg0, SourcePos pos)
 
template<typename T >
static ConstExprlConstFoldBinaryLogicalOp (BinaryExpr::Op op, const T *v0, const T *v1, ConstExpr *carg0)
 
template<typename T , typename TRef >
static ConstExprlConstFoldBinaryArithOp (BinaryExpr::Op op, const T *v0, const T *v1, ConstExpr *carg0, SourcePos pos)
 
static ConstExprlConstFoldBoolBinaryOp (BinaryExpr::Op op, const bool *v0, const bool *v1, ConstExpr *carg0)
 
template<typename T >
static ExprlConstFoldBinaryFPOp (ConstExpr *constArg0, ConstExpr *constArg1, BinaryExpr::Op op, BinaryExpr *origExpr, SourcePos pos)
 
template<typename T , typename TRef >
static ExprlConstFoldBinaryIntOp (ConstExpr *constArg0, ConstExpr *constArg1, BinaryExpr::Op op, BinaryExpr *origExpr, SourcePos pos)
 
static bool lCanImproveVectorDivide (Expr *arg0, Expr *arg1, int *divisor)
 
static std::pair< llvm::Constant *, bool > lGetBinaryExprStorageConstant (const Type *type, const BinaryExpr *bExpr, bool isStorageType)
 
static const char * lOpString (AssignExpr::Op op)
 
static llvm::Value * lEmitOpAssign (AssignExpr::Op op, Expr *arg0, Expr *arg1, const Type *type, Symbol *baseSym, SourcePos pos, FunctionEmitContext *ctx)
 
static bool lCheckForConstStructMember (SourcePos pos, const StructType *structType, const StructType *initialType)
 
static llvm::Value * lEmitVaryingSelect (FunctionEmitContext *ctx, llvm::Value *test, llvm::Value *expr1, llvm::Value *expr2, const Type *type)
 
static void lEmitSelectExprCode (FunctionEmitContext *ctx, llvm::Value *testVal, llvm::Value *oldMask, llvm::Value *fullMask, Expr *expr, llvm::Value *exprPtr)
 
template<typename T >
ExprlConstFoldSelect (const bool bv[], ConstExpr *constExpr1, ConstExpr *constExpr2, const Type *exprType, SourcePos pos)
 
static const FunctionTypelGetFunctionType (Expr *func)
 
bool FullResolveOverloads (Expr *func, ExprList *args, std::vector< const Type *> *argTypes, std::vector< bool > *argCouldBeNULL, std::vector< bool > *argIsConstant)
 
static std::pair< llvm::Constant *, bool > lGetExprListConstant (const Type *type, const ExprList *eList, bool isStorageType)
 
static llvm::Value * lAddVaryingOffsetsIfNeeded (FunctionEmitContext *ctx, llvm::Value *ptr, const Type *ptrRefType)
 
static bool lVaryingStructHasUniformMember (const Type *type, SourcePos pos)
 
static llvm::Value * lConvertToSlicePointer (FunctionEmitContext *ctx, llvm::Value *ptr, const PointerType *slicePtrType)
 
static void lCheckIndicesVersusBounds (const Type *baseExprType, Expr *index)
 
static llvm::Value * lConvertPtrToSliceIfNeeded (FunctionEmitContext *ctx, llvm::Value *ptr, const Type **type)
 
static int lIdentifierToVectorElement (char id)
 
template<typename From , typename To >
static void lConvertElement (From from, To *to)
 
template<typename To >
static void lConvertElement (bool from, To *to)
 
template<typename From >
static void lConvertElement (From from, bool *to)
 
static void lConvertElement (bool from, bool *to)
 
template<typename From , typename To >
static void lConvert (const From *from, To *to, int count, bool forceVarying)
 
static std::pair< llvm::Constant *, bool > lGetConstExprConstant (const Type *constType, const ConstExpr *cExpr, bool isStorageType)
 
static llvm::Value * lTypeConvAtomic (FunctionEmitContext *ctx, llvm::Value *exprVal, const AtomicType *toType, const AtomicType *fromType, SourcePos pos)
 
static llvm::Value * lUniformValueToVarying (FunctionEmitContext *ctx, llvm::Value *value, const Type *type, SourcePos pos)
 
static const TypelDeconstifyType (const Type *t)
 
static llvm::Constant * lConvertPointerConstant (llvm::Constant *c, const Type *constType)
 
static std::string lGetOverloadCandidateMessage (const std::vector< Symbol *> &funcs, const std::vector< const Type *> &argTypes, const std::vector< bool > *argCouldBeNULL)
 
static bool lIsMatchWithTypeWidening (const Type *callType, const Type *funcArgType)
 
static bool lArgIsPointerType (const Type *type)
 

Detailed Description

Implementations of expression classes.

Definition in file expr.cpp.

Macro Definition Documentation

◆ FOLD_OP

#define FOLD_OP (   O,
 
)
Value:
case O: \
for (int i = 0; i < count; ++i) \
result[i] = (v0[i] E v1[i]); \
break

Definition at line 2011 of file expr.cpp.

Referenced by lConstFoldBinaryLogicalOp(), and lConstFoldBoolBinaryOp().

◆ FOLD_OP_REF

#define FOLD_OP_REF (   O,
  E,
  TRef 
)
Value:
case O: \
for (int i = 0; i < count; ++i) { \
result[i] = (v0[i] E v1[i]); \
TRef r = (TRef)v0[i] E(TRef) v1[i]; \
if (result[i] != r) \
Warning(pos, "Binary expression with type \"%s\" can't represent value.", \
carg0->GetType()->GetString().c_str()); \
} \
break

Definition at line 2017 of file expr.cpp.

Referenced by lConstFoldBinaryArithOp(), and lConstFoldBinaryIntOp().

Function Documentation

◆ CanConvertTypes()

bool CanConvertTypes ( const Type fromType,
const Type toType,
const char *  errorMsgBase = NULL,
SourcePos  pos = SourcePos() 
)

This function indicates whether it's legal to convert from fromType to toType. If the optional errorMsgBase and source position parameters are provided, then an error message is issued if the type conversion isn't possible.

Definition at line 544 of file expr.cpp.

References lDoTypeConv().

Referenced by FunctionSymbolExpr::computeOverloadCost(), and FunctionCallExpr::TypeCheck().

◆ FullResolveOverloads()

bool FullResolveOverloads ( Expr func,
ExprList args,
std::vector< const Type *> *  argTypes,
std::vector< bool > *  argCouldBeNULL,
std::vector< bool > *  argIsConstant 
)

◆ InitSymbol()

void InitSymbol ( llvm::Value *  ptr,
const Type symType,
Expr initExpr,
FunctionEmitContext ctx,
SourcePos  pos 
)

◆ lAddVaryingOffsetsIfNeeded()

static llvm::Value* lAddVaryingOffsetsIfNeeded ( FunctionEmitContext ctx,
llvm::Value *  ptr,
const Type ptrRefType 
)
static

When computing pointer values, we need to apply a per-lane offset when we have a varying pointer that is itself indexing into varying data. Consdier the following ispc code:

uniform float u[] = ...; float v[] = ...; int index = ...; float a = u[index]; float b = v[index];

To compute the varying pointer that holds the addresses to load from for u[index], we basically just need to multiply index element-wise by sizeof(float) before doing the memory load. For v[index], we need to do the same scaling but also need to add per-lane offsets <0, sizeof(float), 2*sizeof(float), ...> so that the i'th lane loads the i'th of the varying values at its index value.

This function handles figuring out when this additional offset is needed and then incorporates it in the varying pointer value.

Definition at line 3977 of file expr.cpp.

References Assert, Type::GetAsUniformType(), PointerType::GetBaseType(), FunctionEmitContext::GetElementPtrInst(), PointerType::GetVarying(), Type::IsBasicType(), PointerType::IsSlice(), Type::IsUniformType(), Type::IsVaryingType(), and FunctionEmitContext::ProgramIndexVector().

Referenced by IndexExpr::GetLValue(), MemberExpr::GetLValue(), IndexExpr::GetValue(), and DerefExpr::GetValue().

◆ lArgIsPointerType()

static bool lArgIsPointerType ( const Type type)
static

Definition at line 7800 of file expr.cpp.

References ReferenceType::GetReferenceTarget().

Referenced by FunctionSymbolExpr::computeOverloadCost().

◆ lArrayToPointer()

static Expr* lArrayToPointer ( Expr expr)
static

◆ lCanImproveVectorDivide()

static bool lCanImproveVectorDivide ( Expr arg0,
Expr arg1,
int *  divisor 
)
static

◆ lCheckForConstStructMember()

static bool lCheckForConstStructMember ( SourcePos  pos,
const StructType structType,
const StructType initialType 
)
static

Recursively checks a structure type to see if it (or any struct type that it holds) has a const-qualified member.

Definition at line 2951 of file expr.cpp.

References Error(), StructType::GetElementCount(), StructType::GetElementName(), StructType::GetElementType(), Type::GetString(), StructType::GetString(), and Type::IsConstType().

Referenced by AssignExpr::TypeCheck().

◆ lCheckIndicesVersusBounds()

static void lCheckIndicesVersusBounds ( const Type baseExprType,
Expr index 
)
static

If the given array index is a compile time constant, check to see if it value/values don't go past the end of the array; issue a warning if so.

Definition at line 4186 of file expr.cpp.

References CollectionType::GetElementCount(), SequentialType::GetElementType(), Type::GetSOAWidth(), ConstExpr::GetValues(), IndexExpr::index, ISPC_MAX_NVEC, ASTNode::pos, and Warning().

Referenced by IndexExpr::GetLValue().

◆ lConstFoldBinaryArithOp()

template<typename T , typename TRef >
static ConstExpr* lConstFoldBinaryArithOp ( BinaryExpr::Op  op,
const T *  v0,
const T *  v1,
ConstExpr carg0,
SourcePos  pos 
)
static

Constant fold binary arithmetic ops.

Definition at line 2077 of file expr.cpp.

References BinaryExpr::Add, ConstExpr::Count(), BinaryExpr::Div, Error(), FOLD_OP_REF, ConstExpr::GetType(), ISPC_MAX_NVEC, BinaryExpr::Mul, ASTNode::pos, and BinaryExpr::Sub.

◆ lConstFoldBinaryFPOp()

template<typename T >
static Expr* lConstFoldBinaryFPOp ( ConstExpr constArg0,
ConstExpr constArg1,
BinaryExpr::Op  op,
BinaryExpr origExpr,
SourcePos  pos 
)
static

Definition at line 2128 of file expr.cpp.

References ConstExpr::GetValues(), ISPC_MAX_NVEC, and lConstFoldBinaryLogicalOp().

◆ lConstFoldBinaryIntOp() [1/2]

template<typename T , typename TRef >
static ConstExpr* lConstFoldBinaryIntOp ( BinaryExpr::Op  op,
const T *  v0,
const T *  v1,
ConstExpr carg0,
SourcePos  pos 
)
static

Constant fold the binary integer operations that aren't also applicable to floating-point types.

Definition at line 2032 of file expr.cpp.

References BinaryExpr::BitAnd, BinaryExpr::BitOr, BinaryExpr::BitXor, ConstExpr::Count(), FOLD_OP_REF, ConstExpr::GetType(), ISPC_MAX_NVEC, BinaryExpr::Mod, ASTNode::pos, BinaryExpr::Shl, and BinaryExpr::Shr.

◆ lConstFoldBinaryIntOp() [2/2]

template<typename T , typename TRef >
static Expr* lConstFoldBinaryIntOp ( ConstExpr constArg0,
ConstExpr constArg1,
BinaryExpr::Op  op,
BinaryExpr origExpr,
SourcePos  pos 
)
static

Definition at line 2143 of file expr.cpp.

References ConstExpr::GetValues(), ISPC_MAX_NVEC, and lConstFoldBinaryLogicalOp().

◆ lConstFoldBinaryLogicalOp()

template<typename T >
static ConstExpr* lConstFoldBinaryLogicalOp ( BinaryExpr::Op  op,
const T *  v0,
const T *  v1,
ConstExpr carg0 
)
static

◆ lConstFoldBoolBinaryOp()

static ConstExpr* lConstFoldBoolBinaryOp ( BinaryExpr::Op  op,
const bool *  v0,
const bool *  v1,
ConstExpr carg0 
)
static

◆ lConstFoldSelect()

template<typename T >
Expr* lConstFoldSelect ( const bool  bv[],
ConstExpr constExpr1,
ConstExpr constExpr2,
const Type exprType,
SourcePos  pos 
)

Definition at line 3270 of file expr.cpp.

References ConstExpr::GetValues(), and ISPC_MAX_NVEC.

◆ lConvert()

template<typename From , typename To >
static void lConvert ( const From *  from,
To *  to,
int  count,
bool  forceVarying 
)
static

Type conversion utility function

Definition at line 5362 of file expr.cpp.

References g, Target::getVectorWidth(), lConvertElement(), and Globals::target.

Referenced by ConstExpr::GetValues().

◆ lConvertElement() [1/4]

template<typename From , typename To >
static void lConvertElement ( From  from,
To *  to 
)
inlinestatic

Definition at line 5346 of file expr.cpp.

Referenced by lConvert().

◆ lConvertElement() [2/4]

template<typename To >
static void lConvertElement ( bool  from,
To *  to 
)
inlinestatic

When converting from bool types to numeric types, make sure the result is one or zero.

Definition at line 5351 of file expr.cpp.

◆ lConvertElement() [3/4]

template<typename From >
static void lConvertElement ( From  from,
bool *  to 
)
inlinestatic

When converting numeric types to bool, compare to zero. (Do we actually need this one??)

Definition at line 5355 of file expr.cpp.

◆ lConvertElement() [4/4]

static void lConvertElement ( bool  from,
bool *  to 
)
inlinestatic

And bool -> bool is just assignment

Definition at line 5358 of file expr.cpp.

◆ lConvertPointerConstant()

static llvm::Constant* lConvertPointerConstant ( llvm::Constant *  c,
const Type constType 
)
static

◆ lConvertPtrToSliceIfNeeded()

static llvm::Value* lConvertPtrToSliceIfNeeded ( FunctionEmitContext ctx,
llvm::Value *  ptr,
const Type **  type 
)
static

Converts the given pointer value to a slice pointer if the pointer points to SOA'ed data.

Definition at line 4221 of file expr.cpp.

References Assert, PointerType::GetAsSlice(), PointerType::GetBaseType(), PointerType::IsSlice(), Type::IsSOAType(), and lConvertToSlicePointer().

Referenced by IndexExpr::GetLValue().

◆ lConvertToSlicePointer()

static llvm::Value* lConvertToSlicePointer ( FunctionEmitContext ctx,
llvm::Value *  ptr,
const PointerType slicePtrType 
)
static

Utility routine that takes a regualr pointer (either uniform or varying) and returns a slice pointer with zero offsets.

Definition at line 4169 of file expr.cpp.

References Assert, Globals::ctx, g, FunctionEmitContext::InsertInst(), LLVMGetName(), and PointerType::LLVMType().

Referenced by lConvertPtrToSliceIfNeeded().

◆ lCreateBinaryOperatorCall()

Expr* lCreateBinaryOperatorCall ( const BinaryExpr::Op  bop,
Expr a0,
Expr a1,
const SourcePos sp 
)

◆ lDeconstifyType()

static const Type* lDeconstifyType ( const Type t)
static

◆ lDoTypeConv()

static bool lDoTypeConv ( const Type fromType,
const Type toType,
Expr **  expr,
bool  failureOk,
const char *  errorMsgBase,
SourcePos  pos 
)
static

◆ lEmitBinaryArith()

static llvm::Value* lEmitBinaryArith ( BinaryExpr::Op  op,
llvm::Value *  value0,
llvm::Value *  value1,
const Type type0,
const Type type1,
FunctionEmitContext ctx,
SourcePos  pos 
)
static

◆ lEmitBinaryBitOp()

static llvm::Value* lEmitBinaryBitOp ( BinaryExpr::Op  op,
llvm::Value *  arg0Val,
llvm::Value *  arg1Val,
bool  isUnsigned,
FunctionEmitContext ctx 
)
static

Utility routine to emit the binary bitwise operator corresponding to the given BinaryExpr::Op.

Definition at line 1357 of file expr.cpp.

References FunctionEmitContext::BinaryOperator(), BinaryExpr::BitAnd, BinaryExpr::BitOr, BinaryExpr::BitXor, FATAL, BinaryExpr::Shl, and BinaryExpr::Shr.

Referenced by BinaryExpr::GetValue(), and lEmitOpAssign().

◆ lEmitBinaryCmp()

static llvm::Value* lEmitBinaryCmp ( BinaryExpr::Op  op,
llvm::Value *  e0Val,
llvm::Value *  e1Val,
const Type type,
FunctionEmitContext ctx,
SourcePos  pos 
)
static

◆ lEmitBinaryPointerArith()

static llvm::Value* lEmitBinaryPointerArith ( BinaryExpr::Op  op,
llvm::Value *  value0,
llvm::Value *  value1,
const Type type0,
const Type type1,
FunctionEmitContext ctx,
SourcePos  pos 
)
static

◆ lEmitLogicalOp()

llvm::Value* lEmitLogicalOp ( BinaryExpr::Op  op,
Expr arg0,
Expr arg1,
FunctionEmitContext ctx,
SourcePos  pos 
)

◆ lEmitNegate()

static llvm::Value* lEmitNegate ( Expr arg,
SourcePos  pos,
FunctionEmitContext ctx 
)
static

◆ lEmitOpAssign()

static llvm::Value* lEmitOpAssign ( AssignExpr::Op  op,
Expr arg0,
Expr arg1,
const Type type,
Symbol baseSym,
SourcePos  pos,
FunctionEmitContext ctx 
)
static

◆ lEmitPrePostIncDec()

static llvm::Value* lEmitPrePostIncDec ( UnaryExpr::Op  op,
Expr expr,
SourcePos  pos,
FunctionEmitContext ctx 
)
static

◆ lEmitSelectExprCode()

static void lEmitSelectExprCode ( FunctionEmitContext ctx,
llvm::Value *  testVal,
llvm::Value *  oldMask,
llvm::Value *  fullMask,
Expr expr,
llvm::Value *  exprPtr 
)
static

◆ lEmitVaryingSelect()

static llvm::Value* lEmitVaryingSelect ( FunctionEmitContext ctx,
llvm::Value *  test,
llvm::Value *  expr1,
llvm::Value *  expr2,
const Type type 
)
static

Emit code to select between two varying values based on a varying test value.

Definition at line 3092 of file expr.cpp.

References FunctionEmitContext::AllocaInst(), Assert, Globals::ctx, g, PointerType::GetUniform(), Type::LLVMStorageType(), FunctionEmitContext::LoadInst(), and FunctionEmitContext::StoreInst().

Referenced by SelectExpr::GetValue().

◆ lGetBinaryExprStorageConstant()

static std::pair<llvm::Constant *, bool> lGetBinaryExprStorageConstant ( const Type type,
const BinaryExpr bExpr,
bool  isStorageType 
)
static

◆ lGetConstExprConstant()

static std::pair<llvm::Constant *, bool> lGetConstExprConstant ( const Type constType,
const ConstExpr cExpr,
bool  isStorageType 
)
static

◆ lGetExprListConstant()

static std::pair<llvm::Constant *, bool> lGetExprListConstant ( const Type type,
const ExprList eList,
bool  isStorageType 
)
static

◆ lGetFunctionType()

static const FunctionType* lGetFunctionType ( Expr func)
static

◆ lGetOverloadCandidateMessage()

static std::string lGetOverloadCandidateMessage ( const std::vector< Symbol *> &  funcs,
const std::vector< const Type *> &  argTypes,
const std::vector< bool > *  argCouldBeNULL 
)
static

Definition at line 7713 of file expr.cpp.

References Assert, and FunctionType::GetString().

Referenced by FunctionSymbolExpr::ResolveOverloads().

◆ lIdentifierToVectorElement()

static int lIdentifierToVectorElement ( char  id)
static

Map one character ids to vector element numbers. Allow a few different conventions–xyzw, rgba, uv.

Definition at line 4460 of file expr.cpp.

Referenced by VectorMemberExpr::getElementNumber(), and VectorMemberExpr::GetValue().

◆ lIsAllIntZeros()

static bool lIsAllIntZeros ( Expr expr)
static

◆ lIsDifficultShiftAmount()

static bool lIsDifficultShiftAmount ( Expr expr)
static

◆ lIsMatchWithTypeWidening()

static bool lIsMatchWithTypeWidening ( const Type callType,
const Type funcArgType 
)
static

Helper function used for function overload resolution: returns true if converting the argument to the call type only requires a type conversion that won't lose information. Otherwise return false.

Definition at line 7740 of file expr.cpp.

References AtomicType::basicType, FATAL, Type::IsUniformType(), AtomicType::TYPE_BOOL, AtomicType::TYPE_DOUBLE, AtomicType::TYPE_FLOAT, AtomicType::TYPE_INT16, AtomicType::TYPE_INT32, AtomicType::TYPE_INT64, AtomicType::TYPE_INT8, AtomicType::TYPE_UINT16, AtomicType::TYPE_UINT32, AtomicType::TYPE_UINT64, and AtomicType::TYPE_UINT8.

Referenced by FunctionSymbolExpr::computeOverloadCost().

◆ lLLVMConstantValue()

static llvm::Constant* lLLVMConstantValue ( const Type type,
llvm::LLVMContext *  ctx,
double  value 
)
static

◆ lMaskForSymbol()

static llvm::Value* lMaskForSymbol ( Symbol baseSym,
FunctionEmitContext ctx 
)
static

◆ lMatchingBoolType()

static const Type* lMatchingBoolType ( const Type type)
static

Given an atomic or vector type, this returns a boolean type with the same "shape". In other words, if the given type is a vector type of three uniform ints, the returned type is a vector type of three uniform bools.

Definition at line 779 of file expr.cpp.

References Assert, VectorType::GetElementCount(), Type::IsBasicType(), Type::IsReferenceType(), Type::IsUniformType(), AtomicType::UniformBool, and AtomicType::VaryingBool.

Referenced by UnaryExpr::GetType(), BinaryExpr::GetType(), UnaryExpr::TypeCheck(), and SelectExpr::TypeCheck().

◆ lOpString() [1/2]

static const char* lOpString ( BinaryExpr::Op  op)
static

◆ lOpString() [2/2]

static const char* lOpString ( AssignExpr::Op  op)
static

◆ lOptimizeBitNot()

template<typename T >
static Expr* lOptimizeBitNot ( ConstExpr constExpr,
const Type type,
SourcePos  pos 
)
static

Definition at line 1084 of file expr.cpp.

References ConstExpr::GetValues(), and ISPC_MAX_NVEC.

◆ lOptimizeNegate()

template<typename T >
static Expr* lOptimizeNegate ( ConstExpr constExpr,
const Type type,
SourcePos  pos 
)
static

Definition at line 1092 of file expr.cpp.

References ConstExpr::GetValues(), and ISPC_MAX_NVEC.

◆ lStoreAssignResult()

static void lStoreAssignResult ( llvm::Value *  value,
llvm::Value *  ptr,
const Type valueType,
const Type ptrType,
FunctionEmitContext ctx,
Symbol baseSym 
)
static

◆ lTypeConvAtomic()

static llvm::Value* lTypeConvAtomic ( FunctionEmitContext ctx,
llvm::Value *  exprVal,
const AtomicType toType,
const AtomicType fromType,
SourcePos  pos 
)
static

Handle all the grungy details of type conversion between atomic types. Given an input value in exprVal of type fromType, convert it to the llvm::Value with type toType.

Definition at line 6018 of file expr.cpp.

References AtomicType::basicType, LLVMTypes::BoolVectorType, FunctionEmitContext::CastInst(), FunctionEmitContext::CmpInst(), LLVMTypes::DoubleType, LLVMTypes::DoubleVectorType, FATAL, LLVMTypes::FloatType, LLVMTypes::FloatVectorType, FunctionEmitContext::FPCastInst(), g, Target::GENERIC, Target::getISA(), FunctionEmitContext::I1VecToBoolVec(), LLVMTypes::Int16Type, LLVMTypes::Int16VectorType, LLVMTypes::Int1VectorType, LLVMTypes::Int32Type, LLVMTypes::Int32VectorType, LLVMTypes::Int64Type, LLVMTypes::Int64VectorType, LLVMTypes::Int8Type, LLVMTypes::Int8VectorType, Type::IsUniformType(), Type::IsVaryingType(), LLVMDouble(), LLVMDoubleVector(), LLVMFloat(), LLVMFloatVector(), LLVMGetName(), LLVMInt16(), LLVMInt16Vector(), LLVMInt32(), LLVMInt32Vector(), LLVMInt64(), LLVMInt64Vector(), LLVMInt8(), LLVMInt8Vector(), PerformanceWarning(), FunctionEmitContext::SExtInst(), FunctionEmitContext::SmearUniform(), Globals::target, FunctionEmitContext::TruncInst(), AtomicType::TYPE_BOOL, AtomicType::TYPE_DOUBLE, AtomicType::TYPE_FLOAT, AtomicType::TYPE_INT16, AtomicType::TYPE_INT32, AtomicType::TYPE_INT64, AtomicType::TYPE_INT8, AtomicType::TYPE_UINT16, AtomicType::TYPE_UINT32, AtomicType::TYPE_UINT64, AtomicType::TYPE_UINT8, and FunctionEmitContext::ZExtInst().

Referenced by TypeCastExpr::GetValue(), and lUniformValueToVarying().

◆ lUniformValueToVarying()

static llvm::Value* lUniformValueToVarying ( FunctionEmitContext ctx,
llvm::Value *  value,
const Type type,
SourcePos  pos 
)
static

◆ lVaryingStructHasUniformMember()

static bool lVaryingStructHasUniformMember ( const Type type,
SourcePos  pos 
)
static

Check to see if the given type is an array of or pointer to a varying struct type that in turn has a member with bound 'uniform' variability. Issue an error and return true if such a member is found.

Definition at line 4011 of file expr.cpp.

References AssertPos, Error(), Module::errorCount, Type::GetAsVaryingType(), PointerType::GetBaseType(), StructType::GetElementCount(), StructType::GetElementName(), ArrayType::GetElementType(), StructType::GetElementType(), Type::GetString(), StructType::GetString(), Type::IsUniformType(), Type::IsVaryingType(), m, and IndexExpr::type.

Referenced by IndexExpr::GetValue(), and DerefExpr::GetValue().

◆ MakeBinaryExpr()

Expr* MakeBinaryExpr ( BinaryExpr::Op  o,
Expr a,
Expr b,
SourcePos  p 
)

Definition at line 1617 of file expr.cpp.

References BinaryExpr::BinaryExpr(), lCreateBinaryOperatorCall(), and BinaryExpr::op.

◆ PossiblyResolveFunctionOverloads()

bool PossiblyResolveFunctionOverloads ( Expr expr,
const Type type 
)

◆ TypeConvertExpr()

Expr* TypeConvertExpr ( Expr expr,
const Type toType,
const char *  errorMsgBase 
)

This function attempts to convert the given expression to the given type, returning a pointer to a new expression that is the result. If the required type conversion is illegal, it returns NULL and prints an error message using the provided string to indicate the context for which type conversion was being applied (e.g. "function call parameter").

Definition at line 548 of file expr.cpp.

References Debug(), Type::GetString(), Expr::GetType(), lDoTypeConv(), and ASTNode::pos.

Referenced by Module::AddGlobalVariable(), checkInit(), FunctionEmitContext::CurrentLanesReturned(), DeclStmt::EmitCode(), FunctionCallExpr::GetValue(), InitSymbol(), lEmitLogicalOp(), lGetExprListConstant(), IfStmt::TypeCheck(), UnaryExpr::TypeCheck(), DoStmt::TypeCheck(), BinaryExpr::TypeCheck(), ForStmt::TypeCheck(), AssignExpr::TypeCheck(), SelectExpr::TypeCheck(), ForeachStmt::TypeCheck(), FunctionCallExpr::TypeCheck(), IndexExpr::TypeCheck(), SwitchStmt::TypeCheck(), TypeCastExpr::TypeCheck(), AssertStmt::TypeCheck(), and NewExpr::TypeCheck().