LLVM Discussion Forums

MLIR documented syntax for region production rule

In https://mlir.llvm.org/docs/LangRef/#regions

The production rule given for region is:

region ::= `{` block* `}`

Similarly the production rule for block is:

block           ::= block-label operation+
block-label     ::= block-id block-arg-list? `:`
block-id        ::= caret-id
caret-id        ::= `^` suffix-id

This implies that blocks must start with ‘^’

In the production rule for functions the function body has a region.

My confusion stems from seeing many examples–both within the same document and in the MLIR toy example for functions, where no block (with ‘^’) is defined. Does this mean that single block functions do not need the ‘^’ designator? If so is this documented? Is there another explanation to clear up my confusion?


The entry block to the region may omit the block label in the custom form of the operation. The syntax needs to be updated to reflect that.

MLIR functions are not special compared to other operations. Regions in any operation are allowed to do that.

Thanks! If the region has multiple blocks, must the entry block have (not omit) the block label?

It may omit the label regardless of the number of blocks.

Seems like to be strict we should either have the generic printing not omit the entry block label even when there are no argument, or update the grammar to reflect this.