예제 #1
0
        private static bool AnalyzeHeapNode(NodeBlock block, DHeap node)
        {
            // Easy case: compiler needed a lvalue.
            if (node.uses.Count == 2)
            {
                DUse lastUse  = node.uses.Last();
                DUse firstUse = node.uses.First();
                if ((lastUse.node.type == NodeType.Call ||
                     lastUse.node.type == NodeType.SysReq) &&
                    firstUse.node.type == NodeType.Store &&
                    firstUse.index == 0)
                {
                    lastUse.node.replaceOperand(lastUse.index, firstUse.node.getOperand(1));
                    return(true);
                }

                if ((lastUse.node.type == NodeType.Call ||
                     lastUse.node.type == NodeType.SysReq) &&
                    firstUse.node.type == NodeType.MemCopy &&
                    firstUse.index == 0)
                {
                    // heap -> memcpy always reads from DAT + constant
                    DMemCopy     memcopy = (DMemCopy)firstUse.node;
                    DConstant    cv      = (DConstant)memcopy.from;
                    DInlineArray ia      = new DInlineArray(cv.value, memcopy.bytes);
                    block.nodes.insertAfter(node, ia);
                    lastUse.node.replaceOperand(lastUse.index, ia);

                    // Give the inline array some type information.
                    Signature signature = SignatureOf(lastUse.node);
                    TypeUnit  tu        = TypeUnit.FromArgument(signature.args[lastUse.index]);
                    ia.addType(tu);
                    return(true);
                }
            }

            return(false);
        }
예제 #2
0
        private string buildInlineArray(DInlineArray ia)
        {
            Debug.Assert(ia.typeSet.numTypes == 1);
            TypeUnit tu = ia.typeSet[0];

            Debug.Assert(tu.kind == TypeUnit.Kind.Array);
            Debug.Assert(tu.dims == 1);

            if (tu.type.isString)
            {
                string s = file_.stringFromData(ia.address);
                return(buildString(s));
            }

            string text = "{";

            for (int i = 0; i < ia.size / 4; i++)
            {
                if (tu.type.type == CellType.Float)
                {
                    float f = file_.floatFromData(ia.address + i * 4);
                    text += f;
                }
                else
                {
                    int v = file_.int32FromData(ia.address);
                    text += buildTag(tu.type) + v;
                }
                if (i != (ia.size / 4) - 1)
                {
                    text += ",";
                }
            }
            text += "}";
            return(text);
        }
예제 #3
0
파일: Nodes.cs 프로젝트: maxijabase/SPCode
 public virtual void visit(DInlineArray ia)
 {
 }
예제 #4
0
        private static bool AnalyzeHeapNode(NodeBlock block, DHeap node)
        {
            // Easy case: compiler needed a lvalue.
            if (node.uses.Count == 2)
            {
                DUse lastUse = node.uses.Last();
                DUse firstUse = node.uses.First();
                if ((lastUse.node.type == NodeType.Call ||
                     lastUse.node.type == NodeType.SysReq) &&
                    firstUse.node.type == NodeType.Store &&
                    firstUse.index == 0)
                {
                    lastUse.node.replaceOperand(lastUse.index, firstUse.node.getOperand(1));
                    return true;
                }

                if ((lastUse.node.type == NodeType.Call ||
                     lastUse.node.type == NodeType.SysReq) &&
                    firstUse.node.type == NodeType.MemCopy &&
                    firstUse.index == 0)
                {
                    // heap -> memcpy always reads from DAT + constant
                    DMemCopy memcopy = (DMemCopy)firstUse.node;
                    DConstant cv = (DConstant)memcopy.from;
                    DInlineArray ia = new DInlineArray(cv.value, memcopy.bytes);
                    block.nodes.insertAfter(node, ia);
                    lastUse.node.replaceOperand(lastUse.index, ia);

                    // Give the inline array some type information.
                    Signature signature = SignatureOf(lastUse.node);
                    TypeUnit tu = TypeUnit.FromArgument(signature.args[lastUse.index]);
                    ia.addType(tu);
                    return true;
                }
            }

            return false;
        }
예제 #5
0
        private string buildInlineArray(DInlineArray ia)
        {
            Debug.Assert(ia.typeSet.numTypes == 1);
            TypeUnit tu = ia.typeSet[0];

            Debug.Assert(tu.kind == TypeUnit.Kind.Array);
            Debug.Assert(tu.dims == 1);

            if (tu.type.isString)
            {
                string s = file_.stringFromData(ia.address);
                return buildString(s);
            }

            string text = "{";
            for (int i = 0; i < ia.size / 4; i++)
            {
                if (tu.type.type == CellType.Float)
                {
                    float f = file_.floatFromData(ia.address + i * 4);
                    text += f;
                }
                else
                {
                    int v = file_.int32FromData(ia.address);
                    text += buildTag(tu.type) + v;
                }
                if (i != (ia.size / 4) - 1)
                    text += ",";
            }
            text += "}";
            return text;
        }
예제 #6
0
파일: Nodes.cs 프로젝트: not1ce111/Spedit
 public virtual void visit(DInlineArray ia) { }