Commit 7fa800a0 authored by Kunshan Wang's avatar Kunshan Wang

irbuilder comminst stubs

parent 5f51b057
import re
from typing import List, Union, Tuple, Any, Callable, TypeVar
from typing import List, Union, Tuple, Any, Callable, TypeVar, Mapping
from typing.re import Pattern
import tempfile, os.path
Predicate = Union[str,
Tuple[Pattern, ...],
Callable[[Any], bool]]
......@@ -62,3 +64,61 @@ def inject_lines(parent: str, begin: Predicate, end: Predicate, generated: str)
new_lines = lines[:begin_line+1] + generated.splitlines() + lines[end_line:]
return "\n".join(new_lines)
STANDARD_PREFIX_BEGIN = "GEN:BEGIN:"
STANDARD_PREFIX_END = "GEN:END:"
class StandardInjectableFile(object):
def __init__(self, path: str, injection_points: List[str] = None):
self.path = path
if injection_points is None:
injection_points = []
self.injection_points = injection_points
def inject_many(self, m: Mapping[str, str], force=False):
with open(self.path) as f:
orig_txt = f.read()
txt = orig_txt
for inj_point, inj_content in m.items():
if inj_point not in self.injection_points and not force:
raise Exception("Unknown injection point '{}'".format(inj_point))
inj_begin = STANDARD_PREFIX_BEGIN + inj_point
inj_end = STANDARD_PREFIX_END + inj_point
new_txt = inject_lines(txt, inj_begin, inj_end, inj_content)
txt = new_txt
with tempfile.NamedTemporaryFile("w", delete=False) as f:
print("Backup to temporary file: {} -> {}".format(self.path, f.name))
f.write(orig_txt)
with open(self.path, "w") as f:
print("Writing to file: {}".format(self.path))
f.write(txt)
def make_injectable_file_set(
root_path: str,
items : List[Tuple[str, str, List[str]]],
) -> Mapping[str, StandardInjectableFile]:
m = {}
for name, path, inj_points in items:
full_path = os.path.join(root_path, path)
sif = StandardInjectableFile(full_path, inj_points)
m[name] = sif
return m
class InjectableFileSet(object):
def __init__(self, m: Mapping[str, List[str]]):
self.injectable_files = {}
for path, inj_points in m.items():
inj_file = StandardInjectableFile(path, inj_points)
self.injectable_files[path] = inj_file
def __getitem__(self, key):
try:
return self.injectable_files[key]
except KeyError as e:
raise Exception("Unknown injectable file {}".format(key))
"""
Read muapi.h and write common instruction definitions in reStructuredText.
Usage: python3 muapitoirbuildercomminstsimpl.py
"""
import muapiparser
import sys, os
from collections import namedtuple
from refimpl2injectablefiles import injectable_files
start_id_comminst = 0x300 # this is in the spec
#start_id_constant = 0x400
CommInstDesc = namedtuple("CommInstDesc", """
funcname
paramnames
cparamtys
cretty
muid
muname
muparamtys
muretty
pragmas
arrays
sizes
bools
""".split())
_type_map = {
"void" : "",
"MuID" : "int<32>",
"MuName" : "iref<int<8>>",
"MuBool" : "int<32>",
"MuWPID" : "int<32>",
"MuArraySize" : "int<64>",
"MuBinOptr" : "int<32>",
"MuCmpOptr" : "int<32>",
"MuConvOptr" : "int<32>",
"MuDestKind" : "int<32>",
"MuMemOrd" : "int<32>",
"MuAtomicRMWOptr" : "int<32>",
"MuCallConv" : "int<32>",
"MuCommInst" : "int<32>",
"MuFlag" : "int<32>",
"int" : "int<32>",
"long" : "int<64>",
"int8_t" : "int<8>",
"uint8_t" : "int<8>",
"int16_t" : "int<16>",
"uint16_t" : "int<16>",
"int32_t" : "int<32>",
"uint32_t" : "int<32>",
"int64_t" : "int<64>",
"uint64_t" : "int<64>",
"intptr_t" : "int<64>",
"uintptr_t" : "int<64>",
"float" : "float",
"double" : "double",
}
def to_mu_ty(cty):
if cty.endswith("*"):
return "iref<{}>".format(to_mu_ty(cty[:-1]))
elif cty.startswith("Mu") and cty.endswith("Node"):
return "irnoderef"
elif cty in _type_map:
return _type_map[cty]
else:
raise Exception("I don't know how to translate: {}".format(cty))
def get_comminsts(ast):
muctx_methods = [s["methods"] for s in ast["structs"]
if s["name"] == "MuCtx"][0]
index_new_bundle = 0
while muctx_methods[index_new_bundle]["name"] != "new_bundle":
index_new_bundle += 1
next_id = start_id_comminst
comminsts = []
for i in range(index_new_bundle, len(muctx_methods)):
meth = muctx_methods[i]
name = meth["name"]
cparams = meth["params"]
cretty = meth["ret_ty"]
pragmas = meth["pragmas"]
arrays = {}
sizes = set()
bools = set()
paramnames = []
cparamtys = []
muparamtys = []
for param in cparams[1:]: # skip MuCtx*
pn = param["name"]
pt = param["type"]
mpt = to_mu_ty(pt)
paramnames.append(pn)
cparamtys.append(pt)
muparamtys.append(mpt)
mypragmas = [pw for pw in (p.split(":") for p in pragmas) if pw[0] == pn]
for pragma in mypragmas:
if pragma[1] == "array":
sz = pragma[2]
arrays[pn] = sz
sizes.add(sz)
elif pragma[1] == "bool":
bools.add(pn)
muretty = to_mu_ty(cretty)
comminst = CommInstDesc(
funcname = name,
paramnames = paramnames,
cparamtys = cparamtys,
cretty = cretty,
pragmas = pragmas,
muid = next_id,
muname = "@uvm.irbuilder." + name,
muparamtys = muparamtys,
muretty = muretty,
arrays = arrays,
sizes = sizes,
bools = bools,
)
comminsts.append(comminst)
next_id += 1
return comminsts
def gen_comminsts_defs(comminsts):
lines = []
for comminst in comminsts:
lines.append(' commInst(0x{:x}, "{}")'.format(
comminst.muid, comminst.muname))
return "\n".join(lines)
_mu_ty_to_internal = {
"": "", # no return values
#"int<1>": "I1",
#"int<8>": "I8",
#"int<16>": "I16",
"int<32>": "I32",
#"int<64>": "I64",
#"float": "FLOAT",
#"double": "DOUBLE",
"irnoderef": "IRNODEREF",
}
def mu_ty_to_internal(mty):
if mty in _mu_ty_to_internal:
return _mu_ty_to_internal[mty]
raise Exception("I don't know how to convert to internal: {}".format(mty))
def gen_comminsts_retvals(comminsts):
lines = []
for comminst in comminsts:
lines.append(' case "{}" => Seq({})'.format(
comminst.muname, mu_ty_to_internal(comminst.muretty)))
return "\n".join(lines)
def gen_comminsts_impls(comminsts):
lines = []
for comminst in comminsts:
lines.append(' case "{}" => ???'.format(comminst.muname))
return "\n".join(lines)
my_dir = os.path.dirname(__file__)
muapi_h_path = os.path.join(my_dir, "../cbinding/muapi.h")
#dst_path = os.path.join(my_dir, "../pythonbinding/libmu.py")
def main():
with open(muapi_h_path) as f:
txt = f.read()
ast = muapiparser.parse_muapi(txt)
comminsts = get_comminsts(ast)
comminsts_defs = gen_comminsts_defs(comminsts)
comminsts_retvals = gen_comminsts_retvals(comminsts)
comminsts_impls = gen_comminsts_impls(comminsts)
#print(comminsts_defs)
injectable_files["comminsts.scala"].inject_many({
"IRBUILDER_COMMINSTS": comminsts_defs,
})
injectable_files["internals.scala"].inject_many({
"IRBUILDER_RETVALS": comminsts_retvals,
})
injectable_files["ir-ci-exec"].inject_many({
"IRBUILDER_IMPL": comminsts_impls,
})
#print()
#print_constants(ast) # Do not print. This merely pollutes the pre-loaded
# space with more constants, and not profitable.
# We keep muapi.h as the canonical definition.
# Clients should define their own constants.
if __name__=='__main__':
main()
import injecttools
import os.path
_my_dir = os.path.dirname(__file__)
_refimpl2_root = os.path.join(_my_dir, "..")
def _make_injectable_file_set(m):
m2 = {os.path.join(_refimpl2_root, k): v for k,v in m.items()}
return InjectableFileSet(m2)
injectable_files = injecttools.make_injectable_file_set(_refimpl2_root, [
("comminsts.scala", "src/main/scala/uvm/comminsts/comminsts.scala",
["IRBUILDER_COMMINSTS"]),
("internals.scala", "src/main/scala/uvm/refimpl/internals.scala",
["IRBUILDER_RETVALS"]),
("ir-ci-exec", "src/main/scala/uvm/refimpl/itpr/IRBuilderCommInstExecutor.scala",
["IRBUILDER_IMPL"]),
])
......@@ -65,4 +65,96 @@ object CommInsts extends SimpleNamespace[CommInst] {
commInst(0x260, "@uvm.meta.set_trap_handler")
// Common instructions for IR builder API here:
/// GEN:BEGIN:IRBUILDER_COMMINSTS
commInst(0x300, "@uvm.irbuilder.new_bundle")
commInst(0x301, "@uvm.irbuilder.load_bundle_from_node")
commInst(0x302, "@uvm.irbuilder.abort_bundle_node")
commInst(0x303, "@uvm.irbuilder.get_node")
commInst(0x304, "@uvm.irbuilder.get_id")
commInst(0x305, "@uvm.irbuilder.set_name")
commInst(0x306, "@uvm.irbuilder.new_type_int")
commInst(0x307, "@uvm.irbuilder.new_type_float")
commInst(0x308, "@uvm.irbuilder.new_type_double")
commInst(0x309, "@uvm.irbuilder.new_type_uptr")
commInst(0x30a, "@uvm.irbuilder.set_type_uptr")
commInst(0x30b, "@uvm.irbuilder.new_type_ufuncptr")
commInst(0x30c, "@uvm.irbuilder.set_type_ufuncptr")
commInst(0x30d, "@uvm.irbuilder.new_type_struct")
commInst(0x30e, "@uvm.irbuilder.new_type_hybrid")
commInst(0x30f, "@uvm.irbuilder.new_type_array")
commInst(0x310, "@uvm.irbuilder.new_type_vector")
commInst(0x311, "@uvm.irbuilder.new_type_void")
commInst(0x312, "@uvm.irbuilder.new_type_ref")
commInst(0x313, "@uvm.irbuilder.set_type_ref")
commInst(0x314, "@uvm.irbuilder.new_type_iref")
commInst(0x315, "@uvm.irbuilder.set_type_iref")
commInst(0x316, "@uvm.irbuilder.new_type_weakref")
commInst(0x317, "@uvm.irbuilder.set_type_weakref")
commInst(0x318, "@uvm.irbuilder.new_type_funcref")
commInst(0x319, "@uvm.irbuilder.set_type_funcref")
commInst(0x31a, "@uvm.irbuilder.new_type_tagref64")
commInst(0x31b, "@uvm.irbuilder.new_type_threadref")
commInst(0x31c, "@uvm.irbuilder.new_type_stackref")
commInst(0x31d, "@uvm.irbuilder.new_type_framecursorref")
commInst(0x31e, "@uvm.irbuilder.new_type_irnoderef")
commInst(0x31f, "@uvm.irbuilder.new_funcsig")
commInst(0x320, "@uvm.irbuilder.new_const_int")
commInst(0x321, "@uvm.irbuilder.new_const_int_ex")
commInst(0x322, "@uvm.irbuilder.new_const_float")
commInst(0x323, "@uvm.irbuilder.new_const_double")
commInst(0x324, "@uvm.irbuilder.new_const_null")
commInst(0x325, "@uvm.irbuilder.new_const_seq")
commInst(0x326, "@uvm.irbuilder.new_global_cell")
commInst(0x327, "@uvm.irbuilder.new_func")
commInst(0x328, "@uvm.irbuilder.new_func_ver")
commInst(0x329, "@uvm.irbuilder.new_exp_func")
commInst(0x32a, "@uvm.irbuilder.new_bb")
commInst(0x32b, "@uvm.irbuilder.new_nor_param")
commInst(0x32c, "@uvm.irbuilder.new_exc_param")
commInst(0x32d, "@uvm.irbuilder.new_inst_res")
commInst(0x32e, "@uvm.irbuilder.add_dest")
commInst(0x32f, "@uvm.irbuilder.add_keepalives")
commInst(0x330, "@uvm.irbuilder.new_binop")
commInst(0x331, "@uvm.irbuilder.new_cmp")
commInst(0x332, "@uvm.irbuilder.new_conv")
commInst(0x333, "@uvm.irbuilder.new_select")
commInst(0x334, "@uvm.irbuilder.new_branch")
commInst(0x335, "@uvm.irbuilder.new_branch2")
commInst(0x336, "@uvm.irbuilder.new_switch")
commInst(0x337, "@uvm.irbuilder.add_switch_dest")
commInst(0x338, "@uvm.irbuilder.new_call")
commInst(0x339, "@uvm.irbuilder.new_tailcall")
commInst(0x33a, "@uvm.irbuilder.new_ret")
commInst(0x33b, "@uvm.irbuilder.new_throw")
commInst(0x33c, "@uvm.irbuilder.new_extractvalue")
commInst(0x33d, "@uvm.irbuilder.new_insertvalue")
commInst(0x33e, "@uvm.irbuilder.new_extractelement")
commInst(0x33f, "@uvm.irbuilder.new_insertelement")
commInst(0x340, "@uvm.irbuilder.new_shufflevector")
commInst(0x341, "@uvm.irbuilder.new_new")
commInst(0x342, "@uvm.irbuilder.new_newhybrid")
commInst(0x343, "@uvm.irbuilder.new_alloca")
commInst(0x344, "@uvm.irbuilder.new_allocahybrid")
commInst(0x345, "@uvm.irbuilder.new_getiref")
commInst(0x346, "@uvm.irbuilder.new_getfieldiref")
commInst(0x347, "@uvm.irbuilder.new_getelemiref")
commInst(0x348, "@uvm.irbuilder.new_shiftiref")
commInst(0x349, "@uvm.irbuilder.new_getvarpartiref")
commInst(0x34a, "@uvm.irbuilder.new_load")
commInst(0x34b, "@uvm.irbuilder.new_store")
commInst(0x34c, "@uvm.irbuilder.new_cmpxchg")
commInst(0x34d, "@uvm.irbuilder.new_atomicrmw")
commInst(0x34e, "@uvm.irbuilder.new_fence")
commInst(0x34f, "@uvm.irbuilder.new_trap")
commInst(0x350, "@uvm.irbuilder.new_watchpoint")
commInst(0x351, "@uvm.irbuilder.new_wpbranch")
commInst(0x352, "@uvm.irbuilder.new_ccall")
commInst(0x353, "@uvm.irbuilder.new_newthread")
commInst(0x354, "@uvm.irbuilder.new_swapstack_ret")
commInst(0x355, "@uvm.irbuilder.new_swapstack_kill")
commInst(0x356, "@uvm.irbuilder.set_newstack_pass_values")
commInst(0x357, "@uvm.irbuilder.set_newstack_throw_exc")
commInst(0x358, "@uvm.irbuilder.new_comminst")
/// GEN:END:IRBUILDER_COMMINSTS
}
\ No newline at end of file
......@@ -193,6 +193,98 @@ object TypeInferer {
case "@uvm.meta.disable_watchPoint" => Seq()
case "@uvm.meta.set_trap_handler" => Seq()
/// GEN:BEGIN:IRBUILDER_RETVALS
case "@uvm.irbuilder.new_bundle" => Seq(IRNODEREF)
case "@uvm.irbuilder.load_bundle_from_node" => Seq()
case "@uvm.irbuilder.abort_bundle_node" => Seq()
case "@uvm.irbuilder.get_node" => Seq(IRNODEREF)
case "@uvm.irbuilder.get_id" => Seq(I32)
case "@uvm.irbuilder.set_name" => Seq()
case "@uvm.irbuilder.new_type_int" => Seq(IRNODEREF)
case "@uvm.irbuilder.new_type_float" => Seq(IRNODEREF)
case "@uvm.irbuilder.new_type_double" => Seq(IRNODEREF)
case "@uvm.irbuilder.new_type_uptr" => Seq(IRNODEREF)
case "@uvm.irbuilder.set_type_uptr" => Seq()
case "@uvm.irbuilder.new_type_ufuncptr" => Seq(IRNODEREF)
case "@uvm.irbuilder.set_type_ufuncptr" => Seq()
case "@uvm.irbuilder.new_type_struct" => Seq(IRNODEREF)
case "@uvm.irbuilder.new_type_hybrid" => Seq(IRNODEREF)
case "@uvm.irbuilder.new_type_array" => Seq(IRNODEREF)
case "@uvm.irbuilder.new_type_vector" => Seq(IRNODEREF)
case "@uvm.irbuilder.new_type_void" => Seq(IRNODEREF)
case "@uvm.irbuilder.new_type_ref" => Seq(IRNODEREF)
case "@uvm.irbuilder.set_type_ref" => Seq()
case "@uvm.irbuilder.new_type_iref" => Seq(IRNODEREF)
case "@uvm.irbuilder.set_type_iref" => Seq()
case "@uvm.irbuilder.new_type_weakref" => Seq(IRNODEREF)
case "@uvm.irbuilder.set_type_weakref" => Seq()
case "@uvm.irbuilder.new_type_funcref" => Seq(IRNODEREF)
case "@uvm.irbuilder.set_type_funcref" => Seq()
case "@uvm.irbuilder.new_type_tagref64" => Seq(IRNODEREF)
case "@uvm.irbuilder.new_type_threadref" => Seq(IRNODEREF)
case "@uvm.irbuilder.new_type_stackref" => Seq(IRNODEREF)
case "@uvm.irbuilder.new_type_framecursorref" => Seq(IRNODEREF)
case "@uvm.irbuilder.new_type_irnoderef" => Seq(IRNODEREF)
case "@uvm.irbuilder.new_funcsig" => Seq(IRNODEREF)
case "@uvm.irbuilder.new_const_int" => Seq(IRNODEREF)
case "@uvm.irbuilder.new_const_int_ex" => Seq(IRNODEREF)
case "@uvm.irbuilder.new_const_float" => Seq(IRNODEREF)
case "@uvm.irbuilder.new_const_double" => Seq(IRNODEREF)
case "@uvm.irbuilder.new_const_null" => Seq(IRNODEREF)
case "@uvm.irbuilder.new_const_seq" => Seq(IRNODEREF)
case "@uvm.irbuilder.new_global_cell" => Seq(IRNODEREF)
case "@uvm.irbuilder.new_func" => Seq(IRNODEREF)
case "@uvm.irbuilder.new_func_ver" => Seq(IRNODEREF)
case "@uvm.irbuilder.new_exp_func" => Seq(IRNODEREF)
case "@uvm.irbuilder.new_bb" => Seq(IRNODEREF)
case "@uvm.irbuilder.new_nor_param" => Seq(IRNODEREF)
case "@uvm.irbuilder.new_exc_param" => Seq(IRNODEREF)
case "@uvm.irbuilder.new_inst_res" => Seq(IRNODEREF)
case "@uvm.irbuilder.add_dest" => Seq()
case "@uvm.irbuilder.add_keepalives" => Seq()
case "@uvm.irbuilder.new_binop" => Seq(IRNODEREF)
case "@uvm.irbuilder.new_cmp" => Seq(IRNODEREF)
case "@uvm.irbuilder.new_conv" => Seq(IRNODEREF)
case "@uvm.irbuilder.new_select" => Seq(IRNODEREF)
case "@uvm.irbuilder.new_branch" => Seq(IRNODEREF)
case "@uvm.irbuilder.new_branch2" => Seq(IRNODEREF)
case "@uvm.irbuilder.new_switch" => Seq(IRNODEREF)
case "@uvm.irbuilder.add_switch_dest" => Seq()
case "@uvm.irbuilder.new_call" => Seq(IRNODEREF)
case "@uvm.irbuilder.new_tailcall" => Seq(IRNODEREF)
case "@uvm.irbuilder.new_ret" => Seq(IRNODEREF)
case "@uvm.irbuilder.new_throw" => Seq(IRNODEREF)
case "@uvm.irbuilder.new_extractvalue" => Seq(IRNODEREF)
case "@uvm.irbuilder.new_insertvalue" => Seq(IRNODEREF)
case "@uvm.irbuilder.new_extractelement" => Seq(IRNODEREF)
case "@uvm.irbuilder.new_insertelement" => Seq(IRNODEREF)
case "@uvm.irbuilder.new_shufflevector" => Seq(IRNODEREF)
case "@uvm.irbuilder.new_new" => Seq(IRNODEREF)
case "@uvm.irbuilder.new_newhybrid" => Seq(IRNODEREF)
case "@uvm.irbuilder.new_alloca" => Seq(IRNODEREF)
case "@uvm.irbuilder.new_allocahybrid" => Seq(IRNODEREF)
case "@uvm.irbuilder.new_getiref" => Seq(IRNODEREF)
case "@uvm.irbuilder.new_getfieldiref" => Seq(IRNODEREF)
case "@uvm.irbuilder.new_getelemiref" => Seq(IRNODEREF)
case "@uvm.irbuilder.new_shiftiref" => Seq(IRNODEREF)
case "@uvm.irbuilder.new_getvarpartiref" => Seq(IRNODEREF)
case "@uvm.irbuilder.new_load" => Seq(IRNODEREF)
case "@uvm.irbuilder.new_store" => Seq(IRNODEREF)
case "@uvm.irbuilder.new_cmpxchg" => Seq(IRNODEREF)
case "@uvm.irbuilder.new_atomicrmw" => Seq(IRNODEREF)
case "@uvm.irbuilder.new_fence" => Seq(IRNODEREF)
case "@uvm.irbuilder.new_trap" => Seq(IRNODEREF)
case "@uvm.irbuilder.new_watchpoint" => Seq(IRNODEREF)
case "@uvm.irbuilder.new_wpbranch" => Seq(IRNODEREF)
case "@uvm.irbuilder.new_ccall" => Seq(IRNODEREF)
case "@uvm.irbuilder.new_newthread" => Seq(IRNODEREF)
case "@uvm.irbuilder.new_swapstack_ret" => Seq(IRNODEREF)
case "@uvm.irbuilder.new_swapstack_kill" => Seq(IRNODEREF)
case "@uvm.irbuilder.set_newstack_pass_values" => Seq()
case "@uvm.irbuilder.set_newstack_throw_exc" => Seq()
case "@uvm.irbuilder.new_comminst" => Seq(IRNODEREF)
/// GEN:END:IRBUILDER_RETVALS
}
}
}
\ No newline at end of file
......@@ -14,7 +14,7 @@ import uvm.refimpl.nat.NativeCallResult
/**
* A part of the InterpreterThread that interprets common instructions
*/
trait CommInstExecutor extends InterpreterActions with ObjectPinner {
trait CommInstExecutor extends InterpreterActions with ObjectPinner with IRBuilderCommInstExecutor {
import InterpreterThread.logger
implicit protected def mutator: Mutator
......@@ -23,6 +23,10 @@ trait CommInstExecutor extends InterpreterActions with ObjectPinner {
override def interpretCurrentCommonInstruction(): Unit = {
assert(curInst.isInstanceOf[InstCommInst])
val InstCommInst(ci, flagList, typeList, sigList, argList, excClause, keepalives) = curInst
if (ci.name.get.startsWith("@uvm.irbuilder")) {
return interpretCurrentIRBuilderCommonInstruction()
}
ci.name.get match {
// Thread and stack operations
......
package uvm.refimpl.itpr
import scala.annotation.tailrec
import scala.collection.mutable.ArrayBuffer
import org.slf4j.LoggerFactory
import com.typesafe.scalalogging.Logger
import uvm._
import uvm.comminsts._
import uvm.refimpl._
import uvm.refimpl.mem._
import uvm.refimpl.mem.TypeSizes.Word
import uvm.ssavariables._
import uvm.types._
import uvm.refimpl.nat.NativeCallResult
/**
* A part of the InterpreterThread that interprets common instructions
*/
trait IRBuilderCommInstExecutor extends InterpreterActions with ObjectPinner {
import InterpreterThread.logger
implicit protected def mutator: Mutator
implicit protected def memorySupport: MemorySupport
protected def irBuilder = microVM.irBuilder
def interpretCurrentIRBuilderCommonInstruction(): Unit = {
assert(curInst.isInstanceOf[InstCommInst])
val InstCommInst(ci, flagList, typeList, sigList, argList, excClause, keepalives) = curInst
assert(ci.name.get.startsWith("@uvm.irbuilder"))
ci.name.get match {
/// GEN:BEGIN:IRBUILDER_IMPL
case "@uvm.irbuilder.new_bundle" => ???
case "@uvm.irbuilder.load_bundle_from_node" => ???
case "@uvm.irbuilder.abort_bundle_node" => ???
case "@uvm.irbuilder.get_node" => ???
case "@uvm.irbuilder.get_id" => ???
case "@uvm.irbuilder.set_name" => ???
case "@uvm.irbuilder.new_type_int" => ???
case "@uvm.irbuilder.new_type_float" => ???
case "@uvm.irbuilder.new_type_double" => ???
case "@uvm.irbuilder.new_type_uptr" => ???
case "@uvm.irbuilder.set_type_uptr" => ???
case "@uvm.irbuilder.new_type_ufuncptr" => ???
case "@uvm.irbuilder.set_type_ufuncptr" => ???
case "@uvm.irbuilder.new_type_struct" => ???
case "@uvm.irbuilder.new_type_hybrid" => ???
case "@uvm.irbuilder.new_type_array" => ???
case "@uvm.irbuilder.new_type_vector" => ???
case "@uvm.irbuilder.new_type_void" => ???
case "@uvm.irbuilder.new_type_ref" => ???
case "@uvm.irbuilder.set_type_ref" => ???
case "@uvm.irbuilder.new_type_iref" => ???
case "@uvm.irbuilder.set_type_iref" => ???
case "@uvm.irbuilder.new_type_weakref" => ???
case "@uvm.irbuilder.set_type_weakref" => ???
case "@uvm.irbuilder.new_type_funcref" => ???
case "@uvm.irbuilder.set_type_funcref" => ???
case "@uvm.irbuilder.new_type_tagref64" => ???
case "@uvm.irbuilder.new_type_threadref" => ???
case "@uvm.irbuilder.new_type_stackref" => ???
case "@uvm.irbuilder.new_type_framecursorref" => ???
case "@uvm.irbuilder.new_type_irnoderef" => ???
case "@uvm.irbuilder.new_funcsig" => ???
case "@uvm.irbuilder.new_const_int" => ???
case "@uvm.irbuilder.new_const_int_ex" => ???
case "@uvm.irbuilder.new_const_float" => ???
case "@uvm.irbuilder.new_const_double" => ???
case "@uvm.irbuilder.new_const_null" => ???
case "@uvm.irbuilder.new_const_seq" => ???
case "@uvm.irbuilder.new_global_cell" => ???
case "@uvm.irbuilder.new_func" => ???
case "@uvm.irbuilder.new_func_ver" => ???
case "@uvm.irbuilder.new_exp_func" => ???
case "@uvm.irbuilder.new_bb" => ???
case "@uvm.irbuilder.new_nor_param" => ???
case "@uvm.irbuilder.new_exc_param" => ???
case "@uvm.irbuilder.new_inst_res" => ???
case "@uvm.irbuilder.add_dest" => ???
case "@uvm.irbuilder.add_keepalives" => ???
case "@uvm.irbuilder.new_binop" => ???
case "@uvm.irbuilder.new_cmp" => ???
case "@uvm.irbuilder.new_conv" => ???
case "@uvm.irbuilder.new_select" => ???
case "@uvm.irbuilder.new_branch" => ???
case "@uvm.irbuilder.new_branch2" => ???
case "@uvm.irbuilder.new_switch" => ???
case "@uvm.irbuilder.add_switch_dest" => ???
case "@uvm.irbuilder.new_call" => ???
case "@uvm.irbuilder.new_tailcall" => ???
case "@uvm.irbuilder.new_ret" => ???
case "@uvm.irbuilder.new_throw" => ???
case "@uvm.irbuilder.new_extractvalue" => ???
case "@uvm.irbuilder.new_insertvalue" => ???
case "@uvm.irbuilder.new_extractelement" => ???
case "@uvm.irbuilder.new_insertelement" => ???
case "@uvm.irbuilder.new_shufflevector" => ???
case "@uvm.irbuilder.new_new" => ???
case "@uvm.irbuilder.new_newhybrid" => ???
case "@uvm.irbuilder.new_alloca" => ???
case "@uvm.irbuilder.new_allocahybrid" => ???
case "@uvm.irbuilder.new_getiref" => ???
case "@uvm.irbuilder.new_getfieldiref" => ???
case "@uvm.irbuilder.new_getelemiref" => ???
case "@uvm.irbuilder.new_shiftiref" => ???
case "@uvm.irbuilder.new_getvarpartiref" => ???
case "@uvm.irbuilder.new_load" => ???
case "@uvm.irbuilder.new_store" => ???
case "@uvm.irbuilder.new_cmpxchg" => ???
case "@uvm.irbuilder.new_atomicrmw" => ???
case "@uvm.irbuilder.new_fence" => ???
case "@uvm.irbuilder.new_trap" => ???
case "@uvm.irbuilder.new_watchpoint" => ???
case "@uvm.irbuilder.new_wpbranch" => ???
case "@uvm.irbuilder.new_ccall" => ???
case "@uvm.irbuilder.new_newthread" => ???
case "@uvm.irbuilder.new_swapstack_ret" => ???
case "@uvm.irbuilder.new_swapstack_kill" => ???
case "@uvm.irbuilder.set_newstack_pass_values" => ???
case "@uvm.irbuilder.set_newstack_throw_exc" => ???
case "@uvm.irbuilder.new_comminst" => ???
/// GEN:END:IRBUILDER_IMPL
case ciName => {
throw new UvmRefImplException("Unimplemented IR builder common instruction %s".format(ciName))
}
}
}
}
\ No newline at end of file
......@@ -96,21 +96,22 @@ object ValueBox {
case _: TypeInt => BoxInt(0)
case _: TypeFloat => BoxFloat(0.0f)
case _: TypeDouble => BoxDouble(0.0d)
case _: TypeUPtr => BoxPointer(0L)
case _: TypeUFuncPtr => BoxPointer(0L)
case TypeStruct(fieldTys) => BoxSeq(fieldTys.map(makeBoxForType))
case _: TypeHybrid => throw new UvmRefImplException("hybrid cannot be an SSA variable type")
case TypeArray(elemTy, len) => BoxSeq(Seq.fill(len.toInt)(makeBoxForType(elemTy)))
case TypeVector(elemTy, len) => BoxSeq(Seq.fill(len.toInt)(makeBoxForType(elemTy)))
case _: TypeVoid => throw new UvmRefImplException("void cannot be an SSA variable type")
case _: TypeRef => BoxRef(0L)
case _: TypeIRef => BoxIRef(0L, 0L)
case _: TypeWeakRef => throw new UvmRefImplException("weakref cannot be an SSA variable type")
case TypeStruct(fieldTys) => BoxSeq(fieldTys.map(makeBoxForType))
case TypeArray(elemTy, len) => BoxSeq(Seq.fill(len.toInt)(makeBoxForType(elemTy)))
case _: TypeHybrid => throw new UvmRefImplException("hybrid cannot be an SSA variable type")
case _: TypeVoid => throw new UvmRefImplException("void cannot be an SSA variable type")
case _: TypeTagRef64 => BoxTagRef64(0L)
case _: TypeFuncRef => BoxFunc(None)
case _: TypeStackRef => BoxStack(None)
case _: TypeThreadRef => BoxThread(None)
case _: TypeFrameCursorRef => BoxFrameCursor(None)
case _: TypeTagRef64 => BoxTagRef64(0L)
case _: TypeUPtr => BoxPointer(0L)
case _: TypeUFuncPtr => BoxPointer(0L)
case _: TypeIRNodeRef => BoxIRNode(None)
}
}
\ No newline at end of file