| 1 | //===- CIROpDefinitions.h - CIR op implementation helpers -------*- C++ -*-===// |
| 2 | // |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | // See https://llvm.org/LICENSE.txt for license information. |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | // |
| 9 | // This header declares the custom directive parsers and printers implemented |
| 10 | // in CIRDialect.cpp and referenced by the TableGen-generated CIR operation |
| 11 | // definitions, which are compiled in separate shards. |
| 12 | // |
| 13 | //===----------------------------------------------------------------------===// |
| 14 | |
| 15 | #ifndef CLANG_LIB_CIR_DIALECT_IR_CIROPDEFINITIONS_H |
| 16 | #define CLANG_LIB_CIR_DIALECT_IR_CIROPDEFINITIONS_H |
| 17 | |
| 18 | #include "clang/CIR/Dialect/IR/CIRDialect.h" |
| 19 | |
| 20 | #include "mlir/IR/OpImplementation.h" |
| 21 | |
| 22 | namespace cir { |
| 23 | |
| 24 | mlir::ParseResult parseOmittedTerminatorRegion(mlir::OpAsmParser &parser, |
| 25 | mlir::Region ®ion); |
| 26 | void printOmittedTerminatorRegion(mlir::OpAsmPrinter &printer, cir::ScopeOp &op, |
| 27 | mlir::Region ®ion); |
| 28 | |
| 29 | mlir::OptionalParseResult |
| 30 | parseGlobalMemorySpace(mlir::AsmParser &p, |
| 31 | mlir::ptr::MemorySpaceAttrInterface &attr); |
| 32 | void printGlobalMemorySpace(mlir::AsmPrinter &printer, cir::GlobalOp op, |
| 33 | mlir::ptr::MemorySpaceAttrInterface attr); |
| 34 | |
| 35 | mlir::ParseResult parseAssumeBundle( |
| 36 | mlir::OpAsmParser &p, cir::AssumeBundleKindAttr &bundleKindAttr, |
| 37 | llvm::SmallVector<mlir::OpAsmParser::UnresolvedOperand, 4> &bundleArgs, |
| 38 | llvm::SmallVector<mlir::Type, 1> &bundleArgTypes); |
| 39 | void printAssumeBundle(mlir::OpAsmPrinter &p, cir::AssumeOp op, |
| 40 | cir::AssumeBundleKindAttr kindAttr, |
| 41 | mlir::OperandRange bundleArgs, |
| 42 | mlir::TypeRange bundleArgTypes); |
| 43 | |
| 44 | mlir::ParseResult parseIndirectBrOpSucessors( |
| 45 | mlir::OpAsmParser &parser, mlir::Type &flagType, |
| 46 | llvm::SmallVectorImpl<mlir::Block *> &succOperandBlocks, |
| 47 | llvm::SmallVectorImpl< |
| 48 | llvm::SmallVector<mlir::OpAsmParser::UnresolvedOperand>> &succOperands, |
| 49 | llvm::SmallVectorImpl<llvm::SmallVector<mlir::Type>> &succOperandsTypes); |
| 50 | void printIndirectBrOpSucessors(mlir::OpAsmPrinter &p, cir::IndirectBrOp op, |
| 51 | mlir::Type flagType, mlir::SuccessorRange succs, |
| 52 | mlir::OperandRangeRange succOperands, |
| 53 | const mlir::TypeRangeRange &succOperandsTypes); |
| 54 | |
| 55 | mlir::ParseResult parseSwitchFlatOpCases( |
| 56 | mlir::OpAsmParser &parser, mlir::Type flagType, mlir::ArrayAttr &caseValues, |
| 57 | llvm::SmallVectorImpl<mlir::Block *> &caseDestinations, |
| 58 | llvm::SmallVectorImpl< |
| 59 | llvm::SmallVector<mlir::OpAsmParser::UnresolvedOperand>> &caseOperands, |
| 60 | llvm::SmallVectorImpl<llvm::SmallVector<mlir::Type>> &caseOperandTypes); |
| 61 | void printSwitchFlatOpCases(mlir::OpAsmPrinter &p, cir::SwitchFlatOp op, |
| 62 | mlir::Type flagType, mlir::ArrayAttr caseValues, |
| 63 | mlir::SuccessorRange caseDestinations, |
| 64 | mlir::OperandRangeRange caseOperands, |
| 65 | const mlir::TypeRangeRange &caseOperandTypes); |
| 66 | |
| 67 | mlir::ParseResult parseComdatName(mlir::OpAsmParser &parser, |
| 68 | mlir::StringAttr &comdatAttr); |
| 69 | void printComdatName(mlir::OpAsmPrinter &p, cir::GlobalOp op, |
| 70 | mlir::StringAttr comdat); |
| 71 | |
| 72 | mlir::ParseResult parseGlobalOpTypeAndInitialValue( |
| 73 | mlir::OpAsmParser &parser, mlir::TypeAttr &typeAttr, |
| 74 | mlir::Attribute &initialValueAttr, mlir::Region &ctorRegion, |
| 75 | mlir::Region &dtorRegion); |
| 76 | void printGlobalOpTypeAndInitialValue(mlir::OpAsmPrinter &p, cir::GlobalOp op, |
| 77 | mlir::TypeAttr type, |
| 78 | mlir::Attribute initAttr, |
| 79 | mlir::Region &ctorRegion, |
| 80 | mlir::Region &dtorRegion); |
| 81 | |
| 82 | mlir::ParseResult parseCopyTypes(mlir::OpAsmParser &parser, mlir::Type &srcType, |
| 83 | mlir::Type &dstType); |
| 84 | void printCopyTypes(mlir::OpAsmPrinter &printer, mlir::Operation *, |
| 85 | mlir::Type srcType, mlir::Type dstType); |
| 86 | |
| 87 | mlir::ParseResult parseTryHandlerRegions( |
| 88 | mlir::OpAsmParser &parser, |
| 89 | llvm::SmallVectorImpl<std::unique_ptr<mlir::Region>> &handlerRegions, |
| 90 | mlir::ArrayAttr &handlerTypes); |
| 91 | void printTryHandlerRegions(mlir::OpAsmPrinter &printer, cir::TryOp op, |
| 92 | mlir::MutableArrayRef<mlir::Region> handlerRegions, |
| 93 | mlir::ArrayAttr handlerTypes); |
| 94 | |
| 95 | mlir::ParseResult parseEhDispatchDestinations( |
| 96 | mlir::OpAsmParser &parser, mlir::ArrayAttr &catchTypes, |
| 97 | llvm::SmallVectorImpl<mlir::Block *> &catchDestinations, |
| 98 | mlir::Block *&defaultDestination, mlir::UnitAttr &defaultIsCatchAll); |
| 99 | void printEhDispatchDestinations(mlir::OpAsmPrinter &p, cir::EhDispatchOp op, |
| 100 | mlir::ArrayAttr catchTypes, |
| 101 | mlir::SuccessorRange catchDestinations, |
| 102 | mlir::Block *defaultDestination, |
| 103 | mlir::UnitAttr defaultIsCatchAll); |
| 104 | |
| 105 | } // namespace cir |
| 106 | |
| 107 | #endif // CLANG_LIB_CIR_DIALECT_IR_CIROPDEFINITIONS_H |
| 108 | |