Intel SPMD Program Compiler  1.11.0
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
ConstExpr Class Reference

Expression representing a compile-time constant value. More...

#include <expr.h>

Inheritance diagram for ConstExpr:
Inheritance graph
[legend]
Collaboration diagram for ConstExpr:
Collaboration graph
[legend]

Public Member Functions

 ConstExpr (const Type *t, int8_t i, SourcePos p)
 
 ConstExpr (const Type *t, int8_t *i, SourcePos p)
 
 ConstExpr (const Type *t, uint8_t u, SourcePos p)
 
 ConstExpr (const Type *t, uint8_t *u, SourcePos p)
 
 ConstExpr (const Type *t, int16_t i, SourcePos p)
 
 ConstExpr (const Type *t, int16_t *i, SourcePos p)
 
 ConstExpr (const Type *t, uint16_t u, SourcePos p)
 
 ConstExpr (const Type *t, uint16_t *u, SourcePos p)
 
 ConstExpr (const Type *t, int32_t i, SourcePos p)
 
 ConstExpr (const Type *t, int32_t *i, SourcePos p)
 
 ConstExpr (const Type *t, uint32_t u, SourcePos p)
 
 ConstExpr (const Type *t, uint32_t *u, SourcePos p)
 
 ConstExpr (const Type *t, float f, SourcePos p)
 
 ConstExpr (const Type *t, float *f, SourcePos p)
 
 ConstExpr (const Type *t, double d, SourcePos p)
 
 ConstExpr (const Type *t, double *d, SourcePos p)
 
 ConstExpr (const Type *t, int64_t i, SourcePos p)
 
 ConstExpr (const Type *t, int64_t *i, SourcePos p)
 
 ConstExpr (const Type *t, uint64_t i, SourcePos p)
 
 ConstExpr (const Type *t, uint64_t *i, SourcePos p)
 
 ConstExpr (const Type *t, bool b, SourcePos p)
 
 ConstExpr (const Type *t, bool *b, SourcePos p)
 
 ConstExpr (ConstExpr *old, double *values)
 
 ConstExpr (ConstExpr *old, SourcePos pos)
 
llvm::Value * GetValue (FunctionEmitContext *ctx) const
 
const TypeGetType () const
 
void Print () const
 
llvm::Constant * GetConstant (const Type *type) const
 
ExprTypeCheck ()
 
ExprOptimize ()
 
int EstimateCost () const
 
int GetValues (bool *, bool forceVarying=false) const
 
int GetValues (int8_t *, bool forceVarying=false) const
 
int GetValues (uint8_t *, bool forceVarying=false) const
 
int GetValues (int16_t *, bool forceVarying=false) const
 
int GetValues (uint16_t *, bool forceVarying=false) const
 
int GetValues (int32_t *, bool forceVarying=false) const
 
int GetValues (uint32_t *, bool forceVarying=false) const
 
int GetValues (float *, bool forceVarying=false) const
 
int GetValues (int64_t *, bool forceVarying=false) const
 
int GetValues (uint64_t *, bool forceVarying=false) const
 
int GetValues (double *, bool forceVarying=false) const
 
int Count () const
 
- Public Member Functions inherited from Expr
 Expr (SourcePos p, unsigned scid)
 
virtual llvm::Value * GetLValue (FunctionEmitContext *ctx) const
 
virtual const TypeGetLValueType () const
 
virtual SymbolGetBaseSymbol () const
 
- Public Member Functions inherited from ASTNode
 ASTNode (SourcePos p, unsigned scid)
 
virtual ~ASTNode ()
 
unsigned getValueID () const
 

Static Public Member Functions

static bool classof (ConstExpr const *)
 
static bool classof (ASTNode const *N)
 
- Static Public Member Functions inherited from Expr
static bool classof (Expr const *)
 
static bool classof (ASTNode const *N)
 
- Static Public Member Functions inherited from ASTNode
static bool classof (ASTNode const *)
 

Private Member Functions

AtomicType::BasicType getBasicType () const
 

Private Attributes

const Typetype
 
union {
   int8_t   int8Val [ISPC_MAX_NVEC]
 
   uint8_t   uint8Val [ISPC_MAX_NVEC]
 
   int16_t   int16Val [ISPC_MAX_NVEC]
 
   uint16_t   uint16Val [ISPC_MAX_NVEC]
 
   int32_t   int32Val [ISPC_MAX_NVEC]
 
   uint32_t   uint32Val [ISPC_MAX_NVEC]
 
   bool   boolVal [ISPC_MAX_NVEC]
 
   float   floatVal [ISPC_MAX_NVEC]
 
   double   doubleVal [ISPC_MAX_NVEC]
 
   int64_t   int64Val [ISPC_MAX_NVEC]
 
   uint64_t   uint64Val [ISPC_MAX_NVEC]
 
}; 
 

Additional Inherited Members

- Public Types inherited from ASTNode
enum  ASTNodeTy {
  AddressOfExprID, AssignExprID, BinaryExprID, ConstExprID,
  DerefExprID, PtrDerefExprID, RefDerefExprID, ExprListID,
  FunctionCallExprID, FunctionSymbolExprID, IndexExprID, StructMemberExprID,
  VectorMemberExprID, NewExprID, NullPointerExprID, ReferenceExprID,
  SelectExprID, SizeOfExprID, SymbolExprID, SyncExprID,
  TypeCastExprID, UnaryExprID, MaxExprID, AssertStmtID,
  BreakStmtID, CaseStmtID, ContinueStmtID, DeclStmtID,
  DefaultStmtID, DeleteStmtID, DoStmtID, ExprStmtID,
  ForeachActiveStmtID, ForeachStmtID, ForeachUniqueStmtID, ForStmtID,
  GotoStmtID, IfStmtID, LabeledStmtID, PrintStmtID,
  ReturnStmtID, StmtListID, SwitchStmtID, UnmaskedStmtID
}
 
- Public Attributes inherited from ASTNode
SourcePos pos
 

Detailed Description

Expression representing a compile-time constant value.

This class can currently represent compile-time constants of anything that is an AtomicType or an EnumType; for anything more complex, we don't currently have a representation of a compile-time constant that can be further reasoned about.

Definition at line 362 of file expr.h.

Constructor & Destructor Documentation

◆ ConstExpr() [1/24]

ConstExpr::ConstExpr ( const Type t,
int8_t  i,
SourcePos  p 
)

Create a ConstExpr from a uniform int8 value

Definition at line 4852 of file expr.cpp.

References AssertPos, Type::Equal(), Type::GetAsConstType(), int8Val, ASTNode::pos, type, and AtomicType::UniformInt8.

◆ ConstExpr() [2/24]

ConstExpr::ConstExpr ( const Type t,
int8_t *  i,
SourcePos  p 
)

Create a ConstExpr from a varying int8 value

Definition at line 4859 of file expr.cpp.

References AssertPos, Count(), Type::Equal(), Type::GetAsConstType(), int8Val, ASTNode::pos, type, AtomicType::UniformInt8, and AtomicType::VaryingInt8.

◆ ConstExpr() [3/24]

ConstExpr::ConstExpr ( const Type t,
uint8_t  u,
SourcePos  p 
)

Create a ConstExpr from a uniform uint8 value

Definition at line 4868 of file expr.cpp.

References AssertPos, Type::Equal(), Type::GetAsConstType(), ASTNode::pos, type, uint8Val, and AtomicType::UniformUInt8.

◆ ConstExpr() [4/24]

ConstExpr::ConstExpr ( const Type t,
uint8_t *  u,
SourcePos  p 
)

Create a ConstExpr from a varying uint8 value

Definition at line 4875 of file expr.cpp.

References AssertPos, Count(), Type::Equal(), Type::GetAsConstType(), ASTNode::pos, type, uint8Val, AtomicType::UniformUInt8, and AtomicType::VaryingUInt8.

◆ ConstExpr() [5/24]

ConstExpr::ConstExpr ( const Type t,
int16_t  i,
SourcePos  p 
)

Create a ConstExpr from a uniform int16 value

Definition at line 4884 of file expr.cpp.

References AssertPos, Type::Equal(), Type::GetAsConstType(), int16Val, ASTNode::pos, type, and AtomicType::UniformInt16.

◆ ConstExpr() [6/24]

ConstExpr::ConstExpr ( const Type t,
int16_t *  i,
SourcePos  p 
)

Create a ConstExpr from a varying int16 value

Definition at line 4891 of file expr.cpp.

References AssertPos, Count(), Type::Equal(), Type::GetAsConstType(), int16Val, ASTNode::pos, type, AtomicType::UniformInt16, and AtomicType::VaryingInt16.

◆ ConstExpr() [7/24]

ConstExpr::ConstExpr ( const Type t,
uint16_t  u,
SourcePos  p 
)

Create a ConstExpr from a uniform uint16 value

Definition at line 4900 of file expr.cpp.

References AssertPos, Type::Equal(), Type::GetAsConstType(), ASTNode::pos, type, uint16Val, and AtomicType::UniformUInt16.

◆ ConstExpr() [8/24]

ConstExpr::ConstExpr ( const Type t,
uint16_t *  u,
SourcePos  p 
)

Create a ConstExpr from a varying uint16 value

Definition at line 4907 of file expr.cpp.

References AssertPos, Count(), Type::Equal(), Type::GetAsConstType(), ASTNode::pos, type, uint16Val, AtomicType::UniformUInt16, and AtomicType::VaryingUInt16.

◆ ConstExpr() [9/24]

ConstExpr::ConstExpr ( const Type t,
int32_t  i,
SourcePos  p 
)

Create a ConstExpr from a uniform int32 value

Definition at line 4916 of file expr.cpp.

References AssertPos, Type::Equal(), Type::GetAsConstType(), int32Val, ASTNode::pos, type, and AtomicType::UniformInt32.

◆ ConstExpr() [10/24]

ConstExpr::ConstExpr ( const Type t,
int32_t *  i,
SourcePos  p 
)

Create a ConstExpr from a varying int32 value

Definition at line 4923 of file expr.cpp.

References AssertPos, Count(), Type::Equal(), Type::GetAsConstType(), int32Val, ASTNode::pos, type, AtomicType::UniformInt32, and AtomicType::VaryingInt32.

◆ ConstExpr() [11/24]

ConstExpr::ConstExpr ( const Type t,
uint32_t  u,
SourcePos  p 
)

Create a ConstExpr from a uniform uint32 value

Definition at line 4932 of file expr.cpp.

References AssertPos, Type::Equal(), Type::GetAsConstType(), Type::IsUniformType(), ASTNode::pos, type, uint32Val, and AtomicType::UniformUInt32.

◆ ConstExpr() [12/24]

ConstExpr::ConstExpr ( const Type t,
uint32_t *  u,
SourcePos  p 
)

Create a ConstExpr from a varying uint32 value

Definition at line 4940 of file expr.cpp.

References AssertPos, Count(), Type::Equal(), Type::GetAsConstType(), ASTNode::pos, type, uint32Val, AtomicType::UniformUInt32, and AtomicType::VaryingUInt32.

◆ ConstExpr() [13/24]

ConstExpr::ConstExpr ( const Type t,
float  f,
SourcePos  p 
)

Create a ConstExpr from a uniform float value

Definition at line 4950 of file expr.cpp.

References AssertPos, Type::Equal(), floatVal, Type::GetAsConstType(), ASTNode::pos, type, and AtomicType::UniformFloat.

◆ ConstExpr() [14/24]

ConstExpr::ConstExpr ( const Type t,
float *  f,
SourcePos  p 
)

Create a ConstExpr from a varying float value

Definition at line 4957 of file expr.cpp.

References AssertPos, Count(), Type::Equal(), floatVal, Type::GetAsConstType(), ASTNode::pos, type, AtomicType::UniformFloat, and AtomicType::VaryingFloat.

◆ ConstExpr() [15/24]

ConstExpr::ConstExpr ( const Type t,
double  d,
SourcePos  p 
)

Create a ConstExpr from a uniform double value

Definition at line 4998 of file expr.cpp.

References AssertPos, doubleVal, Type::Equal(), Type::GetAsConstType(), ASTNode::pos, type, and AtomicType::UniformDouble.

◆ ConstExpr() [16/24]

ConstExpr::ConstExpr ( const Type t,
double *  d,
SourcePos  p 
)

Create a ConstExpr from a varying double value

Definition at line 5005 of file expr.cpp.

References AssertPos, Count(), doubleVal, Type::Equal(), Type::GetAsConstType(), ASTNode::pos, type, AtomicType::UniformDouble, and AtomicType::VaryingDouble.

◆ ConstExpr() [17/24]

ConstExpr::ConstExpr ( const Type t,
int64_t  i,
SourcePos  p 
)

Create a ConstExpr from a uniform int64 value

Definition at line 4966 of file expr.cpp.

References AssertPos, Type::Equal(), Type::GetAsConstType(), int64Val, ASTNode::pos, type, and AtomicType::UniformInt64.

◆ ConstExpr() [18/24]

ConstExpr::ConstExpr ( const Type t,
int64_t *  i,
SourcePos  p 
)

Create a ConstExpr from a varying int64 value

Definition at line 4973 of file expr.cpp.

References AssertPos, Count(), Type::Equal(), Type::GetAsConstType(), int64Val, ASTNode::pos, type, AtomicType::UniformInt64, and AtomicType::VaryingInt64.

◆ ConstExpr() [19/24]

ConstExpr::ConstExpr ( const Type t,
uint64_t  i,
SourcePos  p 
)

Create a ConstExpr from a uniform uint64 value

Definition at line 4982 of file expr.cpp.

References AssertPos, Type::Equal(), Type::GetAsConstType(), ASTNode::pos, type, uint64Val, and AtomicType::UniformUInt64.

◆ ConstExpr() [20/24]

ConstExpr::ConstExpr ( const Type t,
uint64_t *  i,
SourcePos  p 
)

Create a ConstExpr from a varying uint64 value

Definition at line 4989 of file expr.cpp.

References AssertPos, Count(), Type::Equal(), Type::GetAsConstType(), ASTNode::pos, type, uint64Val, AtomicType::UniformUInt64, and AtomicType::VaryingUInt64.

◆ ConstExpr() [21/24]

ConstExpr::ConstExpr ( const Type t,
bool  b,
SourcePos  p 
)

Create a ConstExpr from a uniform bool value

Definition at line 5014 of file expr.cpp.

References AssertPos, boolVal, Type::Equal(), Type::GetAsConstType(), ASTNode::pos, type, and AtomicType::UniformBool.

◆ ConstExpr() [22/24]

ConstExpr::ConstExpr ( const Type t,
bool *  b,
SourcePos  p 
)

Create a ConstExpr from a varying bool value

Definition at line 5021 of file expr.cpp.

References AssertPos, boolVal, Count(), Type::Equal(), Type::GetAsConstType(), ASTNode::pos, type, AtomicType::UniformBool, and AtomicType::VaryingBool.

◆ ConstExpr() [23/24]

ConstExpr::ConstExpr ( ConstExpr old,
double *  values 
)

◆ ConstExpr() [24/24]

ConstExpr::ConstExpr ( ConstExpr old,
SourcePos  pos 
)

Member Function Documentation

◆ classof() [1/2]

static bool ConstExpr::classof ( ConstExpr const *  )
inlinestatic

Definition at line 423 of file expr.h.

◆ classof() [2/2]

static bool ConstExpr::classof ( ASTNode const *  N)
inlinestatic

Definition at line 424 of file expr.h.

References ASTNode::ConstExprID, and ASTNode::getValueID().

◆ Count()

int ConstExpr::Count ( ) const

Return the number of values in the ConstExpr; should be either 1, if it has uniform type, or the target's vector width if it's varying.

Definition at line 5657 of file expr.cpp.

References g, GetType(), Target::getVectorWidth(), Type::IsVaryingType(), and Globals::target.

Referenced by ConstExpr(), GetConstant(), GetValues(), lConstFoldBinaryArithOp(), lConstFoldBinaryIntOp(), lConstFoldBinaryLogicalOp(), lConstFoldBoolBinaryOp(), and Print().

◆ EstimateCost()

int ConstExpr::EstimateCost ( ) const
virtual

Estimate the execution cost of the node (not including the cost of the children. The value returned should be based on the COST_* enumerant values defined in ispc.h.

Implements ASTNode.

Definition at line 5773 of file expr.cpp.

◆ getBasicType()

AtomicType::BasicType ConstExpr::getBasicType ( ) const
private

Definition at line 5126 of file expr.cpp.

References AssertPos, AtomicType::basicType, ASTNode::pos, type, and AtomicType::TYPE_UINT32.

Referenced by ConstExpr(), GetValue(), GetValues(), and Print().

◆ GetConstant()

llvm::Constant * ConstExpr::GetConstant ( const Type type) const
virtual

◆ GetType()

const Type * ConstExpr::GetType ( ) const
virtual

Returns the Type of the expression.

Implements Expr.

Definition at line 5136 of file expr.cpp.

References type.

Referenced by Count(), lConstFoldBinaryArithOp(), lConstFoldBinaryIntOp(), lConstFoldBinaryLogicalOp(), lConstFoldBoolBinaryOp(), UnaryExpr::Optimize(), SelectExpr::Optimize(), and Print().

◆ GetValue()

llvm::Value * ConstExpr::GetValue ( FunctionEmitContext ctx) const
virtual

◆ GetValues() [1/11]

int ConstExpr::GetValues ( bool *  b,
bool  forceVarying = false 
) const

◆ GetValues() [2/11]

int ConstExpr::GetValues ( int8_t *  ip,
bool  forceVarying = false 
) const

◆ GetValues() [3/11]

int ConstExpr::GetValues ( uint8_t *  up,
bool  forceVarying = false 
) const

◆ GetValues() [4/11]

int ConstExpr::GetValues ( int16_t *  ip,
bool  forceVarying = false 
) const

◆ GetValues() [5/11]

int ConstExpr::GetValues ( uint16_t *  up,
bool  forceVarying = false 
) const

◆ GetValues() [6/11]

int ConstExpr::GetValues ( int32_t *  ip,
bool  forceVarying = false 
) const

◆ GetValues() [7/11]

int ConstExpr::GetValues ( uint32_t *  up,
bool  forceVarying = false 
) const

◆ GetValues() [8/11]

int ConstExpr::GetValues ( float *  fp,
bool  forceVarying = false 
) const

◆ GetValues() [9/11]

int ConstExpr::GetValues ( int64_t *  ip,
bool  forceVarying = false 
) const

◆ GetValues() [10/11]

int ConstExpr::GetValues ( uint64_t *  up,
bool  forceVarying = false 
) const

◆ GetValues() [11/11]

int ConstExpr::GetValues ( double *  d,
bool  forceVarying = false 
) const

◆ Optimize()

Expr * ConstExpr::Optimize ( )
virtual

This method should perform early optimizations of the expression (constant folding, etc.) and return a pointer to the resulting expression. If an error is encountered during optimization, NULL should be returned.

Implements Expr.

Definition at line 5769 of file expr.cpp.

◆ Print()

void ConstExpr::Print ( ) const
virtual

◆ TypeCheck()

Expr * ConstExpr::TypeCheck ( )
virtual

This method should perform type checking of the expression and return a pointer to the resulting expression. If an error is encountered, NULL should be returned.

Implements Expr.

Definition at line 5771 of file expr.cpp.

Member Data Documentation

◆ @1

union { ... }

◆ boolVal

bool ConstExpr::boolVal[ISPC_MAX_NVEC]

Definition at line 468 of file expr.h.

Referenced by ConstExpr(), GetValue(), GetValues(), and Print().

◆ doubleVal

double ConstExpr::doubleVal[ISPC_MAX_NVEC]

Definition at line 470 of file expr.h.

Referenced by ConstExpr(), GetValue(), GetValues(), and Print().

◆ floatVal

float ConstExpr::floatVal[ISPC_MAX_NVEC]

Definition at line 469 of file expr.h.

Referenced by ConstExpr(), GetValue(), GetValues(), and Print().

◆ int16Val

int16_t ConstExpr::int16Val[ISPC_MAX_NVEC]

Definition at line 464 of file expr.h.

Referenced by ConstExpr(), GetValue(), GetValues(), and Print().

◆ int32Val

int32_t ConstExpr::int32Val[ISPC_MAX_NVEC]

Definition at line 466 of file expr.h.

Referenced by ConstExpr(), GetValue(), GetValues(), and Print().

◆ int64Val

int64_t ConstExpr::int64Val[ISPC_MAX_NVEC]

Definition at line 471 of file expr.h.

Referenced by ConstExpr(), GetValue(), GetValues(), and Print().

◆ int8Val

int8_t ConstExpr::int8Val[ISPC_MAX_NVEC]

Definition at line 462 of file expr.h.

Referenced by ConstExpr(), GetValue(), GetValues(), and Print().

◆ type

const Type* ConstExpr::type
private

Definition at line 460 of file expr.h.

Referenced by ConstExpr(), getBasicType(), GetConstant(), GetType(), and GetValue().

◆ uint16Val

uint16_t ConstExpr::uint16Val[ISPC_MAX_NVEC]

Definition at line 465 of file expr.h.

Referenced by ConstExpr(), GetValue(), GetValues(), and Print().

◆ uint32Val

uint32_t ConstExpr::uint32Val[ISPC_MAX_NVEC]

Definition at line 467 of file expr.h.

Referenced by ConstExpr(), GetValue(), GetValues(), and Print().

◆ uint64Val

uint64_t ConstExpr::uint64Val[ISPC_MAX_NVEC]

Definition at line 472 of file expr.h.

Referenced by ConstExpr(), GetValue(), GetValues(), and Print().

◆ uint8Val

uint8_t ConstExpr::uint8Val[ISPC_MAX_NVEC]

Definition at line 463 of file expr.h.

Referenced by ConstExpr(), GetValue(), GetValues(), and Print().


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