Class Util

    • Constructor Detail

      • Util

        public Util()
    • Method Detail

      • endsWithConditionalBranch

        public static boolean endsWithConditionalBranch​(ControlFlowGraph G,
                                                        IBasicBlock b)
        Does basic block b end with a conditional branch instruction?
      • endsWithSwitch

        public static boolean endsWithSwitch​(ControlFlowGraph G,
                                             IBasicBlock b)
        Does basic block b end with a switch instruction?
      • getFallThruBlock

        public static <I,​T extends IBasicBlock<I>> T getFallThruBlock​(ControlFlowGraph<I,​T> G,
                                                                            T b)
        Given that b falls through to the next basic block, what basic block does it fall through to?
      • getNotTakenSuccessor

        public static <I,​T extends IBasicBlock<I>> T getNotTakenSuccessor​(ControlFlowGraph<I,​T> G,
                                                                                T b)
        Given that b ends with a conditional branch, return the basic block to which control transfers if the branch is not taken.
      • getTakenSuccessor

        public static <I,​T extends IBasicBlock<I>> T getTakenSuccessor​(ControlFlowGraph<I,​T> G,
                                                                             T b)
        Given that b ends with a conditional branch, return the basic block to which control transfers if the branch is taken.
      • resolveSwitch

        public static <I,​T extends IBasicBlock<I>> T resolveSwitch​(ControlFlowGraph<I,​T> G,
                                                                         T b,
                                                                         int c)
        When the tested value of the switch statement in b has value c, which basic block does control transfer to.
      • isSwitchDefault

        public static <I,​T extends IBasicBlock<I>> boolean isSwitchDefault​(ControlFlowGraph<I,​T> G,
                                                                                 T b,
                                                                                 T s)
        Is block s the default case for the switch instruction which is the last instruction of block b?
      • getSwitchLabel

        public static <I,​T extends IBasicBlock<I>> int getSwitchLabel​(ControlFlowGraph<I,​T> G,
                                                                            T b,
                                                                            T s)
        When a switch statement at the end of block b transfers control to block s, which case was taken? TODO: Is this correct? Can't we have multiple cases that apply? Check on this.
      • resolveBranch

        public static <I,​T extends IBasicBlock<I>> T resolveBranch​(ControlFlowGraph<I,​T> G,
                                                                         T bb,
                                                                         int c1,
                                                                         int c2)
        To which IBasicBlock does control flow from basic block bb, which ends in a conditional branch, when the conditional branch operands evaluate to the constants c1 and c2, respectively. Callers must resolve the constant values from the SymbolTable before calling this method. These integers are not value numbers;
      • whichPred

        public static <I,​T extends IBasicBlock<I>> int whichPred​(ControlFlowGraph<I,​T> cfg,
                                                                       T a,
                                                                       T b)
        Given that a is a predecessor of b in the cfg .. When we enumerate the predecessors of b in order, which is the first index in this order in which a appears? Note that this order corresponds to the order of operands in a phi instruction.