Commit 34244646 authored by Kunshan Wang's avatar Kunshan Wang

Move IRBuilder outside uvm.refimpl package.

parent 57d9be2c
package uvm.refimpl
package uvm.ir.irbuilder
import scala.collection.mutable.ArrayBuffer
import uvm.utils.IDFactory
import uvm._
import uvm.types._
import uvm.ssavariables._
import uvm.comminsts.CommInst
import uvm.comminsts.CommInsts
object DestKind extends Enumeration {
val NORMAL, EXCEPT, TRUE, FALSE, DEFAULT, DISABLED, ENABLED = Value
}
private[refimpl] object IRBuilder {
private[irbuilder] object IRBuilder {
type BN = BundleNode
type CN[+T <: Identified] = ChildNode[T]
......@@ -48,9 +46,9 @@ class IRBuilder(globalBundle: GlobalBundle, idFactory: IDFactory) {
node
}
def getNode(b: BN, id: Int): CN[_] = {
def getNode(b: BN, id: Int): CN[_ <: Identified] = {
val ent = globalBundle.allNs.get(id).getOrElse {
throw new UvmRuntimeException("No entity has id %d".format(id))
throw new IllegalArgumentException("No entity has id %d".format(id))
}
new ChildNode(ent)
......
......@@ -12,6 +12,7 @@ import uvm.refimpl.mem.TypeSizes.Word
import uvm.refimpl.nat.NativeCallHelper
import uvm.staticanalysis.StaticAnalyzer
import uvm.utils.IDFactory
import uvm.ir.irbuilder.IRBuilder
object MicroVM {
val DEFAULT_SOS_SIZE: Word = 2L * 1024L * 1024L; // 2MiB
......@@ -49,7 +50,9 @@ class MicroVM(vmConf: VMConf) {
val trapManager = new TrapManager()
val contexts = new HashSet[MuCtx]()
val irReader = new UIRTextReader(new IDFactory(MicroVM.FIRST_CLIENT_USABLE_ID), recordSourceInfo=vmConf.sourceInfo)
val idFactory = new IDFactory(MicroVM.FIRST_CLIENT_USABLE_ID)
val irBuilder = new IRBuilder(globalBundle, idFactory)
val irReader = new UIRTextReader(idFactory, recordSourceInfo=vmConf.sourceInfo)
val hailScriptLoader = new HailScriptLoader(recordSourceInfo=vmConf.sourceInfo)
val staticAnalyzer = new StaticAnalyzer()
......
......@@ -2,6 +2,7 @@ package uvm.refimpl
import uvm._
import uvm.refimpl.itpr._
import uvm.ir.irbuilder._
/**
* Mix-in to MuCtx to support the IR building API.
......@@ -12,11 +13,16 @@ trait MuCtxIRBuilderPart {
protected def addHandle[T <: MuValue](h: T): T
@inline
def IRNODEREF = InternalTypes.IRNODEREF
private def IRNODEREF = InternalTypes.IRNODEREF
private def irBuilder = microVM.irBuilder
private def makeConcreteMuIRNode(node: IRNode): MuIRNode = {
???
}
def newBundle(): MuBundleNode = {
val b = new TrantientBundle()
val node = new BundleNode(b)
val node = irBuilder.newBundle()
addHandle(MuBundleNode(IRNODEREF, BoxIRNode(Some(node))))
}
......@@ -31,7 +37,9 @@ trait MuCtxIRBuilderPart {
}
def getNode(b: MuBundleNode, id: Int): MuIRNode = {
???
require(!b.isNull, "bundle must not be NULL")
val node = irBuilder.getNode(b.vb.node.get.asInstanceOf[BundleNode], id)
addHandle(makeConcreteMuIRNode(node))
}
def getID(node: MuChildNode): Int = {
......
......@@ -8,6 +8,9 @@ import uvm.ssavariables._
import uvm.ssavariables.AtomicRMWOptr._
import uvm.ssavariables.MemoryOrder._
import uvm.types._
import uvm.ir.irbuilder.IRNode
import uvm.ir.irbuilder.ChildNode
import uvm.ir.irbuilder.BundleNode
object MuValue {
def apply(ty: Type, vb: ValueBox): MuValue = (ty, vb) match {
......
......@@ -4,6 +4,7 @@ import uvm._
import uvm.types._
import uvm.refimpl._
import uvm.refimpl.mem.TypeSizes.Word
import uvm.ir.irbuilder.IRNode
abstract class ValueBox {
def copyFrom(other: ValueBox): Unit
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment