FLANG
Public Member Functions | List of all members
SelectCaseOpConversion Struct Reference
Inheritance diagram for SelectCaseOpConversion:
fir::FIROpConversion< fir::SelectCaseOp > fir::ConvertFIRToLLVMPattern

Public Member Functions

llvm::LogicalResult matchAndRewrite (fir::SelectCaseOp caseOp, OpAdaptor adaptor, mlir::ConversionPatternRewriter &rewriter) const override
 
- Public Member Functions inherited from fir::FIROpConversion< fir::SelectCaseOp >
 FIROpConversion (const LLVMTypeConverter &typeConverter, const fir::FIRToLLVMPassOptions &options, mlir::PatternBenefit benefit=1)
 
void rewrite (mlir::Operation *op, mlir::ArrayRef< mlir::Value > operands, mlir::ConversionPatternRewriter &rewriter) const final
 Wrappers around the RewritePattern methods that pass the derived op type.
 
void rewrite (mlir::Operation *op, mlir::ArrayRef< mlir::ValueRange > operands, mlir::ConversionPatternRewriter &rewriter) const final
 
virtual void rewrite (fir::SelectCaseOp op, OpAdaptor adaptor, mlir::ConversionPatternRewriter &rewriter) const
 
virtual void rewrite (fir::SelectCaseOp op, OneToNOpAdaptor adaptor, mlir::ConversionPatternRewriter &rewriter) const
 
llvm::LogicalResult match (mlir::Operation *op) const final
 
virtual llvm::LogicalResult match (fir::SelectCaseOp op) const
 
llvm::LogicalResult matchAndRewrite (mlir::Operation *op, mlir::ArrayRef< mlir::Value > operands, mlir::ConversionPatternRewriter &rewriter) const final
 
llvm::LogicalResult matchAndRewrite (mlir::Operation *op, mlir::ArrayRef< mlir::ValueRange > operands, mlir::ConversionPatternRewriter &rewriter) const final
 
virtual llvm::LogicalResult matchAndRewrite (fir::SelectCaseOp op, OpAdaptor adaptor, mlir::ConversionPatternRewriter &rewriter) const
 
virtual llvm::LogicalResult matchAndRewrite (fir::SelectCaseOp op, OneToNOpAdaptor adaptor, mlir::ConversionPatternRewriter &rewriter) const
 
- Public Member Functions inherited from fir::ConvertFIRToLLVMPattern
 ConvertFIRToLLVMPattern (llvm::StringRef rootOpName, mlir::MLIRContext *context, const fir::LLVMTypeConverter &typeConverter, const fir::FIRToLLVMPassOptions &options, mlir::PatternBenefit benefit=1)
 

Additional Inherited Members

- Public Types inherited from fir::FIROpConversion< fir::SelectCaseOp >
using OpAdaptor = typename SourceOp::Adaptor
 
using OneToNOpAdaptor = typename SourceOp::template GenericAdaptor< mlir::ArrayRef< mlir::ValueRange > >
 
- Protected Member Functions inherited from fir::ConvertFIRToLLVMPattern
mlir::Type convertType (mlir::Type ty) const
 
mlir::Type convertObjectType (mlir::Type firType) const
 
mlir::LLVM::ConstantOp genI32Constant (mlir::Location loc, mlir::ConversionPatternRewriter &rewriter, int value) const
 
mlir::LLVM::ConstantOp genConstantOffset (mlir::Location loc, mlir::ConversionPatternRewriter &rewriter, int offset) const
 
mlir::Value integerCast (mlir::Location loc, mlir::ConversionPatternRewriter &rewriter, mlir::Type ty, mlir::Value val, bool fold=false) const
 
TypePair getBoxTypePair (mlir::Type firBoxTy) const
 
mlir::Value getValueFromBox (mlir::Location loc, TypePair boxTy, mlir::Value box, mlir::Type resultTy, mlir::ConversionPatternRewriter &rewriter, int boxValue) const
 Construct code sequence to extract the specific value from a fir.box.
 
llvm::SmallVector< mlir::Value, 3 > getDimsFromBox (mlir::Location loc, llvm::ArrayRef< mlir::Type > retTys, TypePair boxTy, mlir::Value box, mlir::Value dim, mlir::ConversionPatternRewriter &rewriter) const
 
llvm::SmallVector< mlir::Value, 3 > getDimsFromBox (mlir::Location loc, llvm::ArrayRef< mlir::Type > retTys, TypePair boxTy, mlir::Value box, int dim, mlir::ConversionPatternRewriter &rewriter) const
 
mlir::Value loadDimFieldFromBox (mlir::Location loc, TypePair boxTy, mlir::Value box, mlir::Value dim, int off, mlir::Type ty, mlir::ConversionPatternRewriter &rewriter) const
 
mlir::Value getDimFieldFromBox (mlir::Location loc, TypePair boxTy, mlir::Value box, int dim, int off, mlir::Type ty, mlir::ConversionPatternRewriter &rewriter) const
 
mlir::Value getStrideFromBox (mlir::Location loc, TypePair boxTy, mlir::Value box, unsigned dim, mlir::ConversionPatternRewriter &rewriter) const
 
mlir::Value getBaseAddrFromBox (mlir::Location loc, TypePair boxTy, mlir::Value box, mlir::ConversionPatternRewriter &rewriter) const
 Read base address from a fir.box. Returned address has type ty.
 
mlir::Value getElementSizeFromBox (mlir::Location loc, mlir::Type resultTy, TypePair boxTy, mlir::Value box, mlir::ConversionPatternRewriter &rewriter) const
 
mlir::Value getRankFromBox (mlir::Location loc, TypePair boxTy, mlir::Value box, mlir::ConversionPatternRewriter &rewriter) const
 Read base address from a fir.box. Returned address has type ty.
 
mlir::Value getExtraFromBox (mlir::Location loc, TypePair boxTy, mlir::Value box, mlir::ConversionPatternRewriter &rewriter) const
 Read the extra field from a fir.box.
 
mlir::Type getBoxEleTy (mlir::Type type, llvm::ArrayRef< std::int64_t > indexes) const
 
mlir::Type getLlvmObjectTypeFromBoxType (mlir::Type boxType) const
 
mlir::Value loadTypeDescAddress (mlir::Location loc, TypePair boxTy, mlir::Value box, mlir::ConversionPatternRewriter &rewriter) const
 Read the address of the type descriptor from a box.
 
mlir::Value genBoxAttributeCheck (mlir::Location loc, TypePair boxTy, mlir::Value box, mlir::ConversionPatternRewriter &rewriter, unsigned maskValue) const
 
mlir::Value computeBoxSize (mlir::Location, TypePair boxTy, mlir::Value box, mlir::ConversionPatternRewriter &rewriter) const
 
template<typename... ARGS>
mlir::LLVM::GEPOp genGEP (mlir::Location loc, mlir::Type ty, mlir::ConversionPatternRewriter &rewriter, mlir::Value base, ARGS... args) const
 
mlir::Block * getBlockForAllocaInsert (mlir::Operation *op, mlir::Region *parentRegion) const
 
mlir::Value genAllocaAndAddrCastWithType (mlir::Location loc, mlir::Type llvmObjectTy, unsigned alignment, mlir::ConversionPatternRewriter &rewriter) const
 
const fir::LLVMTypeConverterlowerTy () const
 
void attachTBAATag (mlir::LLVM::AliasAnalysisOpInterface op, mlir::Type baseFIRType, mlir::Type accessFIRType, mlir::LLVM::GEPOp gep) const
 
unsigned getAllocaAddressSpace (mlir::ConversionPatternRewriter &rewriter) const
 
unsigned getProgramAddressSpace (mlir::ConversionPatternRewriter &rewriter) const
 
- Protected Attributes inherited from fir::ConvertFIRToLLVMPattern
const fir::FIRToLLVMPassOptionsoptions
 

Detailed Description

Conversion of fir.select_case

The fir.select_case operation is converted to a if-then-else ladder. Depending on the case condition type, one or several comparison and conditional branching can be generated.

A point value case such as case(4), a lower bound case such as case(5:) or an upper bound case such as case(:3) are converted to a simple comparison between the selector value and the constant value in the case. The block associated with the case condition is then executed if the comparison succeed otherwise it branch to the next block with the comparison for the next case conditon.

A closed interval case condition such as case(7:10) is converted with a first comparison and conditional branching for the lower bound. If successful, it branch to a second block with the comparison for the upper bound in the same case condition.

TODO: lowering of CHARACTER type cases is not handled yet.

Member Function Documentation

◆ matchAndRewrite()

llvm::LogicalResult SelectCaseOpConversion::matchAndRewrite ( fir::SelectCaseOp  caseOp,
OpAdaptor  adaptor,
mlir::ConversionPatternRewriter &  rewriter 
) const
inlineoverridevirtual

The documentation for this struct was generated from the following file: