Loop: Methods for 'Loop' Objects

LoopR Documentation

Methods for Loop Objects

Description

Given a Loop object, these functions allow us to query different characteristics it may have.

getLoopBlocks gets all of the BasicBlock-class for a given loop. These are the blocks between the incoming/header block that dominates the loops' blocks, and the back-edge that leads back to the header.

Usage

isAnnotatedParallel(loop)
isRotatedForm(loop)
isLoopSimplifyForm(loop)
isGuarded(loop)
getGuardBranch(loop)
isCanonical(x)
numBlocks(x, ...)
numBackEdges(x, ...)
getParent(x)
getPredecessor(x, ...)
getHeader(x, ...)
isExiting(loop)
subLoops(loop)
preHeader(loop)
latch(loop)
isLatch(loop, block)
getIncomingAndBackEdge(loop)
isLoopInvariant(loop, val)
hasLoopInvariantOperands(loop, val)
getInductionVariable(loop, se = NULL, ...)
getBounds(x, y, ...)
getLoopBlocks(x, ...)
isAuxInductionVariable(loop, phi, se)

Arguments

loop, x

a Loop object, obtained from e.g. getLoops or getLoopFor For getLoopBlocks, this argument can also be the loop's LoopIncomingAndBackEdge object.

val

a Value-class object from the LLVM IR code

se, y

a ScalarEvolution object. See loopAnalysis.

block

a BasicBlock-class object

phi

a PHINode-class object

...

additional arguments for methods

Author(s)

DTL

Examples

f = system.file("IR/loop.ir", package = "Rllvm")
m = parseIR(f)
fun = m$nestedLoop
la = loopAnalysis(fun)
loops = getLoops(la)

sapply(loops, depth)
sapply(loops, isCanonical, la$scalarEvolution)
sapply(loops, numBlocks)
bl = lapply(loops, getLoopBlocks)

lapply(loops, getInductionVariable)

subLoops(loops[[2]])

inner = subLoops(loops[[2]])[[1]]
p = getParent(inner)
identical(p, loops[[2]])

preHeader(loops[[1]])


ins = getInstructions(m$nestedLoop)
w = sapply(ins, function(i) contains(loops[[3]], i))

getIncomingAndBackEdge(loops[[3]])



lapply(loops, getBounds, la)


duncantl/Rllvm documentation built on April 23, 2024, 6:14 p.m.