Skip to content

Commit

Permalink
Allow isolated regions to form isolated SSA name scopes in the printer.
Browse files Browse the repository at this point in the history
This will allow for naming values the same as existing SSA values for regions attached to operations that are isolated from above. This fits in with how the system already allows separate name scopes for sibling regions. This name shadowing can be enabled in the custom parser of operations by setting the 'enableNameShadowing' flag to true when calling 'parseRegion'.

%arg = constant 10 : i32
foo.op {
  %arg = constant 10 : i32
}

PiperOrigin-RevId: 264255999
  • Loading branch information
River707 authored and tensorflower-gardener committed Aug 19, 2019
1 parent 36f4806 commit 305516f
Show file tree
Hide file tree
Showing 9 changed files with 194 additions and 104 deletions.
2 changes: 2 additions & 0 deletions mlir/include/mlir/IR/OpBase.td
Expand Up @@ -1025,6 +1025,8 @@ class PredOpTrait<string descr, Pred pred> : OpTrait {
def Broadcastable : NativeOpTrait<"BroadcastableTwoOperandsOneResult">;
// X op Y == Y op X
def Commutative : NativeOpTrait<"IsCommutative">;
// Op is isolated from above.
def IsolatedFromAbove : NativeOpTrait<"IsIsolatedFromAbove">;
// Op results are float or vectors/tensors thereof.
def ResultsAreFloatLike : NativeOpTrait<"ResultsAreFloatLike">;
// Op has no side effect.
Expand Down
16 changes: 11 additions & 5 deletions mlir/include/mlir/IR/OpImplementation.h
Expand Up @@ -411,18 +411,24 @@ class OpAsmParser {

/// Parses a region. Any parsed blocks are appended to "region" and must be
/// moved to the op regions after the op is created. The first block of the
/// region takes "arguments" of types "argTypes".
/// region takes "arguments" of types "argTypes". If "enableNameShadowing" is
/// set to true, the argument names are allowed to shadow the names of other
/// existing SSA values defined above the region scope. "enableNameShadowing"
/// can only be set to true for regions attached to operations that are
/// "IsolatedFromAbove".
virtual ParseResult parseRegion(Region &region,
ArrayRef<OperandType> arguments,
ArrayRef<Type> argTypes) = 0;
ArrayRef<Type> argTypes,
bool enableNameShadowing = false) = 0;

/// Parses a region if present.
virtual ParseResult parseOptionalRegion(Region &region,
ArrayRef<OperandType> arguments,
ArrayRef<Type> argTypes) = 0;
ArrayRef<Type> argTypes,
bool enableNameShadowing = false) = 0;

/// Parse a region argument. Region arguments define new values; so this also
/// checks if values with the same name have not been defined yet.
/// Parse a region argument, this argument is resolved when calling
/// 'parseRegion'.
virtual ParseResult parseRegionArgument(OperandType &argument) = 0;

/// Parse zero or more region arguments with a specified surrounding
Expand Down

0 comments on commit 305516f

Please sign in to comment.