Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mu-impl-ref2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
5
Issues
5
List
Boards
Labels
Milestones
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
mu
mu-impl-ref2
Commits
ef89c4e5
Commit
ef89c4e5
authored
May 02, 2016
by
Kunshan Wang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow comparing between pointers
parent
886a718f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
81 additions
and
0 deletions
+81
-0
src/main/scala/uvm/refimpl/itpr/InstructionExecutor.scala
src/main/scala/uvm/refimpl/itpr/InstructionExecutor.scala
+1
-0
src/test/scala/uvm/refimpl/itpr/UvmInterpreterSpec.scala
src/test/scala/uvm/refimpl/itpr/UvmInterpreterSpec.scala
+60
-0
tests/uvm-refimpl-test/basic-tests.uir
tests/uvm-refimpl-test/basic-tests.uir
+20
-0
No files found.
src/main/scala/uvm/refimpl/itpr/InstructionExecutor.scala
View file @
ef89c4e5
...
...
@@ -73,6 +73,7 @@ trait InstructionExecutor extends InterpreterActions with CommInstExecutor {
val
(
op2b
,
op2o
)
=
b2
.
asIRef
PrimOpHelpers
.
irefCmp
(
op
,
op1b
,
op1o
,
op2b
,
op2o
,
ctx
)
}
case
t
:
AbstractPointerType
=>
PrimOpHelpers
.
intCmp
(
op
,
TypeSizes
.
WORD_SIZE_BITS
.
toInt
,
b1
.
asPtr
,
b2
.
asPtr
,
ctx
)
case
_
=>
throw
new
UvmRuntimeException
(
ctx
+
"Comparison not suitable for type %s"
.
format
(
opndTy
))
}
}
...
...
src/test/scala/uvm/refimpl/itpr/UvmInterpreterSpec.scala
View file @
ef89c4e5
...
...
@@ -360,6 +360,66 @@ class UvmInterpreterSpec extends UvmBundleTesterBase {
ctx
.
closeContext
()
}
"Comparing operations"
should
"work on pointer types"
in
{
val
ctx
=
microVM
.
newContext
()
val
func
=
ctx
.
handleFromFunc
(
"@cmpptr"
)
val
a0
=
ctx
.
handleFromPtr
(
"@ptri64"
,
1
)
val
a1
=
ctx
.
handleFromPtr
(
"@ptri64"
,
2
)
testFunc
(
ctx
,
func
,
Seq
(
a0
,
a1
))
{
(
ctx
,
th
,
st
,
wp
)
=>
val
Seq
(
eq
,
ne
,
ult
,
ule
,
ugt
,
uge
,
slt
,
sle
,
sgt
,
sge
)
=
ctx
.
dumpKeepalives
(
st
,
0
)
eq
.
vb
.
asUInt
(
1
)
shouldEqual
0
ne
.
vb
.
asUInt
(
1
)
shouldEqual
1
ult
.
vb
.
asUInt
(
1
)
shouldEqual
1
ule
.
vb
.
asUInt
(
1
)
shouldEqual
1
ugt
.
vb
.
asUInt
(
1
)
shouldEqual
0
uge
.
vb
.
asUInt
(
1
)
shouldEqual
0
slt
.
vb
.
asUInt
(
1
)
shouldEqual
1
sle
.
vb
.
asUInt
(
1
)
shouldEqual
1
sgt
.
vb
.
asUInt
(
1
)
shouldEqual
0
sge
.
vb
.
asUInt
(
1
)
shouldEqual
0
Rebind
(
st
,
PassValues
(
Seq
()))
}
testFunc
(
ctx
,
func
,
Seq
(
a0
,
a0
))
{
(
ctx
,
th
,
st
,
wp
)
=>
val
Seq
(
eq
,
ne
,
ult
,
ule
,
ugt
,
uge
,
slt
,
sle
,
sgt
,
sge
)
=
ctx
.
dumpKeepalives
(
st
,
0
)
eq
.
vb
.
asUInt
(
1
)
shouldEqual
1
ne
.
vb
.
asUInt
(
1
)
shouldEqual
0
ult
.
vb
.
asUInt
(
1
)
shouldEqual
0
ule
.
vb
.
asUInt
(
1
)
shouldEqual
1
ugt
.
vb
.
asUInt
(
1
)
shouldEqual
0
uge
.
vb
.
asUInt
(
1
)
shouldEqual
1
slt
.
vb
.
asUInt
(
1
)
shouldEqual
0
sle
.
vb
.
asUInt
(
1
)
shouldEqual
1
sgt
.
vb
.
asUInt
(
1
)
shouldEqual
0
sge
.
vb
.
asUInt
(
1
)
shouldEqual
1
Rebind
(
st
,
PassValues
(
Seq
()))
}
val
a2
=
ctx
.
handleFromPtr
(
"@ptri64"
,
-
3
)
testFunc
(
ctx
,
func
,
Seq
(
a0
,
a2
))
{
(
ctx
,
th
,
st
,
wp
)
=>
val
Seq
(
eq
,
ne
,
ult
,
ule
,
ugt
,
uge
,
slt
,
sle
,
sgt
,
sge
)
=
ctx
.
dumpKeepalives
(
st
,
0
)
eq
.
vb
.
asUInt
(
1
)
shouldEqual
0
ne
.
vb
.
asUInt
(
1
)
shouldEqual
1
slt
.
vb
.
asUInt
(
1
)
shouldEqual
0
sle
.
vb
.
asUInt
(
1
)
shouldEqual
0
sgt
.
vb
.
asUInt
(
1
)
shouldEqual
1
sge
.
vb
.
asUInt
(
1
)
shouldEqual
1
Rebind
(
st
,
PassValues
(
Seq
()))
}
ctx
.
closeContext
()
}
"Comparing operations"
should
"work on float"
in
{
val
ctx
=
microVM
.
newContext
()
...
...
tests/uvm-refimpl-test/basic-tests.uir
View file @
ef89c4e5
...
...
@@ -137,6 +137,26 @@
COMMINST @uvm.thread_exit
}
.funcsig @cmpptr_sig = (@ptri64 @ptri64) -> ()
.funcdef @cmpptr VERSION %v1 <@cmpptr_sig> {
%entry(<@ptri64> %p0 <@ptri64> %p1):
%eq = EQ <@ptri64> %p0 %p1
%ne = NE <@ptri64> %p0 %p1
%ult = ULT <@ptri64> %p0 %p1
%ule = ULE <@ptri64> %p0 %p1
%ugt = UGT <@ptri64> %p0 %p1
%uge = UGE <@ptri64> %p0 %p1
%slt = SLT <@ptri64> %p0 %p1
%sle = SLE <@ptri64> %p0 %p1
%sgt = SGT <@ptri64> %p0 %p1
%sge = SGE <@ptri64> %p0 %p1
[%trap] TRAP <> KEEPALIVE (
%eq %ne %ult %ule %ugt %uge %slt %sle %sgt %sge
)
COMMINST @uvm.thread_exit
}
.funcsig @cmp_f_sig = (@float @float) -> ()
.funcdef @cmp_f VERSION %v1 <@cmp_f_sig> {
%entry(<@float> %p0 <@float> %p1):
...
...
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