Commit d7a76d9e authored by Kunshan Wang's avatar Kunshan Wang

New bundle building API. (not tested yet)

parent f0f14163
......@@ -563,10 +563,10 @@ struct MuIRBuilder {
// Create basic block. Also create its parameters.
void (*new_bb)(MuIRBuilder *b, MuID id,
MuID *nor_param_ids, MuArraySize n_nor_param_ids,
MuID *nor_param_ids, MuTypeNode *nor_param_types, MuArraySize n_nor_params,
MuID exc_param_id,
MuInstNode *insts, MuArraySize ninsts);
/// MUAPIPARSER nor_param_ids:array:n_nor_param_ids;exc_param_id:optional;insts:array:ninsts
/// MUAPIPARSER nor_param_ids:array:n_nor_params;nor_param_types:array:n_nor_params;exc_param_id:optional;insts:array:ninsts
// Create a destination clause.
void (*new_dest_clause)(MuIRBuilder *b, MuID id,
......@@ -694,9 +694,11 @@ struct MuIRBuilder {
/// MUAPIPARSER result_ids:array:nretvals;rettys:array:nretvals;exc_clause:optional;keepalive_clause:optional
void (*new_watchpoint)(MuIRBuilder *b, MuID id, MuWPID wpid,
MuID *result_ids, MuTypeNode *rettys, MuArraySize nretvals,
MuExcClause exc_clause, MuKeepaliveClause keepalive_clause);
/// MUAPIPARSER result_ids:array:nretvals;rettys:array:nretvals;exc_clause:optional;keepalive_clause:optional
void (*new_wpbranch )(MuIRBuilder *b, MuID id, MuWPID wpid);
MuDestClause dis, MuDestClause ena, MuDestClause exc,
MuKeepaliveClause keepalive_clause);
/// MUAPIPARSER result_ids:array:nretvals;rettys:array:nretvals;exc:optional;keepalive_clause:optional
void (*new_wpbranch )(MuIRBuilder *b, MuID id, MuWPID wpid,
MuDestClause dis, MuDestClause ena);
void (*new_ccall)(MuIRBuilder *b, MuID id, MuID *result_ids, MuArraySize n_result_ids,
MuCallConv callconv,
......
......@@ -155,7 +155,7 @@ instBody
| 'BRANCH' dest=destClause # InstBranch
| 'BRANCH2' cond=value ifTrue=destClause ifFalse=destClause # InstBranch2
| 'SWITCH' '<' ty=type '>' opnd=value defDest=destClause '{'
(caseVal+=value caseDest+=destClause )* '}' # InstSwitch
(caseVal+=constant caseDest+=destClause )* '}' # InstSwitch
// Inter-function Control Flow
| 'CALL' funcCallBody excClause keepaliveClause # InstCall
......
......@@ -10,6 +10,7 @@ import scala.collection.mutable.ArrayBuffer
/** This class converts the soup of ID-referenced nodes into the refimpl's internal AST. */
class BundleConstructor(idNameMap: Map[MuID, MuName], nodeList: Seq[IRBuilderNode], globalBundle: GlobalBundle) {
val idNodeMap = nodeList.map(n => (n.id, n)).toMap
val bundle = new TrantientBundle()
......@@ -29,21 +30,44 @@ class BundleConstructor(idNameMap: Map[MuID, MuName], nodeList: Seq[IRBuilderNod
}
implicit def resTy(id: MuID): Type = cascadeLookup(id, bundle.typeNs, globalBundle.typeNs)
implicit def resTys(ids: Seq[MuID]): Seq[Type] = ids.map(resTy)
implicit def resSig(id: MuID): FuncSig = cascadeLookup(id, bundle.funcSigNs, globalBundle.funcSigNs)
implicit def resConst(id: MuID): Constant = cascadeLookup(id, bundle.constantNs, globalBundle.constantNs)
// used by InstSwitch
def resConst(id: MuID): Constant = cascadeLookup(id, bundle.constantNs, globalBundle.constantNs)
implicit def resGlobalVar(id: MuID): GlobalVariable = cascadeLookup(id, bundle.globalVarNs, globalBundle.globalVarNs)
// These auto-resolution may conflict with the resVar method when building instructions. Explicitly enable them in methods.
def resGlobalVar(id: MuID): GlobalVariable = cascadeLookup(id, bundle.globalVarNs, globalBundle.globalVarNs)
implicit def resFunc(id: MuID): Function = cascadeLookup(id, bundle.funcNs, globalBundle.funcNs)
def resFunc(id: MuID): Function = cascadeLookup(id, bundle.funcNs, globalBundle.funcNs)
implicit def resConstInt(id: MuID): ConstInt = resConst(id) match {
def resConstInt(id: MuID): ConstInt = resGlobalVar(id) match {
case ci: ConstInt => ci
case other => throw new AssertionError("Constant int expected, but %d found. ID: %d".format(other.getClass.getName, id))
}
def needType[E <: Type](id: MuID, expectedType: Class[E], n: String): E = {
val t = resTy(id)
if (!(expectedType.isAssignableFrom(t.getClass))) {
throw new IRBuilderException("Type id:%d name:%s does not match expected type. Expected %s, actually %s.".format(
id, idNameMap.getOrElse(id, "(no name)"), n, t))
}
t.asInstanceOf[E]
}
def needInt(id: MuID) = needType(id, classOf[TypeInt], "int")
def needStruct(id: MuID) = needType(id, classOf[TypeStruct], "struct")
def needAbsStruct(id: MuID) = needType(id, classOf[AbstractStructType], "struct or hybrid")
def needArray(id: MuID) = needType(id, classOf[TypeArray], "array")
def needVector(id: MuID) = needType(id, classOf[TypeVector], "vector")
def needHybrid(id: MuID) = needType(id, classOf[TypeHybrid], "hybrid")
def needSeq(id: MuID) = needType(id, classOf[AbstractSeqType], "array or vector")
def makeBundle(): TrantientBundle = {
// Enable auto resolution in this global scope
@inline implicit def _resGlobalVar = resGlobalVar _
@inline implicit def _resFunc = resFunc _
// Classify nodes into categories for phasing.
val typeNodes = new ArrayBuffer[IRTypeNode]
......@@ -150,35 +174,244 @@ class BundleConstructor(idNameMap: Map[MuID, MuName], nodeList: Seq[IRBuilderNod
bundle.funcNs.add(muNode)
}
case NodeExpFunc(id: MuID, func: MuFuncNode, callconv: Flag, cookie: MuConstIntNode) => {
val muNode = new ExposedFunc(func, callconv, cookie)
val muNode = new ExposedFunc(func, callconv, resConstInt(cookie))
setIDAndMaybeName(muNode, id)
bundle.expFuncNs.add(muNode)
}
}
phase2.doAll()
// Now all top-level definitions are created and their inter-references are resolved
// Phase 3: Define all defined functions (.funcdef)
val phase3 = new Later()
funcVers foreach { irNode =>
val muNode = new FuncVer(irNode.func)
setIDAndMaybeName(muNode, irNode.id)
bundle.funcVerNs.add(muNode)
phase3 { () =>
phase3 { () =>
defineFunction(irNode, muNode)
}
}
phase3.doAll()
bundle
}
def defineFunction(irNode: NodeFuncVer, muFunc: FuncVer): Unit = {
???
def defineFunction(irNode: NodeFuncVer, muFuncVer: FuncVer): Unit = {
val irBBmuBBs = irNode.bbs.map { bbID =>
val irBB = idNodeMap(bbID).asInstanceOf[NodeBB]
val muBB = new BasicBlock(muFuncVer)
setIDAndMaybeName(muBB, bbID)
muFuncVer.bbs += muBB
muFuncVer.bbNs.add(muBB)
(irBB, muBB)
}
for ((irBB, muBB) <- irBBmuBBs) {
for ((norParamID, norParamTyID) <- irBB.norParamIDs zip irBB.norParamTys) {
val muType = resTy(norParamTyID)
val muNorParam = NorParam(muType)
setIDAndMaybeName(muNorParam, norParamID)
muBB.norParams += muNorParam
muBB.localVarNs.add(muNorParam)
}
for (excParamID <- irBB.excParamID) {
val muExcParam = ExcParam()
setIDAndMaybeName(muExcParam, excParamID)
muBB.excParam = Some(muExcParam)
muBB.localVarNs.add(muExcParam)
}
for (instID <- irBB.insts) {
val irInst = idNodeMap(instID).asInstanceOf[IRInstNode]
val muInst = defineInst(muFuncVer, muBB, irInst)
setIDAndMaybeName(muInst, instID)
muBB.insts += muInst
muBB.localInstNs.add(muInst)
}
}
}
}
\ No newline at end of file
def defineInst(muFuncVer: FuncVer, muBB: BasicBlock, irInst: IRInstNode): Instruction = try {
import BundleConstructorImplicitMagics._
implicit val self = this
implicit val bbNs = muFuncVer.bbNs
implicit val localVarNs = muBB.localVarNs
implicit def resVar(id: MuVarNode): SSAVariable = {
localVarNs.get(id).getOrElse {
cascadeLookup(id, bundle.globalVarNs, globalBundle.globalVarNs)
}
}
implicit def resVars(ids: Seq[MuVarNode]): Seq[SSAVariable] = {
ids.map(resVar)
}
// used by keepalives
def resLocalVar(id: MuVarNode): LocalVariable = {
localVarNs.get(id).getOrElse {
throw new IRBuilderException("Local variable id:%d name:%s not found".format(id,
idNameMap.getOrElse(id, "(no name)")))
}
}
@inline
implicit def resBB(id: MuBBNode): BasicBlock = {
bbNs(id)
}
@inline
implicit def resDestClause(id: MuDestClause): DestClause = {
val NodeDestClause(_, dest, vars) = idNodeMap(id).asInstanceOf[NodeDestClause]
DestClause(dest, vars.map(resVar))
}
@inline
implicit def resExcClause(maybeID: Option[MuExcClause]): Option[ExcClause] = maybeID map { id =>
val irExcClause = idNodeMap(id).asInstanceOf[NodeExcClause]
ExcClause(irExcClause.nor, irExcClause.exc)
}
@inline
implicit def resKeepalives(maybeID: Option[MuKeepaliveClause]): Seq[LocalVariable] = maybeID map { id =>
val irKeepaliveClause = idNodeMap(id).asInstanceOf[NodeKeepaliveClause]
irKeepaliveClause.vars.map(resLocalVar)
} getOrElse(Seq())
@inline
implicit def resCurStackClause(id: MuCurStackClause): CurStackAction = {
val irCurStackClause = idNodeMap(id).asInstanceOf[IRCurStackClauseNode]
irCurStackClause match {
case NodeCscRetWith(_, tys) => RetWith(tys)
case NodeCscKillOld(_) => KillOld()
}
}
@inline
implicit def resNewStackClause(id: MuNewStackClause): NewStackAction = {
val irNewStackClause = idNodeMap(id).asInstanceOf[IRNewStackClauseNode]
irNewStackClause match {
case NodeNscPassValues(_, tys, vars) => PassValues(tys, vars)
case NodeNscThrowExc(_, exc) => ThrowExc(exc)
}
}
val muInst: Instruction = irInst match {
case NodeBinOp(id, resultID, optr, ty, opnd1, opnd2, excClause) =>
InstBinOp(optr, ty, opnd1, opnd2, excClause) --> resultID
case NodeCmp(id, resultID, optr, ty, opnd1, opnd2) =>
InstCmp(optr, ty, opnd1, opnd2) --> resultID
case NodeConv(id, resultID, optr, fromTy, toTy, opnd) =>
InstConv(optr, fromTy, toTy, opnd) --> resultID
case NodeSelect(id, resultID, condTy, opndTy, cond, ifTrue, ifFalse) =>
InstSelect(condTy, opndTy, cond, ifTrue, ifFalse) --> resultID
case NodeBranch(id, dest) =>
InstBranch(dest)
case NodeBranch2(id, cond, ifTrue, ifFalse) =>
InstBranch2(cond, ifTrue, ifFalse)
case NodeSwitch(id, opndTy, opnd, defaultDest, cases, dests) => {
val caseDests = for ((c, d) <- cases zip dests) yield {
(resConst(c), resDestClause(d))
}
InstSwitch(opndTy, opnd, defaultDest, ArrayBuffer(caseDests:_*))
}
case NodeCall(id, resultIDs, sig, callee, args, excClause, keepaliveClause) =>
InstCall(sig, callee, args, excClause, keepaliveClause) --> resultIDs
case NodeTailCall(id, sig, callee, args) =>
InstTailCall(sig, callee, args)
case NodeRet(id, rvs) =>
InstRet(muFuncVer, rvs)
case NodeThrow(id, exc) =>
InstThrow(exc)
case NodeExtractValue(id, resultID, strty, index, opnd) =>
InstExtractValue(needStruct(strty), index, opnd) --> resultID
case NodeInsertValue(id, resultID, strty, index, opnd, newval) =>
InstInsertValue(needStruct(strty), index, opnd, newval) --> resultID
case NodeExtractElement(id, resultID, seqty, indty, opnd, index) =>
InstExtractElement(needSeq(seqty), needInt(indty), opnd, index) --> resultID
case NodeInsertElement(id, resultID, seqty, indty, opnd, index, newval) =>
InstInsertElement(needSeq(seqty), needInt(indty), opnd, index, newval) --> resultID
case NodeShuffleVector(id, resultID, vecty, maskty, vec1, vec2, mask) =>
InstShuffleVector(needVector(vecty), needVector(maskty), vec1, vec2, mask) --> resultID
case NodeNew(id, resultID, allocty, excClause) =>
InstNew(allocty, excClause) --> resultID
case NodeNewHybrid(id, resultID, allocty, lenty, length, excClause) =>
InstNewHybrid(needHybrid(allocty), needInt(lenty), length, excClause) --> resultID
case NodeAlloca(id, resultID, allocty, excClause) =>
InstAlloca(allocty, excClause) --> resultID
case NodeAllocaHybrid(id, resultID, allocty, lenty, length, excClause) =>
InstAllocaHybrid(needHybrid(allocty), needInt(lenty), length, excClause) --> resultID
case NodeGetIRef(id, resultID, refty, opnd) =>
InstGetIRef(refty, opnd) --> resultID
case NodeGetFieldIRef(id, resultID, isPtr, refty, index, opnd) =>
InstGetFieldIRef(isPtr, needStruct(refty), index, opnd) --> resultID
case NodeGetElemIRef(id, resultID, isPtr, refty, indty, opnd, index) =>
InstGetElemIRef(isPtr, needSeq(refty), needInt(indty), opnd, index) --> resultID
case NodeShiftIRef(id, resultID, isPtr, refty, offty, opnd, offset) =>
InstShiftIRef(isPtr, refty, needInt(offty), opnd, offset) --> resultID
case NodeGetVarPartIRef(id, resultID, isPtr, refty, opnd) =>
InstGetVarPartIRef(isPtr, needHybrid(refty), opnd) --> resultID
case NodeLoad(id, resultID, isPtr, ord, refty, loc, excClause) =>
InstLoad(isPtr, ord, refty, loc, excClause) --> resultID
case NodeStore(id, isPtr, ord, refty, loc, newval, excClause) =>
InstStore(isPtr, ord, refty, loc, newval, excClause)
case NodeCmpXchg(id, valueResultID, succResultID, isPtr, isWeak, ordSucc, ordFail, refty, loc, expected, desired, excClause) =>
InstCmpXchg(isPtr, isWeak, ordSucc, ordFail, refty, loc, expected, desired, excClause) --> (valueResultID, succResultID)
case NodeAtomicRMW(id, resultID, isPtr, ord, optr, refTy, loc, opnd, excClause) =>
InstAtomicRMW(isPtr, ord, optr, refTy, loc, opnd, excClause) --> resultID
case NodeFence(id, ord) =>
InstFence(ord)
case NodeTrap(id, resultIDs, rettys, excClause, keepaliveClause) =>
InstTrap(rettys, excClause, keepaliveClause) --> resultIDs
case NodeWatchPoint(id, wpid, resultIDs, rettys, dis, ena, exc, keepaliveClause) =>
InstWatchPoint(wpid, rettys, dis, ena, exc.map(resDestClause), keepaliveClause) --> resultIDs
case NodeWPBranch(id, wpid, dis, ena) =>
InstWPBranch(wpid, dis, ena)
case NodeCCall(id, resultIDs, callconv, calleeTy, sig, callee, args, excClause, keepaliveClause) =>
InstCCall(callconv, calleeTy, sig, callee, args, excClause, keepaliveClause) --> resultIDs
case NodeNewThread(id, resultID, stack, threadlocal, newStackClause, excClause) =>
InstNewThread(stack, threadlocal.map(resVar), newStackClause, excClause) --> resultID
case NodeSwapStack(id, resultIDs, swappee, curStackClause, newStackClause, excClause, keepaliveClause) =>
InstSwapStack(swappee, curStackClause, newStackClause, excClause, keepaliveClause) --> resultIDs
case NodeCommInst(id, resultIDs, opcode, flags, tys, sigs, args, excClause, keepaliveClause) =>
InstCommInst(opcode, flags, tys, sigs.map(resSig), args, excClause, keepaliveClause) --> resultIDs
}
muInst
} catch {
case e: Exception => {
throw new IRBuilderException("Exception thrown when building instruction. Func: %s, ver: %s, bb: %s, inst: %d:%s".format(
muFuncVer.func.repr, muFuncVer.repr, muBB.repr, irInst.id, idNameMap.getOrElse(irInst.id, "(no name)")), e)
}
}
}
private object BundleConstructorImplicitMagics {
implicit class AddResultsSeq[T <: Instruction](val inst: T) extends AnyVal {
@inline
def -->(resultIDs: Seq[MuID])(implicit self: BundleConstructor, localVarNs: Namespace[LocalVariable]): T = {
inst-->(resultIDs:_*)
}
}
implicit class AddResultsVarArg[T <: Instruction](val inst: T) extends AnyVal {
@inline
def -->(resultIDs: MuID*)(implicit self: BundleConstructor, localVarNs: Namespace[LocalVariable]): T = {
val instResults = for ((resultID, i) <- resultIDs.zipWithIndex) yield {
val instRes = InstResult(inst, i)
self.setIDAndMaybeName(instRes, resultID)
localVarNs.add(instRes)
instRes
}
inst.results = instResults.toIndexedSeq
inst
}
}
}
......@@ -29,7 +29,7 @@ object IRBuilder {
table
}
def validateName(name: String): String = {
def validateName(name: String): MuName = {
if (name.startsWith("%")) {
throw new IllegalNameException("Name must be global (starting with '@') when using the IR building API. Found: %s".format(name))
} else if (!name.startsWith("@")) {
......@@ -62,6 +62,7 @@ trait IRBuilderListener {
class IRBuilder(val id: MuInternalID,
globalBundle: GlobalBundle, idFactory: IDFactory, irBuilderListener: Option[IRBuilderListener])
extends HasID {
import IRBuilder._
import IRBuilderNode._
private def nextID(): Int = idFactory.getID()
......@@ -90,7 +91,7 @@ class IRBuilder(val id: MuInternalID,
def genSym(name: Option[String]): MuID = {
val id = nextID()
name foreach { n =>
idNameMap(id) = n
idNameMap(id) = validateName(n)
}
id
}
......@@ -218,8 +219,8 @@ class IRBuilder(val id: MuInternalID,
val _node = new NodeFuncVer(id, func, bbs)
onNewNodeCreated(_node)
}
def newBB(id: MuID, norParamIDs: Seq[MuID], excParamID: Option[MuID], insts: Seq[MuInstNode]): Unit = {
val _node = new NodeBB(id, norParamIDs, excParamID, insts)
def newBB(id: MuID, norParamIDs: Seq[MuID], norParamTys: Seq[MuTypeNode], excParamID: Option[MuID], insts: Seq[MuInstNode]): Unit = {
val _node = new NodeBB(id, norParamIDs, norParamTys, excParamID, insts)
onNewNodeCreated(_node)
}
def newDestClause(id: MuID, dest: MuBBNode, vars: Seq[MuVarNode]): Unit = {
......@@ -250,8 +251,8 @@ class IRBuilder(val id: MuInternalID,
val _node = new NodeNscThrowExc(id, exc)
onNewNodeCreated(_node)
}
def newBinOp(id: MuID, resultID: MuID, optr: BinOptr.Value, ty: MuTypeNode, opnd1: MuVarNode, opnd2: MuVarNode, excClaues: Option[MuExcClause]): Unit = {
val _node = new NodeBinOp(id, resultID, optr, ty, opnd1, opnd2, excClaues)
def newBinOp(id: MuID, resultID: MuID, optr: BinOptr.Value, ty: MuTypeNode, opnd1: MuVarNode, opnd2: MuVarNode, excClause: Option[MuExcClause]): Unit = {
val _node = new NodeBinOp(id, resultID, optr, ty, opnd1, opnd2, excClause)
onNewNodeCreated(_node)
}
def newCmp(id: MuID, resultID: MuID, optr: CmpOptr.Value, ty: MuTypeNode, opnd1: MuVarNode, opnd2: MuVarNode): Unit = {
......@@ -278,8 +279,8 @@ class IRBuilder(val id: MuInternalID,
val _node = new NodeSwitch(id, opndTy, opnd, defaultDest, cases, dests)
onNewNodeCreated(_node)
}
def newCall(id: MuID, resultIds: Seq[MuID], sig: MuFuncSigNode, callee: MuVarNode, args: Seq[MuVarNode], excClause: Option[MuExcClause], keepaliveClause: Option[MuKeepaliveClause]): Unit = {
val _node = new NodeCall(id, resultIds, sig, callee, args, excClause, keepaliveClause)
def newCall(id: MuID, resultIDs: Seq[MuID], sig: MuFuncSigNode, callee: MuVarNode, args: Seq[MuVarNode], excClause: Option[MuExcClause], keepaliveClause: Option[MuKeepaliveClause]): Unit = {
val _node = new NodeCall(id, resultIDs, sig, callee, args, excClause, keepaliveClause)
onNewNodeCreated(_node)
}
def newTailCall(id: MuID, sig: MuFuncSigNode, callee: MuVarNode, args: Seq[MuVarNode]): Unit = {
......@@ -370,32 +371,32 @@ class IRBuilder(val id: MuInternalID,
val _node = new NodeFence(id, ord)
onNewNodeCreated(_node)
}
def newTrap(id: MuID, resultIds: Seq[MuID], rettys: Seq[MuTypeNode], excClause: Option[MuExcClause], keepaliveClause: Option[MuKeepaliveClause]): Unit = {
val _node = new NodeTrap(id, resultIds, rettys, excClause, keepaliveClause)
def newTrap(id: MuID, resultIDs: Seq[MuID], rettys: Seq[MuTypeNode], excClause: Option[MuExcClause], keepaliveClause: Option[MuKeepaliveClause]): Unit = {
val _node = new NodeTrap(id, resultIDs, rettys, excClause, keepaliveClause)
onNewNodeCreated(_node)
}
def newWatchPoint(id: MuID, wpid: MuWPID, resultIds: Seq[MuID], rettys: Seq[MuTypeNode], excClause: Option[MuExcClause], keepaliveClause: Option[MuKeepaliveClause]): Unit = {
val _node = new NodeWatchPoint(id, wpid, resultIds, rettys, excClause, keepaliveClause)
def newWatchPoint(id: MuID, wpid: MuWPID, resultIDs: Seq[MuID], rettys: Seq[MuTypeNode], dis: MuDestClause, ena: MuDestClause, exc: Option[MuDestClause], keepaliveClause: Option[MuKeepaliveClause]): Unit = {
val _node = new NodeWatchPoint(id, wpid, resultIDs, rettys, dis, ena, exc, keepaliveClause)
onNewNodeCreated(_node)
}
def newWPBranch(id: MuID, wpid: MuWPID): Unit = {
val _node = new NodeWPBranch(id, wpid)
def newWPBranch(id: MuID, wpid: MuWPID, dis: MuDestClause, ena: MuDestClause): Unit = {
val _node = new NodeWPBranch(id, wpid, dis, ena)
onNewNodeCreated(_node)
}
def newCCall(id: MuID, resultIds: Seq[MuID], callconv: Flag, calleeTy: MuTypeNode, sig: MuFuncSigNode, callee: MuVarNode, args: Seq[MuVarNode], excClause: Option[MuExcClause], keepaliveClause: Option[MuKeepaliveClause]): Unit = {
val _node = new NodeCCall(id, resultIds, callconv, calleeTy, sig, callee, args, excClause, keepaliveClause)
def newCCall(id: MuID, resultIDs: Seq[MuID], callconv: Flag, calleeTy: MuTypeNode, sig: MuFuncSigNode, callee: MuVarNode, args: Seq[MuVarNode], excClause: Option[MuExcClause], keepaliveClause: Option[MuKeepaliveClause]): Unit = {
val _node = new NodeCCall(id, resultIDs, callconv, calleeTy, sig, callee, args, excClause, keepaliveClause)
onNewNodeCreated(_node)
}
def newNewThread(id: MuID, resultID: MuID, stack: MuVarNode, threadlocal: Option[MuVarNode], newStackClause: MuNewStackClause, excClause: Option[MuExcClause]): Unit = {
val _node = new NodeNewThread(id, resultID, stack, threadlocal, newStackClause, excClause)
onNewNodeCreated(_node)
}
def newSwapStack(id: MuID, resultIds: Seq[MuID], swappee: MuVarNode, curStackClause: MuCurStackClause, newStackClause: MuNewStackClause, excClause: Option[MuExcClause], keepaliveClause: Option[MuKeepaliveClause]): Unit = {
val _node = new NodeSwapStack(id, resultIds, swappee, curStackClause, newStackClause, excClause, keepaliveClause)
def newSwapStack(id: MuID, resultIDs: Seq[MuID], swappee: MuVarNode, curStackClause: MuCurStackClause, newStackClause: MuNewStackClause, excClause: Option[MuExcClause], keepaliveClause: Option[MuKeepaliveClause]): Unit = {
val _node = new NodeSwapStack(id, resultIDs, swappee, curStackClause, newStackClause, excClause, keepaliveClause)
onNewNodeCreated(_node)
}
def newCommInst(id: MuID, resultIds: Seq[MuID], opcode: CommInst, flags: Seq[Flag], tys: Seq[MuTypeNode], sigs: Seq[MuFuncSigNode], args: Seq[MuVarNode], excClause: Option[MuExcClause], keepaliveClause: Option[MuKeepaliveClause]): Unit = {
val _node = new NodeCommInst(id, resultIds, opcode, flags, tys, sigs, args, excClause, keepaliveClause)
def newCommInst(id: MuID, resultIDs: Seq[MuID], opcode: CommInst, flags: Seq[Flag], tys: Seq[MuTypeNode], sigs: Seq[MuFuncSigNode], args: Seq[MuVarNode], excClause: Option[MuExcClause], keepaliveClause: Option[MuKeepaliveClause]): Unit = {
val _node = new NodeCommInst(id, resultIDs, opcode, flags, tys, sigs, args, excClause, keepaliveClause)
onNewNodeCreated(_node)
}
// GEN:END:IRBUILDERNODE_CONSTRUCTORS
......
......@@ -47,6 +47,11 @@ abstract class IRTypeNode extends TypeSigLike
abstract class IRSigNode extends TypeSigLike
abstract class IRConstNode extends OtherTopLevelNode
// Other nodes with refimpl-level superclasses
abstract class IRInstNode extends IRBuilderNode
abstract class IRCurStackClauseNode extends IRBuilderNode
abstract class IRNewStackClauseNode extends IRBuilderNode
// EXT:BEGIN:IRBUILDER_NODES
// format: OFF
......@@ -93,56 +98,56 @@ case class NodeExpFunc(id: MuID, func: MuFuncNode, callconv: Flag, cookie: MuCon
case class NodeFuncVer(id: MuID, func: MuFuncNode, bbs: Seq[MuBBNode]) extends IRBuilderNode
case class NodeBB(id: MuID, norParamIDs: Seq[MuID], excParamID: Option[MuID], insts: Seq[MuInstNode]) extends IRBuilderNode
case class NodeBB(id: MuID, norParamIDs: Seq[MuID], norParamTys: Seq[MuTypeNode], excParamID: Option[MuID], insts: Seq[MuInstNode]) extends IRBuilderNode
case class NodeDestClause(id: MuID, dest: MuBBNode, vars: Seq[MuVarNode]) extends IRBuilderNode
case class NodeExcClause(id: MuID, nor: MuDestClause, exc: MuDestClause) extends IRBuilderNode
case class NodeKeepaliveClause(id: MuID, vars: Seq[MuLocalVarNode]) extends IRBuilderNode
case class NodeCscRetWith(id: MuID, rettys: Seq[MuVarNode]) extends IRBuilderNode
case class NodeCscKillOld(id: MuID) extends IRBuilderNode
case class NodeCscRetWith(id: MuID, rettys: Seq[MuVarNode]) extends IRCurStackClauseNode
case class NodeCscKillOld(id: MuID) extends IRCurStackClauseNode
case class NodeNscPassValues(id: MuID, tys: Seq[MuTypeNode], vars: Seq[MuVarNode]) extends IRBuilderNode
case class NodeNscThrowExc(id: MuID, exc: MuVarNode) extends IRBuilderNode
case class NodeNscPassValues(id: MuID, tys: Seq[MuTypeNode], vars: Seq[MuVarNode]) extends IRNewStackClauseNode
case class NodeNscThrowExc(id: MuID, exc: MuVarNode) extends IRNewStackClauseNode
case class NodeBinOp(id: MuID, resultID: MuID, optr: BinOptr.Value, ty: MuTypeNode, opnd1: MuVarNode, opnd2: MuVarNode, excClaues: Option[MuExcClause]) extends IRBuilderNode
case class NodeCmp(id: MuID, resultID: MuID, optr: CmpOptr.Value, ty: MuTypeNode, opnd1: MuVarNode, opnd2: MuVarNode) extends IRBuilderNode
case class NodeConv(id: MuID, resultID: MuID, optr: ConvOptr.Value, fromTy: MuTypeNode, toTy: MuTypeNode, opnd: MuVarNode) extends IRBuilderNode
case class NodeSelect(id: MuID, resultID: MuID, condTy: MuTypeNode, opndTy: MuTypeNode, cond: MuVarNode, ifTrue: MuVarNode, ifFalse: MuVarNode) extends IRBuilderNode
case class NodeBranch(id: MuID, dest: MuDestClause) extends IRBuilderNode
case class NodeBranch2(id: MuID, cond: MuVarNode, ifTrue: MuDestClause, ifFalse: MuDestClause) extends IRBuilderNode
case class NodeSwitch(id: MuID, opndTy: MuTypeNode, opnd: MuVarNode, defaultDest: MuDestClause, cases: Seq[MuConstNode], dests: Seq[MuDestClause]) extends IRBuilderNode
case class NodeCall(id: MuID, resultIds: Seq[MuID], sig: MuFuncSigNode, callee: MuVarNode, args: Seq[MuVarNode], excClause: Option[MuExcClause], keepaliveClause: Option[MuKeepaliveClause]) extends IRBuilderNode
case class NodeTailCall(id: MuID, sig: MuFuncSigNode, callee: MuVarNode, args: Seq[MuVarNode]) extends IRBuilderNode
case class NodeRet(id: MuID, rvs: Seq[MuVarNode]) extends IRBuilderNode
case class NodeThrow(id: MuID, exc: MuVarNode) extends IRBuilderNode
case class NodeExtractValue(id: MuID, resultID: MuID, strty: MuTypeNode, index: Int, opnd: MuVarNode) extends IRBuilderNode
case class NodeInsertValue(id: MuID, resultID: MuID, strty: MuTypeNode, index: Int, opnd: MuVarNode, newval: MuVarNode) extends IRBuilderNode
case class NodeExtractElement(id: MuID, resultID: MuID, seqty: MuTypeNode, indty: MuTypeNode, opnd: MuVarNode, index: MuVarNode) extends IRBuilderNode
case class NodeInsertElement(id: MuID, resultID: MuID, seqty: MuTypeNode, indty: MuTypeNode, opnd: MuVarNode, index: MuVarNode, newval: MuVarNode) extends IRBuilderNode
case class NodeShuffleVector(id: MuID, resultID: MuID, vecty: MuTypeNode, maskty: MuTypeNode, vec1: MuVarNode, vec2: MuVarNode, mask: MuVarNode) extends IRBuilderNode
case class NodeNew(id: MuID, resultID: MuID, allocty: MuTypeNode, excClause: Option[MuExcClause]) extends IRBuilderNode
case class NodeNewHybrid(id: MuID, resultID: MuID, allocty: MuTypeNode, lenty: MuTypeNode, length: MuVarNode, excClause: Option[MuExcClause]) extends IRBuilderNode
case class NodeAlloca(id: MuID, resultID: MuID, allocty: MuTypeNode, excClause: Option[MuExcClause]) extends IRBuilderNode
case class NodeAllocaHybrid(id: MuID, resultID: MuID, allocty: MuTypeNode, lenty: MuTypeNode, length: MuVarNode, excClause: Option[MuExcClause]) extends IRBuilderNode
case class NodeGetIRef(id: MuID, resultID: MuID, refty: MuTypeNode, opnd: MuVarNode) extends IRBuilderNode
case class NodeGetFieldIRef(id: MuID, resultID: MuID, isPtr: Boolean, refty: MuTypeNode, index: Int, opnd: MuVarNode) extends IRBuilderNode
case class NodeGetElemIRef(id: MuID, resultID: MuID, isPtr: Boolean, refty: MuTypeNode, indty: MuTypeNode, opnd: MuVarNode, index: MuVarNode) extends IRBuilderNode
case class NodeShiftIRef(id: MuID, resultID: MuID, isPtr: Boolean, refty: MuTypeNode, offty: MuTypeNode, opnd: MuVarNode, offset: MuVarNode) extends IRBuilderNode
case class NodeGetVarPartIRef(id: MuID, resultID: MuID, isPtr: Boolean, refty: MuTypeNode, opnd: MuVarNode) extends IRBuilderNode
case class NodeLoad(id: MuID, resultID: MuID, isPtr: Boolean, ord: MemoryOrder.Value, refty: MuTypeNode, loc: MuVarNode, excClause: Option[MuExcClause]) extends IRBuilderNode
case class NodeStore(id: MuID, isPtr: Boolean, ord: MemoryOrder.Value, refty: MuTypeNode, loc: MuVarNode, newval: MuVarNode, excClause: Option[MuExcClause]) extends IRBuilderNode
case class NodeCmpXchg(id: MuID, valueResultID: MuID, succResultID: MuID, isPtr: Boolean, isWeak: Boolean, ordSucc: MemoryOrder.Value, ordFail: MemoryOrder.Value, refty: MuTypeNode, loc: MuVarNode, expected: MuVarNode, desired: MuVarNode, excClause: Option[MuExcClause]) extends IRBuilderNode
case class NodeAtomicRMW(id: MuID, resultID: MuID, isPtr: Boolean, ord: MemoryOrder.Value, optr: AtomicRMWOptr.Value, refTy: MuTypeNode, loc: MuVarNode, opnd: MuVarNode, excClause: Option[MuExcClause]) extends IRBuilderNode
case class NodeFence(id: MuID, ord: MemoryOrder.Value) extends IRBuilderNode
case class NodeTrap(id: MuID, resultIds: Seq[MuID], rettys: Seq[MuTypeNode], excClause: Option[MuExcClause], keepaliveClause: Option[MuKeepaliveClause]) extends IRBuilderNode
case class NodeWatchPoint(id: MuID, wpid: MuWPID, resultIds: Seq[MuID], rettys: Seq[MuTypeNode], excClause: Option[MuExcClause], keepaliveClause: Option[MuKeepaliveClause]) extends IRBuilderNode
case class NodeWPBranch(id: MuID, wpid: MuWPID) extends IRBuilderNode
case class NodeCCall(id: MuID, resultIds: Seq[MuID], callconv: Flag, calleeTy: MuTypeNode, sig: MuFuncSigNode, callee: MuVarNode, args: Seq[MuVarNode], excClause: Option[MuExcClause], keepaliveClause: Option[MuKeepaliveClause]) extends IRBuilderNode
case class NodeNewThread(id: MuID, resultID: MuID, stack: MuVarNode, threadlocal: Option[MuVarNode], newStackClause: MuNewStackClause, excClause: Option[MuExcClause]) extends IRBuilderNode
case class NodeSwapStack(id: MuID, resultIds: Seq[MuID], swappee: MuVarNode, curStackClause: MuCurStackClause, newStackClause: MuNewStackClause, excClause: Option[MuExcClause], keepaliveClause: Option[MuKeepaliveClause]) extends IRBuilderNode
case class NodeCommInst(id: MuID, resultIds: Seq[MuID], opcode: CommInst, flags: Seq[Flag], tys: Seq[MuTypeNode], sigs: Seq[MuFuncSigNode], args: Seq[MuVarNode], excClause: Option[MuExcClause], keepaliveClause: Option[MuKeepaliveClause]) extends IRBuilderNode
case class NodeBinOp(id: MuID, resultID: MuID, optr: BinOptr.Value, ty: MuTypeNode, opnd1: MuVarNode, opnd2: MuVarNode, excClause: Option[MuExcClause]) extends IRInstNode
case class NodeCmp(id: MuID, resultID: MuID, optr: CmpOptr.Value, ty: MuTypeNode, opnd1: MuVarNode, opnd2: MuVarNode) extends IRInstNode
case class NodeConv(id: MuID, resultID: MuID, optr: ConvOptr.Value, fromTy: MuTypeNode, toTy: MuTypeNode, opnd: MuVarNode) extends IRInstNode
case class NodeSelect(id: MuID, resultID: MuID, condTy: MuTypeNode, opndTy: MuTypeNode, cond: MuVarNode, ifTrue: MuVarNode, ifFalse: MuVarNode) extends IRInstNode
case class NodeBranch(id: MuID, dest: MuDestClause) extends IRInstNode
case class NodeBranch2(id: MuID, cond: MuVarNode, ifTrue: MuDestClause, ifFalse: MuDestClause) extends IRInstNode
case class NodeSwitch(id: MuID, opndTy: MuTypeNode, opnd: MuVarNode, defaultDest: MuDestClause, cases: Seq[MuConstNode], dests: Seq[MuDestClause]) extends IRInstNode
case class NodeCall(id: MuID, resultIDs: Seq[MuID], sig: MuFuncSigNode, callee: MuVarNode, args: Seq[MuVarNode], excClause: Option[MuExcClause], keepaliveClause: Option[MuKeepaliveClause]) extends IRInstNode
case class NodeTailCall(id: MuID, sig: MuFuncSigNode, callee: MuVarNode, args: Seq[MuVarNode]) extends IRInstNode
case class NodeRet(id: MuID, rvs: Seq[MuVarNode]) extends IRInstNode
case class NodeThrow(id: MuID, exc: MuVarNode) extends IRInstNode
case class NodeExtractValue(id: MuID, resultID: MuID, strty: MuTypeNode, index: Int, opnd: MuVarNode) extends IRInstNode
case class NodeInsertValue(id: MuID, resultID: MuID, strty: MuTypeNode, index: Int, opnd: MuVarNode, newval: MuVarNode) extends IRInstNode
case class NodeExtractElement(id: MuID, resultID: MuID, seqty: MuTypeNode, indty: MuTypeNode, opnd: MuVarNode, index: MuVarNode) extends IRInstNode
case class NodeInsertElement(id: MuID, resultID: MuID, seqty: MuTypeNode, indty: MuTypeNode, opnd: MuVarNode, index: MuVarNode, newval: MuVarNode) extends IRInstNode
case class NodeShuffleVector(id: MuID, resultID: MuID, vecty: MuTypeNode, maskty: MuTypeNode, vec1: MuVarNode, vec2: MuVarNode, mask: MuVarNode) extends IRInstNode
case class NodeNew(id: MuID, resultID: MuID, allocty: MuTypeNode, excClause: Option[MuExcClause]) extends IRInstNode
case class NodeNewHybrid(id: MuID, resultID: MuID, allocty: MuTypeNode, lenty: MuTypeNode, length: MuVarNode<