clang  13.0.0git
Classes | Macros | Enumerations | Functions
CGExprScalar.cpp File Reference
#include "CGCXXABI.h"
#include "CGCleanup.h"
#include "CGDebugInfo.h"
#include "CGObjCRuntime.h"
#include "CGOpenMPRuntime.h"
#include "CodeGenFunction.h"
#include "CodeGenModule.h"
#include "ConstantEmitter.h"
#include "TargetInfo.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/Attr.h"
#include "clang/AST/DeclObjC.h"
#include "clang/AST/Expr.h"
#include "clang/AST/RecordLayout.h"
#include "clang/AST/StmtVisitor.h"
#include "clang/Basic/CodeGenOptions.h"
#include "clang/Basic/TargetInfo.h"
#include "llvm/ADT/APFixedPoint.h"
#include "llvm/ADT/Optional.h"
#include "llvm/IR/CFG.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/FixedPointBuilder.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/GetElementPtrTypeIterator.h"
#include "llvm/IR/GlobalVariable.h"
#include "llvm/IR/Intrinsics.h"
#include "llvm/IR/IntrinsicsPowerPC.h"
#include "llvm/IR/MatrixBuilder.h"
#include "llvm/IR/Module.h"
#include <cstdarg>
Include dependency graph for CGExprScalar.cpp:

Go to the source code of this file.

Classes

struct  GEPOffsetAndOverflow
 

Macros

#define HANDLEBINOP(OP)
 
#define VISITCOMP(CODE, UI, SI, FP, SIG)
 
#define COMPOUND_OP(Op)
 

Enumerations

enum  IntrinsicType { VCMPEQ, VCMPGT }
 

Functions

static std::pair< ScalarExprEmitter::ImplicitConversionCheckKind, std::pair< llvm::Value *, SanitizerMask > > EmitIntegerTruncationCheckHelper (Value *Src, QualType SrcType, Value *Dst, QualType DstType, CGBuilderTy &Builder)
 
static bool PromotionIsPotentiallyEligibleForImplicitIntegerConversionCheck (QualType SrcType, QualType DstType)
 
static std::pair< ScalarExprEmitter::ImplicitConversionCheckKind, std::pair< llvm::Value *, SanitizerMask > > EmitIntegerSignChangeCheckHelper (Value *Src, QualType SrcType, Value *Dst, QualType DstType, CGBuilderTy &Builder)
 
static int getMaskElt (llvm::ShuffleVectorInst *SVI, unsigned Idx, unsigned Off)
 
static int getAsInt32 (llvm::ConstantInt *C, llvm::Type *I32Ty)
 
static BinOpInfo createBinOpInfoFromIncDec (const UnaryOperator *E, llvm::Value *InVal, bool IsInc, FPOptions FPFeatures)
 
static ValueemitPointerArithmetic (CodeGenFunction &CGF, const BinOpInfo &op, bool isSubtraction)
 Emit pointer + index arithmetic. More...
 
static ValuebuildFMulAdd (llvm::Instruction *MulOp, Value *Addend, const CodeGenFunction &CGF, CGBuilderTy &Builder, bool negMul, bool negAdd)
 
static ValuetryEmitFMulAdd (const BinOpInfo &op, const CodeGenFunction &CGF, CGBuilderTy &Builder, bool isSub=false)
 
static llvm::Intrinsic::ID GetIntrinsic (IntrinsicType IT, BuiltinType::Kind ElemKind)
 
static bool isCheapEnoughToEvaluateUnconditionally (const Expr *E, CodeGenFunction &CGF)
 isCheapEnoughToEvaluateUnconditionally - Return true if the specified expression is cheap enough and side-effect-free enough to evaluate unconditionally instead of conditionally. More...
 
static ValueConvertVec3AndVec4 (CGBuilderTy &Builder, CodeGenFunction &CGF, Value *Src, unsigned NumElementsDst)
 
static ValuecreateCastsForTypeOfSameSize (CGBuilderTy &Builder, const llvm::DataLayout &DL, Value *Src, llvm::Type *DstTy, StringRef Name="")
 
static GEPOffsetAndOverflow EmitGEPOffsetInBytes (Value *BasePtr, Value *GEPVal, llvm::LLVMContext &VMContext, CodeGenModule &CGM, CGBuilderTy &Builder)
 Evaluate given GEPVal, which is either an inbounds GEP, or a constant, and compute the total offset it applies from it's base pointer BasePtr. More...
 

Macro Definition Documentation

◆ COMPOUND_OP

#define COMPOUND_OP (   Op)
Value:
case BO_##Op##Assign: \
return Scalar.EmitCompoundAssignLValue(E, &ScalarExprEmitter::Emit##Op, \
Result)

◆ HANDLEBINOP

#define HANDLEBINOP (   OP)
Value:
Value *VisitBin ## OP(const BinaryOperator *E) { \
return Emit ## OP(EmitBinOps(E)); \
} \
Value *VisitBin ## OP ## Assign(const CompoundAssignOperator *E) { \
return EmitCompoundAssign(E, &ScalarExprEmitter::Emit ## OP); \
}

Definition at line 801 of file CGExprScalar.cpp.

◆ VISITCOMP

#define VISITCOMP (   CODE,
  UI,
  SI,
  FP,
  SIG 
)
Value:
Value *VisitBin##CODE(const BinaryOperator *E) { \
return EmitCompare(E, llvm::ICmpInst::UI, llvm::ICmpInst::SI, \
llvm::FCmpInst::FP, SIG); }

Definition at line 824 of file CGExprScalar.cpp.

Enumeration Type Documentation

◆ IntrinsicType

Enumerator
VCMPEQ 
VCMPGT 

Definition at line 3968 of file CGExprScalar.cpp.

Function Documentation

◆ buildFMulAdd()

static Value* buildFMulAdd ( llvm::Instruction *  MulOp,
Value Addend,
const CodeGenFunction CGF,
CGBuilderTy Builder,
bool  negMul,
bool  negAdd 
)
static

Definition at line 3508 of file CGExprScalar.cpp.

◆ ConvertVec3AndVec4()

static Value* ConvertVec3AndVec4 ( CGBuilderTy Builder,
CodeGenFunction CGF,
Value Src,
unsigned  NumElementsDst 
)
static

Definition at line 4703 of file CGExprScalar.cpp.

◆ createBinOpInfoFromIncDec()

static BinOpInfo createBinOpInfoFromIncDec ( const UnaryOperator E,
llvm::Value InVal,
bool  IsInc,
FPOptions  FPFeatures 
)
static

Definition at line 2412 of file CGExprScalar.cpp.

References clang::Expr::getType().

◆ createCastsForTypeOfSameSize()

static Value* createCastsForTypeOfSameSize ( CGBuilderTy Builder,
const llvm::DataLayout &  DL,
Value Src,
llvm::Type *  DstTy,
StringRef  Name = "" 
)
static

Definition at line 4726 of file CGExprScalar.cpp.

◆ EmitGEPOffsetInBytes()

static GEPOffsetAndOverflow EmitGEPOffsetInBytes ( Value BasePtr,
Value GEPVal,
llvm::LLVMContext &  VMContext,
CodeGenModule CGM,
CGBuilderTy Builder 
)
static

Evaluate given GEPVal, which is either an inbounds GEP, or a constant, and compute the total offset it applies from it's base pointer BasePtr.

Returns offset in bytes and a boolean flag whether an overflow happened during evaluation.

Return the result of the given binary operation.

Definition at line 4930 of file CGExprScalar.cpp.

◆ EmitIntegerSignChangeCheckHelper()

static std::pair<ScalarExprEmitter::ImplicitConversionCheckKind, std::pair<llvm::Value *, SanitizerMask> > EmitIntegerSignChangeCheckHelper ( Value Src,
QualType  SrcType,
Value Dst,
QualType  DstType,
CGBuilderTy Builder 
)
static

Definition at line 1062 of file CGExprScalar.cpp.

◆ EmitIntegerTruncationCheckHelper()

static std::pair<ScalarExprEmitter::ImplicitConversionCheckKind, std::pair<llvm::Value *, SanitizerMask> > EmitIntegerTruncationCheckHelper ( Value Src,
QualType  SrcType,
Value Dst,
QualType  DstType,
CGBuilderTy Builder 
)
static

Definition at line 968 of file CGExprScalar.cpp.

◆ emitPointerArithmetic()

static Value* emitPointerArithmetic ( CodeGenFunction CGF,
const BinOpInfo &  op,
bool  isSubtraction 
)
static

◆ getAsInt32()

static int getAsInt32 ( llvm::ConstantInt *  C,
llvm::Type *  I32Ty 
)
static

Definition at line 1795 of file CGExprScalar.cpp.

◆ GetIntrinsic()

static llvm::Intrinsic::ID GetIntrinsic ( IntrinsicType  IT,
BuiltinType::Kind  ElemKind 
)
static

Definition at line 3970 of file CGExprScalar.cpp.

References VCMPEQ.

◆ getMaskElt()

static int getMaskElt ( llvm::ShuffleVectorInst *  SVI,
unsigned  Idx,
unsigned  Off 
)
static

Definition at line 1787 of file CGExprScalar.cpp.

◆ isCheapEnoughToEvaluateUnconditionally()

static bool isCheapEnoughToEvaluateUnconditionally ( const Expr E,
CodeGenFunction CGF 
)
static

isCheapEnoughToEvaluateUnconditionally - Return true if the specified expression is cheap enough and side-effect-free enough to evaluate unconditionally instead of conditionally.

This is used to convert control flow into selects in some cases.

Definition at line 4500 of file CGExprScalar.cpp.

References clang::CodeGen::CodeGenFunction::getContext(), clang::Expr::IgnoreParens(), and clang::Expr::isEvaluatable().

◆ PromotionIsPotentiallyEligibleForImplicitIntegerConversionCheck()

static bool PromotionIsPotentiallyEligibleForImplicitIntegerConversionCheck ( QualType  SrcType,
QualType  DstType 
)
static

Definition at line 1004 of file CGExprScalar.cpp.

References clang::Type::isIntegerType().

◆ tryEmitFMulAdd()

static Value* tryEmitFMulAdd ( const BinOpInfo &  op,
const CodeGenFunction CGF,
CGBuilderTy Builder,
bool  isSub = false 
)
static

Definition at line 3545 of file CGExprScalar.cpp.

EmitCompare
static llvm::Value * EmitCompare(CGBuilderTy &Builder, CodeGenFunction &CGF, const BinaryOperator *E, llvm::Value *LHS, llvm::Value *RHS, CompareKind Kind, const char *NameSuffix="")
Definition: CGExprAgg.cpp:950
clang::BinaryOperator
A builtin binary operation expression such as "x + y" or "x <= y".
Definition: Expr.h:3787
Value
Value
Definition: UninitializedValues.cpp:102
clang::CompoundAssignOperator
CompoundAssignOperator - For compound assignments (e.g.
Definition: Expr.h:4034