Changeset View
Changeset View
Standalone View
Standalone View
mlir/include/mlir/IR/Module.h
Show All 25 Lines | |||||
/// ModuleOp represents a module, or an operation containing one region with a | /// ModuleOp represents a module, or an operation containing one region with a | ||||
/// single block containing opaque operations. The region of a module is not | /// single block containing opaque operations. The region of a module is not | ||||
/// allowed to implicitly capture global values, and all external references | /// allowed to implicitly capture global values, and all external references | ||||
/// must use symbolic references via attributes(e.g. via a string name). | /// must use symbolic references via attributes(e.g. via a string name). | ||||
class ModuleOp | class ModuleOp | ||||
: public Op< | : public Op< | ||||
ModuleOp, OpTrait::ZeroOperands, OpTrait::ZeroResult, | ModuleOp, OpTrait::ZeroOperands, OpTrait::ZeroResult, | ||||
OpTrait::IsIsolatedFromAbove, OpTrait::SymbolTable, | OpTrait::IsIsolatedFromAbove, OpTrait::SymbolTable, | ||||
OpTrait::SingleBlockImplicitTerminator<ModuleTerminatorOp>::Impl> { | OpTrait::SingleBlockImplicitTerminator<ModuleTerminatorOp>::Impl, | ||||
SymbolOpInterface::Trait> { | |||||
public: | public: | ||||
using Op::Op; | using Op::Op; | ||||
using Op::print; | using Op::print; | ||||
static StringRef getOperationName() { return "module"; } | static StringRef getOperationName() { return "module"; } | ||||
static void build(Builder *builder, OperationState &result, | static void build(Builder *builder, OperationState &result, | ||||
Optional<StringRef> name = llvm::None); | Optional<StringRef> name = llvm::None); | ||||
▲ Show 20 Lines • Show All 47 Lines • ▼ Show 20 Lines | void insert(Operation *insertPt, Operation *op) { | ||||
insert(Block::iterator(insertPt), op); | insert(Block::iterator(insertPt), op); | ||||
} | } | ||||
void insert(Block::iterator insertPt, Operation *op) { | void insert(Block::iterator insertPt, Operation *op) { | ||||
auto *body = getBody(); | auto *body = getBody(); | ||||
if (insertPt == body->end()) | if (insertPt == body->end()) | ||||
insertPt = Block::iterator(body->getTerminator()); | insertPt = Block::iterator(body->getTerminator()); | ||||
body->getOperations().insert(insertPt, op); | body->getOperations().insert(insertPt, op); | ||||
} | } | ||||
//===--------------------------------------------------------------------===// | |||||
// SymbolOpInterface Methods | |||||
//===--------------------------------------------------------------------===// | |||||
/// A ModuleOp may optionally define a symbol. | |||||
bool isOptionalSymbol() { return true; } | |||||
}; | }; | ||||
/// The ModuleTerminatorOp is a special terminator operation for the body of a | /// The ModuleTerminatorOp is a special terminator operation for the body of a | ||||
/// ModuleOp, it has no semantic meaning beyond keeping the body of a ModuleOp | /// ModuleOp, it has no semantic meaning beyond keeping the body of a ModuleOp | ||||
/// well-formed. | /// well-formed. | ||||
/// | /// | ||||
/// This operation does _not_ have a custom syntax. However, ModuleOp will omit | /// This operation does _not_ have a custom syntax. However, ModuleOp will omit | ||||
/// the terminator in their custom syntax for brevity. | /// the terminator in their custom syntax for brevity. | ||||
▲ Show 20 Lines • Show All 65 Lines • Show Last 20 Lines |