R/dominates.R

Defines functions PostDominatorTree DominatorTree

Documented in DominatorTree PostDominatorTree

setMethod("dominates", c("DominatorTree", "Instruction", "Instruction"),
           function(x, y, z, ...) 
             .Call("R_DominatorTree_dominates_instruction_instruction", x, y, z))

setMethod("dominates", c("DominatorTree", "Instruction", "BasicBlock"),
           function(x, y, z, ...) 
              .Call("R_DominatorTree_dominates_instruction_block", x, y, z))

setMethod("dominates", c("Instruction", "Instruction"),
           function(x, y, z, ...)  
          dominates(DominatorTree(as(x, "Function")), x, y))

setMethod("dominates", c("Instruction", "BasicBlock"),
           function(x, y, z, ...)  
          dominates(DominatorTree(as(x, "Function")), x, y))


# Not part of the LLVM API but just convenience for R users
# Probably can reduce these to fewer by coercing the second and third argument to Instruction and BasicBlock respectively.
setMethod("dominates", c("BasicBlock", "BasicBlock"),
           function(x, y, z, ...)  
             dominates(DominatorTree(as(x, "Function")), x[[1]], y))

setMethod("dominates", c("BasicBlock", "Instruction"),
           function(x, y, z, ...)  
             dominates(DominatorTree(as(x, "Function")), x[[1]], getParent(y)))

setMethod("dominates", c("DominatorTree", "BasicBlock", "BasicBlock"),
           function(x, y, z, ...)  
             dominates(x, y[[1]], z))

setMethod("dominates", c("DominatorTree", "BasicBlock", "Instruction"),
           function(x, y, z, ...)  
               dominates(x, y[[1]], getParent(z)))



DominatorTree =
function(fun, ...)
{
   .Call("R_DominatorTree", as(fun, "Function"))
}

PostDominatorTree =
function(fun, ...)
{
   .Call("R_PostDominatorTree", as(fun, "Function"))
}





setMethod("dominates", c("PostDominatorTree", "Instruction", "Instruction"),
           function(x, y, z, ...) 
             .Call("R_PostDominatorTree_dominates_instruction_instruction", x, y, z))

setMethod("dominates", c("PostDominatorTree", "BasicBlock", "BasicBlock"),
           function(x, y, z, ...) 
              .Call("R_PostDominatorTree_dominates_block_block", x, y, z))


setMethod("postDominates", c("Instruction", "Instruction"),
          function(x, y, z, ...)
              dominates(PostDominatorTree(as(x, "Function")), x, y))


setMethod("postDominates", c("BasicBlock", "BasicBlock"),
          function(x, y, z, ...)
              dominates(PostDominatorTree(as(x, "Function")), x, y))
duncantl/Rllvm documentation built on May 13, 2024, 7:45 p.m.