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
5a852f01
Commit
5a852f01
authored
Nov 23, 2014
by
Kunshan Wang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added an "allNs" for all identified entities.
parent
948473b4
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
52 additions
and
20 deletions
+52
-20
src/main/scala/uvm/Bundle.scala
src/main/scala/uvm/Bundle.scala
+18
-14
src/main/scala/uvm/ir/textinput/UIRTextReader.scala
src/main/scala/uvm/ir/textinput/UIRTextReader.scala
+17
-3
src/test/scala/uvm/ir/textinput/TestingBundlesValidators.scala
...est/scala/uvm/ir/textinput/TestingBundlesValidators.scala
+17
-3
No files found.
src/main/scala/uvm/Bundle.scala
View file @
5a852f01
...
...
@@ -7,20 +7,23 @@ class Bundle {
/*
* There is a hierarchy of namespaces. A subnode is a subset of the parent.
*
* + typeNs // All types
* + funcSigNs // All function signatures
* + funcVerNs // All function versions
* + varNs // All variables, global or local
* + globalVarNs // Global variables
* + constantNs // Constants
* + globalCellNs // Global cells
* + funcNs // Functions
* + localVarNs // Local variables (per function version)
* + bbNs // Basic blocks (per function version)
* + allNs // All Identified entities
* + typeNs // All types
* + funcSigNs // All function signatures
* + funcVerNs // All function versions
* + varNs // All variables, global or local
* + globalVarNs // Global variables
* + constantNs // Constants
* + globalCellNs // Global cells
* + funcNs // Functions
* + localVarNs // Local variables (per function version)
* + bbNs // Basic blocks (per function version)
*
* TODO: Should there be a global "basic block ns for all function versions"?
*/
val
allNs
=
new
SimpleNamespace
[
Identified
]()
val
typeNs
=
new
SimpleNamespace
[
Type
]()
val
funcSigNs
=
new
SimpleNamespace
[
FuncSig
]()
val
funcVerNs
=
new
SimpleNamespace
[
FuncVer
]()
...
...
@@ -31,7 +34,6 @@ class Bundle {
val
globalCellNs
=
new
SimpleNamespace
[
GlobalCell
]()
val
funcNs
=
new
SimpleNamespace
[
Function
]()
private
def
simpleMerge
[
T
<:
Identified
](
oldNs
:
Namespace
[
T
],
newNs
:
Namespace
[
T
])
{
for
(
cand
<-
newNs
.
all
)
{
if
(!
cand
.
isInstanceOf
[
Function
]
||
oldNs
.
get
(
cand
.
id
)
==
None
)
{
...
...
@@ -57,14 +59,16 @@ class Bundle {
}
}
}
def
merge
(
newBundle
:
Bundle
)
{
simpleMerge
(
varNs
,
newBundle
.
varNs
)
simpleMerge
(
globalVarNs
,
newBundle
.
globalVarNs
)
simpleMerge
(
allNs
,
newBundle
.
allNs
)
simpleMerge
(
typeNs
,
newBundle
.
typeNs
)
simpleMerge
(
funcSigNs
,
newBundle
.
funcSigNs
)
simpleMerge
(
funcVerNs
,
newBundle
.
funcVerNs
)
simpleMerge
(
varNs
,
newBundle
.
varNs
)
simpleMerge
(
globalVarNs
,
newBundle
.
globalVarNs
)
simpleMerge
(
constantNs
,
newBundle
.
constantNs
)
simpleMerge
(
globalCellNs
,
newBundle
.
globalCellNs
)
simpleMerge
(
funcVerNs
,
newBundle
.
funcVerNs
)
mergeFunc
(
funcNs
,
newBundle
.
funcNs
)
}
}
src/main/scala/uvm/ir/textinput/UIRTextReader.scala
View file @
5a852f01
...
...
@@ -138,19 +138,28 @@ class UIRTextReader(val idFactory: IDFactory) {
// Add entities to namespaces.
def
addTy
(
obj
:
Type
)
:
Unit
=
bundle
.
typeNs
.
add
(
obj
)
def
addSig
(
obj
:
FuncSig
)
:
Unit
=
bundle
.
funcSigNs
.
add
(
obj
)
def
addTy
(
obj
:
Type
)
:
Unit
=
{
bundle
.
allNs
.
add
(
obj
)
bundle
.
typeNs
.
add
(
obj
)
}
def
addSig
(
obj
:
FuncSig
)
:
Unit
=
{
bundle
.
allNs
.
add
(
obj
)
bundle
.
funcSigNs
.
add
(
obj
)
}
def
addConst
(
obj
:
Constant
)
:
Unit
=
{
bundle
.
allNs
.
add
(
obj
)
bundle
.
constantNs
.
add
(
obj
)
bundle
.
globalVarNs
.
add
(
obj
)
bundle
.
varNs
.
add
(
obj
)
}
def
addGlobalCell
(
obj
:
GlobalCell
)
:
Unit
=
{
bundle
.
allNs
.
add
(
obj
)
bundle
.
globalCellNs
.
add
(
obj
)
bundle
.
globalVarNs
.
add
(
obj
)
bundle
.
varNs
.
add
(
obj
)
}
def
addFunc
(
obj
:
Function
)
:
Unit
=
{
bundle
.
allNs
.
add
(
obj
)
bundle
.
funcNs
.
add
(
obj
)
bundle
.
globalVarNs
.
add
(
obj
)
bundle
.
varNs
.
add
(
obj
)
...
...
@@ -158,8 +167,12 @@ class UIRTextReader(val idFactory: IDFactory) {
def
addLocalVar
(
obj
:
LocalVariable
,
localNs
:
Namespace
[
LocalVariable
])
=
{
localNs
.
add
(
obj
)
bundle
.
varNs
.
add
(
obj
)
bundle
.
allNs
.
add
(
obj
)
}
def
addFuncVer
(
obj
:
FuncVer
)
:
Unit
=
{
bundle
.
allNs
.
add
(
obj
)
bundle
.
funcVerNs
.
add
(
obj
)
}
def
addFuncVer
(
obj
:
FuncVer
)
:
Unit
=
bundle
.
funcVerNs
.
add
(
obj
)
// Resolve types, with parse-time checking.
...
...
@@ -328,6 +341,7 @@ class UIRTextReader(val idFactory: IDFactory) {
bb
.
id
=
idFactory
.
getID
()
bb
.
name
=
Some
(
globalize
(
bbCtx
.
label
().
name
()))
ver
.
bbNs
.
add
(
bb
)
bundle
.
allNs
.
add
(
bb
)
bb
.
insts
=
bbCtx
.
inst
.
map
(
mkInst
)
...
...
src/test/scala/uvm/ir/textinput/TestingBundlesValidators.scala
View file @
5a852f01
...
...
@@ -11,6 +11,7 @@ import UIRTextReader.globalize
trait
TestingBundlesValidators
extends
Matchers
with
ExtraMatchers
{
implicit
class
MagicalOur
(
b
:
Bundle
)
{
def
anything
(
s
:
String
)
=
b
.
allNs
(
s
)
def
ty
(
s
:
String
)
=
b
.
typeNs
(
s
)
def
const
(
s
:
String
)
=
b
.
constantNs
(
s
)
def
value
(
s
:
String
)
=
b
.
varNs
(
s
)
...
...
@@ -129,6 +130,13 @@ trait TestingBundlesValidators extends Matchers with ExtraMatchers {
its
.
elemTy
shouldBe
(
our
ty
"@double"
)
its
.
len
shouldEqual
2
}
// Testing namespaces
val
i8
=
our
ty
"@i8"
our
anything
"@i8"
shouldBe
i8
val
sig0
=
our
sig
"@sig0"
our
anything
"@sig0"
shouldBe
sig0
}
def
validateConstants
(
bundle
:
Bundle
)
{
...
...
@@ -217,13 +225,15 @@ trait TestingBundlesValidators extends Matchers with ExtraMatchers {
}
// Testing namespaces
va
r
ci8
=
our
const
"@ci8"
va
l
ci8
=
our
const
"@ci8"
our
globalValue
"@ci8"
shouldBe
ci8
our
value
"@ci8"
shouldBe
ci8
our
anything
"@ci8"
shouldBe
ci8
va
r
gi64
=
our
globalCell
"@gi64"
va
l
gi64
=
our
globalCell
"@gi64"
our
globalValue
"@gi64"
shouldBe
gi64
our
value
"@gi64"
shouldBe
gi64
our
anything
"@gi64"
shouldBe
gi64
}
def
validateFunctions
(
bundle
:
Bundle
)
{
...
...
@@ -293,16 +303,20 @@ trait TestingBundlesValidators extends Matchers with ExtraMatchers {
val
main
=
our
func
"@main"
our
globalValue
"@main"
shouldBe
main
our
value
"@main"
shouldBe
main
our
anything
"@main"
shouldBe
main
val
mainV1
=
our
funcVer
"@main_v1"
our
anything
"@main_v1"
shouldBe
mainV1
val
argcGN
=
"@main_v1.argc"
val
argc
=
mainV1
.
localVarNs
(
argcGN
)
our
value
argcGN
shouldBe
argc
our
anything
argcGN
shouldBe
argc
val
addGN
=
"@main_v1.add"
val
add
=
mainV1
.
localVarNs
(
addGN
)
our
value
addGN
shouldBe
add
our
anything
addGN
shouldBe
add
}
def
in
(
func
:
Function
)(
f
:
(
Function
,
FuncVer
)
=>
Unit
)
{
...
...
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