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
8876d93c
Commit
8876d93c
authored
Jun 06, 2016
by
Kunshan Wang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
c interface
parent
5ac4d9fd
Changes
6
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
533 additions
and
58 deletions
+533
-58
cbinding/muapi.h
cbinding/muapi.h
+11
-11
migrate_scripts/irbuildertomuctx.py
migrate_scripts/irbuildertomuctx.py
+2
-0
migrate_scripts/muapitoncs.py
migrate_scripts/muapitoncs.py
+167
-0
src/main/scala/uvm/ir/irbuilder/IRBuilder.scala
src/main/scala/uvm/ir/irbuilder/IRBuilder.scala
+21
-6
src/main/scala/uvm/refimpl/MuCtxIRBuilderPart.scala
src/main/scala/uvm/refimpl/MuCtxIRBuilderPart.scala
+11
-0
src/main/scala/uvm/refimpl/nat/nativeClientSupport.scala
src/main/scala/uvm/refimpl/nat/nativeClientSupport.scala
+321
-41
No files found.
cbinding/muapi.h
View file @
8876d93c
...
@@ -122,9 +122,9 @@ typedef MuFlag MuDestKind;
...
@@ -122,9 +122,9 @@ typedef MuFlag MuDestKind;
#define MU_DEST_EXCEPT 0x02
#define MU_DEST_EXCEPT 0x02
#define MU_DEST_TRUE 0x03
#define MU_DEST_TRUE 0x03
#define MU_DEST_FALSE 0x04
#define MU_DEST_FALSE 0x04
#define MU_DEST_DEFAULT 0x0
4
#define MU_DEST_DEFAULT 0x0
5
#define MU_DEST_DISABLED 0x0
5
#define MU_DEST_DISABLED 0x0
6
#define MU_DEST_ENABLED 0x0
6
#define MU_DEST_ENABLED 0x0
7
// Binary operators
// Binary operators
typedef
MuFlag
MuBinOptr
;
typedef
MuFlag
MuBinOptr
;
...
@@ -413,10 +413,10 @@ struct MuCtx {
...
@@ -413,10 +413,10 @@ struct MuCtx {
MuChildNode
(
*
get_node
)(
MuCtx
*
ctx
,
MuBundleNode
b
,
MuID
id
);
MuChildNode
(
*
get_node
)(
MuCtx
*
ctx
,
MuBundleNode
b
,
MuID
id
);
// Get the ID of the IR node "node".
// Get the ID of the IR node "node".
MuID
(
*
get_id
)(
MuCtx
*
ctx
,
MuChildNode
node
);
MuID
(
*
get_id
)(
MuCtx
*
ctx
,
Mu
BundleNode
b
,
Mu
ChildNode
node
);
// Set the name of the IR node. MuName is '\0' terminated char*.
// Set the name of the IR node. MuName is '\0' terminated char*.
void
(
*
set_name
)(
MuCtx
*
ctx
,
MuChildNode
node
,
MuName
name
);
void
(
*
set_name
)(
MuCtx
*
ctx
,
Mu
BundleNode
b
,
Mu
ChildNode
node
,
MuName
name
);
/// Create top-level definitions. When created, they are added to the bundle "b".
/// Create top-level definitions. When created, they are added to the bundle "b".
...
@@ -463,9 +463,9 @@ struct MuCtx {
...
@@ -463,9 +463,9 @@ struct MuCtx {
MuConstNode
(
*
new_const_float
)(
MuCtx
*
ctx
,
MuBundleNode
b
,
MuTypeNode
ty
,
float
value
);
MuConstNode
(
*
new_const_float
)(
MuCtx
*
ctx
,
MuBundleNode
b
,
MuTypeNode
ty
,
float
value
);
MuConstNode
(
*
new_const_double
)(
MuCtx
*
ctx
,
MuBundleNode
b
,
MuTypeNode
ty
,
double
value
);
MuConstNode
(
*
new_const_double
)(
MuCtx
*
ctx
,
MuBundleNode
b
,
MuTypeNode
ty
,
double
value
);
// new_const_null works for all general reference types, but not uptr or ufuncptr.
// new_const_null works for all general reference types, but not uptr or ufuncptr.
MuConstNode
(
*
new_const_null
)(
MuCtx
*
ctx
,
MuBundleNode
b
);
MuConstNode
(
*
new_const_null
)(
MuCtx
*
ctx
,
MuBundleNode
b
,
MuTypeNode
ty
);
// new_const_seq works for structs, arrays and vectors. Constants are non-recursive, so there is no populate_list_const.
// new_const_seq works for structs, arrays and vectors. Constants are non-recursive, so there is no populate_list_const.
MuConstNode
(
*
new_const_seq
)(
MuCtx
*
ctx
,
MuBundleNode
b
,
MuConstNode
*
elems
,
int
nelems
);
MuConstNode
(
*
new_const_seq
)(
MuCtx
*
ctx
,
MuBundleNode
b
,
Mu
TypeNode
ty
,
Mu
ConstNode
*
elems
,
int
nelems
);
// Create global cell
// Create global cell
MuGlobalNode
(
*
new_global_cell
)(
MuCtx
*
ctx
,
MuBundleNode
b
,
MuTypeNode
ty
);
MuGlobalNode
(
*
new_global_cell
)(
MuCtx
*
ctx
,
MuBundleNode
b
,
MuTypeNode
ty
);
...
@@ -515,7 +515,7 @@ struct MuCtx {
...
@@ -515,7 +515,7 @@ struct MuCtx {
MuInstNode
(
*
new_branch
)(
MuCtx
*
ctx
,
MuBBNode
bb
);
MuInstNode
(
*
new_branch
)(
MuCtx
*
ctx
,
MuBBNode
bb
);
MuInstNode
(
*
new_branch2
)(
MuCtx
*
ctx
,
MuBBNode
bb
,
MuVarNode
cond
);
MuInstNode
(
*
new_branch2
)(
MuCtx
*
ctx
,
MuBBNode
bb
,
MuVarNode
cond
);
MuInstNode
(
*
new_switch
)(
MuCtx
*
ctx
,
MuBBNode
bb
,
MuVarNode
opnd
);
MuInstNode
(
*
new_switch
)(
MuCtx
*
ctx
,
MuBBNode
bb
,
Mu
TypeNode
opnd_ty
,
Mu
VarNode
opnd
);
void
(
*
add_switch_dest
)(
MuCtx
*
ctx
,
MuInstNode
sw
,
MuConstNode
key
,
MuBBNode
dest
,
MuVarNode
*
vars
,
int
nvars
);
void
(
*
add_switch_dest
)(
MuCtx
*
ctx
,
MuInstNode
sw
,
MuConstNode
key
,
MuBBNode
dest
,
MuVarNode
*
vars
,
int
nvars
);
MuInstNode
(
*
new_call
)(
MuCtx
*
ctx
,
MuBBNode
bb
,
MuFuncSigNode
sig
,
MuVarNode
callee
,
MuVarNode
*
args
,
int
nargs
);
MuInstNode
(
*
new_call
)(
MuCtx
*
ctx
,
MuBBNode
bb
,
MuFuncSigNode
sig
,
MuVarNode
callee
,
MuVarNode
*
args
,
int
nargs
);
...
@@ -543,7 +543,7 @@ struct MuCtx {
...
@@ -543,7 +543,7 @@ struct MuCtx {
MuInstNode
(
*
new_load
)(
MuCtx
*
ctx
,
MuBBNode
bb
,
int
is_ptr
,
MuMemOrd
ord
,
MuTypeNode
refty
,
MuVarNode
loc
);
MuInstNode
(
*
new_load
)(
MuCtx
*
ctx
,
MuBBNode
bb
,
int
is_ptr
,
MuMemOrd
ord
,
MuTypeNode
refty
,
MuVarNode
loc
);
MuInstNode
(
*
new_store
)(
MuCtx
*
ctx
,
MuBBNode
bb
,
int
is_ptr
,
MuMemOrd
ord
,
MuTypeNode
refty
,
MuVarNode
loc
,
MuVarNode
newval
);
MuInstNode
(
*
new_store
)(
MuCtx
*
ctx
,
MuBBNode
bb
,
int
is_ptr
,
MuMemOrd
ord
,
MuTypeNode
refty
,
MuVarNode
loc
,
MuVarNode
newval
);
MuInstNode
(
*
new_cmpxchg
)(
MuCtx
*
ctx
,
MuBBNode
bb
,
int
is_ptr
,
int
is_weak
,
MuMemOrd
ord_succ
,
MuMemOrd
ord_fail
,
MuTypeNode
refty
,
MuVarNode
loc
,
MuVarNode
expected
,
MuVarNode
desired
);
MuInstNode
(
*
new_cmpxchg
)(
MuCtx
*
ctx
,
MuBBNode
bb
,
int
is_ptr
,
int
is_weak
,
MuMemOrd
ord_succ
,
MuMemOrd
ord_fail
,
MuTypeNode
refty
,
MuVarNode
loc
,
MuVarNode
expected
,
MuVarNode
desired
);
MuInstNode
(
*
new_atomicrmw
)(
MuCtx
*
ctx
,
MuBBNode
bb
,
int
is_ptr
,
MuMemOrd
ord
,
MuAtomicRMWOp
optr
,
Mu
VarNode
loc
,
MuVarNode
opnd
);
MuInstNode
(
*
new_atomicrmw
)(
MuCtx
*
ctx
,
MuBBNode
bb
,
int
is_ptr
,
MuMemOrd
ord
,
MuAtomicRMWOp
optr
,
Mu
TypeNode
refTy
,
MuVarNode
loc
,
MuVarNode
opnd
);
MuInstNode
(
*
new_fence
)(
MuCtx
*
ctx
,
MuBBNode
bb
,
MuMemOrd
ord
);
MuInstNode
(
*
new_fence
)(
MuCtx
*
ctx
,
MuBBNode
bb
,
MuMemOrd
ord
);
MuInstNode
(
*
new_trap
)(
MuCtx
*
ctx
,
MuBBNode
bb
,
MuTypeNode
*
rettys
,
int
nrettys
);
MuInstNode
(
*
new_trap
)(
MuCtx
*
ctx
,
MuBBNode
bb
,
MuTypeNode
*
rettys
,
int
nrettys
);
...
@@ -553,10 +553,10 @@ struct MuCtx {
...
@@ -553,10 +553,10 @@ struct MuCtx {
MuInstNode
(
*
new_ccall
)(
MuCtx
*
ctx
,
MuBBNode
bb
,
MuCallConv
callconv
,
MuTypeNode
callee_ty
,
MuFuncSigNode
sig
,
MuVarNode
callee
,
MuVarNode
*
args
,
int
nargs
);
MuInstNode
(
*
new_ccall
)(
MuCtx
*
ctx
,
MuBBNode
bb
,
MuCallConv
callconv
,
MuTypeNode
callee_ty
,
MuFuncSigNode
sig
,
MuVarNode
callee
,
MuVarNode
*
args
,
int
nargs
);
MuInstNode
(
*
new_newthread
)(
MuCtx
*
ctx
,
MuBBNode
bb
,
MuVarNode
stack
,
MuVarNode
threadlocal
);
MuInstNode
(
*
new_newthread
)(
MuCtx
*
ctx
,
MuBBNode
bb
,
MuVarNode
stack
,
MuVarNode
threadlocal
);
MuInstNode
(
*
new_swapstack_ret
)(
MuCtx
*
ctx
,
MuBBNode
bb
,
MuVarNode
swappee
,
MuTypeNode
*
tys
,
int
n
tys
);
MuInstNode
(
*
new_swapstack_ret
)(
MuCtx
*
ctx
,
MuBBNode
bb
,
MuVarNode
swappee
,
MuTypeNode
*
ret_tys
,
int
nret_
tys
);
MuInstNode
(
*
new_swapstack_kill
)(
MuCtx
*
ctx
,
MuBBNode
bb
,
MuVarNode
swappee
);
MuInstNode
(
*
new_swapstack_kill
)(
MuCtx
*
ctx
,
MuBBNode
bb
,
MuVarNode
swappee
);
void
(
*
set_newstack_pass_values
)(
MuCtx
*
ctx
,
MuInstNode
inst
,
MuTypeNode
tys
,
MuVarNode
*
vars
,
int
nvars
);
void
(
*
set_newstack_pass_values
)(
MuCtx
*
ctx
,
MuInstNode
inst
,
MuTypeNode
*
tys
,
MuVarNode
*
vars
,
int
nvars
);
void
(
*
set_newstack_throw_exc
)(
MuCtx
*
ctx
,
MuInstNode
inst
,
MuVarNode
exc
);
void
(
*
set_newstack_throw_exc
)(
MuCtx
*
ctx
,
MuInstNode
inst
,
MuVarNode
exc
);
MuInstNode
(
*
new_comminst
)(
MuCtx
*
ctx
,
MuBBNode
bb
,
MuCommInst
opcode
,
MuInstNode
(
*
new_comminst
)(
MuCtx
*
ctx
,
MuBBNode
bb
,
MuCommInst
opcode
,
...
...
migrate_scripts/irbuildertomuctx.py
View file @
8876d93c
...
@@ -2,6 +2,8 @@
...
@@ -2,6 +2,8 @@
USAGE: python3 migrate_scripts/irbuildertomuctx.py < src/main/scala/uvm/ir/irbuilder/IRBuilder.scala | xclip -selection c
USAGE: python3 migrate_scripts/irbuildertomuctx.py < src/main/scala/uvm/ir/irbuilder/IRBuilder.scala | xclip -selection c
And then paste the result into src/main/scala/uvm/refimpl/MuCtxIRBuilderPart.scala
And then paste the result into src/main/scala/uvm/refimpl/MuCtxIRBuilderPart.scala
Use pbcopy on Mac.
"""
"""
import
re
import
re
...
...
migrate_scripts/muapitoncs.py
0 → 100644
View file @
8876d93c
"""
Converts MuCtx methods in muapi.h to nativeClientSupport
USAGE: python3 muapitoncs.py < cbinding/muapi.h | xclip -selection c
then paste in function signatures, then paste the result in
src/main/scala/uvm/refimpl/nat/nativeClientSupport.scala
Use pbcopy on Mac.
"""
import
sys
import
re
r_comment
=
re
.
compile
(
r'//.*$'
,
re
.
MULTILINE
)
r_decl
=
re
.
compile
(
r'(?P<ret>\w+)\s*\(\s*\*\s*(?P<name>\w+)\s*\)\s*\((?P<params>[^)]*)\)\s*;'
)
r_param
=
re
.
compile
(
r'\s*(?P<type>\w+)\s*(?P<ptr>\*?)\s*(?P<name>\w+)'
)
r_value_ty
=
re
.
compile
(
r'Mu\w*(Value|Node)'
)
begin
=
"/// IR Builder API"
end
=
"// Common instruction opcodes"
lines
=
sys
.
stdin
.
read
().
splitlines
()
l1
=
[
n
for
(
n
,
l
)
in
enumerate
(
lines
)
if
begin
in
l
][
0
]
l2
=
[
n
for
(
n
,
l
)
in
enumerate
(
lines
)
if
end
in
l
][
0
]
text
=
"
\n
"
.
join
(
lines
[
l1
+
1
:
l2
])
text
=
r_comment
.
sub
(
""
,
text
)
_simple_map
=
{
"void"
:
"Unit"
,
"int"
:
"Int"
,
"long"
:
"Long"
,
"uint64_t"
:
"Long"
,
"uint64_t*"
:
"LongPtr"
,
"float"
:
"Float"
,
"double"
:
"Double"
,
}
def
conv_ret_ty
(
ty
):
if
ty
in
_simple_map
:
ty
=
_simple_map
[
ty
]
m
=
r_value_ty
.
match
(
ty
)
if
m
is
not
None
:
return
(
True
,
"MuValueFak"
)
else
:
return
(
False
,
ty
)
_special_case
=
{
"id"
:
"ID"
,
"uptr"
:
"UPtr"
,
"ufuncptr"
:
"UFuncPtr"
,
"iref"
:
"IRef"
,
"weakref"
:
"WeakRef"
,
"funcref"
:
"FuncRef"
,
"tagref64"
:
"TagRef64"
,
"threadref"
:
"ThreadRef"
,
"stackref"
:
"StackRef"
,
"framecursorref"
:
"FrameCursorRef"
,
"irnoderef"
:
"IRNodeRef"
,
"funcsig"
:
"FuncSig"
,
"bb"
:
"BB"
,
"keepalives"
:
"KeepAlives"
,
"binop"
:
"BinOp"
,
"tailcall"
:
"TailCall"
,
"extractvalue"
:
"ExtractValue"
,
"insertvalue"
:
"InsertValue"
,
"extractelement"
:
"ExtractElement"
,
"insertelement"
:
"InsertElement"
,
"shufflevector"
:
"ShuffleVector"
,
"newhybrid"
:
"NewHybrid"
,
"allocahybrid"
:
"AllocaHybrid"
,
"getiref"
:
"GetIRef"
,
"getfieldiref"
:
"GetFieldIRef"
,
"getelemiref"
:
"GetElemIRef"
,
"shiftiref"
:
"ShiftIRef"
,
"getvarpartiref"
:
"GetVarPartIRef"
,
"cmpxchg"
:
"CmpXchg"
,
"atomicrmw"
:
"AtomicRMW"
,
"watchpoint"
:
"WatchPoint"
,
"wpbranch"
:
"WPBranch"
,
"ccall"
:
"CCall"
,
"newthread"
:
"NewThread"
,
"newstack"
:
"NewStack"
,
"swapstack"
:
"SwapStack"
,
"comminst"
:
"CommInst"
,
}
def
toCamelCase
(
name
):
ins
=
name
.
split
(
"_"
)
outs
=
[
ins
[
0
]]
for
inn
in
ins
[
1
:]:
if
inn
in
_special_case
:
outs
.
append
(
_special_case
[
inn
])
else
:
outs
.
append
(
inn
[
0
].
upper
()
+
inn
[
1
:])
return
""
.
join
(
outs
)
_special_param
=
{
}
def
conv_param_ty
(
name
,
ty
):
if
ty
==
"MuCtx*"
:
return
"MuCtx"
elif
r_value_ty
.
match
(
ty
)
is
not
None
and
ty
.
endswith
(
"*"
):
return
"MuValueFakArrayPtr"
elif
ty
==
"MuFlag*"
:
return
"MuFlagArrayPtr"
elif
name
==
"threadlocal"
and
ty
==
"MuVarNode"
:
return
"Option[MuVarNode]"
elif
ty
in
_special_param
:
return
_special_param
[
ty
]
elif
ty
in
_simple_map
:
return
_simple_map
[
ty
]
else
:
return
ty
def
conv_param_val
(
func
,
name
,
ty
):
if
ty
==
"MuValueFakArrayPtr"
:
if
func
==
"set_newstack_pass_values"
:
lenvar
=
"nvars"
else
:
lenvar
=
"n"
+
name
return
"readFromValueFakArray({}, {})"
.
format
(
name
,
lenvar
)
elif
ty
==
"MuFlagArrayPtr"
:
lenvar
=
"n"
+
name
return
"readFromFlagArray({}, {})"
.
format
(
name
,
lenvar
)
elif
name
in
[
"is_ptr"
,
"is_weak"
]:
return
name
+
" != 0"
else
:
return
name
_num_params
=
"nfieldtys nfixedtys nparamtys nrettys nelems nargs nrvs nvars nflags ntys nsigs nret_tys"
.
split
()
def
forward_call
(
func
,
params
):
params
=
[
p
for
p
in
params
if
p
[
0
]
not
in
_num_params
]
return
"ctx.{}({})"
.
format
(
toCamelCase
(
func
),
", "
.
join
(
conv_param_val
(
func
,
n
,
t
)
for
n
,
t
in
params
))
for
m
in
r_decl
.
finditer
(
text
):
name
,
params
,
ret
=
[
m
.
groupdict
()[
k
]
for
k
in
"name params ret"
.
split
()]
params_out
=
[]
params
=
params
.
split
(
","
)
for
param
in
params
:
mp
=
r_param
.
search
(
param
)
pt
,
pp
,
pn
=
[
mp
.
groupdict
()[
k
]
for
k
in
"type ptr name"
.
split
()]
pt
=
conv_param_ty
(
pn
,
pt
+
pp
)
params_out
.
append
((
pn
,
pt
))
params_out_str
=
", "
.
join
(
"{}: {}"
.
format
(
pn
,
pt
)
for
pn
,
pt
in
params_out
)
is_value
,
ret
=
conv_ret_ty
(
ret
)
impl
=
forward_call
(
name
,
params_out
[
1
:])
if
is_value
:
impl
=
"exposeMuValue(ctx, {})"
.
format
(
impl
)
print
(
" def {}({}): {} = {}"
.
format
(
name
,
params_out_str
,
ret
,
impl
))
src/main/scala/uvm/ir/irbuilder/IRBuilder.scala
View file @
8876d93c
package
uvm.ir.irbuilder
package
uvm.ir.irbuilder
import
scala.collection.mutable.ArrayBuffer
import
scala.collection.mutable.ArrayBuffer
import
uvm.utils.IDFactory
import
uvm._
import
uvm._
import
uvm.types._
import
uvm.ssavariables._
import
uvm.comminsts.CommInsts
import
uvm.comminsts.CommInsts
import
uvm.ssavariables._
import
uvm.types._
import
uvm.utils.IDFactory
object
DestKind
extends
Enumeration
{
object
DestKind
extends
Enumeration
{
val
NORMAL
,
EXCEPT
,
TRUE
,
FALSE
,
DEFAULT
,
DISABLED
,
ENABLED
=
Value
val
NORMAL
,
EXCEPT
,
TRUE
,
FALSE
,
DEFAULT
,
DISABLED
,
ENABLED
=
Value
...
@@ -417,6 +418,11 @@ class IRBuilder(globalBundle: GlobalBundle, idFactory: IDFactory) {
...
@@ -417,6 +418,11 @@ class IRBuilder(globalBundle: GlobalBundle, idFactory: IDFactory) {
newInst
(
bb
,
inst
)
newInst
(
bb
,
inst
)
}
}
def
newWPBranch
(
bb
:
CN
[
BB
],
wpid
:
Int
)
:
CN
[
InstWPBranch
]
=
{
val
inst
=
InstWPBranch
(
wpid
,
null
,
null
)
newInst
(
bb
,
inst
)
}
def
newCCall
(
bb
:
CN
[
BB
],
callConv
:
Flag
,
calleeTy
:
CN
[
Type
],
sig
:
CN
[
FuncSig
],
callee
:
CN
[
Var
],
args
:
Seq
[
CN
[
Var
]])
:
CN
[
InstCCall
]
=
{
def
newCCall
(
bb
:
CN
[
BB
],
callConv
:
Flag
,
calleeTy
:
CN
[
Type
],
sig
:
CN
[
FuncSig
],
callee
:
CN
[
Var
],
args
:
Seq
[
CN
[
Var
]])
:
CN
[
InstCCall
]
=
{
val
inst
=
InstCCall
(
callConv
,
calleeTy
,
sig
,
callee
,
args
,
None
,
Seq
())
val
inst
=
InstCCall
(
callConv
,
calleeTy
,
sig
,
callee
,
args
,
None
,
Seq
())
newInst
(
bb
,
inst
)
newInst
(
bb
,
inst
)
...
@@ -439,8 +445,7 @@ class IRBuilder(globalBundle: GlobalBundle, idFactory: IDFactory) {
...
@@ -439,8 +445,7 @@ class IRBuilder(globalBundle: GlobalBundle, idFactory: IDFactory) {
newInst
(
bb
,
inst
)
newInst
(
bb
,
inst
)
}
}
def
setNewStackPassValues
(
inst
:
CN
[
Instruction
],
tys
:
Seq
[
CN
[
Type
]],
vars
:
Seq
[
CN
[
Var
]])
:
Unit
=
{
private
def
setNewStackClause
(
inst
:
CN
[
Instruction
],
newStackClause
:
NewStackAction
)
:
Unit
=
{
val
newStackClause
=
PassValues
(
tys
,
vars
)
inst
.
obj
match
{
inst
.
obj
match
{
case
i
:
InstNewThread
=>
i
.
newStackAction
=
newStackClause
case
i
:
InstNewThread
=>
i
.
newStackAction
=
newStackClause
case
i
:
InstSwapStack
=>
i
.
newStackAction
=
newStackClause
case
i
:
InstSwapStack
=>
i
.
newStackAction
=
newStackClause
...
@@ -450,6 +455,16 @@ class IRBuilder(globalBundle: GlobalBundle, idFactory: IDFactory) {
...
@@ -450,6 +455,16 @@ class IRBuilder(globalBundle: GlobalBundle, idFactory: IDFactory) {
}
}
}
}
def
setNewStackPassValues
(
inst
:
CN
[
Instruction
],
tys
:
Seq
[
CN
[
Type
]],
vars
:
Seq
[
CN
[
Var
]])
:
Unit
=
{
val
newStackClause
=
PassValues
(
tys
,
vars
)
setNewStackClause
(
inst
,
newStackClause
)
}
def
setNewStackThrowExc
(
inst
:
CN
[
Instruction
],
exc
:
CN
[
Var
])
:
Unit
=
{
val
newStackClause
=
ThrowExc
(
exc
)
setNewStackClause
(
inst
,
newStackClause
)
}
def
newCommInst
(
bb
:
CN
[
BB
],
opcode
:
Int
,
flags
:
Seq
[
Flag
],
tys
:
Seq
[
CN
[
Type
]],
sigs
:
Seq
[
CN
[
FuncSig
]],
args
:
Seq
[
CN
[
Var
]])
:
CN
[
InstCommInst
]
=
{
def
newCommInst
(
bb
:
CN
[
BB
],
opcode
:
Int
,
flags
:
Seq
[
Flag
],
tys
:
Seq
[
CN
[
Type
]],
sigs
:
Seq
[
CN
[
FuncSig
]],
args
:
Seq
[
CN
[
Var
]])
:
CN
[
InstCommInst
]
=
{
val
commInst
=
CommInsts
.
get
(
opcode
).
getOrElse
{
val
commInst
=
CommInsts
.
get
(
opcode
).
getOrElse
{
throw
new
IllegalArgumentException
(
"No such common instruction. opcode: %d 0x%x"
.
format
(
opcode
,
opcode
))
throw
new
IllegalArgumentException
(
"No such common instruction. opcode: %d 0x%x"
.
format
(
opcode
,
opcode
))
...
...
src/main/scala/uvm/refimpl/MuCtxIRBuilderPart.scala
View file @
8876d93c
...
@@ -576,6 +576,11 @@ trait MuCtxIRBuilderPart {
...
@@ -576,6 +576,11 @@ trait MuCtxIRBuilderPart {
addHandle
(
irBuilder
.
newWatchPoint
(
bb
,
wpid
,
retTys
))
addHandle
(
irBuilder
.
newWatchPoint
(
bb
,
wpid
,
retTys
))
}
}
def
newWPBranch
(
bb
:
MuBBNode
,
wpid
:
Int
)
:
MuInstNode
=
{
require
(!
bb
.
isNull
,
"bb must not be NULL"
)
addHandle
(
irBuilder
.
newWPBranch
(
bb
,
wpid
))
}
def
newCCall
(
bb
:
MuBBNode
,
callConv
:
Flag
,
calleeTy
:
MuTypeNode
,
sig
:
MuFuncSigNode
,
callee
:
MuVarNode
,
args
:
Seq
[
MuVarNode
])
:
MuInstNode
=
{
def
newCCall
(
bb
:
MuBBNode
,
callConv
:
Flag
,
calleeTy
:
MuTypeNode
,
sig
:
MuFuncSigNode
,
callee
:
MuVarNode
,
args
:
Seq
[
MuVarNode
])
:
MuInstNode
=
{
require
(!
bb
.
isNull
,
"bb must not be NULL"
)
require
(!
bb
.
isNull
,
"bb must not be NULL"
)
require
(!
calleeTy
.
isNull
,
"calleeTy must not be NULL"
)
require
(!
calleeTy
.
isNull
,
"calleeTy must not be NULL"
)
...
@@ -611,6 +616,12 @@ trait MuCtxIRBuilderPart {
...
@@ -611,6 +616,12 @@ trait MuCtxIRBuilderPart {
irBuilder
.
setNewStackPassValues
(
inst
,
tys
,
vars
)
irBuilder
.
setNewStackPassValues
(
inst
,
tys
,
vars
)
}
}
def
setNewStackThrowExc
(
inst
:
MuInstNode
,
exc
:
MuVarNode
)
:
Unit
=
{
require
(!
inst
.
isNull
,
"inst must not be NULL"
)
require
(!
exc
.
isNull
,
"exc must not be NULL"
)
irBuilder
.
setNewStackThrowExc
(
inst
,
exc
)
}
def
newCommInst
(
bb
:
MuBBNode
,
opcode
:
Int
,
flags
:
Seq
[
Flag
],
tys
:
Seq
[
MuTypeNode
],
sigs
:
Seq
[
MuFuncSigNode
],
args
:
Seq
[
MuVarNode
])
:
MuInstNode
=
{
def
newCommInst
(
bb
:
MuBBNode
,
opcode
:
Int
,
flags
:
Seq
[
Flag
],
tys
:
Seq
[
MuTypeNode
],
sigs
:
Seq
[
MuFuncSigNode
],
args
:
Seq
[
MuVarNode
])
:
MuInstNode
=
{
require
(!
bb
.
isNull
,
"bb must not be NULL"
)
require
(!
bb
.
isNull
,
"bb must not be NULL"
)
for
((
n
,
i
)
<-
tys
.
zipWithIndex
)
require
(!
n
.
isNull
,
"tys[%d] must not be NULL"
.
format
(
i
))
for
((
n
,
i
)
<-
tys
.
zipWithIndex
)
require
(!
n
.
isNull
,
"tys[%d] must not be NULL"
.
format
(
i
))
...
...
src/main/scala/uvm/refimpl/nat/nativeClientSupport.scala
View file @
8876d93c
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