Commit d1171fa4 authored by Kunshan Wang's avatar Kunshan Wang

Fixed native tests.

parent fea12c70
......@@ -15,6 +15,7 @@ $SED -i 's/putDouble("@double",/handleFromDouble(/g' $FN
$SED -i 's/putConstant/handleFromConst/g' $FN
$SED -i 's/putGlobal/handleFromGlobal/g' $FN
$SED -i 's/putFunction/handleFromFunc/g' $FN
$SED -i 's/putExpFunc/handleFromExpose/g' $FN
$SED -i 's/toInt(\(\w\+\),\s*\(signExt\s*=\s*\)\?true)/handleToSInt(\1.asInstanceOf[MuIntValue])/g' $FN
$SED -i 's/toInt(\(\w\+\))/handleToUInt(\1.asInstanceOf[MuIntValue])/g' $FN
$SED -i 's/toFloat/handleToFloat/g' $FN
......
......@@ -3,13 +3,13 @@ if [ x$SED == x ]; then
SED=sed
fi
$SED -i 's/\(%\w\+\)\s*=\s*TRAP/[\1] TRAP/g' $FN
$SED -i 's/NEWSTACK\s*<\(@\w\+\)>\s*\(@\w\+\)/COMMINST @uvm.new_stack <[\1]> (\2)/g' $FN
$SED -i 's/NEWSTACK\s*<\(@[0-9a-zA-Z._-]\+\)>\s*\(@\w\+\)/COMMINST @uvm.new_stack <[\1]> (\2)/g' $FN
$SED -i 's/COMMINST\s*@uvm\.new_thread\s*(\([@%]\w\+\))/NEWTHREAD \1 PASS_VALUES /g' $FN
$SED -i 's/TRAP\s*<@void>/TRAP <>/g' $FN
$SED -i 's/noparamsnoret/v_v/g' $FN
#$SED -i 's/@void\s*(\([^)]*\))/(\1) -> ()/g' $FN
$SED -i '/\.funcsig/ {s/=\s*\(@\w\+\)\s*(\([^)]*\))/= (\2) -> (\1)/}' $FN
$SED -i 's/@funcdumb/@frv_v/g' $FN
$SED -i '/\.funcsig/ {s/@void\s*(\([^)]*\))/(\1) -> ()}/g' $FN
$SED -i '/\.funcsig/ {s/=\s*\(@\w\+\)\s*(\([^)]*\))/= (\2) -> (\1)/}' $FN
$SED -i 's/@i_ii/@ii_i/g' $FN
$SED -i 's/RET @VOID/RET ()/g' $FN
$SED -i 's/hybrid\s*<@void\s*/hybrid</g' $FN
......
......@@ -682,7 +682,6 @@ trait InstructionExecutor extends InterpreterActions with CommInstExecutor {
val addr = boxOf(callee).asInstanceOf[BoxPointer].addr
val argBoxes = argList.map(boxOf)
val retBox = resultBox(0)
val shouldIncrementPC = curStack.callNative(sig, addr, argBoxes)
if (shouldIncrementPC) {
......
......@@ -46,7 +46,7 @@ case class InstResult(inst: Instruction, index: Int) extends LocalVariable
abstract class Instruction extends IdentifiedSettable {
var results: Seq[InstResult] = Seq()
override def toString = "%s %s".format(this.repr, this.getClass.getSimpleName)
override def toString = "[(%s) = %s %s]".format(this.results.map(_.repr).mkString(" "), this.repr, this.getClass.getSimpleName)
}
/// enumerations
......
......@@ -20,10 +20,10 @@ class UvmInterpreterNativeTests extends UvmBundleTesterBase {
ROOT_LOGGER_NAME -> INFO,
"uvm.refimpl.itpr" -> DEBUG)
preloadBundles("tests/uvm-refimpl-test/native-tests.uir")
preloadBundles("tests/uvm-refimpl-test/primitives.uir", "tests/uvm-refimpl-test/native-tests.uir")
"The CCALL instruction" should "call the getpid() function" in {
val ca = microVM.newClientAgent()
val ctx = microVM.newContext()
val lib = Library.getDefault()
val funcAddr = lib.getSymbolAddress("getpid")
......@@ -33,58 +33,58 @@ class UvmInterpreterNativeTests extends UvmBundleTesterBase {
println("actualPID = %d".format(actualPID))
val func = ca.putFunction("@getpidtest")
val func = ctx.handleFromFunc("@getpidtest")
val a0 = ca.putInt("@i64", funcAddr)
val a0 = ctx.handleFromInt64( funcAddr)
testFunc(ca, func, Seq(a0)) { (ca, th, st, wp) =>
val Seq(fp, rv) = ca.dumpKeepalives(st, 0)
testFunc(ctx, func, Seq(a0)) { (ctx, th, st, wp) =>
val Seq(fp, rv) = ctx.dumpKeepalives(st, 0)
fp.vb.asPointer shouldEqual funcAddr
rv.vb.asSInt(32) shouldEqual actualPID
TrapRebindPassVoid(st)
returnFromTrap(st)
}
ca.close()
ctx.closeContext()
}
"The CCALL instruction" should "call the write() function" in {
val ca = microVM.newClientAgent()
val ctx = microVM.newContext()
val lib = Library.getDefault()
val funcAddr = lib.getSymbolAddress("write")
val func = ca.putFunction("@writetest")
val func = ctx.handleFromFunc("@writetest")
val a0 = ca.putPointer("@write_fp", funcAddr)
val a0 = ctx.handleFromFP("@write_fp", funcAddr)
testFunc(ca, func, Seq(a0)) { (ca, th, st, wp) =>
val Seq(fp, rv, buf, bufV0P) = ca.dumpKeepalives(st, 0)
testFunc(ctx, func, Seq(a0)) { (ctx, th, st, wp) =>
val Seq(fp, rv, buf, bufV0P) = ctx.dumpKeepalives(st, 0)
fp.vb.asPointer shouldEqual funcAddr
rv.vb.asSInt(64) shouldEqual 6
TrapRebindPassVoid(st)
returnFromTrap(st)
}
ca.close()
ctx.closeContext()
}
"The CCALL instruction" should "call the memcpy() function" in {
val ca = microVM.newClientAgent()
val ctx = microVM.newContext()
val lib = Library.getDefault()
val funcAddr = lib.getSymbolAddress("memcpy")
val hgfp = ca.putGlobal("@FP_MEMCPY")
val hfp = ca.putPointer("@memcpy_fp", funcAddr)
ca.store(MemoryOrder.NOT_ATOMIC, hgfp, hfp)
val hgfp = ctx.handleFromGlobal("@FP_MEMCPY")
val hfp = ctx.handleFromFP("@memcpy_fp", funcAddr)
ctx.store(MemoryOrder.NOT_ATOMIC, hgfp, hfp)
val func = ca.putFunction("@memcpytest")
val func = ctx.handleFromFunc("@memcpytest")
testFunc(ca, func, Seq()) { (ca, th, st, wp) =>
val Seq(fp, rv, ob, b0, b1, b2, b3, b4, b5) = ca.dumpKeepalives(st, 0)
testFunc(ctx, func, Seq()) { (ctx, th, st, wp) =>
val Seq(fp, rv, ob, b0, b1, b2, b3, b4, b5) = ctx.dumpKeepalives(st, 0)
fp.vb.asPointer shouldEqual funcAddr
rv.vb.asPointer shouldEqual ob.vb.asPointer
......@@ -96,9 +96,9 @@ class UvmInterpreterNativeTests extends UvmBundleTesterBase {
b4.vb.asSInt(8) shouldEqual 'o'
b5.vb.asSInt(8) shouldEqual '\n'
TrapRebindPassVoid(st)
returnFromTrap(st)
}
ca.close()
ctx.closeContext()
}
}
\ No newline at end of file
......@@ -28,20 +28,20 @@ class UvmInterpreterNativeTestsExtra extends UvmBundleTesterBase {
throw new RuntimeException("Need to compile the structtest.so library. cd into tests/c-snippets and invoke 'make'.")
}
preloadBundles("tests/uvm-refimpl-test/native-tests.uir")
preloadBundles("tests/uvm-refimpl-test/primitives.uir", "tests/uvm-refimpl-test/native-tests.uir")
"The CCALL instruction" should "handle struct parameters in foo" in {
val ca = microVM.newClientAgent()
val ctx = microVM.newContext()
val lib = Library.openLibrary(fileName, Library.NOW)
val funcAddr = lib.getSymbolAddress("foo_func")
val func = ca.putFunction("@foo_func_test")
val func = ctx.handleFromFunc("@foo_func_test")
val a0 = ca.putInt("@i64", funcAddr)
val a0 = ctx.handleFromInt64( funcAddr)
testFunc(ca, func, Seq(a0)) { (ca, th, st, wp) =>
val Seq(fp, rv, a, b, c, d) = ca.dumpKeepalives(st, 0)
testFunc(ctx, func, Seq(a0)) { (ctx, th, st, wp) =>
val Seq(fp, rv, a, b, c, d) = ctx.dumpKeepalives(st, 0)
fp.vb.asPointer shouldEqual funcAddr
......@@ -52,24 +52,24 @@ class UvmInterpreterNativeTestsExtra extends UvmBundleTesterBase {
c.vb.asUInt(16) shouldEqual 0xa5a5
d.vb.asUInt(8) shouldEqual 0x61
TrapRebindPassVoid(st)
returnFromTrap(st)
}
ca.close()
ctx.closeContext()
}
"The CCALL instruction" should "handle struct parameters in bar involving pointers" in {
val ca = microVM.newClientAgent()
val ctx = microVM.newContext()
val lib = Library.openLibrary(fileName, Library.NOW)
val funcAddr = lib.getSymbolAddress("bar_func")
val func = ca.putFunction("@bar_func_test")
val func = ctx.handleFromFunc("@bar_func_test")
val a0 = ca.putInt("@i64", funcAddr)
val a0 = ctx.handleFromInt64( funcAddr)
testFunc(ca, func, Seq(a0)) { (ca, th, st, wp) =>
val Seq(fp, rv, a, b) = ca.dumpKeepalives(st, 0)
testFunc(ctx, func, Seq(a0)) { (ctx, th, st, wp) =>
val Seq(fp, rv, a, b) = ctx.dumpKeepalives(st, 0)
fp.vb.asPointer shouldEqual funcAddr
......@@ -78,24 +78,24 @@ class UvmInterpreterNativeTestsExtra extends UvmBundleTesterBase {
a.vb.asPointer shouldEqual 0x123456789abcdef0L
b.vb.asPointer shouldEqual 0xfedcba9876543210L
TrapRebindPassVoid(st)
returnFromTrap(st)
}
ca.close()
ctx.closeContext()
}
"The CCALL instruction" should "handle struct parameters and return value in baz" in {
val ca = microVM.newClientAgent()
val ctx = microVM.newContext()
val lib = Library.openLibrary(fileName, Library.NOW)
val funcAddr = lib.getSymbolAddress("baz_func")
val func = ca.putFunction("@baz_func_test")
val func = ctx.handleFromFunc("@baz_func_test")
val a0 = ca.putInt("@i64", funcAddr)
val a0 = ctx.handleFromInt64( funcAddr)
testFunc(ca, func, Seq(a0)) { (ca, th, st, wp) =>
val Seq(fp, rv, a, b, c, pextra, aextra) = ca.dumpKeepalives(st, 0)
testFunc(ctx, func, Seq(a0)) { (ctx, th, st, wp) =>
val Seq(fp, rv, a, b, c, pextra, aextra) = ctx.dumpKeepalives(st, 0)
fp.vb.asPointer shouldEqual funcAddr
......@@ -126,9 +126,9 @@ class UvmInterpreterNativeTestsExtra extends UvmBundleTesterBase {
m.getInt(ptr+4) shouldEqual 5
m.getDouble(ptr+8) shouldEqual 6.0
TrapRebindPassVoid(st)
returnFromTrap(st)
}
ca.close()
ctx.closeContext()
}
}
\ No newline at end of file
......@@ -12,12 +12,8 @@ import com.kenai.jffi.{ Type => JType }
import uvm.FuncSig
import uvm.{ Function => MFunc }
import uvm.ir.textinput.ExtraMatchers
import uvm.refimpl.itpr.BoxDouble
import uvm.refimpl.itpr.BoxInt
import uvm.refimpl.itpr.BoxPointer
import uvm.types.TypeDouble
import uvm.types.TypeInt
import uvm.types.TypeUFuncPtr
import uvm.refimpl.itpr._
import uvm.types._
class NativeStackKeeperTest extends FlatSpec with Matchers with ExtraMatchers {
behavior of "NativeStackKeeper"
......@@ -50,17 +46,16 @@ class NativeStackKeeperTest extends FlatSpec with Matchers with ExtraMatchers {
autoClose(nsk) {
val i32 = TypeInt(32)
val sig = FuncSig(i32, Seq(i32, i32))
val sig = FuncSig(Seq(i32, i32), Seq(i32))
val box1 = BoxInt(3)
val box2 = BoxInt(4)
val boxRv = BoxInt(-1)
val result = nsk.callNative(sig, addr, Seq(box1, box2), boxRv)
val result = nsk.callNative(sig, addr, Seq(box1, box2))
result shouldBe NativeCallResult.Return()
boxRv.value shouldBe 7
result shouldBeA[NativeCallResult.ReturnToMu] { its =>
its.maybeRvb shouldBe Some(BoxInt(7))
}
}
}
......@@ -74,9 +69,9 @@ class NativeStackKeeperTest extends FlatSpec with Matchers with ExtraMatchers {
autoClose(nsk) {
val d = TypeDouble()
val dtdSig = FuncSig(d, Seq(d))
val dtdSig = FuncSig(Seq(d), Seq(d))
val dtd = TypeUFuncPtr(dtdSig)
val sig = FuncSig(d, Seq(d, dtd))
val sig = FuncSig(Seq(d, dtd), Seq(d))
val mockMuCallbackFunc = new MFunc()
mockMuCallbackFunc.sig = dtdSig
......@@ -87,44 +82,34 @@ class NativeStackKeeperTest extends FlatSpec with Matchers with ExtraMatchers {
val b1 = BoxDouble(3.0)
val b2 = BoxPointer(mockClosAddr)
val br = BoxDouble(-1.0)
val r1 = nsk.callNative(sig, addr, Seq(b1, b2), br)
val r1 = nsk.callNative(sig, addr, Seq(b1, b2))
println("Hello. I received r1")
r1 shouldBeA[NativeCallResult.CallBack] { its =>
r1 shouldBeA[NativeCallResult.CallMu] { its =>
its.func shouldBe mockMuCallbackFunc
its.cookie shouldBe 42
its.args.size shouldBe 1
its.args(0) shouldBeA[BoxDouble] {whose =>
whose.value shouldBe 3.0
its.args(0) shouldBe BoxDouble(3.0)
}
its.retBox shouldBeA[BoxDouble] { b =>
b.value = 9.0
}
}
val r2 = nsk.returnToNative(Some(BoxDouble(9.0)))
val r2 = nsk.returnToCallBack()
println("Hello. I received r2")
r2 shouldBeA[NativeCallResult.CallBack] { its =>
r2 shouldBeA[NativeCallResult.CallMu] { its =>
its.func shouldBe mockMuCallbackFunc
its.cookie shouldBe 42
its.args.size shouldBe 1
its.args(0) shouldBeA[BoxDouble] {whose =>
whose.value shouldBe 4.0
its.args(0) shouldBe BoxDouble(4.0)
}
its.retBox shouldBeA[BoxDouble] { b =>
b.value = 16.0
}
}
val r3 = nsk.returnToCallBack()
val r3 = nsk.returnToNative(Some(BoxDouble(16.0)))
println("Hello. I received r3")
r3 shouldBe NativeCallResult.Return()
br.value shouldBe 25.0
r3 shouldBe NativeCallResult.ReturnToMu(Some(BoxDouble(25.0)))
}
}
......@@ -138,9 +123,9 @@ class NativeStackKeeperTest extends FlatSpec with Matchers with ExtraMatchers {
autoClose(nsk) {
val d = TypeDouble()
val dtdSig = FuncSig(d, Seq(d))
val dtdSig = FuncSig(Seq(d), Seq(d))
val dtd = TypeUFuncPtr(dtdSig)
val sig = FuncSig(d, Seq(d, dtd))
val sig = FuncSig(Seq(d, dtd), Seq(d))
val clos = new Closure() {
def invoke(buf: Buffer): Unit = {
......@@ -159,11 +144,11 @@ class NativeStackKeeperTest extends FlatSpec with Matchers with ExtraMatchers {
val b2 = BoxPointer(closHandle.getAddress)
val br = BoxDouble(-1.0)
nsk.callNative(sig, addr, Seq(b1, b2), br)
val result = nsk.callNative(sig, addr, Seq(b1, b2))
closHandle.dispose()
br.value shouldBe 25.0
result shouldBe NativeCallResult.ReturnToMu(Some(BoxDouble(25.0)))
}
}
}
\ No newline at end of file
.typedef @i1 = int<1>
.typedef @i6 = int<6>
.typedef @i8 = int<8>
.typedef @i16 = int<16>
.typedef @i32 = int<32>
.typedef @i52 = int<52>
.typedef @i64 = int<64>
.typedef @float = float
.typedef @double = double
.typedef @void = void
.funcsig @noparamsnoret = @void ()
.typedef @funcdumb = funcref<@noparamsnoret>
.typedef @thread = threadref
.typedef @stack = stackref
.typedef @tagref64 = tagref64
.const @TRUE <@i64> = 1
.const @FALSE <@i64> = 0
.const @I32_0 <@i32> = 0
.const @I32_1 <@i32> = 1
.const @I32_2 <@i32> = 2
.const @I32_3 <@i32> = 3
.const @I32_4 <@i32> = 4
.const @I32_5 <@i32> = 5
.const @I32_6 <@i32> = 6
.const @I32_7 <@i32> = 7
.const @I64_0 <@i64> = 0
.const @I64_1 <@i64> = 1
.const @I64_2 <@i64> = 2
.const @I64_3 <@i64> = 3
.const @I64_4 <@i64> = 4
.const @I64_5 <@i64> = 5
.const @I64_6 <@i64> = 6
.const @I64_7 <@i64> = 7
.const @F_0 <@float> = 0.0f
.const @F_1 <@float> = 1.0f
.const @F_2 <@float> = 2.0f
.const @F_3 <@float> = 3.0f
.const @F_4 <@float> = 4.0f
.const @F_5 <@float> = 5.0f
.const @F_6 <@float> = 6.0f
.const @F_7 <@float> = 7.0f
.const @D_0 <@double> = 0.0d
.const @D_1 <@double> = 1.0d
.const @D_2 <@double> = 2.0d
.const @D_3 <@double> = 3.0d
.const @D_4 <@double> = 4.0d
.const @D_5 <@double> = 5.0d
.const @D_6 <@double> = 6.0d
.const @D_7 <@double> = 7.0d
.typedef @4xfloat = vector <@float 4>
.typedef @4xi32 = vector <@i32 4>
.typedef @2xdouble = vector <@double 2>
.const @4xI32_V1 <@4xi32> = {@I32_0 @I32_1 @I32_2 @I32_3}
.const @4xI32_V2 <@4xi32> = {@I32_4 @I32_5 @I32_6 @I32_7}
.const @4xF_V1 <@4xfloat> = {@F_0 @F_1 @F_2 @F_3}
.const @4xF_V2 <@4xfloat> = {@F_4 @F_5 @F_6 @F_7}
.const @2xD_V1 <@2xdouble> = {@D_0 @D_1}
.const @2xD_V2 <@2xdouble> = {@D_2 @D_3}
.funcsig @i_i = @i64 (@i64)
.funcsig @i_ii = @i64 (@i64 @i64)
.typedef @refvoid = ref<@void>
.typedef @irefvoid = iref<@void>
.typedef @weakrefvoid = weakref<@void>
.const @NULLREF <@refvoid> = NULL
.const @NULLIREF <@irefvoid> = NULL
.const @NULLFUNC <@funcdumb> = NULL
.const @NULLSTACK <@stack> = NULL
.typedef @refi8 = ref<@i8>
.typedef @refi16 = ref<@i16>
.typedef @refi32 = ref<@i32>
.typedef @refi64 = ref<@i64>
.typedef @reffloat = ref<@float>
.typedef @refdouble = ref<@double>
.typedef @irefi8 = iref<@i8>
.typedef @irefi16 = iref<@i16>
.typedef @irefi32 = iref<@i32>
.typedef @irefi64 = iref<@i64>
.typedef @ireffloat = iref<@float>
.typedef @irefdouble= iref<@double>
.const @NULLREF_I64 <@refi64> = NULL
.const @NULLIREF_I64 <@irefi64> = NULL
.typedef @ptrvoid = uptr<@void>
.typedef @ptri8 = uptr<@i8>
.typedef @ptri16 = uptr<@i16>
.typedef @ptri32 = uptr<@i32>
.typedef @ptri64 = uptr<@i64>
.typedef @ptrfloat = uptr<@float>
.typedef @ptrdouble = uptr<@double>
.typedef @ptrptrvoid = uptr<@ptrvoid>
.typedef @ptrfpnoparamsnoret = uptr<@fpnoparamsnoret>
.typedef @ptrfpi_i = uptr<@fpi_i>
.typedef @fpnoparamsnoret = ufuncptr<@noparamsnoret>
.typedef @fpi_i = ufuncptr<@i_i>
.typedef @fpi_ii = ufuncptr<@i_ii>
.funcsig @v_a = @void (@i64)
.funcsig @getpid_sig = @i32 ()
// require "primitives.uir"
.funcsig @a_v = (@i64) -> ()
.funcsig @getpid_sig = () -> (@i32)
.typedef @getpid_fp = ufuncptr<@getpid_sig>
.funcdef @getpidtest VERSION @getpidtest_v1 <@v_a> {
.funcdef @getpidtest VERSION @getpidtest_v1 <@a_v> {
%entry(<@i64> %p0):
%fp = PTRCAST <@i64 @getpid_fp> %p0
%rv = CCALL #DEFAULT <@getpid_fp @getpid_sig> %fp ()
%trap = TRAP <@void> KEEPALIVE (%fp %rv)
[%trap] TRAP <> KEEPALIVE (%fp %rv)
COMMINST @uvm.thread_exit
}
.typedef @size_t = int<64>
.funcsig @write_sig = @size_t (@i32 @ptrvoid @size_t)
.funcsig @write_sig = (@i32 @ptrvoid @size_t) -> (@size_t)
.typedef @write_fp = ufuncptr<@write_sig>
.typedef @CharBuf = hybrid<@i64 @i8>
......@@ -136,7 +25,7 @@
.const @I8_o <@i8> = 0x6f
.const @I8_NL <@i8> = 0x0a
.funcsig @writetest_sig = @void (@write_fp)
.funcsig @writetest_sig = (@write_fp) -> (@void)
.funcdef @writetest VERSION @writetest_v1 <@writetest_sig> {
%entry(<@write_fp> %fp):
%buf = NEWHYBRID <@CharBuf @i64> @I64_6
......@@ -161,16 +50,16 @@
COMMINST @uvm.native.unpin <@irefi8> (%buf_v0)
%trap = TRAP <@void> KEEPALIVE (%fp %rv %buf %buf_v0_p)
[%trap] TRAP <> KEEPALIVE (%fp %rv %buf %buf_v0_p)
COMMINST @uvm.thread_exit
}
.funcsig @memcpy_sig = @ptrvoid (@ptrvoid @ptrvoid @size_t)
.funcsig @memcpy_sig = (@ptrvoid @ptrvoid @size_t) -> (@ptrvoid)
.typedef @memcpy_fp = ufuncptr<@write_sig>
.global @FP_MEMCPY <@memcpy_fp>
.funcdef @memcpytest VERSION @memcpytest_v1 <@noparamsnoret> {
.funcdef @memcpytest VERSION @memcpytest_v1 <@v_v> {
%entry():
%fp = LOAD <@memcpy_fp> @FP_MEMCPY
......@@ -215,21 +104,21 @@
%buf2_v5 = SHIFTIREF <@i8 @i64> %buf2_v4 @I64_1
%buf2_5 = LOAD <@i8> %buf2_v5
%trap = TRAP <@void> KEEPALIVE (%fp %rv %buf2_v0_p %buf2_0 %buf2_1 %buf2_2 %buf2_3 %buf2_4 %buf2_5)
[%trap] TRAP <> KEEPALIVE (%fp %rv %buf2_v0_p %buf2_0 %buf2_1 %buf2_2 %buf2_3 %buf2_4 %buf2_5)
COMMINST @uvm.thread_exit
}
.typedef @struct_foo = struct<@i64 @i32 @i16 @i8>
.typedef @struct_bar = struct<@ptrvoid @fpnoparamsnoret>
.typedef @struct_bar = struct<@ptrvoid @fpv_v>
.typedef @struct_baz1 = struct<@float @i32>
.typedef @struct_baz = struct<@struct_baz1 @double>
.typedef @irefstruct_baz = iref<@struct_baz>
.typedef @ptrstruct_baz = uptr<@struct_baz>
.funcsig @foo_func_sig = @void (@struct_foo @ptri64 @ptri32 @ptri16 @ptri8)
.funcsig @bar_func_sig = @void (@struct_bar @ptrptrvoid @ptrfpnoparamsnoret)
.funcsig @baz_func_sig = @struct_baz (@struct_baz @ptrfloat @ptri32 @ptrdouble @ptrstruct_baz)
.funcsig @foo_func_sig = (@struct_foo @ptri64 @ptri32 @ptri16 @ptri8) -> (@void)
.funcsig @bar_func_sig = (@struct_bar @ptrptrvoid @ptrfpv_v) -> (@void)
.funcsig @baz_func_sig = (@struct_baz @ptrfloat @ptri32 @ptrdouble @ptrstruct_baz) -> (@struct_baz)
.typedef @foo_func_fp = ufuncptr<@foo_func_sig>
.typedef @bar_func_fp = ufuncptr<@bar_func_sig>
.typedef @baz_func_fp = ufuncptr<@baz_func_sig>
......@@ -241,7 +130,7 @@
.const @o_foo <@struct_foo> = {@I64BIG @I32BIG @I16BIG @I8BIG}
.funcdef @foo_func_test VERSION @foo_func_test_v1 <@v_a> {
.funcdef @foo_func_test VERSION @foo_func_test_v1 <@a_v> {
%entry(<@i64> %p0):
%fp = PTRCAST <@i64 @foo_func_fp> %p0
......@@ -266,41 +155,41 @@
%c = LOAD <@i64> %ac
%d = LOAD <@i64> %ad
%trap = TRAP <@void> KEEPALIVE (%fp %rv %a %b %c %d)
[%trap] TRAP <> KEEPALIVE (%fp %rv %a %b %c %d)
COMMINST @uvm.thread_exit
}
.const @o_bar_a <@ptrvoid> = 0x123456789abcdef0
.const @o_bar_b <@fpnoparamsnoret> = 0xfedcba9876543210
.const @o_bar_b <@fpv_v> = 0xfedcba9876543210
.const @o_bar <@struct_bar> = {@o_bar_a @o_bar_b}
.typedef @irefptrvoid = iref<@ptrvoid>
.typedef @ireffpnoparamsnoret = iref<@fpnoparamsnoret>
.typedef @ireffpv_v = iref<@fpv_v>
.funcdef @bar_func_test VERSION @bar_func_test_v1 <@v_a> {
.funcdef @bar_func_test VERSION @bar_func_test_v1 <@a_v> {
%entry(<@i64> %p0):
%fp = PTRCAST <@i64 @bar_func_fp> %p0
%aa = ALLOCA <@ptrvoid>
%ab = ALLOCA <@fpnoparamsnoret>
%ab = ALLOCA <@fpv_v>
%pa = COMMINST @uvm.native.pin <@irefptrvoid> (%aa)
%pb = COMMINST @uvm.native.pin <@ireffpnoparamsnoret> (%ab)
%pb = COMMINST @uvm.native.pin <@ireffpv_v> (%ab)
%rv = CCALL #DEFAULT <@bar_func_fp @bar_func_sig> %fp (@o_bar %pa %pb)
COMMINST @uvm.native.unpin <@ireffpnoparamsnoret> (%ab)
COMMINST @uvm.native.unpin <@ireffpv_v> (%ab)
COMMINST @uvm.native.unpin <@irefptrvoid> (%aa)
%a = LOAD <@ptrvoid> %aa
%b = LOAD <@fpnoparamsnoret> %ab
%b = LOAD <@fpv_v> %ab
%trap = TRAP <@void> KEEPALIVE (%fp %rv %a %b)
[%trap] TRAP <> KEEPALIVE (%fp %rv %a %b)
COMMINST @uvm.thread_exit
}
.const @o_baz_a <@struct_baz1> = {@F_1 @I32_2}
.const @o_baz <@struct_baz> = {@o_baz_a @D_3}
.funcdef @baz_func_test VERSION @baz_func_test_v1 <@v_a> {
.funcdef @baz_func_test VERSION @baz_func_test_v1 <@a_v> {
%entry(<@i64> %p0):
%fp = PTRCAST <@i64 @baz_func_fp> %p0
......@@ -323,7 +212,7 @@
%b = LOAD <@i32> %ab
%c = LOAD <@double> %ac
%trap = TRAP <@void> KEEPALIVE (%fp %rv %a %b %c %pextra %aextra)
[%trap] TRAP <> KEEPALIVE (%fp %rv %a %b %c %pextra %aextra)
COMMINST @uvm.native.unpin <@irefstruct_baz> (%aextra)
......
......@@ -25,8 +25,20 @@
.typedef @2xfloat = vector <@float 2>
.typedef @4xdouble = vector <@double 4>
.typedef @refi8 = ref<@i8>
.typedef @refi16 = ref<@i16>
.typedef @refi32 = ref<@i32>
.typedef @refi64 = ref<@i64>
.typedef @reffloat = ref<@float>
.typedef @refdouble = ref<@double>
.typedef @irefi8 = iref<@i8>
.typedef @irefi16 = iref<@i16>
.typedef @irefi32 = iref<@i32>
.typedef @irefi64 = iref<@i64>
.typedef @ireffloat = iref<@float>
.typedef @irefdouble= iref<@double>
.typedef @weakrefi64 = weakref<@i64>
.typedef @refvoid = ref<@void>
......@@ -43,11 +55,13 @@
.typedef @ptrfloat = uptr<@float>
.typedef @ptrdouble = uptr<@double>
.typedef @ptrptrvoid = uptr<@ptrvoid>
.typedef @ptrfpi_i = uptr<@fpi_i>
.typedef @fpv_v = ufuncptr<@v_v>
.typedef @fpi_i = ufuncptr<@i_i>
.typedef @fpii_i = ufuncptr<@ii_i>
.typedef @ptrfpv_v = uptr<@fpv_v>
.typedef @ptrfpi_i = uptr<@fpi_i>
.typedef @ptrfpii_i = uptr<@fpii_i>
.funcsig @v_v = () -> ()
......
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