Skip to content

Commit

Permalink
fix intra block pred
Browse files Browse the repository at this point in the history
  • Loading branch information
ailrst committed Jan 29, 2024
1 parent eee6803 commit b46eb70
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
1 change: 1 addition & 0 deletions src/main/scala/ir/IRCursor.scala
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ trait IntraProcIRCursor extends IRWalk[CFGPosition, CFGPosition] {
case b: Block =>
b.kind match {
case CallReturn(from) => Set(from)
case Entry(proc) => Set(proc)
case _ => b.incomingJumps.asInstanceOf[Set[CFGPosition]]
}
case proc: Procedure => Set() // intraproc
Expand Down
17 changes: 10 additions & 7 deletions src/main/scala/ir/Program.scala
Original file line number Diff line number Diff line change
Expand Up @@ -293,11 +293,14 @@ class Parameter(var name: String, var size: Int, var value: Register) {
sealed trait BlockKind


trait Regular extends BlockKind
object Regular extends BlockKind
case class CallReturn(from: Call) extends Regular
case class Return(from: Procedure) extends Regular
case class Entry(from: Procedure) extends Regular
/* Block is the fallthrough / return target of a call. */
case class CallReturn(from: Call) extends BlockKind

/* Block is the single return point for a procedure */
case class Return(from: Procedure) extends BlockKind

/* Block is the single entry point for a procedure */
case class Entry(from: Procedure) extends BlockKind

class Block private (
private val _kind: BlockKind,
Expand Down Expand Up @@ -335,8 +338,8 @@ class Block private (

def kind : BlockKind = {
_kind match {
case c: Regular if (parent.entryBlock.contains(this)) => Entry(parent)
case c: Regular if (parent.returnBlock.contains(this)) => Return(parent)
case c if (parent.entryBlock.contains(this)) => Entry(parent)
case c if (parent.returnBlock.contains(this)) => Return(parent)
case _ => _kind
}
}
Expand Down

0 comments on commit b46eb70

Please sign in to comment.