summaryrefslogtreecommitdiff
path: root/Source/Concurrency/TypeCheck.cs
diff options
context:
space:
mode:
authorGravatar qadeer <unknown>2014-01-09 08:13:15 -0800
committerGravatar qadeer <unknown>2014-01-09 08:13:15 -0800
commit59732afd306a62d53143c2e627fadb97fc0ee9c8 (patch)
tree1ea899d27fbbbe9993726422d93c69a87645be20 /Source/Concurrency/TypeCheck.cs
parenta0da62d4eba25d38b35445378a9cfd7dafed25ba (diff)
some optimizations to mover checks
Diffstat (limited to 'Source/Concurrency/TypeCheck.cs')
-rw-r--r--Source/Concurrency/TypeCheck.cs38
1 files changed, 38 insertions, 0 deletions
diff --git a/Source/Concurrency/TypeCheck.cs b/Source/Concurrency/TypeCheck.cs
index 9d9c661c..6aef686b 100644
--- a/Source/Concurrency/TypeCheck.cs
+++ b/Source/Concurrency/TypeCheck.cs
@@ -31,6 +31,19 @@ namespace Microsoft.Boogie
public CodeExpr thatAction;
public List<Variable> thatInParams;
public List<Variable> thatOutParams;
+ public HashSet<Variable> usedGlobalVars;
+ public HashSet<Variable> modifiedGlobalVars;
+ public HashSet<Variable> gateUsedGlobalVars;
+ public bool isNonBlocking;
+
+ public bool CommutesWith(ActionInfo actionInfo)
+ {
+ if (this.modifiedGlobalVars.Intersect(actionInfo.usedGlobalVars).Count() > 0)
+ return false;
+ if (this.usedGlobalVars.Intersect(actionInfo.modifiedGlobalVars).Count() > 0)
+ return false;
+ return true;
+ }
public bool IsRightMover
{
@@ -55,6 +68,12 @@ namespace Microsoft.Boogie
this.thatGate = new List<AssertCmd>();
this.thatInParams = new List<Variable>();
this.thatOutParams = new List<Variable>();
+ this.isNonBlocking = true;
+
+ foreach (Block block in codeExpr.Blocks)
+ {
+ block.Cmds.ForEach(x => this.isNonBlocking = this.isNonBlocking && !(x is AssumeCmd));
+ }
var cmds = thisAction.Blocks[0].Cmds;
for (int i = 0; i < cmds.Count; i++)
@@ -136,6 +155,25 @@ namespace Microsoft.Boogie
blockMap[block].TransferCmd = new GotoCmd(block.TransferCmd.tok, thatGotoCmdLabelNames, thatGotoCmdLabelTargets);
}
this.thatAction = new CodeExpr(thatLocVars, thatBlocks);
+
+ {
+ VariableCollector collector = new VariableCollector();
+ collector.Visit(codeExpr);
+ this.usedGlobalVars = new HashSet<Variable>(collector.usedVars.Where(x => x is GlobalVariable));
+ }
+
+ List<Variable> modifiedVars = new List<Variable>();
+ foreach (Block block in codeExpr.Blocks)
+ {
+ block.Cmds.ForEach(cmd => cmd.AddAssignedVariables(modifiedVars));
+ }
+ this.modifiedGlobalVars = new HashSet<Variable>(modifiedVars.Where(x => x is GlobalVariable));
+
+ {
+ VariableCollector collector = new VariableCollector();
+ this.thisGate.ForEach (assertCmd => collector.Visit(assertCmd));
+ this.gateUsedGlobalVars = new HashSet<Variable>(collector.usedVars.Where(x => x is GlobalVariable));
+ }
}
}