Example #1
0
        private void FinalizeCodeBlock()
        {
            //TcbDependencyUpdate.Process(CodeBlock);

            //OutputTrace("Dependency Update");

            //Re-order computations so that less expensive output variables and temps are computed first
            TcbReOrderComputations.Process(CodeBlock, FixOutputComputationsOrder);

            this.ReportNormal("Re-order Computations", CodeBlock);

            if (EnableTestEvaluation)
            {
                EvaluationDataHistory.AddEvaluation("Re-order computations");
            }

            //Minimize number of temporary variables needed in the final code
            TcbReUseTempVariables.Process(CodeBlock);

            this.ReportNormal("Re-use Temp Variables", CodeBlock);

            CodeBlock.UpdateParametersDictionary();

            if (EnableTestEvaluation)
            {
                EvaluationDataHistory.AddEvaluation("Re-use temp variables");

                this.ReportNormal("Evaluation History", EvaluationDataHistory);
            }
        }
Example #2
0
        //private void OutputTrace(string traceItemTitle)
        //{
        //    if (ReferenceEquals(_progress, null))
        //        return;

        //    this.ReportNormal(traceItemTitle, CodeBlock.ToString());
        //}

        //private void OutputTrace(string traceItemTitle, string traceItemText)
        //{
        //    if (ReferenceEquals(_progress, null))
        //        return;

        //    this.ReportNormal(traceItemTitle, traceItemText);
        //}

        private void InitializeCodeBlock()
        {
            //Generate low-level code if not already generated and initialize target code block
            TcbInitialize.Process(CodeBlock, Generator.GenerateLowLevelItems());

            this.ReportNormal("Initialize Code Block", CodeBlock);

            if (EnableTestEvaluation)
            {
                EvaluationDataHistory =
                    _inputsWithTestValues == null || _inputsWithTestValues.Count == 0
                    ? new TlCodeBlockEvaluationHistory(CodeBlock, -5.0D, 5.0D)
                    : new TlCodeBlockEvaluationHistory(CodeBlock, _inputsWithTestValues);

                EvaluationDataHistory.AddEvaluation("Initialize Code Block");
            }
        }
Example #3
0
        private void ProcessSubExpressions()
        {
            //Use full reduction algorithm to produce less computations and simplest possible RHS expressions
            //but may take longer time and may require more temp variables
            if (GMacCompilerOptions.ReduceLowLevelRhsSubExpressions)
            {
                TcbReduceRhsExpressions.Process(CodeBlock);

                this.ReportNormal("Reduce RHS Sub-expressions", CodeBlock);

                if (EnableTestEvaluation)
                {
                    EvaluationDataHistory.AddEvaluation("Reduce RHS Sub-expressions");
                }

                return;
            }

            //Use partial reduction algorithm to factor out sub expressions used multiple times during
            //computation but may produce larger RHS expressions per temp\output variable

            //Remove temp variables having duplicate RHS expressions
            TcbRemoveDuplicateTemps.Process(CodeBlock);

            this.ReportNormal("Remove Duplicate Temps", CodeBlock);

            if (EnableTestEvaluation)
            {
                EvaluationDataHistory.AddEvaluation("Remove Duplicate Temps");
            }

            //Factor common sub-expressions into separate low-level temp variables
            TcbFactorSubExpressions.Process(CodeBlock);

            this.ReportNormal("Factor Common Sub-expressions", CodeBlock);

            if (EnableTestEvaluation)
            {
                EvaluationDataHistory.AddEvaluation("Factor Common Sub-expressions");
            }
        }