clang 22.0.0git
CIRDialect.cpp File Reference
#include "clang/CIR/Dialect/IR/CIRDialect.h"
#include "clang/CIR/Dialect/IR/CIROpsEnums.h"
#include "clang/CIR/Dialect/IR/CIRTypes.h"
#include "mlir/IR/DialectImplementation.h"
#include "mlir/Interfaces/ControlFlowInterfaces.h"
#include "mlir/Interfaces/FunctionImplementation.h"
#include "mlir/Support/LLVM.h"
#include "clang/CIR/Dialect/IR/CIROpsDialect.cpp.inc"
#include "clang/CIR/Dialect/IR/CIROpsEnums.cpp.inc"
#include "clang/CIR/MissingFeatures.h"
#include "llvm/ADT/SetOperations.h"
#include "llvm/ADT/SmallSet.h"
#include "llvm/Support/LogicalResult.h"
#include "clang/CIR/Dialect/IR/CIROps.cpp.inc"

Go to the source code of this file.

Macros

#define GET_OP_LIST
#define REGISTER_ENUM_TYPE(Ty)
#define GET_OP_CLASSES

Functions

static int parseOptionalKeywordAlternative (AsmParser &parser, ArrayRef< llvm::StringRef > keywords)
template<typename EnumTy, typename RetTy = EnumTy>
static RetTy parseOptionalCIRKeyword (AsmParser &parser, EnumTy defaultValue)
 Parse an enum from the keyword, or default to the provided default value.
template<typename EnumTy, typename RetTy = EnumTy>
static ParseResult parseCIRKeyword (AsmParser &parser, RetTy &result)
 Parse an enum from the keyword, return failure if the keyword is not found.
static LogicalResult ensureRegionTerm (OpAsmParser &parser, Region &region, SMLoc errLoc)
static bool omitRegionTerm (mlir::Region &r)
void printVisibilityAttr (OpAsmPrinter &printer, cir::VisibilityAttr &visibility)
void parseVisibilityAttr (OpAsmParser &parser, cir::VisibilityAttr &visibility)
static mlir::ParseResult parseOmittedTerminatorRegion (mlir::OpAsmParser &parser, mlir::Region &region)
static void printOmittedTerminatorRegion (mlir::OpAsmPrinter &printer, cir::ScopeOp &op, mlir::Region &region)
static LogicalResult checkConstantTypes (mlir::Operation *op, mlir::Type opType, mlir::Attribute attrType)
static bool isIntOrBoolCast (cir::CastOp op)
static Value tryFoldCastChain (cir::CastOp op)
static mlir::ParseResult parseCallCommon (mlir::OpAsmParser &parser, mlir::OperationState &result)
static void printCallCommon (mlir::Operation *op, mlir::FlatSymbolRefAttr calleeSym, mlir::Value indirectCallee, mlir::OpAsmPrinter &printer, bool isNothrow, cir::SideEffect sideEffect)
static LogicalResult verifyCallCommInSymbolUses (mlir::Operation *op, SymbolTableCollection &symbolTable)
static mlir::LogicalResult checkReturnAndFunction (cir::ReturnOp op, cir::FuncOp function)
static ParseResult parseSwitchOp (OpAsmParser &parser, mlir::Region &regions, mlir::OpAsmParser::UnresolvedOperand &cond, mlir::Type &condType)
static void printSwitchOp (OpAsmPrinter &p, cir::SwitchOp op, mlir::Region &bodyRegion, mlir::Value condition, mlir::Type condType)
static ParseResult parseSwitchFlatOpCases (OpAsmParser &parser, Type flagType, mlir::ArrayAttr &caseValues, SmallVectorImpl< Block * > &caseDestinations, SmallVectorImpl< llvm::SmallVector< OpAsmParser::UnresolvedOperand > > &caseOperands, SmallVectorImpl< llvm::SmallVector< Type > > &caseOperandTypes)
 <cases> ::= [ (case (, case )* )?
static void printSwitchFlatOpCases (OpAsmPrinter &p, cir::SwitchFlatOp op, Type flagType, mlir::ArrayAttr caseValues, SuccessorRange caseDestinations, OperandRangeRange caseOperands, const TypeRangeRange &caseOperandTypes)
static ParseResult parseConstantValue (OpAsmParser &parser, mlir::Attribute &valueAttr)
static void printConstant (OpAsmPrinter &p, Attribute value)
static void printGlobalOpTypeAndInitialValue (OpAsmPrinter &p, cir::GlobalOp op, TypeAttr type, Attribute initAttr, mlir::Region &ctorRegion, mlir::Region &dtorRegion)
static ParseResult parseGlobalOpTypeAndInitialValue (OpAsmParser &parser, TypeAttr &typeAttr, Attribute &initialValueAttr, mlir::Region &ctorRegion, mlir::Region &dtorRegion)
static llvm::StringRef getLinkageAttrNameString ()
 Returns the name used for the linkage attribute.
static bool isBoolNot (cir::UnaryOp op)
static OpFoldResult foldUnaryBitOp (mlir::Attribute inputAttr, llvm::function_ref< llvm::APInt(const llvm::APInt &)> func, bool poisonZero=false)
static void printTryHandlerRegions (mlir::OpAsmPrinter &printer, cir::TryOp op, mlir::MutableArrayRef< mlir::Region > handlerRegions, mlir::ArrayAttr handlerTypes)
static mlir::ParseResult parseTryHandlerRegions (mlir::OpAsmParser &parser, llvm::SmallVectorImpl< std::unique_ptr< mlir::Region > > &handlerRegions, mlir::ArrayAttr &handlerTypes)

Macro Definition Documentation

◆ GET_OP_CLASSES

#define GET_OP_CLASSES

Definition at line 3082 of file CIRDialect.cpp.

◆ GET_OP_LIST

#define GET_OP_LIST

◆ REGISTER_ENUM_TYPE

#define REGISTER_ENUM_TYPE ( Ty)
Value:
template <> struct EnumTraits<cir::Ty> { \
static llvm::StringRef stringify(cir::Ty value) { \
return stringify##Ty(value); \
} \
static unsigned getMaxEnumVal() { return cir::getMaxEnumValFor##Ty(); } \
}

Definition at line 121 of file CIRDialect.cpp.

Function Documentation

◆ checkConstantTypes()

LogicalResult checkConstantTypes ( mlir::Operation * op,
mlir::Type opType,
mlir::Attribute attrType )
static

Definition at line 312 of file CIRDialect.cpp.

◆ checkReturnAndFunction()

mlir::LogicalResult checkReturnAndFunction ( cir::ReturnOp op,
cir::FuncOp function )
static

Definition at line 885 of file CIRDialect.cpp.

◆ ensureRegionTerm()

LogicalResult ensureRegionTerm ( OpAsmParser & parser,
Region & region,
SMLoc errLoc )
static

◆ foldUnaryBitOp()

OpFoldResult foldUnaryBitOp ( mlir::Attribute inputAttr,
llvm::function_ref< llvm::APInt(const llvm::APInt &)> func,
bool poisonZero = false )
static

Definition at line 2584 of file CIRDialect.cpp.

◆ getLinkageAttrNameString()

llvm::StringRef getLinkageAttrNameString ( )
static

Returns the name used for the linkage attribute.

This must correspond to the name of the attribute in ODS.

Definition at line 1619 of file CIRDialect.cpp.

◆ isBoolNot()

bool isBoolNot ( cir::UnaryOp op)
static

Definition at line 2081 of file CIRDialect.cpp.

◆ isIntOrBoolCast()

bool isIntOrBoolCast ( cir::CastOp op)
static

Definition at line 603 of file CIRDialect.cpp.

Referenced by tryFoldCastChain().

◆ omitRegionTerm()

bool omitRegionTerm ( mlir::Region & r)
static

Definition at line 192 of file CIRDialect.cpp.

Referenced by printOmittedTerminatorRegion().

◆ parseCallCommon()

mlir::ParseResult parseCallCommon ( mlir::OpAsmParser & parser,
mlir::OperationState & result )
static

Definition at line 704 of file CIRDialect.cpp.

References parseCIRKeyword().

◆ parseCIRKeyword()

template<typename EnumTy, typename RetTy = EnumTy>
ParseResult parseCIRKeyword ( AsmParser & parser,
RetTy & result )
static

Parse an enum from the keyword, return failure if the keyword is not found.

Definition at line 151 of file CIRDialect.cpp.

References parseOptionalKeywordAlternative().

Referenced by parseCallCommon().

◆ parseConstantValue()

ParseResult parseConstantValue ( OpAsmParser & parser,
mlir::Attribute & valueAttr )
static

Definition at line 1338 of file CIRDialect.cpp.

Referenced by parseGlobalOpTypeAndInitialValue().

◆ parseGlobalOpTypeAndInitialValue()

ParseResult parseGlobalOpTypeAndInitialValue ( OpAsmParser & parser,
TypeAttr & typeAttr,
Attribute & initialValueAttr,
mlir::Region & ctorRegion,
mlir::Region & dtorRegion )
static

Definition at line 1457 of file CIRDialect.cpp.

References ensureRegionTerm(), and parseConstantValue().

◆ parseOmittedTerminatorRegion()

mlir::ParseResult parseOmittedTerminatorRegion ( mlir::OpAsmParser & parser,
mlir::Region & region )
static

Definition at line 225 of file CIRDialect.cpp.

References ensureRegionTerm().

◆ parseOptionalCIRKeyword()

template<typename EnumTy, typename RetTy = EnumTy>
RetTy parseOptionalCIRKeyword ( AsmParser & parser,
EnumTy defaultValue )
static

Parse an enum from the keyword, or default to the provided default value.

The return type is the enum type by default, unless overriden with the second template argument.

Definition at line 138 of file CIRDialect.cpp.

References parseOptionalKeywordAlternative().

Referenced by parseVisibilityAttr().

◆ parseOptionalKeywordAlternative()

int parseOptionalKeywordAlternative ( AsmParser & parser,
ArrayRef< llvm::StringRef > keywords )
static

Definition at line 109 of file CIRDialect.cpp.

Referenced by parseCIRKeyword(), and parseOptionalCIRKeyword().

◆ parseSwitchFlatOpCases()

ParseResult parseSwitchFlatOpCases ( OpAsmParser & parser,
Type flagType,
mlir::ArrayAttr & caseValues,
SmallVectorImpl< Block * > & caseDestinations,
SmallVectorImpl< llvm::SmallVector< OpAsmParser::UnresolvedOperand > > & caseOperands,
SmallVectorImpl< llvm::SmallVector< Type > > & caseOperandTypes )
static

<cases> ::= [ (case (, case )* )?

] <case> ::= integer : bb-id (( ssa-use-and-type-list ))?

Definition at line 1261 of file CIRDialect.cpp.

◆ parseSwitchOp()

ParseResult parseSwitchOp ( OpAsmParser & parser,
mlir::Region & regions,
mlir::OpAsmParser::UnresolvedOperand & cond,
mlir::Type & condType )
static

Definition at line 1150 of file CIRDialect.cpp.

◆ parseTryHandlerRegions()

mlir::ParseResult parseTryHandlerRegions ( mlir::OpAsmParser & parser,
llvm::SmallVectorImpl< std::unique_ptr< mlir::Region > > & handlerRegions,
mlir::ArrayAttr & handlerTypes )
static

Definition at line 2999 of file CIRDialect.cpp.

◆ parseVisibilityAttr()

void parseVisibilityAttr ( OpAsmParser & parser,
cir::VisibilityAttr & visibility )

Definition at line 215 of file CIRDialect.cpp.

References parseOptionalCIRKeyword().

◆ printCallCommon()

void printCallCommon ( mlir::Operation * op,
mlir::FlatSymbolRefAttr calleeSym,
mlir::Value indirectCallee,
mlir::OpAsmPrinter & printer,
bool isNothrow,
cir::SideEffect sideEffect )
static

Definition at line 767 of file CIRDialect.cpp.

◆ printConstant()

void printConstant ( OpAsmPrinter & p,
Attribute value )
static

Definition at line 1344 of file CIRDialect.cpp.

Referenced by printGlobalOpTypeAndInitialValue().

◆ printGlobalOpTypeAndInitialValue()

void printGlobalOpTypeAndInitialValue ( OpAsmPrinter & p,
cir::GlobalOp op,
TypeAttr type,
Attribute initAttr,
mlir::Region & ctorRegion,
mlir::Region & dtorRegion )
static

Definition at line 1426 of file CIRDialect.cpp.

References printConstant().

◆ printOmittedTerminatorRegion()

void printOmittedTerminatorRegion ( mlir::OpAsmPrinter & printer,
cir::ScopeOp & op,
mlir::Region & region )
static

Definition at line 235 of file CIRDialect.cpp.

References omitRegionTerm().

◆ printSwitchFlatOpCases()

void printSwitchFlatOpCases ( OpAsmPrinter & p,
cir::SwitchFlatOp op,
Type flagType,
mlir::ArrayAttr caseValues,
SuccessorRange caseDestinations,
OperandRangeRange caseOperands,
const TypeRangeRange & caseOperandTypes )
static

Definition at line 1304 of file CIRDialect.cpp.

◆ printSwitchOp()

void printSwitchOp ( OpAsmPrinter & p,
cir::SwitchOp op,
mlir::Region & bodyRegion,
mlir::Value condition,
mlir::Type condType )
static

Definition at line 1174 of file CIRDialect.cpp.

◆ printTryHandlerRegions()

void printTryHandlerRegions ( mlir::OpAsmPrinter & printer,
cir::TryOp op,
mlir::MutableArrayRef< mlir::Region > handlerRegions,
mlir::ArrayAttr handlerTypes )
static

Definition at line 2973 of file CIRDialect.cpp.

◆ printVisibilityAttr()

void printVisibilityAttr ( OpAsmPrinter & printer,
cir::VisibilityAttr & visibility )

Definition at line 201 of file CIRDialect.cpp.

◆ tryFoldCastChain()

Value tryFoldCastChain ( cir::CastOp op)
static

Definition at line 609 of file CIRDialect.cpp.

References isIntOrBoolCast().

◆ verifyCallCommInSymbolUses()

LogicalResult verifyCallCommInSymbolUses ( mlir::Operation * op,
SymbolTableCollection & symbolTable )
static

Definition at line 819 of file CIRDialect.cpp.

References cir::MissingFeatures::opCallCallConv().