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
d89e5324
Commit
d89e5324
authored
Jun 02, 2016
by
Kunshan Wang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto-generated MuCtxIRBuilderPart
parent
34244646
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
548 additions
and
25 deletions
+548
-25
migrate_scripts/irbuildertomuctx.py
migrate_scripts/irbuildertomuctx.py
+76
-0
src/main/scala/uvm/ir/irbuilder/IRBuilder.scala
src/main/scala/uvm/ir/irbuilder/IRBuilder.scala
+7
-2
src/main/scala/uvm/refimpl/MuCtxIRBuilderPart.scala
src/main/scala/uvm/refimpl/MuCtxIRBuilderPart.scala
+462
-20
src/main/scala/uvm/refimpl/clientInterface.scala
src/main/scala/uvm/refimpl/clientInterface.scala
+3
-3
No files found.
migrate_scripts/irbuildertomuctx.py
0 → 100644
View file @
d89e5324
"""
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
"""
import
re
import
sys
begin
=
"SCRIPT: BEGIN HERE"
end
=
"SCRIPT: END HERE"
replaces
=
[(
re
.
compile
(
x
),
y
)
for
(
x
,
y
)
in
[
(
r'BN'
,
'MuBundleNode'
),
(
r'CN\[_\s*<:\s*Identified\]'
,
'MuChildNode'
),
(
r'CN\[IdentifiedSettable\]'
,
'MuChildNode'
),
(
r'CN\[Type\w*\]'
,
'MuTypeNode'
),
(
r'CN\[Abstract\w+Type\]'
,
'MuTypeNode'
),
(
r'CN\[FuncSig\]'
,
'MuFuncSigNode'
),
(
r'CN\[Const\w+\]'
,
'MuConstNode'
),
(
r'CN\[GlobalCell\]'
,
'MuGlobalNode'
),
(
r'CN\[Function\]'
,
'MuFuncNode'
),
(
r'CN\[ExposedFunc\]'
,
'MuExpFuncNode'
),
(
r'CN\[FuncVer\]'
,
'MuFuncVerNode'
),
(
r'CN\[BasicBlock\]'
,
'MuBBNode'
),
(
r'CN\[BB\]'
,
'MuBBNode'
),
(
r'CN\[SSAVariable\]'
,
'MuVarNode'
),
(
r'CN\[Var\]'
,
'MuVarNode'
),
(
r'CN\[LocalVariable\]'
,
'MuLocalVarNode'
),
(
r'CN\[NorParam\]'
,
'MuNorParamNode'
),
(
r'CN\[ExcParam\]'
,
'MuExcParamNode'
),
(
r'CN\[InstResult\]'
,
'MuInstResNode'
),
(
r'CN\[Inst\w+\]'
,
'MuInstNode'
),
(
r'CN\[HasKeepAliveClause\]'
,
'MuInstNode'
),
]]
sig
=
re
.
compile
(
r'^( def (\w+)\(([^)]*)\):\s+\w+\s+=)'
,
re
.
MULTILINE
)
arg
=
re
.
compile
(
r'(\w*):\s+([a-zA-Z0-9\[\]]+)'
)
node_like
=
re
.
compile
(
r'Mu\w+Node'
)
node_seq_like
=
re
.
compile
(
r'Seq\[Mu\w+Node\]'
)
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
])
for
p
,
t
in
replaces
:
text
=
p
.
sub
(
t
,
text
)
#print(text)
#sys.exit(0)
for
whole
,
name
,
arglist
in
sig
.
findall
(
text
):
print
(
whole
,
"{"
)
argnames
=
[]
for
an
,
at
in
arg
.
findall
(
arglist
):
argnames
.
append
(
an
)
#print(an, at)
if
node_seq_like
.
match
(
at
)
is
not
None
:
print
(
' for((n,i) <- {}.zipWithIndex) require(!n.isNull, "{}[%d] must not be NULL".format(i))'
.
format
(
an
,
an
))
elif
node_like
.
match
(
at
)
is
not
None
:
print
(
' require(!{}.isNull, "{} must not be NULL")'
.
format
(
an
,
an
))
if
name
.
startswith
(
"new"
):
print
(
' addHandle(irBuilder.{}({}))'
.
format
(
name
,
", "
.
join
(
argnames
)))
else
:
print
(
' irBuilder.{}({})'
.
format
(
name
,
", "
.
join
(
argnames
)))
print
(
" }"
)
print
()
#print(whole, name, args)
#for n,a in sig.findall(line):
#args = arg_name.findall(a)
#print(" addHandle(irBuilder.{}({}))".format(n, ", ".join(args)))
src/main/scala/uvm/ir/irbuilder/IRBuilder.scala
View file @
d89e5324
...
...
@@ -40,6 +40,10 @@ class IRBuilder(globalBundle: GlobalBundle, idFactory: IDFactory) {
new
CN
(
obj
)
}
// There are scripts in microvm-refimpl2/migrate_scripts/ to convert this program to the MuCtxIRBuilderPart or the
// common instruction executor. Keep the next line exact
// SCRIPT: BEGIN HERE
def
newBundle
()
:
BN
=
{
val
b
=
new
TrantientBundle
()
val
node
=
new
BN
(
b
)
...
...
@@ -54,7 +58,7 @@ class IRBuilder(globalBundle: GlobalBundle, idFactory: IDFactory) {
new
ChildNode
(
ent
)
}
def
getID
(
b
:
BN
,
node
:
CN
[
Identified
])
:
Int
=
{
def
getID
(
b
:
BN
,
node
:
CN
[
_
<:
Identified
])
:
Int
=
{
node
.
id
}
...
...
@@ -438,7 +442,7 @@ class IRBuilder(globalBundle: GlobalBundle, idFactory: IDFactory) {
}
}
}
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
{
throw
new
IllegalArgumentException
(
"No such common instruction. opcode: %d 0x%x"
.
format
(
opcode
,
opcode
))
...
...
@@ -447,4 +451,5 @@ class IRBuilder(globalBundle: GlobalBundle, idFactory: IDFactory) {
newInst
(
bb
,
inst
)
}
// SCRIPT: END HERE
}
\ No newline at end of file
src/main/scala/uvm/refimpl/MuCtxIRBuilderPart.scala
View file @
d89e5324
This diff is collapsed.
Click to expand it.
src/main/scala/uvm/refimpl/clientInterface.scala
View file @
d89e5324
...
...
@@ -106,12 +106,12 @@ case class MuConstNode(ty: TypeIRNodeRef, vb: BoxIRNode) extends MuGlobalVarNode
case
class
MuGlobalNode
(
ty
:
TypeIRNodeRef
,
vb
:
BoxIRNode
)
extends
MuGlobalVarNode
case
class
MuFuncNode
(
ty
:
TypeIRNodeRef
,
vb
:
BoxIRNode
)
extends
MuGlobalVarNode
case
class
MuExpFuncNode
(
ty
:
TypeIRNodeRef
,
vb
:
BoxIRNode
)
extends
MuGlobalVarNode
case
class
MuFuncVerNode
(
ty
:
TypeIRNodeRef
,
vb
:
BoxIRNode
)
extends
Mu
IR
Node
case
class
MuBBNode
(
ty
:
TypeIRNodeRef
,
vb
:
BoxIRNode
)
extends
Mu
IR
Node
case
class
MuFuncVerNode
(
ty
:
TypeIRNodeRef
,
vb
:
BoxIRNode
)
extends
Mu
Child
Node
case
class
MuBBNode
(
ty
:
TypeIRNodeRef
,
vb
:
BoxIRNode
)
extends
Mu
Child
Node
case
class
MuNorParamNode
(
ty
:
TypeIRNodeRef
,
vb
:
BoxIRNode
)
extends
MuLocalVarNode
case
class
MuExcParamNode
(
ty
:
TypeIRNodeRef
,
vb
:
BoxIRNode
)
extends
MuLocalVarNode
case
class
MuInstResNode
(
ty
:
TypeIRNodeRef
,
vb
:
BoxIRNode
)
extends
MuLocalVarNode
case
class
MuInstNode
(
ty
:
TypeIRNodeRef
,
vb
:
BoxIRNode
)
extends
Mu
IR
Node
case
class
MuInstNode
(
ty
:
TypeIRNodeRef
,
vb
:
BoxIRNode
)
extends
Mu
Child
Node
abstract
class
TrapHandlerResult
object
TrapHandlerResult
{
...
...
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