Intel SPMD Program Compiler  1.9.1
Classes | Macros | Functions
expr.cpp File Reference

Implementations of expression classes. More...

#include "expr.h"
#include "ast.h"
#include "type.h"
#include "sym.h"
#include "ctx.h"
#include "module.h"
#include "util.h"
#include "llvmutil.h"
#include <inttypes.h>
#include <list>
#include <set>
#include <stdio.h>
#include <llvm/IR/Module.h>
#include <llvm/IR/Type.h>
#include <llvm/IR/Instructions.h>
#include <llvm/IR/Function.h>
#include <llvm/IR/DerivedTypes.h>
#include <llvm/IR/LLVMContext.h>
#include <llvm/IR/CallingConv.h>
#include <llvm/ExecutionEngine/GenericValue.h>
#include <llvm/Support/InstIterator.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)
 
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 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 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 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)
 
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

#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 2151 of file expr.cpp.

Referenced by lConstFoldBinaryLogicalOp(), and lConstFoldBoolBinaryOp().

#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 2157 of file expr.cpp.

Referenced by lConstFoldBinaryArithOp(), and lConstFoldBinaryIntOp().

Function Documentation

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 587 of file expr.cpp.

References lDoTypeConv().

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

bool FullResolveOverloads ( Expr func,
ExprList args,
std::vector< const Type * > *  argTypes,
std::vector< bool > *  argCouldBeNULL,
std::vector< bool > *  argIsConstant 
)
void InitSymbol ( llvm::Value *  ptr,
const Type symType,
Expr initExpr,
FunctionEmitContext ctx,
SourcePos  pos 
)
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 4151 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(), and IndexExpr::GetValue().

static bool lArgIsPointerType ( const Type type)
static

Definition at line 8206 of file expr.cpp.

References ReferenceType::GetReferenceTarget().

Referenced by FunctionSymbolExpr::computeOverloadCost().

static Expr* lArrayToPointer ( Expr expr)
static
static bool lCanImproveVectorDivide ( Expr arg0,
Expr arg1,
int *  divisor 
)
static
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 3029 of file expr.cpp.

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

Referenced by AssignExpr::TypeCheck().

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 4389 of file expr.cpp.

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

Referenced by IndexExpr::GetLValue().

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 2222 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.

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

Definition at line 2278 of file expr.cpp.

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

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 2172 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.

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

Definition at line 2294 of file expr.cpp.

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

template<typename T >
static ConstExpr* lConstFoldBinaryLogicalOp ( BinaryExpr::Op  op,
const T *  v0,
const T *  v1,
ConstExpr carg0 
)
static
static ConstExpr* lConstFoldBoolBinaryOp ( BinaryExpr::Op  op,
const bool *  v0,
const bool *  v1,
ConstExpr carg0 
)
static
template<typename T >
Expr* lConstFoldSelect ( const bool  bv[],
ConstExpr constExpr1,
ConstExpr constExpr2,
const Type exprType,
SourcePos  pos 
)

Definition at line 3389 of file expr.cpp.

References ConstExpr::GetValues(), and ISPC_MAX_NVEC.

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 5781 of file expr.cpp.

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

Referenced by ConstExpr::GetValues().

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

Definition at line 5749 of file expr.cpp.

Referenced by lConvert().

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 5758 of file expr.cpp.

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 5766 of file expr.cpp.

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

And bool -> bool is just assignment

Definition at line 5773 of file expr.cpp.

static llvm::Constant* lConvertPointerConstant ( llvm::Constant *  c,
const Type constType 
)
static
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 4424 of file expr.cpp.

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

Referenced by IndexExpr::GetLValue().

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 4367 of file expr.cpp.

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

Referenced by lConvertPtrToSliceIfNeeded().

Expr* lCreateBinaryOperatorCall ( const BinaryExpr::Op  bop,
Expr a0,
Expr a1,
const SourcePos sp 
)
static const Type* lDeconstifyType ( const Type t)
static
static bool lDoTypeConv ( const Type fromType,
const Type toType,
Expr **  expr,
bool  failureOk,
const char *  errorMsgBase,
SourcePos  pos 
)
static
static llvm::Value* lEmitBinaryArith ( BinaryExpr::Op  op,
llvm::Value *  value0,
llvm::Value *  value1,
const Type type0,
const Type type1,
FunctionEmitContext ctx,
SourcePos  pos 
)
static
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 1425 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().

static llvm::Value* lEmitBinaryCmp ( BinaryExpr::Op  op,
llvm::Value *  e0Val,
llvm::Value *  e1Val,
const Type type,
FunctionEmitContext ctx,
SourcePos  pos 
)
static
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* lEmitLogicalOp ( BinaryExpr::Op  op,
Expr arg0,
Expr arg1,
FunctionEmitContext ctx,
SourcePos  pos 
)
static llvm::Value* lEmitNegate ( Expr arg,
SourcePos  pos,
FunctionEmitContext ctx 
)
static
static llvm::Value* lEmitOpAssign ( AssignExpr::Op  op,
Expr arg0,
Expr arg1,
const Type type,
Symbol baseSym,
SourcePos  pos,
FunctionEmitContext ctx 
)
static
static llvm::Value* lEmitPrePostIncDec ( UnaryExpr::Op  op,
Expr expr,
SourcePos  pos,
FunctionEmitContext ctx 
)
static
static void lEmitSelectExprCode ( FunctionEmitContext ctx,
llvm::Value *  testVal,
llvm::Value *  oldMask,
llvm::Value *  fullMask,
Expr expr,
llvm::Value *  exprPtr 
)
static
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 3183 of file expr.cpp.

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

Referenced by SelectExpr::GetValue().

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

Definition at line 8107 of file expr.cpp.

References Assert, and FunctionType::GetString().

Referenced by FunctionSymbolExpr::ResolveOverloads().

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 4697 of file expr.cpp.

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

static bool lIsAllIntZeros ( Expr expr)
static
static bool lIsDifficultShiftAmount ( Expr expr)
static
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 8136 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().

static llvm::Constant* lLLVMConstantValue ( const Type type,
llvm::LLVMContext *  ctx,
double  value 
)
static
static llvm::Value* lMaskForSymbol ( Symbol baseSym,
FunctionEmitContext ctx 
)
static
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 825 of file expr.cpp.

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

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

static const char* lOpString ( BinaryExpr::Op  op)
static
static const char* lOpString ( AssignExpr::Op  op)
static
template<typename T >
static Expr* lOptimizeBitNot ( ConstExpr constExpr,
const Type type,
SourcePos  pos 
)
static

Definition at line 1175 of file expr.cpp.

References ConstExpr::GetValues(), and ISPC_MAX_NVEC.

static void lStoreAssignResult ( llvm::Value *  value,
llvm::Value *  ptr,
const Type valueType,
const Type ptrType,
FunctionEmitContext ctx,
Symbol baseSym 
)
static
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 6246 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().

static llvm::Value* lUniformValueToVarying ( FunctionEmitContext ctx,
llvm::Value *  value,
const Type type 
)
static
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 4188 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(), and m.

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

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

Definition at line 1722 of file expr.cpp.

References lCreateBinaryOperatorCall().

bool PossiblyResolveFunctionOverloads ( Expr expr,
const Type type 
)
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 595 of file expr.cpp.

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

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