Exemple #1
0
 public void disp(Operand oprnd)
 {
     Console.WriteLine(" " + oprnd.opr + " " + oprnd.state);
 }
Exemple #2
0
        public List<Node> Chk_stat(List<Node> Mov_N_List)
        {
            HashSet<Operand> All_opr = new HashSet<Operand>();
            List<Node> UL_Mov = new List<Node>();
            String[] REGS = new String[] { "eax", "ebx", "ecx", "edx", "esi", "edi", "ebp", "esp", "si", "di", "bp", "sp" };
            String[] f_regs;
            //Node temp = new Node();

            foreach (Node temp in Mov_N_List)
            {

                string first = temp.operands[0];
                string sec = temp.operands[1];

                if (REGS.Contains(first))
                {
                    Operand op = new Operand(first, "undef");
                    //first check for reference
                    if (REGS.Contains(sec))
                    {
                        if (op.state.Equals("dd"))
                        {
                            op.state = "def-ref";
                            UL_Mov.Add(temp);//here we added the undef-ref reg's inst in useless Mov list
                            Useless++;
                        }
                        if (op.state.Equals("undef"))
                        {
                            op.state = "undef-ref";
                            UL_Mov.Add(temp);//here we added the undef-ref reg's inst in useless Mov list
                            Useless++;
                        }
                    }
                    if (!REGS.Contains(sec))//first check is sec operand is another than regs it another than REGS the they are definde ie assignde some  Mem address
                    {

                        if (op.state == "def")
                        {
                            op.state = "ref";
                        }
                        else
                        {
                            op.state = "def";
                        }
                    }
                    if (All_opr.Contains(op))
                    {
                        //op.state = "dd";
                        if (op.state == "dd")
                        {
                            op.state = "dd";//ref
                        }
                        else
                        {
                            op.state = "dd";

                        }
                        UL_Mov.Add(temp);//here we added the def-def reg's inst in useless Mov list
                        Useless++;
                    }
                    All_opr.Add(op);
                }
            }
            //Console.WriteLine("from temp");
            //foreach (Operand x in All_opr)
            //{
            //    x.disp(x);
            //}
            return UL_Mov;
        }