Class MmuTreeWalkerBase

    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected ConstantPropagator propagator  
      • Fields inherited from class org.antlr.runtime.tree.TreeParser

        DOWN, input, UP
      • Fields inherited from class org.antlr.runtime.BaseRecognizer

        DEFAULT_TOKEN_CHANNEL, HIDDEN, INITIAL_FOLLOW_STACK_SIZE, MEMO_RULE_FAILED, MEMO_RULE_UNKNOWN, NEXT_TOKEN_RULE_NAME, state
    • Constructor Summary

      Constructors 
      Constructor Description
      MmuTreeWalkerBase​(org.antlr.runtime.tree.TreeNodeStream input, org.antlr.runtime.RecognizerSharedState state)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void assignContext​(TranslatorContext context)  
      void assignIR​(Ir ir)  
      protected java.util.List<java.lang.String> checkContextKeywords​(MmuLanguageContext langCtx, java.util.Collection<org.antlr.runtime.tree.CommonTree> nodes)  
      protected java.math.BigInteger extractBigInteger​(Where w, ru.ispras.fortress.expression.Node expr, java.lang.String exprDesc)  
      protected int extractInt​(Where w, ru.ispras.fortress.expression.Node expr, java.lang.String exprDesc)  
      protected java.math.BigInteger extractPositiveBigInteger​(Where w, ru.ispras.fortress.expression.Node expr, java.lang.String nodeName)  
      protected int extractPositiveInt​(Where w, ru.ispras.fortress.expression.Node expr, java.lang.String nodeName)  
      protected Type findType​(org.antlr.runtime.tree.CommonTree typeId)  
      protected ru.ispras.fortress.expression.Node getConstant​(org.antlr.runtime.tree.CommonTree id)
      Returns the value of the specified constant.
      TranslatorContext getContext()  
      Ir getIR()  
      protected Address newAddress​(org.antlr.runtime.tree.CommonTree addressId, Type type, java.util.List<org.antlr.runtime.tree.CommonTree> memberChain)
      Creates an Address IR object and adds it to the MMU IR.
      protected Stmt newAssert​(org.antlr.runtime.tree.CommonTree place, ru.ispras.fortress.expression.Node condition)  
      protected Stmt newAssignment​(org.antlr.runtime.tree.CommonTree where, ru.ispras.fortress.expression.Node leftExpr, ru.ispras.fortress.expression.Node rightExpr)  
      protected ru.ispras.fortress.expression.Node newAttributeCall​(org.antlr.runtime.tree.CommonTree id, java.util.List<org.antlr.runtime.tree.CommonTree> memberChain)  
      protected ru.ispras.fortress.expression.Node newAttributeRef​(org.antlr.runtime.tree.CommonTree id, boolean isLhs, java.util.List<ru.ispras.fortress.expression.Node> args, org.antlr.runtime.tree.CommonTree attrId)  
      protected ru.ispras.fortress.expression.Node newBitfield​(org.antlr.runtime.tree.CommonTree where, ru.ispras.fortress.expression.Node variable, ru.ispras.fortress.expression.Node fromExpr, ru.ispras.fortress.expression.Node toExpr)  
      protected ru.ispras.fortress.expression.NodeOperation newCall​(org.antlr.runtime.tree.CommonTree node, java.util.List<ru.ispras.fortress.expression.Node> args)  
      protected ru.ispras.fortress.expression.Node newCallExpr​(Where w, ru.ispras.fortress.expression.NodeOperation call)  
      protected Stmt newCallStmt​(ru.ispras.fortress.expression.NodeOperation call)  
      protected ru.ispras.fortress.expression.Node newConcat​(org.antlr.runtime.tree.CommonTree where, ru.ispras.fortress.expression.Node left, ru.ispras.fortress.expression.Node right)  
      protected ru.ispras.fortress.expression.Node newCondExpression​(org.antlr.runtime.tree.CommonTree id, java.util.List<ru.ispras.fortress.util.Pair<ru.ispras.fortress.expression.Node,​ru.ispras.fortress.expression.Node>> blocks)
      Creates a conditional expression of the following kind:
      protected void newConstant​(org.antlr.runtime.tree.CommonTree id, ru.ispras.fortress.expression.Node value)
      Adds a static constant (let expression) to the IR.
      protected Stmt newException​(org.antlr.runtime.tree.CommonTree message)  
      protected ru.ispras.fortress.expression.Node newExpression​(org.antlr.runtime.tree.CommonTree operatorId, ru.ispras.fortress.expression.Node... operands)
      Creates a new operator-based expression.
      protected void newExtern​(org.antlr.runtime.tree.CommonTree id, org.antlr.runtime.tree.CommonTree aliasId, java.util.List<ru.ispras.fortress.expression.Node> args)
      Adds an external variable linked to the specified source entity defined in the ISA specification to the IR.
      protected ru.ispras.fortress.expression.Node newIndexedVariable​(org.antlr.runtime.tree.CommonTree id, ru.ispras.fortress.expression.Node indexExpr)  
      protected Stmt newMark​(org.antlr.runtime.tree.CommonTree text)  
      protected MmuTreeWalkerBase.CommonBuilder newMemoryBuilder​(org.antlr.runtime.tree.CommonTree memoryId, org.antlr.runtime.tree.CommonTree addressArgId, org.antlr.runtime.tree.CommonTree addressArgType, org.antlr.runtime.tree.CommonTree dataArgId, ru.ispras.fortress.expression.Node dataArgSizeExpr)  
      protected MmuTreeWalkerBase.CommonBuilder newSegmentBuilder​(org.antlr.runtime.tree.CommonTree id, org.antlr.runtime.tree.CommonTree addressArgId, org.antlr.runtime.tree.CommonTree addressArgType, org.antlr.runtime.tree.CommonTree outputVarId, org.antlr.runtime.tree.CommonTree outputVarType)  
      protected Stmt newTrace​(org.antlr.runtime.tree.CommonTree format, java.util.List<ru.ispras.fortress.expression.Node> fargs)  
      protected Type newType​(org.antlr.runtime.tree.CommonTree typeId, Type type)  
      protected ru.ispras.fortress.expression.Node newVariable​(boolean isLhs, org.antlr.runtime.tree.CommonTree id)  
      protected void registerFunction​(Callable func)  
      protected Type resolveTypeName​(org.antlr.runtime.tree.CommonTree typeId)  
      • Methods inherited from class org.antlr.runtime.tree.TreeParser

        getAncestor, getCurrentInputSymbol, getErrorHeader, getErrorMessage, getMissingSymbol, getSourceName, getTreeNodeStream, inContext, inContext, matchAny, recoverFromMismatchedToken, reset, setTreeNodeStream, traceIn, traceOut
      • Methods inherited from class org.antlr.runtime.BaseRecognizer

        alreadyParsedRule, beginResync, combineFollows, computeContextSensitiveRuleFOLLOW, computeErrorRecoverySet, consumeUntil, consumeUntil, displayRecognitionError, endResync, failed, getBacktrackingLevel, getGrammarFileName, getNumberOfSyntaxErrors, getRuleInvocationStack, getRuleInvocationStack, getRuleMemoization, getRuleMemoizationCacheSize, getTokenErrorDisplay, getTokenNames, match, memoize, mismatchIsMissingToken, mismatchIsUnwantedToken, pushFollow, recover, recoverFromMismatchedSet, setBacktrackingLevel, toStrings, traceIn, traceOut
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • MmuTreeWalkerBase

        public MmuTreeWalkerBase​(org.antlr.runtime.tree.TreeNodeStream input,
                                 org.antlr.runtime.RecognizerSharedState state)
    • Method Detail

      • assignIR

        public final void assignIR​(Ir ir)
      • getIR

        public final Ir getIR()
      • newConstant

        protected final void newConstant​(org.antlr.runtime.tree.CommonTree id,
                                         ru.ispras.fortress.expression.Node value)
                                  throws SemanticException
        Adds a static constant (let expression) to the IR.
        Parameters:
        id - Constant identifier.
        value - Constant value.
        Throws:
        SemanticException - if the value expression is null.
      • getConstant

        protected final ru.ispras.fortress.expression.Node getConstant​(org.antlr.runtime.tree.CommonTree id)
                                                                throws SemanticException
        Returns the value of the specified constant.
        Parameters:
        id - Constant identifier.
        Returns:
        Constant value.
        Throws:
        SemanticException - if the constant is not defined.
      • newExtern

        protected void newExtern​(org.antlr.runtime.tree.CommonTree id,
                                 org.antlr.runtime.tree.CommonTree aliasId,
                                 java.util.List<ru.ispras.fortress.expression.Node> args)
                          throws SemanticException
        Adds an external variable linked to the specified source entity defined in the ISA specification to the IR.
        Parameters:
        id - Variable name.
        aliasId - Name of the source entity.
        args - Arguments used to access the source entity (e.g. register index, or addressing mode arguments).
        Throws:
        SemanticException - if the variable cannot be linked to the specified ISA entity.
      • newAddress

        protected final Address newAddress​(org.antlr.runtime.tree.CommonTree addressId,
                                           Type type,
                                           java.util.List<org.antlr.runtime.tree.CommonTree> memberChain)
                                    throws SemanticException
        Creates an Address IR object and adds it to the MMU IR.
        Parameters:
        addressId - Address identifier.
        type - Address Address type.
        memberChain - Member chain.
        Returns:
        New Address IR object.
        Throws:
        SemanticException - (1) if the width expression is null; (2) if the width expression cannot be reduced to a constant integer value; (3) if the width value is beyond the Java Integer allowed range; (4) if the width value is less or equal 0.
      • newMemoryBuilder

        protected final MmuTreeWalkerBase.CommonBuilder newMemoryBuilder​(org.antlr.runtime.tree.CommonTree memoryId,
                                                                         org.antlr.runtime.tree.CommonTree addressArgId,
                                                                         org.antlr.runtime.tree.CommonTree addressArgType,
                                                                         org.antlr.runtime.tree.CommonTree dataArgId,
                                                                         ru.ispras.fortress.expression.Node dataArgSizeExpr)
                                                                  throws SemanticException
        Throws:
        SemanticException
      • newSegmentBuilder

        protected final MmuTreeWalkerBase.CommonBuilder newSegmentBuilder​(org.antlr.runtime.tree.CommonTree id,
                                                                          org.antlr.runtime.tree.CommonTree addressArgId,
                                                                          org.antlr.runtime.tree.CommonTree addressArgType,
                                                                          org.antlr.runtime.tree.CommonTree outputVarId,
                                                                          org.antlr.runtime.tree.CommonTree outputVarType)
                                                                   throws SemanticException
        Throws:
        SemanticException
      • registerFunction

        protected final void registerFunction​(Callable func)
      • newCall

        protected final ru.ispras.fortress.expression.NodeOperation newCall​(org.antlr.runtime.tree.CommonTree node,
                                                                            java.util.List<ru.ispras.fortress.expression.Node> args)
                                                                     throws SemanticException
        Throws:
        SemanticException
      • newCallStmt

        protected final Stmt newCallStmt​(ru.ispras.fortress.expression.NodeOperation call)
      • newAssignment

        protected final Stmt newAssignment​(org.antlr.runtime.tree.CommonTree where,
                                           ru.ispras.fortress.expression.Node leftExpr,
                                           ru.ispras.fortress.expression.Node rightExpr)
                                    throws SemanticException
        Throws:
        SemanticException
      • newException

        protected final Stmt newException​(org.antlr.runtime.tree.CommonTree message)
      • newTrace

        protected final Stmt newTrace​(org.antlr.runtime.tree.CommonTree format,
                                      java.util.List<ru.ispras.fortress.expression.Node> fargs)
                               throws SemanticException
        Throws:
        SemanticException
      • newMark

        protected final Stmt newMark​(org.antlr.runtime.tree.CommonTree text)
      • newExpression

        protected final ru.ispras.fortress.expression.Node newExpression​(org.antlr.runtime.tree.CommonTree operatorId,
                                                                         ru.ispras.fortress.expression.Node... operands)
                                                                  throws org.antlr.runtime.RecognitionException
        Creates a new operator-based expression. Works in the following steps:
        1. Find Fortress operator
        2. Reduce all operands
        3. Cast all value operands to common type (bit vector) if required
        4. Make NodeOperation and return
        Parameters:
        operatorId - Operator identifier.
        operands - Array of operands.
        Returns:
        New expression.
        Throws:
        SemanticException - if the specified operator is not defined or does not support operands of the specified types.
        org.antlr.runtime.RecognitionException
      • newCondExpression

        protected final ru.ispras.fortress.expression.Node newCondExpression​(org.antlr.runtime.tree.CommonTree id,
                                                                             java.util.List<ru.ispras.fortress.util.Pair<ru.ispras.fortress.expression.Node,​ru.ispras.fortress.expression.Node>> blocks)
        Creates a conditional expression of the following kind:

        if C1 then V1 (elif Ci then Vi)* else Vn endif.

        Parameters:
        id - Token that marks location of the construction in code.
        blocks - Pairs [code condition expression, value expression].
        Returns:
        New expression.
      • newConcat

        protected final ru.ispras.fortress.expression.Node newConcat​(org.antlr.runtime.tree.CommonTree where,
                                                                     ru.ispras.fortress.expression.Node left,
                                                                     ru.ispras.fortress.expression.Node right)
                                                              throws SemanticException
        Throws:
        SemanticException
      • newBitfield

        protected final ru.ispras.fortress.expression.Node newBitfield​(org.antlr.runtime.tree.CommonTree where,
                                                                       ru.ispras.fortress.expression.Node variable,
                                                                       ru.ispras.fortress.expression.Node fromExpr,
                                                                       ru.ispras.fortress.expression.Node toExpr)
                                                                throws SemanticException
        Throws:
        SemanticException
      • newAttributeRef

        protected final ru.ispras.fortress.expression.Node newAttributeRef​(org.antlr.runtime.tree.CommonTree id,
                                                                           boolean isLhs,
                                                                           java.util.List<ru.ispras.fortress.expression.Node> args,
                                                                           org.antlr.runtime.tree.CommonTree attrId)
                                                                    throws SemanticException
        Throws:
        SemanticException
      • newVariable

        protected final ru.ispras.fortress.expression.Node newVariable​(boolean isLhs,
                                                                       org.antlr.runtime.tree.CommonTree id)
                                                                throws SemanticException
        Throws:
        SemanticException
      • newIndexedVariable

        protected final ru.ispras.fortress.expression.Node newIndexedVariable​(org.antlr.runtime.tree.CommonTree id,
                                                                              ru.ispras.fortress.expression.Node indexExpr)
                                                                       throws SemanticException
        Throws:
        SemanticException
      • newAttributeCall

        protected final ru.ispras.fortress.expression.Node newAttributeCall​(org.antlr.runtime.tree.CommonTree id,
                                                                            java.util.List<org.antlr.runtime.tree.CommonTree> memberChain)
                                                                     throws SemanticException
        Throws:
        SemanticException
      • extractBigInteger

        protected java.math.BigInteger extractBigInteger​(Where w,
                                                         ru.ispras.fortress.expression.Node expr,
                                                         java.lang.String exprDesc)
                                                  throws SemanticException
        Throws:
        SemanticException
      • extractPositiveBigInteger

        protected java.math.BigInteger extractPositiveBigInteger​(Where w,
                                                                 ru.ispras.fortress.expression.Node expr,
                                                                 java.lang.String nodeName)
                                                          throws SemanticException
        Throws:
        SemanticException