Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mu-impl-ref2
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
5
Issues
5
List
Board
Labels
Milestones
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
mu
mu-impl-ref2
Commits
dbc7e2a4
Commit
dbc7e2a4
authored
Oct 10, 2015
by
Kunshan Wang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Passes OSR, native and "simple" tests.
parent
f92fbb2f
Changes
13
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
384 additions
and
366 deletions
+384
-366
InterpreterThread.scala
src/main/scala/uvm/refimpl/itpr/InterpreterThread.scala
+34
-22
stacks.scala
src/main/scala/uvm/refimpl/itpr/stacks.scala
+4
-0
UvmOSRTests.scala
src/test/scala/uvm/refimpl/UvmOSRTests.scala
+8
-8
UvmInterpreterNativeCallbackTests.scala
.../uvm/refimpl/itpr/UvmInterpreterNativeCallbackTests.scala
+28
-14
UvmInterpreterSimpleSumTest.scala
.../scala/uvm/refimpl/itpr/UvmInterpreterSimpleSumTest.scala
+2
-2
UvmInterpreterSimpleTests.scala
...st/scala/uvm/refimpl/itpr/UvmInterpreterSimpleTests.scala
+5
-5
native-callback-tests.uir
tests/uvm-refimpl-test/native-callback-tests.uir
+77
-74
native-tests.uir
tests/uvm-refimpl-test/native-tests.uir
+42
-42
osr-tests-part2.uir
tests/uvm-refimpl-test/osr-tests-part2.uir
+6
-6
osr-tests.uir
tests/uvm-refimpl-test/osr-tests.uir
+23
-26
primitives.uir
tests/uvm-refimpl-test/primitives.uir
+2
-0
simple-sum.uir
tests/uvm-refimpl-test/simple-sum.uir
+8
-10
simple-tests.uir
tests/uvm-refimpl-test/simple-tests.uir
+145
-157
No files found.
src/main/scala/uvm/refimpl/itpr/InterpreterThread.scala
View file @
dbc7e2a4
...
...
@@ -15,6 +15,8 @@ import uvm.refimpl.nat.NativeCallResult
object
InterpreterThread
{
val
logger
=
Logger
(
LoggerFactory
.
getLogger
(
getClass
.
getName
))
val
BOX_VOID
=
new
BoxVoid
()
}
class
InterpreterThread
(
val
id
:
Int
,
initialStack
:
InterpreterStack
,
val
mutator
:
Mutator
)(
...
...
@@ -40,7 +42,7 @@ class InterpreterThread(val id: Int, initialStack: InterpreterStack, val mutator
// Initialisation
rebindPassV
oid
(
initialStack
)
rebindPassV
alue
(
initialStack
,
BOX_VOID
)
// Public interface
...
...
@@ -48,6 +50,7 @@ class InterpreterThread(val id: Int, initialStack: InterpreterStack, val mutator
def
step
()
:
Unit
=
{
if
(!
isRunning
)
throw
new
UvmRefImplException
(
ctx
+
"Attempt to run thread after it has reached exit."
)
if
(
isFutexWaiting
)
throw
new
UvmRefImplException
(
ctx
+
"Attempt to run thread when it is waiting on a futex."
)
topMu
.
justCreated
=
false
interpretCurrentInstruction
()
}
...
...
@@ -1168,11 +1171,11 @@ class InterpreterThread(val id: Int, initialStack: InterpreterStack, val mutator
val
norArgs
=
destClause
.
args
// Copy to edge-assigned boxes, first.
if
(
norArgs
.
length
!=
dest
.
norParams
.
length
)
{
if
(
norArgs
.
length
!=
dest
.
norParams
.
length
)
{
throw
new
UvmRefImplException
(
ctx
+
"Wrong number of arguments. Basic block: %s, expected: %d, actual: %d"
.
format
(
dest
.
repr
,
dest
.
norParams
.
length
,
norArgs
.
length
))
dest
.
repr
,
dest
.
norParams
.
length
,
norArgs
.
length
))
}
for
((
arg
,
np
)
<-
norArgs
zip
dest
.
norParams
)
{
val
argBox
=
boxOf
(
arg
)
val
npEdgeBox
=
edgeAssignedBoxOf
(
np
)
...
...
@@ -1353,36 +1356,45 @@ class InterpreterThread(val id: Int, initialStack: InterpreterStack, val mutator
stack
=
None
}
/** Rebind to a stack. */
private
def
rebind
(
newStack
:
InterpreterStack
)
:
Unit
=
{
/**
* Rebind to a stack.
* @return Return the old state.
*
*/
private
def
rebind
(
newStack
:
InterpreterStack
)
:
StackState
=
{
stack
=
Some
(
newStack
)
val
oldState
=
curStack
.
state
curStack
.
rebindToThread
()
oldState
}
/** Rebind to a stack and pass a value. */
private
def
rebindPassValue
(
newStack
:
InterpreterStack
,
value
:
ValueBox
)
:
Unit
=
{
rebind
(
newStack
)
val
oldState
=
rebind
(
newStack
)
try
{
boxOf
(
curInst
).
copyFrom
(
value
)
}
catch
{
case
e
:
Exception
=>
{
throw
new
UvmRuntimeException
(
ctx
+
"Error during rebinding while assigning the value passed to a stack "
+
"to the instruction waiting for rebinding. This is usually caused by the mismatching between the type of "
+
"READY<T> and the actual value type. The passed value box is a %s."
.
format
(
value
.
getClass
.
getName
),
e
)
top
match
{
case
mf
:
MuFrame
=>
{
if
(
mf
.
justCreated
)
{
mf
.
justCreated
=
false
}
else
{
try
{
boxOf
(
curInst
).
copyFrom
(
value
)
}
catch
{
case
e
:
Exception
=>
{
throw
new
UvmRuntimeException
(
ctx
+
"Error passing value while rebinding. "
+
"The new stack is in state %s, the passed value box is a %s."
.
format
(
oldState
,
value
.
getClass
.
getName
),
e
)
}
}
}
}
case
nf
:
NativeFrame
=>
{
???
}
}
finishHalfExecutedInst
()
}
/** Rebind to a stack and pass void. */
private
def
rebindPassVoid
(
newStack
:
InterpreterStack
)
:
Unit
=
{
rebind
(
newStack
)
finishHalfExecutedInst
()
}
/** Rebind to a stack and throw an exception on that stack. */
private
def
rebindThrowExc
(
newStack
:
InterpreterStack
,
exc
:
ValueBox
)
:
Unit
=
{
rebind
(
newStack
)
...
...
@@ -1422,7 +1434,7 @@ class InterpreterThread(val id: Int, initialStack: InterpreterStack, val mutator
}
case
TrapRebindPassVoid
(
newStack
)
=>
{
val
ns
=
getStackNotNull
(
newStack
)
rebindPassV
oid
(
ns
)
rebindPassV
alue
(
ns
,
BOX_VOID
)
}
case
TrapRebindThrowExc
(
newStack
,
exc
)
=>
{
val
ns
=
getStackNotNull
(
newStack
)
...
...
src/main/scala/uvm/refimpl/itpr/stacks.scala
View file @
dbc7e2a4
...
...
@@ -177,6 +177,10 @@ class MuFrame(val funcVer: FuncVer, val cookie: Long, prev: Option[InterpreterFr
/** Current instruction index within the current basic block */
var
curInstIndex
:
Int
=
0
/** true if the frame is just created (push_frame or new_stack). Binding a thread to the stack or executing an
* instruction will make it false. */
var
justCreated
:
Boolean
=
true
/**
* curInstHalfExecuted is true if the current instruction is partially executed and may continue when resumed.
...
...
src/test/scala/uvm/refimpl/UvmOSRTests.scala
View file @
dbc7e2a4
...
...
@@ -33,20 +33,20 @@ class UvmOSRTests extends UvmBundleTesterBase {
testFunc
(
ca
,
func
,
Seq
(
arg0
))
{
(
ca
,
th
,
st
,
wp
)
=>
nameOf
(
ca
.
currentInstruction
(
st
,
0
))
match
{
case
"@intro_rec_v1.trap_rec"
=>
{
case
"@intro_rec_v1.
zero.
trap_rec"
=>
{
val
Seq
(
n0
)
=
ca
.
dumpKeepalives
(
st
,
0
)
ca
.
toInt
(
n0
)
shouldBe
0
for
(
i
<-
1
to
3
)
{
nameOf
(
ca
.
currentInstruction
(
st
,
i
))
shouldBe
"@intro_rec_v1.rv"
nameOf
(
ca
.
currentInstruction
(
st
,
i
))
shouldBe
"@intro_rec_v1.
nz.
rv"
val
Seq
(
ni
,
nm1i
)
=
ca
.
dumpKeepalives
(
st
,
i
)
ca
.
toInt
(
ni
)
shouldBe
i
ca
.
toInt
(
nm1i
)
shouldBe
(
i
-
1
)
}
nameOf
(
ca
.
currentInstruction
(
st
,
4
))
shouldBe
"@intro_test_base_v1.rv"
nameOf
(
ca
.
currentInstruction
(
st
,
4
))
shouldBe
"@intro_test_base_v1.
entry.
rv"
TrapRebindPassV
oid
(
st
)
TrapRebindPassV
alue
(
st
,
n0
)
}
}
}
...
...
@@ -63,7 +63,7 @@ class UvmOSRTests extends UvmBundleTesterBase {
testFunc
(
ca
,
func
,
Seq
(
arg0
))
{
(
ca
,
th
,
st
,
wp
)
=>
nameOf
(
ca
.
currentInstruction
(
st
,
0
))
match
{
case
"@osr_test_base_v1.trap_base_exit"
=>
{
case
"@osr_test_base_v1.
entry.
trap_base_exit"
=>
{
val
Seq
(
rv
)
=
ca
.
dumpKeepalives
(
st
,
0
)
ca
.
toInt
(
rv
)
shouldBe
6
...
...
@@ -84,7 +84,7 @@ class UvmOSRTests extends UvmBundleTesterBase {
testFunc
(
ca
,
func
,
Seq
(
arg0
))
{
(
ca
,
th
,
st
,
wp
)
=>
nameOf
(
ca
.
currentInstruction
(
st
,
0
))
match
{
case
"@sum_v1.trap_opt"
=>
{
case
"@sum_v1.
opt.
trap_opt"
=>
{
val
Seq
(
n
,
i
,
s
)
=
ca
.
dumpKeepalives
(
st
,
0
)
ca
.
toInt
(
s
)
shouldBe
10
...
...
@@ -108,7 +108,7 @@ class UvmOSRTests extends UvmBundleTesterBase {
// Continue
TrapRebindPassVoid
(
st
)
}
case
"@osr_test_base_v1.trap_base_exit"
=>
{
case
"@osr_test_base_v1.
entry.
trap_base_exit"
=>
{
val
Seq
(
rv
)
=
ca
.
dumpKeepalives
(
st
,
0
)
ca
.
toInt
(
rv
)
shouldBe
28
...
...
@@ -121,7 +121,7 @@ class UvmOSRTests extends UvmBundleTesterBase {
// and OSR should be unnecessary.
testFunc
(
ca
,
func
,
Seq
(
arg0
))
{
(
ca
,
th
,
st
,
wp
)
=>
nameOf
(
ca
.
currentInstruction
(
st
,
0
))
match
{
case
"@osr_test_base_v1.trap_base_exit"
=>
{
case
"@osr_test_base_v1.
entry.
trap_base_exit"
=>
{
val
Seq
(
rv
)
=
ca
.
dumpKeepalives
(
st
,
0
)
ca
.
toInt
(
rv
)
shouldBe
28
...
...
src/test/scala/uvm/refimpl/itpr/UvmInterpreterNativeCallbackTests.scala
View file @
dbc7e2a4
...
...
@@ -48,7 +48,7 @@ class UvmInterpreterNativeCallbackTests extends UvmBundleTesterBase {
testFunc
(
ca
,
muFunc
,
Seq
())
{
(
ca
,
th
,
st
,
wp
)
=>
ca
.
nameOf
(
ca
.
currentInstruction
(
st
,
0
))
match
{
case
"@square.v1.trap"
=>
{
case
"@square.v1.
entry.
trap"
=>
{
val
Seq
(
value
,
cok
)
=
ca
.
dumpKeepalives
(
st
,
0
)
ca
.
toDouble
(
value
)
shouldBe
(
callbackCalled
match
{
...
...
@@ -62,14 +62,14 @@ class UvmInterpreterNativeCallbackTests extends UvmBundleTesterBase {
TrapRebindPassVoid
(
st
)
}
case
"@one_level_test.v1.pretrap"
=>
{
case
"@one_level_test.v1.
entry.
pretrap"
=>
{
val
Seq
(
fp
)
=
ca
.
dumpKeepalives
(
st
,
0
)
ca
.
toPointer
(
fp
)
shouldEqual
nativeFuncAddr
TrapRebindPassVoid
(
st
)
}
case
"@one_level_test.v1.trap"
=>
{
case
"@one_level_test.v1.
entry.
trap"
=>
{
val
Seq
(
fp
,
rv
)
=
ca
.
dumpKeepalives
(
st
,
0
)
ca
.
toPointer
(
fp
)
shouldEqual
nativeFuncAddr
...
...
@@ -103,7 +103,7 @@ class UvmInterpreterNativeCallbackTests extends UvmBundleTesterBase {
testFunc
(
ca
,
muFunc
,
Seq
())
{
(
ca
,
th
,
st
,
wp
)
=>
ca
.
nameOf
(
ca
.
currentInstruction
(
st
,
0
))
match
{
case
"@square.v1.trap"
=>
{
case
"@square.v1.
entry.
trap"
=>
{
val
Seq
(
value
,
cok
)
=
ca
.
dumpKeepalives
(
st
,
0
)
ca
.
toDouble
(
value
)
shouldBe
(
callbackCalled
match
{
...
...
@@ -124,7 +124,7 @@ class UvmInterpreterNativeCallbackTests extends UvmBundleTesterBase {
TrapRebindPassVoid
(
st
)
}
case
"@one_level_test2.v1.pretrap"
=>
{
case
"@one_level_test2.v1.
entry.
pretrap"
=>
{
val
Seq
(
fp
,
cb1
,
cb2
)
=
ca
.
dumpKeepalives
(
st
,
0
)
ca
.
toPointer
(
fp
)
shouldEqual
nativeFuncAddr
...
...
@@ -144,7 +144,7 @@ class UvmInterpreterNativeCallbackTests extends UvmBundleTesterBase {
TrapRebindPassVoid
(
st
)
}
case
"@one_level_test2.v1.trap"
=>
{
case
"@one_level_test2.v1.
entry.
trap"
=>
{
val
Seq
(
fp
,
rv1
,
rv2
,
cb1
,
cb2
)
=
ca
.
dumpKeepalives
(
st
,
0
)
ca
.
toPointer
(
fp
)
shouldEqual
nativeFuncAddr
...
...
@@ -191,7 +191,7 @@ class UvmInterpreterNativeCallbackTests extends UvmBundleTesterBase {
testFunc
(
ca
,
muFunc
,
Seq
(
hCB
))
{
(
ca
,
th
,
st
,
wp
)
=>
ca
.
nameOf
(
ca
.
currentInstruction
(
st
,
0
))
match
{
case
"@square.v1.trap"
=>
{
case
"@square.v1.
entry.
trap"
=>
{
val
Seq
(
value
,
cok
)
=
ca
.
dumpKeepalives
(
st
,
0
)
ca
.
toDouble
(
value
)
shouldBe
(
callbackCalled
match
{
...
...
@@ -205,7 +205,7 @@ class UvmInterpreterNativeCallbackTests extends UvmBundleTesterBase {
TrapRebindPassVoid
(
st
)
}
case
"@one_level_test3.v1.pretrap"
=>
{
case
"@one_level_test3.v1.
entry.
pretrap"
=>
{
val
Seq
(
fp
,
cb
)
=
ca
.
dumpKeepalives
(
st
,
0
)
ca
.
toPointer
(
fp
)
shouldEqual
nativeFuncAddr
...
...
@@ -213,7 +213,7 @@ class UvmInterpreterNativeCallbackTests extends UvmBundleTesterBase {
TrapRebindPassVoid
(
st
)
}
case
"@one_level_test3.v1.trap"
=>
{
case
"@one_level_test3.v1.
entry.
trap"
=>
{
val
Seq
(
fp
,
rv
)
=
ca
.
dumpKeepalives
(
st
,
0
)
ca
.
toPointer
(
fp
)
shouldEqual
nativeFuncAddr
...
...
@@ -254,7 +254,7 @@ class UvmInterpreterNativeCallbackTests extends UvmBundleTesterBase {
testFunc
(
ca
,
hPongTest
,
Seq
(
initialV
,
hPingFP
))
{
(
ca
,
th
,
st
,
wp
)
=>
ca
.
nameOf
(
ca
.
currentInstruction
(
st
,
0
))
match
{
case
"@pong.v1.entrytrap"
=>
{
case
"@pong.v1.entry
.entry
trap"
=>
{
val
Seq
(
v
,
peer
)
=
ca
.
dumpKeepalives
(
st
,
0
)
val
vInt
=
ca
.
toInt
(
v
).
toInt
val
peerAddr
=
ca
.
toPointer
(
peer
)
...
...
@@ -276,7 +276,7 @@ class UvmInterpreterNativeCallbackTests extends UvmBundleTesterBase {
TrapRebindPassVoid
(
st
)
}
case
"@pong.v1.resptrap"
=>
{
case
"@pong.v1.
not_zero.
resptrap"
=>
{
val
Seq
(
v
,
resp
)
=
ca
.
dumpKeepalives
(
st
,
0
)
val
vInt
=
ca
.
toInt
(
v
).
toInt
val
respInt
=
ca
.
toInt
(
resp
).
toInt
...
...
@@ -291,7 +291,7 @@ class UvmInterpreterNativeCallbackTests extends UvmBundleTesterBase {
TrapRebindPassVoid
(
st
)
}
case
"@pong_test.v1.entrytrap"
=>
{
case
"@pong_test.v1.entry
.entry
trap"
=>
{
val
Seq
(
v
,
peer
)
=
ca
.
dumpKeepalives
(
st
,
0
)
ca
.
toInt
(
v
).
toInt
shouldEqual
10
...
...
@@ -299,7 +299,7 @@ class UvmInterpreterNativeCallbackTests extends UvmBundleTesterBase {
TrapRebindPassVoid
(
st
)
}
case
"@pong_test.v1.exittrap"
=>
{
case
"@pong_test.v1.e
ntry.e
xittrap"
=>
{
val
Seq
(
rv
)
=
ca
.
dumpKeepalives
(
st
,
0
)
ca
.
toInt
(
rv
).
toInt
shouldEqual
3628800
...
...
@@ -337,7 +337,21 @@ class UvmInterpreterNativeCallbackTests extends UvmBundleTesterBase {
testFunc
(
ca
,
muFunc
,
Seq
())
{
(
ca
,
th
,
st
,
wp
)
=>
ca
.
nameOf
(
ca
.
currentInstruction
(
st
,
0
))
match
{
case
"@native_sched_test.v1.exittrap"
=>
{
case
"@native_sched_test.v1.body.inspect"
=>
{
val
Seq
(
rv
)
=
ca
.
dumpKeepalives
(
st
,
0
)
val
rvInt
=
ca
.
toInt
(
rv
)
printf
(
"@native_sched_test: rv = %d\n"
,
rvInt
)
TrapRebindPassVoid
(
st
)
}
case
"@take_from_mu.v1.entry.inspect"
=>
{
val
Seq
(
ss
)
=
ca
.
dumpKeepalives
(
st
,
0
)
val
rvInt
=
ca
.
toInt
(
ss
)
printf
(
"@take_from_mu: ss = %d\n"
,
rvInt
)
TrapRebindPassVoid
(
st
)
}
case
"@native_sched_test.v1.exit.exittrap"
=>
{
try
{
val
Seq
(
rvTaker
)
=
ca
.
dumpKeepalives
(
st
,
0
)
...
...
src/test/scala/uvm/refimpl/itpr/UvmInterpreterSimpleSumTest.scala
View file @
dbc7e2a4
...
...
@@ -38,11 +38,11 @@ class UvmInterpreterSimpleSumTest extends UvmBundleTesterBase {
testFunc
(
ca
,
func
,
Seq
(
hFrom
,
hTo
))
{
(
ca
,
th
,
st
,
wp
)
=>
nameOf
(
ca
.
currentInstruction
(
st
,
0
))
match
{
case
"@simplesum_v1.starttrap"
=>
{
case
"@simplesum_v1.
entry.
starttrap"
=>
{
t1
=
System
.
currentTimeMillis
()
TrapRebindPassVoid
(
st
)
}
case
"@simplesum_v1.exittrap"
=>
{
case
"@simplesum_v1.exit
.exit
trap"
=>
{
t2
=
System
.
currentTimeMillis
()
val
Seq
(
sum
)
=
ca
.
dumpKeepalives
(
st
,
0
)
...
...
src/test/scala/uvm/refimpl/itpr/UvmInterpreterSimpleTests.scala
View file @
dbc7e2a4
...
...
@@ -50,7 +50,7 @@ class UvmInterpreterSimpleTests extends UvmBundleTesterBase {
val
trapName
=
nameOf
(
ca
.
currentInstruction
(
st
,
0
))
trapName
match
{
case
"@fibonacci_mat_v1.watch"
=>
{
case
"@fibonacci_mat_v1.
head.
watch"
=>
{
if
(
watch
)
{
val
vhs
=
ca
.
dumpKeepalives
(
st
,
0
)
val
vs
=
vhs
.
map
(
_
.
vb
.
asInt
)
...
...
@@ -58,7 +58,7 @@ class UvmInterpreterSimpleTests extends UvmBundleTesterBase {
}
TrapRebindPassVoid
(
st
)
}
case
"@test_fib_v1.checktrap"
=>
{
case
"@test_fib_v1.
entry.
checktrap"
=>
{
val
Seq
(
r1
,
r2
)
=
ca
.
dumpKeepalives
(
st
,
0
)
r1
.
vb
.
asInt
shouldEqual
55
...
...
@@ -82,14 +82,14 @@ class UvmInterpreterSimpleTests extends UvmBundleTesterBase {
val
trapName
=
nameOf
(
ca
.
currentInstruction
(
st
,
0
))
trapName
match
{
case
"@test_coroutine_v1.trap_body"
=>
{
case
"@test_coroutine_v1.
body.
trap_body"
=>
{
val
Seq
(
v
)
=
ca
.
dumpKeepalives
(
st
,
0
)
println
(
v
.
vb
.
asSInt
(
64
))
TrapRebindPassVoid
(
st
)
}
case
"@test_coroutine_v1.trap_exit"
=>
{
case
"@test_coroutine_v1.
exit.
trap_exit"
=>
{
val
Seq
(
exc
)
=
ca
.
dumpKeepalives
(
st
,
0
)
val
hsi
=
ca
.
putGlobal
(
"@StopIteration"
)
...
...
@@ -115,7 +115,7 @@ class UvmInterpreterSimpleTests extends UvmBundleTesterBase {
val
trapName
=
nameOf
(
ca
.
currentInstruction
(
st
,
0
))
trapName
match
{
case
"@test_multithreading_v1.trap_result"
=>
{
case
"@test_multithreading_v1.
getresult.
trap_result"
=>
{
val
Seq
(
v
)
=
ca
.
dumpKeepalives
(
st
,
0
)
v
.
vb
.
asSInt
(
64
)
shouldEqual
4950
...
...
tests/uvm-refimpl-test/native-callback-tests.uir
View file @
dbc7e2a4
This diff is collapsed.
Click to expand it.
tests/uvm-refimpl-test/native-tests.uir
View file @
dbc7e2a4
...
...
@@ -12,10 +12,10 @@
.funcsig @noparamsnoret = @void ()
.typedef @funcdumb = func<@noparamsnoret>
.typedef @funcdumb = func
ref
<@noparamsnoret>
.typedef @thread = thread
.typedef @stack = stack
.typedef @thread = thread
ref
.typedef @stack = stack
ref
.typedef @tagref64 = tagref64
.const @TRUE <@i64> = 1
...
...
@@ -61,14 +61,14 @@
.typedef @4xi32 = vector <@i32 4>
.typedef @2xdouble = vector <@double 2>
.const @4xI32_V1 <@4xi32> =
VEC
{@I32_0 @I32_1 @I32_2 @I32_3}
.const @4xI32_V2 <@4xi32> =
VEC
{@I32_4 @I32_5 @I32_6 @I32_7}
.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> =
VEC
{@F_0 @F_1 @F_2 @F_3}
.const @4xF_V2 <@4xfloat> =
VEC
{@F_4 @F_5 @F_6 @F_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> =
VEC
{@D_0 @D_1}
.const @2xD_V2 <@2xdouble> =
VEC
{@D_2 @D_3}
.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)
...
...
@@ -96,28 +96,28 @@
.const @NULLREF_I64 <@refi64> = NULL
.const @NULLIREF_I64 <@irefi64> = NULL
.typedef @ptrvoid
=
ptr<@void>
.typedef @ptri8
=
ptr<@i8>
.typedef @ptri16
=
ptr<@i16>
.typedef @ptri32
=
ptr<@i32>
.typedef @ptri64
=
ptr<@i64>
.typedef @ptrfloat
=
ptr<@float>
.typedef @ptrdouble
=
ptr<@double>
.typedef @ptrptrvoid
=
ptr<@ptrvoid>
.typedef @ptrfpnoparamsnoret
=
ptr<@fpnoparamsnoret>
.typedef @ptrfpi_i
=
ptr<@fpi_i>
.typedef @fpnoparamsnoret
=
funcptr<@noparamsnoret>
.typedef @fpi_i
=
funcptr<@i_i>
.typedef @fpi_ii
=
funcptr<@i_ii>
.typedef @ptrvoid
= u
ptr<@void>
.typedef @ptri8
= u
ptr<@i8>
.typedef @ptri16
= u
ptr<@i16>
.typedef @ptri32
= u
ptr<@i32>
.typedef @ptri64
= u
ptr<@i64>
.typedef @ptrfloat
= u
ptr<@float>
.typedef @ptrdouble
= u
ptr<@double>
.typedef @ptrptrvoid
= u
ptr<@ptrvoid>
.typedef @ptrfpnoparamsnoret
= u
ptr<@fpnoparamsnoret>
.typedef @ptrfpi_i
= u
ptr<@fpi_i>
.typedef @fpnoparamsnoret
= u
funcptr<@noparamsnoret>
.typedef @fpi_i
= u
funcptr<@i_i>
.typedef @fpi_ii
= u
funcptr<@i_ii>
.funcsig @v_a = @void (@i64)
.funcsig @getpid_sig = @i32 ()
.typedef @getpid_fp = funcptr<@getpid_sig>
.typedef @getpid_fp =
u
funcptr<@getpid_sig>
.funcdef @getpidtest VERSION @getpidtest_v1 <@v_a>
(%p0)
{
%entry:
.funcdef @getpidtest VERSION @getpidtest_v1 <@v_a> {
%entry
(<@i64> %p0)
:
%fp = PTRCAST <@i64 @getpid_fp> %p0
%rv = CCALL #DEFAULT <@getpid_fp @getpid_sig> %fp ()
...
...
@@ -127,7 +127,7 @@
.typedef @size_t = int<64>
.funcsig @write_sig = @size_t (@i32 @ptrvoid @size_t)
.typedef @write_fp = funcptr<@write_sig>
.typedef @write_fp =
u
funcptr<@write_sig>
.typedef @CharBuf = hybrid<@i64 @i8>
.const @I8_H <@i8> = 0x48
...
...
@@ -137,8 +137,8 @@
.const @I8_NL <@i8> = 0x0a
.funcsig @writetest_sig = @void (@write_fp)
.funcdef @writetest VERSION @writetest_v1 <@writetest_sig>
(%fp)
{
%entry:
.funcdef @writetest VERSION @writetest_v1 <@writetest_sig> {
%entry
(<@write_fp> %fp)
:
%buf = NEWHYBRID <@CharBuf @i64> @I64_6
%buf_i = GETIREF <@CharBuf> %buf
%buf_v0 = GETVARPARTIREF <@CharBuf> %buf_i
...
...
@@ -166,12 +166,12 @@
}
.funcsig @memcpy_sig = @ptrvoid (@ptrvoid @ptrvoid @size_t)
.typedef @memcpy_fp = funcptr<@write_sig>
.typedef @memcpy_fp =
u
funcptr<@write_sig>
.global @FP_MEMCPY <@memcpy_fp>
.funcdef @memcpytest VERSION @memcpytest_v1 <@noparamsnoret>
()
{
%entry:
.funcdef @memcpytest VERSION @memcpytest_v1 <@noparamsnoret> {
%entry
()
:
%fp = LOAD <@memcpy_fp> @FP_MEMCPY
%buf = NEWHYBRID <@CharBuf @i64> @I64_6
...
...
@@ -225,14 +225,14 @@
.typedef @struct_baz = struct<@struct_baz1 @double>
.typedef @irefstruct_baz = iref<@struct_baz>
.typedef @ptrstruct_baz = ptr<@struct_baz>
.typedef @ptrstruct_baz =
u
ptr<@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)
.typedef @foo_func_fp = funcptr<@foo_func_sig>
.typedef @bar_func_fp = funcptr<@bar_func_sig>
.typedef @baz_func_fp = funcptr<@baz_func_sig>
.typedef @foo_func_fp =
u
funcptr<@foo_func_sig>
.typedef @bar_func_fp =
u
funcptr<@bar_func_sig>
.typedef @baz_func_fp =
u
funcptr<@baz_func_sig>
.const @I64BIG <@i64> = 0x55aa55aa55aa55aa
.const @I32BIG <@i32> = 0x5a5a5a5a
...
...
@@ -241,8 +241,8 @@
.const @o_foo <@struct_foo> = {@I64BIG @I32BIG @I16BIG @I8BIG}
.funcdef @foo_func_test VERSION @foo_func_test_v1 <@v_a>
(%p0)
{
%entry:
.funcdef @foo_func_test VERSION @foo_func_test_v1 <@v_a> {
%entry
(<@i64> %p0)
:
%fp = PTRCAST <@i64 @foo_func_fp> %p0
%aa = ALLOCA <@i64>
...
...
@@ -276,8 +276,8 @@
.typedef @irefptrvoid = iref<@ptrvoid>
.typedef @ireffpnoparamsnoret = iref<@fpnoparamsnoret>
.funcdef @bar_func_test VERSION @bar_func_test_v1 <@v_a>
(%p0)
{
%entry:
.funcdef @bar_func_test VERSION @bar_func_test_v1 <@v_a> {
%entry
(<@i64> %p0)
:
%fp = PTRCAST <@i64 @bar_func_fp> %p0
%aa = ALLOCA <@ptrvoid>
...
...
@@ -300,8 +300,8 @@
.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>
(%p0)
{
%entry:
.funcdef @baz_func_test VERSION @baz_func_test_v1 <@v_a> {
%entry
(<@i64> %p0)
:
%fp = PTRCAST <@i64 @baz_func_fp> %p0
%aa = ALLOCA <@float>
...
...
tests/uvm-refimpl-test/osr-tests-part2.uir
View file @
dbc7e2a4
// loaded after "osr-tests.uir" when doing OSR
// Calculate the sum of 0..(n-1) by n*(n-1)/2
.funcdef @sum VERSION @sum_v2 <@i_i>
(%n)
{
%entry:
.funcdef @sum VERSION @sum_v2 <@i_i> {
%entry
(<@i64> %n)
:
%nm1 = SUB <@i64> %n @I64_1
%ntnm1 = MUL <@i64> %n %nm1
%rv = SDIV <@i64> %ntnm1 @I64_2
RET
<@i64>
%rv
RET %rv
}
.funcsig @sum_osr_oneshot_sig = @i64 (@i64 @i64 @i64)
...
...
@@ -14,14 +14,14 @@
// Calculate the remaining sum.
// Given s, i, n, the result is s + (n-i)*(n+i-1)/2
.funcdef @sum_osr_oneshot VERSION @sum_osr_oneshot_v1
<@sum_osr_oneshot_sig>
(%s %i %n)
{
%entry:
<@sum_osr_oneshot_sig> {
%entry
(<@i64> %s <@i64> %i <@i64> %n)
:
%nmi = SUB <@i64> %n %i
%npi = ADD <@i64> %n %i
%npim1 = SUB <@i64> %npi @I64_1
%nmitnpim1 = MUL <@i64> %nmi %npim1
%remsum = SDIV <@i64> %nmitnpim1 @I64_2
%rv = ADD <@i64> %s %remsum
RET
<@i64>
%rv
RET %rv
}
tests/uvm-refimpl-test/osr-tests.uir
View file @
dbc7e2a4
...
...
@@ -2,31 +2,31 @@
.funcsig @v_i = @void (@i64)
.funcdef @intro_test_base VERSION @intro_test_base_v1 <@v_i>
(%n)
{
%entry:
.funcdef @intro_test_base VERSION @intro_test_base_v1 <@v_i> {
%entry
(<@i64> %n)
:
%rv = CALL <@v_i> @intro_rec (%n)
COMMINST @uvm.thread_exit
}
.funcdef @intro_rec VERSION @intro_rec_v1 <@v_i>
(%n)
{
%entry:
.funcdef @intro_rec VERSION @intro_rec_v1 <@v_i> {
%entry
(<@i64> %n)
:
%isz = EQ <@i64> %n @I64_0
BRANCH2 %isz %zero
%nz
BRANCH2 %isz %zero
(%n) %nz(%n)
%zero:
%zero
(<@i64> %n)
:
%trap_rec = TRAP <@i64> KEEPALIVE(%n)
RET
<@i64>
%trap_rec
RET %trap_rec
%nz:
%nz
(<@i64> %n)
:
%nm1 = SUB <@i64> %n @I64_1
%rv = CALL <@v_i> @intro_rec (%nm1) KEEPALIVE(%n %nm1)
RET
<@i64>
%rv
RET %rv
}
.funcdef @osr_test_base VERSION @osr_test_base_v1 <@v_i>
(%n)
{
%entry:
.funcdef @osr_test_base VERSION @osr_test_base_v1 <@v_i> {
%entry
(<@i64> %n)
:
%rv = CALL <@i_i> @sum (%n)
%trap_base_exit = TRAP <@void> KEEPALIVE (%rv)
COMMINST @uvm.thread_exit
...
...
@@ -35,30 +35,27 @@
.const @sum_v1.THRESHOLD <@i64> = 5
// Sum from 0..(n-1), but optimise when adding more than 5 numbers
.funcdef @sum VERSION @sum_v1 <@i_i> (%n) {
%entry:
BRANCH %head
%head:
%i = PHI <@i64> { %entry: @I64_0; %body: %i2; }
%s = PHI <@i64> { %entry: @I64_0; %body: %s2; }
.funcdef @sum VERSION @sum_v1 <@i_i> {
%entry(<@i64> %n):
BRANCH %head(%n @I64_0 @I64_0)
%head(<@i64> %n <@i64> %i <@i64> %s):
%ge_thr = SGE <@i64> %i @sum_v1.THRESHOLD
BRANCH2 %ge_thr %opt
%head2
BRANCH2 %ge_thr %opt
(%n %i %s) %head2(%n %i %s)
%head2:
%head2
(<@i64> %n <@i64> %i <@i64> %s)
:
%lt_n = SLT <@i64> %i %n
BRANCH2 %lt_n %body
%exit
BRANCH2 %lt_n %body
(%n %i %s) %exit(%s)
%body:
%body
(<@i64> %n <@i64> %i <@i64> %s)
:
%i2 = ADD <@i64> %i @I64_1
%s2 = ADD <@i64> %s %i
BRANCH %head
BRANCH %head
(%n %i2 %s2)
%exit:
RET
<@i64>
%s
%exit
(<@i64> %s)
:
RET %s
%opt:
%opt
(<@i64> %n <@i64> %i <@i64> %s)
:
%trap_opt = TRAP <@void> KEEPALIVE(%n %i %s)
THROW @NULLREF // unreachable
}
tests/uvm-refimpl-test/primitives.uir
View file @
dbc7e2a4
...
...
@@ -22,6 +22,8 @@
.typedef @refvoid = ref<@void>
.const @NULLREF <@refvoid> = NULL
.const @VOID <@void> = NULL
.typedef @refi64 = ref<@i64>
.typedef @irefi64 = iref<@i64>
.typedef @weakrefi64 = weakref<@i64>
...
...
tests/uvm-refimpl-test/simple-sum.uir
View file @
dbc7e2a4
// require "primitives.uir"
.funcsig @simplesum_sig = @void (@i64 @i64)
.funcdef @simplesum VERSION @simplesum_v1 <@simplesum_sig>
(%from %to)
{
%entry:
.funcdef @simplesum VERSION @simplesum_v1 <@simplesum_sig> {
%entry
(<@i64> %from <@i64> %to)
:
%starttrap = TRAP <@void>
BRANCH %head
BRANCH %head
(@I64_0 %from %to)
%head:
%sum = PHI <@i64> { %entry: @I64_0; %body: %sum2; }
%i = PHI <@i64> { %entry: %from; %body: %i2; }
%head(<@i64> %sum <@i64> %i <@i64> %to):
%le = SLE <@i64> %i %to
BRANCH2 %le %body
%exit
BRANCH2 %le %body
(%sum %i %to) %exit(%sum)
%body:
%body
(<@i64> %sum <@i64> %i <@i64> %to)
:
%sum2 = ADD <@i64> %sum %i
%i2 = ADD <@i64> %i @I64_1
BRANCH %head
BRANCH %head
(%sum2 %i2 %to)
//%montrap = TRAP <@void> %head %head KEEPALIVE (%from %to %sum %i %le %sum2 %i2)
%exit:
%exit
(<@i64> %sum)
:
%exittrap = TRAP <@void> KEEPALIVE (%sum)
COMMINST @uvm.thread_exit
}
tests/uvm-refimpl-test/simple-tests.uir
View file @
dbc7e2a4
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment