Commit de2867ae authored by Kunshan Wang's avatar Kunshan Wang

internal IR builder nodes

parent 3884e361
""" This is for one-time use only. It generates contents of
uvm.ir.irbuilder/irBuilderNode.scala, but that file should be maintained
manually in the long run. """
import muapiparser
from refimpl2injectablefiles import muapi_h_path
from muapitocstubs import toCamelCase
_to_scala_type = {
"int": "Int",
"MuBool": "Boolean",
}
def to_scala_type(rt):
return _to_scala_type.get(rt, rt)
def generate_node(method):
func_name = toCamelCase(method["name"])
node_name = "Node" + func_name[3:]
params = method["params"][1:] # skip MuIRBuilder*
node_params = []
for param in params:
pn = param['name']
pt = param['type']
nn = toCamelCase(pn)
if param.get("is_sz_param", False):
continue
elif 'array_sz_param' in param:
assert pt.endswith("*")
rt = pt[:-1]
st = to_scala_type(rt)
nt = "Seq[{}]".format(pt[:-1])
elif param.get('is_optional', False):
assert pt in ["MuCString", "MuID"] or pt.endswith("*") or any(
pt.endswith(x) for x in ["Clause", "Node"]), pt
if pt.endswith("*"):
rt = pt[:-1]
else:
rt = pt
st = to_scala_type(rt)
nt = "Option[{}]".format(rt)
else:
rt = pt
st = to_scala_type(rt)
nt = st
node_params.append((nn, nt))
return '''case class {}({}) extends IRBuilderNode(id)'''.format(
node_name, ", ".join("{}: {}".format(nn, nt) for (nn, nt) in node_params))
def generate_things(ast):
irb = [s for s in ast["structs"] if s["name"] == "MuIRBuilder"][0]
nodes = []
for meth in irb["methods"]:
if meth["name"].startswith("new_"):
nodes.append(generate_node(meth))
return "\n".join(nodes)
def main():
with open(muapi_h_path) as f:
src_text = f.read()
ast = muapiparser.parse_muapi(src_text)
generated = generate_things(ast)
print(generated)
if __name__=='__main__':
main()
......@@ -35,7 +35,7 @@ def find_line(lines: List[str], substr: Predicate, start: int = 0) -> int:
if pred(lines[i], substr):
return i
raise KeyError("Not found: " + str(substr) + "\n text:" + str(lines) )
raise Exception("Not found: " + str(substr) + "\n text:" + str(lines) )
def extract_lines(parent: str, begin: Predicate, end: Predicate) -> str:
"""
......
"""
Usage: python3 irbuildernodestoirbuildermethods.py
"""
import re
import sys, os.path, io
import injecttools
from refimpl2injectablefiles import injectable_files, irbuilder_nodes_path
replaces = [(re.compile(x), y) for (x,y) in [
(r'TrantientBundle', 'MuBundleNode'),
(r'TB', 'MuBundleNode'),
(r'Bundle', 'MuBundleNode'),
(r'TopLevel', 'MuChildNode'),
(r'ChildNode', 'MuChildNode'),
(r'Type\w*', 'MuTypeNode'),
(r'Abstract\w+Type', 'MuTypeNode'),
(r'FuncSig', 'MuFuncSigNode'),
(r'Const\w+', 'MuConstNode'),
(r'GlobalCell', 'MuGlobalNode'),
(r'Function', 'MuFuncNode'),
(r'ExposedFunc', 'MuExpFuncNode'),
(r'FuncVer', 'MuFuncVerNode'),
(r'BasicBlock', 'MuBBNode'),
(r'BB', 'MuBBNode'),
(r'SSAVariable', 'MuVarNode'),
(r'Var', 'MuVarNode'),
(r'LocalVariable', 'MuLocalVarNode'),
(r'NorParam', 'MuNorParamNode'),
(r'ExcParam', 'MuExcParamNode'),
(r'InstResult', 'MuInstResNode'),
(r'Inst\w+', 'MuInstNode'),
(r'HasKeepaliveClause', 'MuInstNode'),
]]
case_class_r = re.compile(r'^(case\s+class\s+(\w+)\s*\(([^)]*)\))', re.MULTILINE)
arg = re.compile(r'(\w+):\s*([a-zA-Z0-9\[\].]+)')
begin="EXT:BEGIN:IRBUILDER_NODES"
end="EXT:END:IRBUILDER_NODES"
def main():
with open(irbuilder_nodes_path) as f:
lines = f.read()
text = injecttools.extract_lines(lines, begin, end)
output = io.StringIO()
for whole, name, arglist in case_class_r.findall(text):
node_name = name
func_name = "new" + name[4:]
argnames = []
argtypes = []
for an,at in arg.findall(arglist):
argnames.append(an)
argtypes.append(at)
print(" def {}({}): Unit = {{".format(func_name, ", ".join(
"{}: {}".format(an, at) for an, at in zip(argnames, argtypes))),
file=output)
print(" val _node = new {}({})".format(node_name,
", ".join(argnames)), file=output)
print(" onNewNodeCreated(_node)", file=output)
print(" }", file=output)
#print(output.getvalue())
#return
injectable_files["IRBuilder.scala"].inject_many({
"IRBUILDERNODE_CONSTRUCTORS": output.getvalue(),
})
if __name__=='__main__':
main()
"""
USAGE: python3 migrate_scripts/irbuildertomuctx.py
And then paste the result intoUse pbcopy on Mac.
IRBuilder is no longer part of MuCtx. Don't use this.
"""
import re
......
......@@ -429,4 +429,5 @@ def main():
"STUBS": generated,
})
main()
if __name__=='__main__':
main()
......@@ -300,4 +300,5 @@ def main():
"MuCtx": muctx_stubs,
})
main()
if __name__=='__main__':
main()
......@@ -8,7 +8,8 @@ def _make_injectable_file_set(m):
m2 = {os.path.join(_refimpl2_root, k): v for k,v in m.items()}
return InjectableFileSet(m2)
muapi_h_path = os.path.join(_my_dir, "../cbinding/muapi.h")
muapi_h_path = os.path.join(_refimpl2_root, "cbinding/muapi.h")
irbuilder_nodes_path = os.path.join(_refimpl2_root, "src/main/scala/uvm/ir/irbuilder/irBuilderNodes.scala")
injectable_files = injecttools.make_injectable_file_set(_refimpl2_root, [
("cStubs.scala", "src/main/scala/uvm/refimpl/nat/cStubs.scala",
......@@ -25,4 +26,6 @@ injectable_files = injecttools.make_injectable_file_set(_refimpl2_root, [
["IRBUILDER_IMPL"]),
("MuCtxIRBuilderPart.scala", "src/main/scala/uvm/refimpl/MuCtxIRBuilderPart.scala",
["METHODS"]),
("IRBuilder.scala", "src/main/scala/uvm/ir/irbuilder/IRBuilder.scala",
["IRBUILDERNODE_CONSTRUCTORS"]),
])
python3 irbuildertomuctx.py
python3 muapitocstubs.py
python3 muapitoirbuildercomminstsimpl.py
python3 muapitolibmupy.py
......@@ -8,6 +8,7 @@ import uvm.ssavariables._
import uvm.types._
import uvm.utils.IDFactory
import uvm.staticanalysis.InstructionResultInferer
import scala.collection.mutable.HashMap
object IRBuilder {
......@@ -48,26 +49,22 @@ object IRBuilder {
sym
}
type MuTypeNode = MuID
}
class IRBuilder(globalBundle: GlobalBundle, idFactory: IDFactory) {
import IRBuilder._
import IRBuilderNode._
import uvm.RichIdentifiedSettable._
private def nextID(): Int = idFactory.getID()
private def newObj[T <: IdentifiedSettable, U >: T <: Identified](ns: Namespace[U], obj: T): T = {
obj := nextID()
ns.add(obj)
obj
}
// For relieving my eye fatigue :)
private type TB = TrantientBundle
private type BB = BasicBlock
private type Var = SSAVariable
private val idNameMap = new HashMap[MuID, MuName]()
private val nodeList = new ArrayBuffer[IRBuilderNode]()
private def onNewNodeCreated(node: IRBuilderNode): Unit = {
nodeList += node
}
// There are scripts in microvm-refimpl2/migrate_scripts/ to convert this program to the MuCtxIRBuilderPart or the
// common instruction executor. Keep the next line exact
......@@ -76,358 +73,316 @@ class IRBuilder(globalBundle: GlobalBundle, idFactory: IDFactory) {
def load(): Unit = ???
def abort(): Unit = ???
def genSym(name: Option[String]): Unit = ???
// format: OFF
def newTypeInt (id: MuID, len: Int): Unit = ???
def newTypeFloat (id: MuID): Unit = ???
def newTypeDouble (id: MuID): Unit = ???
def newTypeUPtr (id: MuID): Unit = ???
def newTypeUFuncPtr (id: MuID): Unit = ???
def newTypeVoid (id: MuID): Unit = ???
def newTypeRef (id: MuID): Unit = ???
def newTypeIRef (id: MuID): Unit = ???
def newTypeWeakRef (id: MuID): Unit = ???
def newTypeFuncRef (id: MuID): Unit = ???
def newTypeTagRef64 (id: MuID): Unit = ???
def newTypeThreadRef (id: MuID): Unit = ???
def newTypeStackRef (id: MuID): Unit = ???
def newTypeFrameCursorRef(id: MuID): Unit = ???
def newTypeIRBuilderRef (id: MuID): Unit = ???
def newTypeStruct(b: TB, fieldTys: Seq[Type]): TypeStruct = newObj(b.typeNs, TypeStruct(fieldTys))
def newTypeHybrid(b: TB, fixedTys: Seq[Type], varTy: Type): TypeHybrid = newObj(b.typeNs, TypeHybrid(fixedTys, varTy))
def newTypeArray (b: TB, elemTy: Type, len: Long): TypeArray = newObj(b.typeNs, TypeArray(elemTy, len))
def newTypeVector(b: TB, elemTy: Type, len: Long): TypeVector = newObj(b.typeNs, TypeVector(elemTy, len))
def setTypeUPtr (uptr: TypeUPtr, ty: Type): Unit = uptr.ty = ty
def setTypeRef (ref: TypeRef, ty: Type): Unit = ref.ty = ty
def setTypeIRef (iref: TypeIRef, ty: Type): Unit = iref.ty = ty
def setTypeWeakRef (weakref: TypeWeakRef, ty: Type): Unit = weakref.ty = ty
def setTypeUFuncPtr(ufuncptr: TypeUFuncPtr, sig: FuncSig): Unit = ufuncptr.sig = sig
def setTypeFuncRef (funcref: TypeFuncRef, sig: FuncSig): Unit = funcref.sig = sig
// format: ON
def newFuncSig(b: TB, paramTys: Seq[Type], retTys: Seq[Type]): FuncSig = {
newObj(b.funcSigNs, new FuncSig(paramTys, retTys))
def genSym(name: Option[String]): MuID = {
val id = nextID()
name foreach { n =>
idNameMap(id) = n
}
id
}
// format: OFF
def newConstInt (b: TB, ty: Type, value: BigInt): ConstInt = newObj(b.constantNs, ConstInt(ty, value))
def newConstFloat (b: TB, ty: Type, value: Float): ConstFloat = newObj(b.constantNs, ConstFloat(ty, value))
def newConstDouble(b: TB, ty: Type, value: Double): ConstDouble = newObj(b.constantNs, ConstDouble(ty, value))
def newConstNull (b: TB, ty: Type): ConstNull = newObj(b.constantNs, ConstNull(ty))
def newConstSeq (b: TB, ty: Type, elems: Seq[Constant]): ConstSeq = newObj(b.constantNs, ConstSeq(ty, elems))
def newConstExtern(b: TB, ty: Type, symbol: String): ConstExtern = newObj(b.constantNs, ConstExtern(ty, validateSymbol(symbol)))
// format: ON
def newGlobalCell(b: TB, ty: Type): GlobalCell = newObj(b.globalCellNs, new GlobalCell(ty))
def newFunc(b: TB, sig: FuncSig): Function = {
val func = new Function()
func.sig = sig
newObj(b.funcNs, func)
// GEN:BEGIN:IRBUILDERNODE_CONSTRUCTORS
def newTypeInt(id: MuID, len: Int): Unit = {
val _node = new NodeTypeInt(id, len)
onNewNodeCreated(_node)
}
def newFuncVer(b: TB, func: Function): FuncVer = {
val funcVer = new FuncVer(func)
funcVer.bbs = new ArrayBuffer()
funcVer.bbNs = b.allNs.makeSubSpace[BB]("basic block")
newObj(b.funcVerNs, funcVer)
def newTypeFloat(id: MuID): Unit = {
val _node = new NodeTypeFloat(id)
onNewNodeCreated(_node)
}
def newExpFunc(b: TB, func: Function, callconv: Flag, cookie: ConstInt): ExposedFunc = {
val expFunc = new ExposedFunc(func, callconv, cookie)
newObj(b.expFuncNs, expFunc)
def newTypeDouble(id: MuID): Unit = {
val _node = new NodeTypeDouble(id)
onNewNodeCreated(_node)
}
def newBB(fv: FuncVer): BB = {
val bb = new BB(fv)
fv.bbs += bb
bb.norParams = new ArrayBuffer()
bb.excParam = None
bb.insts = new ArrayBuffer()
val allNs = fv.bbNs.maybeParent.get.asInstanceOf[NestedNamespace[Identified]]
bb.localVarNs = allNs.makeSubSpace[LocalVariable]("local variable")
bb.localInstNs = allNs.makeSubSpace[Instruction]("instruction")
newObj(fv.bbNs, bb)
def newTypeUPtr(id: MuID, ty: MuTypeNode): Unit = {
val _node = new NodeTypeUPtr(id, ty)
onNewNodeCreated(_node)
}
def newNorParam(bb: BB, ty: Type): NorParam = {
val np = NorParam(ty)
bb.norParams += np
newObj(bb.localVarNs, np)
def newTypeUFuncPtr(id: MuID, sig: MuFuncSigNode): Unit = {
val _node = new NodeTypeUFuncPtr(id, sig)
onNewNodeCreated(_node)
}
def newExcParam(bb: BB): ExcParam = {
val ep = ExcParam()
bb.excParam = Some(ep)
newObj(bb.localVarNs, ep)
def newTypeStruct(id: MuID, fieldTys: Seq[MuTypeNode]): Unit = {
val _node = new NodeTypeStruct(id, fieldTys)
onNewNodeCreated(_node)
}
def getInstRes(inst: Instruction, index: Int): InstResult = {
require(0 <= index && index < inst.results.size,
"Instruction %s has only %d results, but result %d is requested".format(inst, inst.results.size, index))
inst.results(index)
def newTypeHybrid(id: MuID, fixedTys: Seq[MuTypeNode], varTy: MuTypeNode): Unit = {
val _node = new NodeTypeHybrid(id, fixedTys, varTy)
onNewNodeCreated(_node)
}
def getNumInstRes(inst: Instruction): Int = {
inst.results.size
def newTypeArray(id: MuID, elemTy: MuTypeNode, len: Long): Unit = {
val _node = new NodeTypeArray(id, elemTy, len)
onNewNodeCreated(_node)
}
private def getOrCreateExcClause(inst: HasExcClause): ExcClause = {
inst.excClause.getOrElse {
val newExcClause = ExcClause(null, null)
inst.excClause = Some(newExcClause)
newExcClause
}
def newTypeVector(id: MuID, elemTy: MuTypeNode, len: Long): Unit = {
val _node = new NodeTypeVector(id, elemTy, len)
onNewNodeCreated(_node)
}
def addKeepalives(inst: HasKeepaliveClause, lvs: Seq[LocalVariable]): Unit = {
inst.keepalives = lvs
def newTypeVoid(id: MuID): Unit = {
val _node = new NodeTypeVoid(id)
onNewNodeCreated(_node)
}
private def inferResults(ns: Namespace[LocalVariable], inst: Instruction): IndexedSeq[InstResult] = {
val nResults = InstructionResultInferer.inferInstResultNum(inst)
val results = for (i <- 0 until nResults) yield {
newObj(ns, InstResult(inst, i))
}
results.to[IndexedSeq]
def newTypeRef(id: MuID, ty: MuTypeNode): Unit = {
val _node = new NodeTypeRef(id, ty)
onNewNodeCreated(_node)
}
private def newInst[T <: Instruction](bb: BB, inst: T): T = {
bb.insts += inst
inst.bb = bb
inst.results = inferResults(bb.localVarNs, inst)
newObj(bb.localInstNs, inst)
def newTypeIRef(id: MuID, ty: MuTypeNode): Unit = {
val _node = new NodeTypeIRef(id, ty)
onNewNodeCreated(_node)
}
def newBinOp(bb: BB, optr: BinOptr.Value, ty: Type, opnd1: Var, opnd2: Var): InstBinOp = {
val inst = InstBinOp(optr, ty, opnd1, opnd2, None)
newInst(bb, inst)
def newTypeWeakRef(id: MuID, ty: MuTypeNode): Unit = {
val _node = new NodeTypeWeakRef(id, ty)
onNewNodeCreated(_node)
}
def newCmp(bb: BB, optr: CmpOptr.Value, ty: Type, opnd1: Var, opnd2: Var): InstCmp = {
val inst = InstCmp(optr, ty, opnd1, opnd2)
newInst(bb, inst)
def newTypeFuncRef(id: MuID, sig: MuFuncSigNode): Unit = {
val _node = new NodeTypeFuncRef(id, sig)
onNewNodeCreated(_node)
}
def newConv(bb: BB, optr: ConvOptr.Value, fromTy: Type, toTy: Type, opnd: Var): InstConv = {
val inst = InstConv(optr, fromTy, toTy, opnd)
newInst(bb, inst)
def newTypeTagRef64(id: MuID): Unit = {
val _node = new NodeTypeTagRef64(id)
onNewNodeCreated(_node)
}
def newSelect(bb: BB, condTy: Type, opndTy: Type, cond: Var, ifTrue: Var, ifFalse: Var): InstSelect = {
val inst = InstSelect(condTy, opndTy, cond, ifTrue, ifFalse)
newInst(bb, inst)
def newTypeThreadRef(id: MuID): Unit = {
val _node = new NodeTypeThreadRef(id)
onNewNodeCreated(_node)
}
def newBranch(bb: BB): InstBranch = {
val inst = InstBranch(null)
newInst(bb, inst)
def newTypeStackRef(id: MuID): Unit = {
val _node = new NodeTypeStackRef(id)
onNewNodeCreated(_node)
}
def newBranch2(bb: BB, cond: Var): InstBranch2 = {
val inst = InstBranch2(cond, null, null)
newInst(bb, inst)
def newTypeFrameCursorRef(id: MuID): Unit = {
val _node = new NodeTypeFrameCursorRef(id)
onNewNodeCreated(_node)
}
def newSwitch(bb: BB, opndTy: Type, opnd: Var): InstSwitch = {
val inst = InstSwitch(opndTy, opnd, null, new ArrayBuffer())
newInst(bb, inst)
def newTypeIRBuilderRef(id: MuID): Unit = {
val _node = new NodeTypeIRBuilderRef(id)
onNewNodeCreated(_node)
}
def addSwitchDest(inst: InstSwitch, key: Var, bb: BB, vars: Seq[Var]): Unit = {
val destClause = DestClause(bb, vars)
inst.cases += (key -> destClause)
def newFuncSig(id: MuID, paramTys: Seq[MuTypeNode], retTys: Seq[MuTypeNode]): Unit = {
val _node = new NodeFuncSig(id, paramTys, retTys)
onNewNodeCreated(_node)
}
def newCall(bb: BB, sig: FuncSig, callee: Var, args: Seq[Var]): InstCall = {
val inst = InstCall(sig, callee, args, None, Seq())
newInst(bb, inst)
def newConstInt(id: MuID, ty: MuTypeNode, value: BigInt): Unit = {
val _node = new NodeConstInt(id, ty, value)
onNewNodeCreated(_node)
}
def newTailCall(bb: BB, sig: FuncSig, callee: Var, args: Seq[Var]): InstTailCall = {
val inst = InstTailCall(sig, callee, args)
newInst(bb, inst)
def newConstFloat(id: MuID, ty: MuTypeNode, value: Float): Unit = {
val _node = new NodeConstFloat(id, ty, value)
onNewNodeCreated(_node)
}
def newRet(bb: BB, rvs: Seq[Var]): InstRet = {
val inst = InstRet(bb.funcVer, rvs)
newInst(bb, inst)
def newConstDouble(id: MuID, ty: MuTypeNode, value: Double): Unit = {
val _node = new NodeConstDouble(id, ty, value)
onNewNodeCreated(_node)
}
def newThrow(bb: BB, exc: Var): InstThrow = {
val inst = InstThrow(exc)
newInst(bb, inst)
def newConstNull(id: MuID, ty: MuTypeNode): Unit = {
val _node = new NodeConstNull(id, ty)
onNewNodeCreated(_node)
}
def newExtractValue(bb: BB, strTy: TypeStruct, index: Int, opnd: Var): InstExtractValue = {
val inst = InstExtractValue(strTy, index, opnd)
newInst(bb, inst)
def newConstSeq(id: MuID, ty: MuTypeNode, elems: Seq[MuGlobalVarNode]): Unit = {
val _node = new NodeConstSeq(id, ty, elems)
onNewNodeCreated(_node)
}
def newInsertValue(bb: BB, strTy: TypeStruct, index: Int, opnd: Var, newVal: Var): InstInsertValue = {
val inst = InstInsertValue(strTy, index, opnd, newVal)
newInst(bb, inst)
def newConstExtern(id: MuID, ty: MuTypeNode, symbol: String): Unit = {
val _node = new NodeConstExtern(id, ty, symbol)
onNewNodeCreated(_node)
}
def newExtractElement(bb: BB, seqTy: AbstractSeqType, indTy: TypeInt, opnd: Var, index: Var): InstExtractElement = {
val inst = InstExtractElement(seqTy, indTy, opnd, index)
newInst(bb, inst)
def newGlobalCell(id: MuID, ty: MuTypeNode): Unit = {
val _node = new NodeGlobalCell(id, ty)
onNewNodeCreated(_node)
}
def newInsertElement(bb: BB, seqTy: AbstractSeqType, indTy: TypeInt, opnd: Var, index: Var, newVal: Var): InstInsertElement = {
val inst = InstInsertElement(seqTy, indTy, opnd, index, newVal)
newInst(bb, inst)
def newFunc(id: MuID, sig: MuFuncSigNode): Unit = {
val _node = new NodeFunc(id, sig)
onNewNodeCreated(_node)
}
def newShuffleVector(bb: BB, vecTy: TypeVector, maskTy: TypeVector, vec1: Var, vec2: Var, mask: Var): InstShuffleVector = {
val inst = InstShuffleVector(vecTy, maskTy, vec1, vec2, mask)
newInst(bb, inst)
def newExpFunc(id: MuID, func: MuFuncNode, callconv: MuCallConv, cookie: MuConstIntNode): Unit = {
val _node = new NodeExpFunc(id, func, callconv, cookie)
onNewNodeCreated(_node)
}
def newNew(bb: BB, allocTy: Type): InstNew = {
val inst = InstNew(allocTy, None)
newInst(bb, inst)
def newFuncVer(id: MuID, func: MuFuncNode, bbs: Seq[MuBBNode]): Unit = {
val _node = new NodeFuncVer(id, func, bbs)
onNewNodeCreated(_node)
}
def newNewHybrid(bb: BB, allocTy: TypeHybrid, lenTy: TypeInt, len: Var): InstNewHybrid = {
val inst = InstNewHybrid(allocTy, lenTy, len, None)
newInst(bb, inst)
def newBB(id: MuID, norParamIDs: Seq[MuID], excParamID: Option[MuID], insts: Seq[MuInstNode]): Unit = {
val _node = new NodeBB(id, norParamIDs, excParamID, insts)
onNewNodeCreated(_node)
}
def newAlloca(bb: BB, allocTy: Type): InstAlloca = {
val inst = InstAlloca(allocTy, None)
newInst(bb, inst)
def newDestClause(id: MuID, dest: MuBBNode, vars: Seq[MuVarNode]): Unit = {
val _node = new NodeDestClause(id, dest, vars)
onNewNodeCreated(_node)
}
def newAllocaHybrid(bb: BB, allocTy: TypeHybrid, lenTy: TypeInt, len: Var): InstAllocaHybrid = {
val inst = InstAllocaHybrid(allocTy, lenTy, len, None)
newInst(bb, inst)
def newExcClause(id: MuID, nor: MuDestClause, exc: MuDestClause): Unit = {
val _node = new NodeExcClause(id, nor, exc)
onNewNodeCreated(_node)
}
def newGetIRef(bb: BB, refTy: Type, opnd: Var): InstGetIRef = {
val inst = InstGetIRef(refTy, opnd)
newInst(bb, inst)
def newKeepAliveClasue(id: MuID, vars: Seq[MuLocalVarNode]): Unit = {
val _node = new NodeKeepAliveClasue(id, vars)
onNewNodeCreated(_node)
}
def newGetFieldIRef(bb: BB, isPtr: Boolean, refTy: AbstractStructType, index: Int, opnd: Var): InstGetFieldIRef = {
val inst = InstGetFieldIRef(isPtr, refTy, index, opnd)
newInst(bb, inst)
def newCscRetWith(id: MuID, rettys: Seq[MuVarNode]): Unit = {
val _node = new NodeCscRetWith(id, rettys)
onNewNodeCreated(_node)
}
def newGetElemIRef(bb: BB, isPtr: Boolean, refTy: AbstractSeqType, indTy: TypeInt, opnd: Var, index: Var): InstGetElemIRef = {
val inst = InstGetElemIRef(isPtr, refTy, indTy, opnd, index)
newInst(bb, inst)
def newCscKillOld(id: MuID): Unit = {
val _node = new NodeCscKillOld(id)
onNewNodeCreated(_node)
}
def newShiftIRef(bb: BB, isPtr: Boolean, refTy: Type, offTy: TypeInt, opnd: Var, offset: Var): InstShiftIRef = {
val inst = InstShiftIRef(isPtr, refTy, offTy, opnd, offset)
newInst(bb, inst)
def newNscPassValues(id: MuID, tys: Seq[MuTypeNode], vars: Seq[MuVarNode]): Unit = {
val _node = new NodeNscPassValues(id, tys, vars)
onNewNodeCreated(_node)
}
def newGetVarPartIRef(bb: BB, isPtr: Boolean, refTy: TypeHybrid, opnd: Var): InstGetVarPartIRef = {
val inst = InstGetVarPartIRef(isPtr, refTy, opnd)
newInst(bb, inst)
def newNscThrowExc(id: MuID, exc: MuVarNode): Unit = {
val _node = new NodeNscThrowExc(id, exc)
onNewNodeCreated(_node)
}
def newLoad(bb: BB, isPtr: Boolean, ord: MemoryOrder.Value, refTy: Type, loc: Var): InstLoad = {
val inst = InstLoad(isPtr, ord, refTy, loc, None)
newInst(bb, inst)
def newBinOp(id: MuID, resultID: MuID, optr: MuBinOptr, ty: MuTypeNode, opnd1: MuVarNode, opnd2: MuVarNode, excClaues: Option[MuExcClause]): Unit = {
val _node = new NodeBinOp(id, resultID, optr, ty, opnd1, opnd2, excClaues)
onNewNodeCreated(_node)
}
def newStore(bb: BB, isPtr: Boolean, ord: MemoryOrder.Value, refTy: Type, loc: Var, newVal: Var): InstStore = {
val inst = InstStore(isPtr, ord, refTy, loc, newVal, None)
newInst(bb, inst)
def newCmp(id: MuID, resultID: MuID, optr: MuBinOptr, ty: MuTypeNode, opnd1: MuVarNode, opnd2: MuVarNode): Unit = {
val _node = new NodeCmp(id, resultID, optr, ty, opnd1, opnd2)