Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
H
hostCompiledSimulation
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Gaurav Kukreja
hostCompiledSimulation
Commits
bfd8bf5b
Commit
bfd8bf5b
authored
May 23, 2014
by
gaurav
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixing indentation in mem.py, and a small bug in CFile.py
parent
71105773
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
111 additions
and
110 deletions
+111
-110
Makefile.macros
Makefile.macros
+1
-1
BlocksFile.py
ir2c/src/BlocksFile.py
+2
-1
CFile.py
ir2c/src/CFile.py
+13
-13
mem.py
ir2c/src/mem.py
+95
-95
No files found.
Makefile.macros
View file @
bfd8bf5b
#Define install directory
export
MYBASEDIR
:=
/home/gaurav/eclipse-workspace/
pycparser_examples
export
MYBASEDIR
:=
/home/gaurav/eclipse-workspace/
sls_thesis_project
#Directory for IR to C tool source
IR2CDIR
=
$(MYBASEDIR)
/ir2c
...
...
ir2c/src/BlocksFile.py
View file @
bfd8bf5b
...
...
@@ -18,7 +18,7 @@ import mem
def
process
(
sourceFile
,
fnHash
):
labelStart
=
"bb "
;
# assuming that all labels names start with BB.
# Change if label prefix changes - Suhas, 31 March 2012
f
=
open
(
sourceFile
+
".12
5
t.blocks"
);
#".t99.blocks");
f
=
open
(
sourceFile
+
".12
7
t.blocks"
);
#".t99.blocks");
line
=
f
.
readline
();
printFlag
=
1
;
memFlag
=
0
;
...
...
@@ -154,4 +154,5 @@ def process(sourceFile,fnHash):
print
line
,
printFlag
=
1
;
line
=
f
.
readline
()
return
1
;
ir2c/src/CFile.py
View file @
bfd8bf5b
...
...
@@ -131,7 +131,7 @@ def readGlobalData(sourceFile,fnHash):
if
stopPrint
==
0
:
#print "Debug. Printing lines from C file"
print
line
;
print
line
,
;
line
=
f
.
readline
();
...
...
ir2c/src/mem.py
View file @
bfd8bf5b
...
...
@@ -126,25 +126,25 @@ def resolveIndirection(istr, varHash):
return
istr
;
def
removePtrCast
(
str
):
def
removePtrCast
(
str
ing
):
re_ptrCast
=
re
.
compile
(
'
\
([^
\
(]+
\
*
\
)'
);
str
=
re_ptrCast
.
sub
(
""
,
str
);
return
str
;
str
ing
=
re_ptrCast
.
sub
(
""
,
string
);
return
str
ing
;
def
resolvePtrMath
(
str
,
ptrList
,
broad
=
0
):
def
resolvePtrMath
(
str
ing
,
ptrList
,
broad
=
0
):
re_var
=
re
.
compile
(
'([
\
w
\
.]+)'
)
#possible variable
re_fn
=
re
.
compile
(
'(
\
w+
\
s*
\
(.*
\
))'
);
#function call ... not to be modified
re_word
=
re
.
compile
(
'
\
w+'
);
m
=
re_fn
.
split
(
str
);
str
=
""
;
m
=
re_fn
.
split
(
str
ing
);
str
ing
=
""
;
for
i
in
range
(
len
(
m
)):
flag
=
1
;
if
i
%
2
==
1
:
flag
=
0
;
m1
=
re_word
.
match
(
m
[
i
]);
if
not
(
m1
.
group
()
in
keywords
.
keywords
):
str
=
str
+
m
[
i
];
string
=
string
+
m
[
i
];
else
:
flag
=
1
;
if
flag
:
...
...
@@ -155,25 +155,25 @@ def resolvePtrMath(str,ptrList,broad=0):
if
(
j
%
2
==
1
)
and
a
[
j
]
.
isdigit
():
# if negative, make sure it is properly sign extended
if
int
(
a
[
j
])
>=
2
**
(
TARGET_BITWIDTH
-
1
):
str
=
str
+
"(int)"
string
=
string
+
"(int)"
# ptr variable
elif
(
j
%
2
==
1
)
and
a
[
j
]
in
ptrList
:
# remove address-of operator
addr
=
0
cast
=
1
re_str
=
re
.
compile
(
'(&)'
)
strTemp
=
re_str
.
split
(
str
);
strTemp
=
re_str
.
split
(
string
);
if
len
(
strTemp
)
>
1
and
not
strTemp
[
-
1
]
.
strip
():
addr
=
1
str
=
''
.
join
(
strTemp
[:
-
2
])
string
=
''
.
join
(
strTemp
[:
-
2
])
# remove unnecessary (and wrong) pointer type cast
re_str
=
re
.
compile
(
'(
\
([
\
w
\
s]+
\
*?
\
s*
\
))'
)
strTemp
=
re_str
.
split
(
str
)
strTemp
=
re_str
.
split
(
string
)
if
len
(
strTemp
)
>
1
and
not
strTemp
[
-
1
]
.
strip
():
if
strTemp
[
-
2
]
.
find
(
'*'
)
>=
0
:
cast
=
0
else
:
str
=
''
.
join
(
strTemp
[:
-
2
])
string
=
''
.
join
(
strTemp
[:
-
2
])
# if it was plain array access, don't cast
if
j
+
1
<
len
(
a
)
and
a
[
j
+
1
]
.
strip
()
.
startswith
(
'['
):
if
not
addr
:
...
...
@@ -183,15 +183,15 @@ def resolvePtrMath(str,ptrList,broad=0):
if
not
addr
:
cast
=
0
# likewise if the pointer is immediately dereferenced
if
str
.
strip
()
.
endswith
(
'*'
):
if
string
.
strip
()
.
endswith
(
'*'
):
cast
=
0
# create properly casted pointer-taking operation
if
cast
:
str
=
str
+
UINTPTR_CAST
if
addr
:
str
=
str
+
"&"
str
=
str
+
a
[
j
];
if
cast
:
string
=
string
+
UINTPTR_CAST
if
addr
:
string
=
string
+
"&"
string
=
string
+
a
[
j
];
else
:
str
=
str
+
m
[
i
];
return
str
;
string
=
string
+
m
[
i
];
return
str
ing
;
...
...
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