summaryrefslogtreecommitdiff
path: root/Source/GPUVerify/UniformExpressionAnalysisVisitor.cs
blob: 76f6b5dec6d3ea135baf6e4b693876e8f3844cc3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Boogie;

namespace GPUVerify
{
    class UniformExpressionAnalysisVisitor : StandardVisitor
    {

        private bool isUniform = true;
        private Dictionary<string, bool> uniformityInfo;

        public UniformExpressionAnalysisVisitor(Dictionary<string, bool> uniformityInfo)
        {
            this.uniformityInfo = uniformityInfo;
        }

        public override Variable VisitVariable(Variable v)
        {
            if (!uniformityInfo.ContainsKey(v.Name))
            {
                isUniform = isUniform && (v is Constant);
            }
            else if (!uniformityInfo[v.Name])
            {
               isUniform = false;
            }

            return v;
        }

        internal bool IsUniform()
        {
            return isUniform;
        }
    }
}