clang 22.0.0git
Macros | Functions
CIRGenExprScalar.cpp File Reference
#include "CIRGenFunction.h"
#include "CIRGenValue.h"
#include "clang/AST/Expr.h"
#include "clang/AST/StmtVisitor.h"
#include "clang/CIR/MissingFeatures.h"
#include "mlir/IR/Location.h"
#include "mlir/IR/Value.h"
#include <cassert>
#include <utility>

Go to the source code of this file.

Macros

#define HANDLEBINOP(OP)
 
#define VISITCOMP(CODE)    mlir::Value VisitBin##CODE(const BinaryOperator *E) { return emitCmp(E); }
 
#define HANDLE_BINOP(OP)
 
#define COMPOUND_OP(Op)
 

Functions

static bool mustVisitNullValue (const Expr *e)
 
static std::optional< QualTypegetUnwidenedIntegerType (const ASTContext &astContext, const Expr *e)
 If e is a widened promoted integer, get its base (unpromoted) type.
 
static bool isWidenedIntegerOp (const ASTContext &astContext, const Expr *e)
 Check if e is a widened promoted integer.
 
static bool canElideOverflowCheck (const ASTContext &astContext, const BinOpInfo &op)
 Check if we can skip the overflow check for Op.
 
static mlir::Value emitPointerArithmetic (CIRGenFunction &cgf, const BinOpInfo &op, bool isSubtraction)
 Emit pointer + index arithmetic.
 
static bool isCheapEnoughToEvaluateUnconditionally (const Expr *e, CIRGenFunction &cgf)
 Return true if the specified expression is cheap enough and side-effect-free enough to evaluate unconditionally instead of conditionally.
 

Macro Definition Documentation

◆ COMPOUND_OP

#define COMPOUND_OP (   Op)
Value:
case BO_##Op##Assign: \
return emitter.emitCompoundAssignLValue(e, &ScalarExprEmitter::emit##Op, \
result)

◆ HANDLE_BINOP

#define HANDLE_BINOP (   OP)
Value:
case BO_##OP: \
return emit##OP(emitBinOps(bo, promotionType));
static void emit(Program &P, llvm::SmallVectorImpl< std::byte > &Code, const T &Val, bool &Success)
Helper to write bytecode and bail out if 32-bit offsets become invalid.

◆ HANDLEBINOP

#define HANDLEBINOP (   OP)
Value:
mlir::Value VisitBin##OP(const BinaryOperator *e) { \
QualType promotionTy = getPromotionType(e->getType()); \
auto result = emit##OP(emitBinOps(e, promotionTy)); \
if (result && !promotionTy.isNull()) \
result = emitUnPromotedValue(result, e->getType()); \
return result; \
} \
mlir::Value VisitBin##OP##Assign(const CompoundAssignOperator *e) { \
return emitCompoundAssign(e, &ScalarExprEmitter::emit##OP); \
}
A builtin binary operation expression such as "x + y" or "x <= y".
Definition: Expr.h:3974
CompoundAssignOperator - For compound assignments (e.g.
Definition: Expr.h:4236
QualType getType() const
Definition: Expr.h:144
A (possibly-)qualified type.
Definition: TypeBase.h:937
bool isNull() const
Return true if this QualType doesn't point to a type yet.
Definition: TypeBase.h:1004

Definition at line 870 of file CIRGenExprScalar.cpp.

◆ VISITCOMP

#define VISITCOMP (   CODE)     mlir::Value VisitBin##CODE(const BinaryOperator *E) { return emitCmp(E); }

Definition at line 972 of file CIRGenExprScalar.cpp.

Function Documentation

◆ canElideOverflowCheck()

static bool canElideOverflowCheck ( const ASTContext astContext,
const BinOpInfo &  op 
)
static

Check if we can skip the overflow check for Op.

Definition at line 1385 of file CIRGenExprScalar.cpp.

References clang::ASTContext::getTypeSize(), getUnwidenedIntegerType(), and clang::Type::isUnsignedIntegerType().

◆ emitPointerArithmetic()

static mlir::Value emitPointerArithmetic ( CIRGenFunction cgf,
const BinOpInfo &  op,
bool  isSubtraction 
)
static

◆ getUnwidenedIntegerType()

static std::optional< QualType > getUnwidenedIntegerType ( const ASTContext astContext,
const Expr e 
)
static

If e is a widened promoted integer, get its base (unpromoted) type.

Definition at line 1365 of file CIRGenExprScalar.cpp.

References clang::Expr::getType(), clang::ASTContext::getTypeSize(), clang::Expr::IgnoreImpCasts(), and clang::ASTContext::isPromotableIntegerType().

Referenced by canElideOverflowCheck(), and isWidenedIntegerOp().

◆ isCheapEnoughToEvaluateUnconditionally()

static bool isCheapEnoughToEvaluateUnconditionally ( const Expr e,
CIRGenFunction cgf 
)
static

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. TODO(cir): can be shared with LLVM codegen.

Definition at line 2121 of file CIRGenExprScalar.cpp.

References clang::CIRGen::CIRGenFunction::getContext(), clang::Expr::IgnoreParens(), and clang::Expr::isEvaluatable().

◆ isWidenedIntegerOp()

static bool isWidenedIntegerOp ( const ASTContext astContext,
const Expr e 
)
static

Check if e is a widened promoted integer.

Definition at line 1379 of file CIRGenExprScalar.cpp.

References getUnwidenedIntegerType().

◆ mustVisitNullValue()

static bool mustVisitNullValue ( const Expr e)
static

Definition at line 1354 of file CIRGenExprScalar.cpp.

References clang::Expr::getType(), and clang::Type::isNullPtrType().