public override Expr VisitNAryExpr(NAryExpr node)
        {
            if (node.Fun is MapSelect)
            {
                Debug.Assert((node.Fun as MapSelect).Arity == 1);
                if (node.Args[0] is NAryExpr)
                {
                    var inner = node.Args[0] as NAryExpr;
                    Debug.Assert(inner.Fun is MapSelect);
                    Debug.Assert(inner.Args[0] is IdentifierExpr);
                    Debug.Assert(QKeyValue.FindBoolAttribute(((IdentifierExpr)inner.Args[0]).Decl.Attributes, "atomic_usedmap"));

                    Expr mapSelect = inner.Args[0];

                    if (QKeyValue.FindBoolAttribute(((IdentifierExpr)inner.Args[0]).Decl.Attributes, "atomic_group_shared")
                        && !GPUVerifyVCGenCommandLineOptions.OnlyIntraGroupRaceChecking)
                    {
                        mapSelect = new NAryExpr(
                            Token.NoToken,
                            new MapSelect(Token.NoToken, 1),
                            new List<Expr> { mapSelect, verifier.GroupSharedIndexingExpr(id) });
                    }

                    mapSelect = new NAryExpr(
                        Token.NoToken,
                        new MapSelect(Token.NoToken, 1),
                        new List<Expr> { mapSelect, VisitExpr(inner.Args[1]) });
                    return new NAryExpr(
                        Token.NoToken,
                        new MapSelect(Token.NoToken, 1),
                        new List<Expr> { mapSelect, VisitExpr(node.Args[1]) });
                }
                else
                {
                    Debug.Assert(node.Args[0] is IdentifierExpr);

                    if (QKeyValue.FindBoolAttribute((node.Args[0] as IdentifierExpr).Decl.Attributes, "group_shared")
                        && !GPUVerifyVCGenCommandLineOptions.OnlyIntraGroupRaceChecking)
                    {
                        var mapSelect = new NAryExpr(
                            Token.NoToken,
                            new MapSelect(Token.NoToken, 1),
                            new List<Expr> { node.Args[0], verifier.GroupSharedIndexingExpr(id) });
                        return new NAryExpr(
                            Token.NoToken,
                            new MapSelect(Token.NoToken, 1),
                            new List<Expr> { mapSelect, VisitExpr(node.Args[1]) });
                    }

                    return base.VisitNAryExpr(node);
                }
            }

            if (node.Fun is FunctionCall)
            {
                FunctionCall call = node.Fun as FunctionCall;

                // Alternate dualisation for "other thread" functions
                if (OtherFunctionNames.Contains(call.Func.Name))
                {
                    Debug.Assert(id == 1 || id == 2);
                    int otherId = id == 1 ? 2 : 1;
                    return new VariableDualiser(otherId, verifier, procName)
                        .VisitExpr(node.Args[0]);
                }
            }

            return base.VisitNAryExpr(node);
        }
Exemple #2
0
        public override AssignLhs VisitMapAssignLhs(MapAssignLhs node)
        {
            var v = node.DeepAssignedVariable;

            if (QKeyValue.FindBoolAttribute(v.Attributes, "group_shared") && !GPUVerifyVCGenCommandLineOptions.OnlyIntraGroupRaceChecking)
            {
                return(new MapAssignLhs(Token.NoToken, new MapAssignLhs(Token.NoToken, node.Map,
                                                                        new List <Expr>(new Expr[] { GPUVerifier.GroupSharedIndexingExpr(id) })),
                                        node.Indexes.Select(idx => this.VisitExpr(idx)).ToList()));
            }
            return(base.VisitMapAssignLhs(node));
        }