clang 23.0.0git
LoweringPrepare.cpp File Reference
#include "PassDetail.h"
#include "mlir/IR/Attributes.h"
#include "mlir/IR/BuiltinAttributeInterfaces.h"
#include "mlir/IR/IRMapping.h"
#include "mlir/IR/Location.h"
#include "mlir/IR/Value.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/Mangle.h"
#include "clang/Basic/Cuda.h"
#include "clang/Basic/Module.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Basic/Specifiers.h"
#include "clang/Basic/TargetCXXABI.h"
#include "clang/Basic/TargetInfo.h"
#include "clang/CIR/Dialect/Builder/CIRBaseBuilder.h"
#include "clang/CIR/Dialect/IR/CIRAttrs.h"
#include "clang/CIR/Dialect/IR/CIRDataLayout.h"
#include "clang/CIR/Dialect/IR/CIRDialect.h"
#include "clang/CIR/Dialect/IR/CIROpsEnums.h"
#include "clang/CIR/Dialect/IR/CIRTypes.h"
#include "clang/CIR/Dialect/Passes.h"
#include "clang/CIR/Interfaces/ASTAttrInterfaces.h"
#include "clang/CIR/MissingFeatures.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/TypeSwitch.h"
#include "llvm/IR/Instructions.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/VirtualFileSystem.h"
#include <memory>
#include <optional>
#include "clang/CIR/Dialect/Passes.h.inc"

Go to the source code of this file.

Namespaces

namespace  mlir

Macros

#define GEN_PASS_DEF_LOWERINGPREPARE

Functions

static SmallString< 128 > getTransformedFileName (mlir::ModuleOp mlirModule)
static cir::FuncOp getCalledFunction (cir::CallOp callOp)
 Return the FuncOp called by callOp.
static mlir::Value lowerScalarToComplexCast (mlir::MLIRContext &ctx, cir::CastOp op)
static mlir::Value lowerComplexToScalarCast (mlir::MLIRContext &ctx, cir::CastOp op, cir::CastKind elemToBoolKind)
static mlir::Value lowerComplexToComplexCast (mlir::MLIRContext &ctx, cir::CastOp op, cir::CastKind scalarCastKind)
static mlir::Value buildComplexBinOpLibCall (LoweringPreparePass &pass, CIRBaseBuilderTy &builder, llvm::StringRef(*libFuncNameGetter)(llvm::APFloat::Semantics), mlir::Location loc, cir::ComplexType ty, mlir::Value lhsReal, mlir::Value lhsImag, mlir::Value rhsReal, mlir::Value rhsImag)
static llvm::StringRef getComplexDivLibCallName (llvm::APFloat::Semantics semantics)
static mlir::Value buildAlgebraicComplexDiv (CIRBaseBuilderTy &builder, mlir::Location loc, mlir::Value lhsReal, mlir::Value lhsImag, mlir::Value rhsReal, mlir::Value rhsImag)
static mlir::Value buildRangeReductionComplexDiv (CIRBaseBuilderTy &builder, mlir::Location loc, mlir::Value lhsReal, mlir::Value lhsImag, mlir::Value rhsReal, mlir::Value rhsImag)
static mlir::Type higherPrecisionElementTypeForComplexArithmetic (mlir::MLIRContext &context, clang::ASTContext &cc, CIRBaseBuilderTy &builder, mlir::Type elementType)
static mlir::Value lowerComplexDiv (LoweringPreparePass &pass, CIRBaseBuilderTy &builder, mlir::Location loc, cir::ComplexDivOp op, mlir::Value lhsReal, mlir::Value lhsImag, mlir::Value rhsReal, mlir::Value rhsImag, mlir::MLIRContext &mlirCx, clang::ASTContext &cc)
static llvm::StringRef getComplexMulLibCallName (llvm::APFloat::Semantics semantics)
static mlir::Value lowerComplexMul (LoweringPreparePass &pass, CIRBaseBuilderTy &builder, mlir::Location loc, cir::ComplexMulOp op, mlir::Value lhsReal, mlir::Value lhsImag, mlir::Value rhsReal, mlir::Value rhsImag)
template<typename AttributeTy>
static llvm::SmallVector< mlir::Attribute > prepareCtorDtorAttrList (mlir::MLIRContext *context, llvm::ArrayRef< std::pair< std::string, uint32_t > > list)
static void lowerArrayDtorCtorIntoLoop (cir::CIRBaseBuilderTy &builder, clang::ASTContext *astCtx, mlir::Operation *op, mlir::Type eltTy, mlir::Value addr, mlir::Value numElements, uint64_t arrayLen, bool isCtor)
 Lower a cir.array.ctor or cir.array.dtor into a do-while loop that iterates over every element.
static llvm::StringRef getCUDAPrefix (clang::ASTContext *astCtx)
static std::string addUnderscoredPrefix (llvm::StringRef prefix, llvm::StringRef name)

Macro Definition Documentation

◆ GEN_PASS_DEF_LOWERINGPREPARE

#define GEN_PASS_DEF_LOWERINGPREPARE

Definition at line 47 of file LoweringPrepare.cpp.

Function Documentation

◆ addUnderscoredPrefix()

std::string addUnderscoredPrefix ( llvm::StringRef prefix,
llvm::StringRef name )
static

Definition at line 1769 of file LoweringPrepare.cpp.

◆ buildAlgebraicComplexDiv()

◆ buildComplexBinOpLibCall()

mlir::Value buildComplexBinOpLibCall ( LoweringPreparePass & pass,
CIRBaseBuilderTy & builder,
llvm::StringRef(* libFuncNameGetter )(llvm::APFloat::Semantics),
mlir::Location loc,
cir::ComplexType ty,
mlir::Value lhsReal,
mlir::Value lhsImag,
mlir::Value rhsReal,
mlir::Value rhsImag )
static

Definition at line 456 of file LoweringPrepare.cpp.

References cir::CIRBaseBuilderTy::createCallOp().

Referenced by lowerComplexDiv(), and lowerComplexMul().

◆ buildRangeReductionComplexDiv()

◆ getCalledFunction()

cir::FuncOp getCalledFunction ( cir::CallOp callOp)
static

Return the FuncOp called by callOp.

Definition at line 71 of file LoweringPrepare.cpp.

◆ getComplexDivLibCallName()

llvm::StringRef getComplexDivLibCallName ( llvm::APFloat::Semantics semantics)
static

Definition at line 485 of file LoweringPrepare.cpp.

Referenced by lowerComplexDiv().

◆ getComplexMulLibCallName()

llvm::StringRef getComplexMulLibCallName ( llvm::APFloat::Semantics semantics)
static

Definition at line 746 of file LoweringPrepare.cpp.

Referenced by lowerComplexMul().

◆ getCUDAPrefix()

llvm::StringRef getCUDAPrefix ( clang::ASTContext * astCtx)
static

Definition at line 1763 of file LoweringPrepare.cpp.

References clang::ASTContext::getLangOpts().

◆ getTransformedFileName()

SmallString< 128 > getTransformedFileName ( mlir::ModuleOp mlirModule)
static

Definition at line 51 of file LoweringPrepare.cpp.

References clang::isPreprocessingNumberBody().

◆ higherPrecisionElementTypeForComplexArithmetic()

◆ lowerArrayDtorCtorIntoLoop()

void lowerArrayDtorCtorIntoLoop ( cir::CIRBaseBuilderTy & builder,
clang::ASTContext * astCtx,
mlir::Operation * op,
mlir::Type eltTy,
mlir::Value addr,
mlir::Value numElements,
uint64_t arrayLen,
bool isCtor )
static

Lower a cir.array.ctor or cir.array.dtor into a do-while loop that iterates over every element.

For cir.array.ctor ops whose partial_dtor region is non-empty, the ctor loop is wrapped in a cir.cleanup.scope whose EH cleanup performs a reverse destruction loop using the partial dtor body.

Definition at line 1412 of file LoweringPrepare.cpp.

References b, cir::CIRBaseBuilderTy::createAlloca(), cir::CIRBaseBuilderTy::createCondition(), cir::CIRBaseBuilderTy::createDoWhile(), cir::CIRBaseBuilderTy::createStore(), cir::CIRBaseBuilderTy::createYield(), cir::CIRBaseBuilderTy::getAlignmentAttr(), cir::CIRBaseBuilderTy::getPointerTo(), cir::CIRBaseBuilderTy::getSignedInt(), clang::ASTContext::getSignedSizeType(), clang::ASTContext::getTypeSize(), and cir::CIRBaseBuilderTy::getUnsignedInt().

◆ lowerComplexDiv()

◆ lowerComplexMul()

◆ lowerComplexToComplexCast()

mlir::Value lowerComplexToComplexCast ( mlir::MLIRContext & ctx,
cir::CastOp op,
cir::CastKind scalarCastKind )
static

◆ lowerComplexToScalarCast()

mlir::Value lowerComplexToScalarCast ( mlir::MLIRContext & ctx,
cir::CastOp op,
cir::CastKind elemToBoolKind )
static

◆ lowerScalarToComplexCast()

mlir::Value lowerScalarToComplexCast ( mlir::MLIRContext & ctx,
cir::CastOp op )
static

◆ prepareCtorDtorAttrList()

template<typename AttributeTy>
llvm::SmallVector< mlir::Attribute > prepareCtorDtorAttrList ( mlir::MLIRContext * context,
llvm::ArrayRef< std::pair< std::string, uint32_t > > list )
static

Definition at line 1338 of file LoweringPrepare.cpp.