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 ...@@ -15,6 +15,7 @@ $SED -i 's/putDouble("@double",/handleFromDouble(/g' $FN
$SED -i 's/putConstant/handleFromConst/g' $FN $SED -i 's/putConstant/handleFromConst/g' $FN
$SED -i 's/putGlobal/handleFromGlobal/g' $FN $SED -i 's/putGlobal/handleFromGlobal/g' $FN
$SED -i 's/putFunction/handleFromFunc/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\+\),\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/toInt(\(\w\+\))/handleToUInt(\1.asInstanceOf[MuIntValue])/g' $FN
$SED -i 's/toFloat/handleToFloat/g' $FN $SED -i 's/toFloat/handleToFloat/g' $FN
......
...@@ -3,13 +3,13 @@ if [ x$SED == x ]; then ...@@ -3,13 +3,13 @@ if [ x$SED == x ]; then
SED=sed SED=sed
fi fi
$SED -i 's/\(%\w\+\)\s*=\s*TRAP/[\1] TRAP/g' $FN $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/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/TRAP\s*<@void>/TRAP <>/g' $FN
$SED -i 's/noparamsnoret/v_v/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 '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/@i_ii/@ii_i/g' $FN
$SED -i 's/RET @VOID/RET ()/g' $FN $SED -i 's/RET @VOID/RET ()/g' $FN
$SED -i 's/hybrid\s*<@void\s*/hybrid</g' $FN $SED -i 's/hybrid\s*<@void\s*/hybrid</g' $FN
......
...@@ -682,7 +682,6 @@ trait InstructionExecutor extends InterpreterActions with CommInstExecutor { ...@@ -682,7 +682,6 @@ trait InstructionExecutor extends InterpreterActions with CommInstExecutor {
val addr = boxOf(callee).asInstanceOf[BoxPointer].addr val addr = boxOf(callee).asInstanceOf[BoxPointer].addr
val argBoxes = argList.map(boxOf) val argBoxes = argList.map(boxOf)
val retBox = resultBox(0)
val shouldIncrementPC = curStack.callNative(sig, addr, argBoxes) val shouldIncrementPC = curStack.callNative(sig, addr, argBoxes)
if (shouldIncrementPC) { if (shouldIncrementPC) {
......
...@@ -46,7 +46,7 @@ case class InstResult(inst: Instruction, index: Int) extends LocalVariable ...@@ -46,7 +46,7 @@ case class InstResult(inst: Instruction, index: Int) extends LocalVariable
abstract class Instruction extends IdentifiedSettable { abstract class Instruction extends IdentifiedSettable {
var results: Seq[InstResult] = Seq() 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 /// enumerations
......
...@@ -20,10 +20,10 @@ class UvmInterpreterNativeTests extends UvmBundleTesterBase { ...@@ -20,10 +20,10 @@ class UvmInterpreterNativeTests extends UvmBundleTesterBase {
ROOT_LOGGER_NAME -> INFO, ROOT_LOGGER_NAME -> INFO,
"uvm.refimpl.itpr" -> DEBUG) "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 { "The CCALL instruction" should "call the getpid() function" in {
val ca = microVM.newClientAgent() val ctx = microVM.newContext()
val lib = Library.getDefault() val lib = Library.getDefault()
val funcAddr = lib.getSymbolAddress("getpid") val funcAddr = lib.getSymbolAddress("getpid")
...@@ -33,58 +33,58 @@ class UvmInterpreterNativeTests extends UvmBundleTesterBase { ...@@ -33,58 +33,58 @@ class UvmInterpreterNativeTests extends UvmBundleTesterBase {
println("actualPID = %d".format(actualPID)) 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) => testFunc(ctx, func, Seq(a0)) { (ctx, th, st, wp) =>
val Seq(fp, rv) = ca.dumpKeepalives(st, 0) val Seq(fp, rv) = ctx.dumpKeepalives(st, 0)
fp.vb.asPointer shouldEqual funcAddr fp.vb.asPointer shouldEqual funcAddr
rv.vb.asSInt(32) shouldEqual actualPID rv.vb.asSInt(32) shouldEqual actualPID
TrapRebindPassVoid(st) returnFromTrap(st)
} }
ca.close() ctx.closeContext()
} }
"The CCALL instruction" should "call the write() function" in { "The CCALL instruction" should "call the write() function" in {
val ca = microVM.newClientAgent() val ctx = microVM.newContext()
val lib = Library.getDefault() val lib = Library.getDefault()
val funcAddr = lib.getSymbolAddress("write") 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) => testFunc(ctx, func, Seq(a0)) { (ctx, th, st, wp) =>
val Seq(fp, rv, buf, bufV0P) = ca.dumpKeepalives(st, 0) val Seq(fp, rv, buf, bufV0P) = ctx.dumpKeepalives(st, 0)
fp.vb.asPointer shouldEqual funcAddr fp.vb.asPointer shouldEqual funcAddr
rv.vb.asSInt(64) shouldEqual 6 rv.vb.asSInt(64) shouldEqual 6
TrapRebindPassVoid(st) returnFromTrap(st)
} }
ca.close() ctx.closeContext()
} }
"The CCALL instruction" should "call the memcpy() function" in { "The CCALL instruction" should "call the memcpy() function" in {
val ca = microVM.newClientAgent() val ctx = microVM.newContext()
val lib = Library.getDefault() val lib = Library.getDefault()
val funcAddr = lib.getSymbolAddress("memcpy") val funcAddr = lib.getSymbolAddress("memcpy")
val hgfp = ca.putGlobal("@FP_MEMCPY") val hgfp = ctx.handleFromGlobal("@FP_MEMCPY")
val hfp = ca.putPointer("@memcpy_fp", funcAddr) val hfp = ctx.handleFromFP("@memcpy_fp", funcAddr)
ca.store(MemoryOrder.NOT_ATOMIC, hgfp, hfp) 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) => testFunc(ctx, func, Seq()) { (ctx, th, st, wp) =>
val Seq(fp, rv, ob, b0, b1, b2, b3, b4, b5) = ca.dumpKeepalives(st, 0) val Seq(fp, rv, ob, b0, b1, b2, b3, b4, b5) = ctx.dumpKeepalives(st, 0)
fp.vb.asPointer shouldEqual funcAddr fp.vb.asPointer shouldEqual funcAddr
rv.vb.asPointer shouldEqual ob.vb.asPointer rv.vb.asPointer shouldEqual ob.vb.asPointer
...@@ -96,9 +96,9 @@ class UvmInterpreterNativeTests extends UvmBundleTesterBase { ...@@ -96,9 +96,9 @@ class UvmInterpreterNativeTests extends UvmBundleTesterBase {
b4.vb.asSInt(8) shouldEqual 'o' b4.vb.asSInt(8) shouldEqual 'o'
b5.vb.asSInt(8) shouldEqual '\n' 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 { ...@@ -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'.") 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 { "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 lib = Library.openLibrary(fileName, Library.NOW)
val funcAddr = lib.getSymbolAddress("foo_func") 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) => testFunc(ctx, func, Seq(a0)) { (ctx, th, st, wp) =>
val Seq(fp, rv, a, b, c, d) = ca.dumpKeepalives(st, 0) val Seq(fp, rv, a, b, c, d) = ctx.dumpKeepalives(st, 0)
fp.vb.asPointer shouldEqual funcAddr fp.vb.asPointer shouldEqual funcAddr
...@@ -52,24 +52,24 @@ class UvmInterpreterNativeTestsExtra extends UvmBundleTesterBase { ...@@ -52,24 +52,24 @@ class UvmInterpreterNativeTestsExtra extends UvmBundleTesterBase {
c.vb.asUInt(16) shouldEqual 0xa5a5 c.vb.asUInt(16) shouldEqual 0xa5a5
d.vb.asUInt(8) shouldEqual 0x61 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 { "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 lib = Library.openLibrary(fileName, Library.NOW)
val funcAddr = lib.getSymbolAddress("bar_func") 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) => testFunc(ctx, func, Seq(a0)) { (ctx, th, st, wp) =>
val Seq(fp, rv, a, b) = ca.dumpKeepalives(st, 0) val Seq(fp, rv, a, b) = ctx.dumpKeepalives(st, 0)
fp.vb.asPointer shouldEqual funcAddr fp.vb.asPointer shouldEqual funcAddr
...@@ -78,24 +78,24 @@ class UvmInterpreterNativeTestsExtra extends UvmBundleTesterBase { ...@@ -78,24 +78,24 @@ class UvmInterpreterNativeTestsExtra extends UvmBundleTesterBase {
a.vb.asPointer shouldEqual 0x123456789abcdef0L a.vb.asPointer shouldEqual 0x123456789abcdef0L
b.vb.asPointer shouldEqual 0xfedcba9876543210L 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 { "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 lib = Library.openLibrary(fileName, Library.NOW)
val funcAddr = lib.getSymbolAddress("baz_func") 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) => testFunc(ctx, func, Seq(a0)) { (ctx, th, st, wp) =>
val Seq(fp, rv, a, b, c, pextra, aextra) = ca.dumpKeepalives(st, 0) val Seq(fp, rv, a, b, c, pextra, aextra) = ctx.dumpKeepalives(st, 0)
fp.vb.asPointer shouldEqual funcAddr fp.vb.asPointer shouldEqual funcAddr
...@@ -126,9 +126,9 @@ class UvmInterpreterNativeTestsExtra extends UvmBundleTesterBase { ...@@ -126,9 +126,9 @@ class UvmInterpreterNativeTestsExtra extends UvmBundleTesterBase {
m.getInt(ptr+4) shouldEqual 5 m.getInt(ptr+4) shouldEqual 5
m.getDouble(ptr+8) shouldEqual 6.0 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 } ...@@ -12,12 +12,8 @@ import com.kenai.jffi.{ Type => JType }
import uvm.FuncSig import uvm.FuncSig
import uvm.{ Function => MFunc } import uvm.{ Function => MFunc }
import uvm.ir.textinput.ExtraMatchers import uvm.ir.textinput.ExtraMatchers
import uvm.refimpl.itpr.BoxDouble import uvm.refimpl.itpr._
import uvm.refimpl.itpr.BoxInt import uvm.types._
import uvm.refimpl.itpr.BoxPointer
import uvm.types.TypeDouble
import uvm.types.TypeInt
import uvm.types.TypeUFuncPtr
class NativeStackKeeperTest extends FlatSpec with Matchers with ExtraMatchers { class NativeStackKeeperTest extends FlatSpec with Matchers with ExtraMatchers {
behavior of "NativeStackKeeper" behavior of "NativeStackKeeper"
...@@ -50,17 +46,16 @@ class NativeStackKeeperTest extends FlatSpec with Matchers with ExtraMatchers { ...@@ -50,17 +46,16 @@ class NativeStackKeeperTest extends FlatSpec with Matchers with ExtraMatchers {
autoClose(nsk) { autoClose(nsk) {
val i32 = TypeInt(32) val i32 = TypeInt(32)
val sig = FuncSig(i32, Seq(i32, i32)) val sig = FuncSig(Seq(i32, i32), Seq(i32))
val box1 = BoxInt(3) val box1 = BoxInt(3)
val box2 = BoxInt(4) 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() result shouldBeA[NativeCallResult.ReturnToMu] { its =>
its.maybeRvb shouldBe Some(BoxInt(7))
boxRv.value shouldBe 7 }
} }
} }
...@@ -74,9 +69,9 @@ class NativeStackKeeperTest extends FlatSpec with Matchers with ExtraMatchers { ...@@ -74,9 +69,9 @@ class NativeStackKeeperTest extends FlatSpec with Matchers with ExtraMatchers {
autoClose(nsk) { autoClose(nsk) {
val d = TypeDouble() val d = TypeDouble()
val dtdSig = FuncSig(d, Seq(d)) val dtdSig = FuncSig(Seq(d), Seq(d))
val dtd = TypeUFuncPtr(dtdSig) val dtd = TypeUFuncPtr(dtdSig)
val sig = FuncSig(d, Seq(d, dtd)) val sig = FuncSig(Seq(d, dtd), Seq(d))
val mockMuCallbackFunc = new MFunc() val mockMuCallbackFunc = new MFunc()
mockMuCallbackFunc.sig = dtdSig mockMuCallbackFunc.sig = dtdSig
...@@ -87,44 +82,34 @@ class NativeStackKeeperTest extends FlatSpec with Matchers with ExtraMatchers { ...@@ -87,44 +82,34 @@ class NativeStackKeeperTest extends FlatSpec with Matchers with ExtraMatchers {
val b1 = BoxDouble(3.0) val b1 = BoxDouble(3.0)
val b2 = BoxPointer(mockClosAddr) 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") println("Hello. I received r1")
r1 shouldBeA[NativeCallResult.CallBack] { its => r1 shouldBeA[NativeCallResult.CallMu] { its =>
its.func shouldBe mockMuCallbackFunc its.func shouldBe mockMuCallbackFunc
its.cookie shouldBe 42 its.cookie shouldBe 42
its.args.size shouldBe 1 its.args.size shouldBe 1
its.args(0) shouldBeA[BoxDouble] {whose => its.args(0) shouldBe BoxDouble(3.0)
whose.value shouldBe 3.0
}
its.retBox shouldBeA[BoxDouble] { b =>
b.value = 9.0
}
} }
val r2 = nsk.returnToCallBack() val r2 = nsk.returnToNative(Some(BoxDouble(9.0)))
println("Hello. I received r2") println("Hello. I received r2")
r2 shouldBeA[NativeCallResult.CallBack] { its =>
r2 shouldBeA[NativeCallResult.CallMu] { its =>
its.func shouldBe mockMuCallbackFunc its.func shouldBe mockMuCallbackFunc
its.cookie shouldBe 42 its.cookie shouldBe 42
its.args.size shouldBe 1 its.args.size shouldBe 1
its.args(0) shouldBeA[BoxDouble] {whose => its.args(0) shouldBe BoxDouble(4.0)
whose.value shouldBe 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") println("Hello. I received r3")
r3 shouldBe NativeCallResult.Return()
r3 shouldBe NativeCallResult.ReturnToMu(Some(BoxDouble(25.0)))
br.value shouldBe 25.0
} }
} }
...@@ -138,9 +123,9 @@ class NativeStackKeeperTest extends FlatSpec with Matchers with ExtraMatchers { ...@@ -138,9 +123,9 @@ class NativeStackKeeperTest extends FlatSpec with Matchers with ExtraMatchers {
autoClose(nsk) { autoClose(nsk) {
val d = TypeDouble() val d = TypeDouble()
val dtdSig = FuncSig(d, Seq(d)) val dtdSig = FuncSig(Seq(d), Seq(d))
val dtd = TypeUFuncPtr(dtdSig) val dtd = TypeUFuncPtr(dtdSig)
val sig = FuncSig(d, Seq(d, dtd)) val sig = FuncSig(Seq(d, dtd), Seq(d))
val clos = new Closure() { val clos = new Closure() {
def invoke(buf: Buffer): Unit = { def invoke(buf: Buffer): Unit = {
...@@ -159,11 +144,11 @@ class NativeStackKeeperTest extends FlatSpec with Matchers with ExtraMatchers { ...@@ -159,11 +144,11 @@ class NativeStackKeeperTest extends FlatSpec with Matchers with ExtraMatchers {
val b2 = BoxPointer(closHandle.getAddress) val b2 = BoxPointer(closHandle.getAddress)
val br = BoxDouble(-1.0) val br = BoxDouble(-1.0)
nsk.callNative(sig, addr, Seq(b1, b2), br) val result = nsk.callNative(sig, addr, Seq(b1, b2))
closHandle.dispose() 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> // require "primitives.uir"
.typedef @i6 = int<6>
.typedef @i8 = int<8> .funcsig @a_v = (@i64) -> ()
.typedef @i16 = int<16>
.typedef @i32 = int<32> .funcsig @getpid_sig = () -> (@i32)
.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 ()
.typedef @getpid_fp = ufuncptr<@getpid_sig> .typedef @getpid_fp = ufuncptr<@getpid_sig>
.funcdef @getpidtest VERSION @getpidtest_v1 <@v_a> { .funcdef @getpidtest VERSION @getpidtest_v1 <@a_v> {
%entry(<@i64> %p0): %entry(<@i64> %p0):
%fp = PTRCAST <@i64 @getpid_fp> %p0 %fp = PTRCAST <@i64 @getpid_fp> %p0
%rv = CCALL #DEFAULT <@getpid_fp @getpid_sig> %fp () %rv = CCALL #DEFAULT <@getpid_fp @getpid_sig> %fp ()
%trap = TRAP <@void> KEEPALIVE (%fp %rv) [%trap] TRAP <> KEEPALIVE (%fp %rv)
COMMINST @uvm.thread_exit COMMINST @uvm.thread_exit
} }
.typedef @size_t = int<64> .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 @write_fp = ufuncptr<@write_sig>
.typedef @CharBuf = hybrid<@i64 @i8> .typedef @CharBuf = hybrid<@i64 @i8>
...@@ -136,7 +25,7 @@ ...@@ -136,7 +25,7 @@
.const @I8_o <@i8> = 0x6f .const @I8_o <@i8> = 0x6f
.const @I8_NL <@i8> = 0x0a .const @I8_NL <@i8> = 0x0a
.funcsig @writetest_sig = @void (@write_fp) .funcsig @writetest_sig = (@write_fp) -> (@void)
.funcdef @writetest VERSION @writetest_v1 <@writetest_sig> { .funcdef @writetest VERSION @writetest_v1 <@writetest_sig> {
%entry(<@write_fp> %fp): %entry(<@write_fp> %fp):
%buf = NEWHYBRID <@CharBuf @i64> @I64_6 %buf = NEWHYBRID <@CharBuf @i64> @I64_6
...@@ -161,16 +50,16 @@ ...@@ -161,16 +50,16 @@
COMMINST @uvm.native.unpin <@irefi8> (%buf_v0) COMMINST @uvm.native.unpin <@irefi8> (%buf_v0)