Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
CodeSamples
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
CompilerConstruction
CodeSamples
Commits
7c15aefe
Commit
7c15aefe
authored
4 years ago
by
Ronald Charles Moore
Browse files
Options
Downloads
Patches
Plain Diff
Updated for LLVM 11 (NOT for LLVM 12 - yet)
Signed-off-by:
Prof. Ronald Moore
<
ronald.moore@h-da.de
>
parent
678ccf32
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
LLVM/cplusplus/Makefile
+21
-15
21 additions, 15 deletions
LLVM/cplusplus/Makefile
LLVM/cplusplus/tests/test9.kal
+1
-1
1 addition, 1 deletion
LLVM/cplusplus/tests/test9.kal
LLVM/cplusplus/toy9.cpp
+1
-1
1 addition, 1 deletion
LLVM/cplusplus/toy9.cpp
with
23 additions
and
17 deletions
LLVM/cplusplus/Makefile
+
21
−
15
View file @
7c15aefe
...
@@ -17,29 +17,38 @@ CC := clang++
...
@@ -17,29 +17,38 @@ CC := clang++
# clang++ -g -O3 toy.cpp `llvm-config --cxxflags --ldflags --system-libs --libs core` -o toy
# clang++ -g -O3 toy.cpp `llvm-config --cxxflags --ldflags --system-libs --libs core` -o toy
# based on that, and some experimentation, we got, for LLVM 3.6...
# based on that, and some experimentation, we got, for LLVM 3.6...
# CFLAGS=-std=c++11 `llvm-config --cxxflags --ldflags --system-libs --libs all` -rdynamic -O3
# CFLAGS=-std=c++11 `llvm-config --cxxflags --ldflags --system-libs --libs all` -rdynamic -O3
# Now, for llvm >= 3.7.1, further experience has brought us to....
# Later, for a while, we piped the output of llvm-config to sed s/no-maybe/no/
# At one time, we piped the output of llvm-config to sed s/no-maybe/no/ .
# Hopefully this is no longer necessary... ?
# (sed was used to hide an incompatibility between llvm-config and clang)
# (sed was used to hide an incompatibility between llvm-config and clang)
# Hopefully this seems to no longer be necessary.
# So, the current solution is...
LLVM_FLAGS
:=
`
llvm-config
--cxxflags
--ldflags
--system-libs
--libs
all
`
LLVM_FLAGS
:=
`
llvm-config
--cxxflags
--ldflags
--system-libs
--libs
all
`
CFLAGS
:=
$(
LLVM_FLAGS
)
-rdynamic
-O3
CFLAGS
:=
$(
LLVM_FLAGS
)
-rdynamic
-O3
## More preliminaries
### Gnu Make Preliminaries -- See also
# See https://www.gnu.org/software/make/manual/html_node/Special-Targets.html
# https://www.gnu.org/software/make/manual/html_node/Special-Targets.html
# In this makefile, we want to keep going even if we find errors
# In this makefile, we want to keep going even if we find errors
.IGNORE
:
# Update: Let's only ignore errors in the tests, not in the build.
.IGNORE
:
$(TESTS)
# Further, we do not want multiple things built at once, even if make called with -j2
# Further, we do not want multiple things built at once, even if make called with -j2
.NOTPARALLEL
:
.NOTPARALLEL
:
# Tell make that the following "targets" are "phony"
# We define the list of tests how, so that we can declare them "phony".
# Cf. https://www.gnu.org/software/make/manual/html_node/Phony-Targets.html#Phony-Targets
# WARNING: test9 is included, but seems to be broken... ?!?
.PHONY
:
all tests clean testclean
TESTS
:=
testModuleMaker testFibonacci test2 test3 test4 test5 test6 test7 test8 test9
# "A phony target is one that is not really the name of a file;
# rather it is just a name for a recipe to be executed
# when you make an explicit request".
# Quote from (see also)
# https://www.gnu.org/software/make/manual/html_node/Phony-Targets.html#Phony-Targets
.PHONY
:
all tests clean testclean $(TESTS)
## Now, the targets -- the things that will get made!
##
## Now, the targets -- the things that will get made!
all
:
$(PROGS)
all
:
$(PROGS)
...
@@ -52,12 +61,13 @@ clean: testclean
...
@@ -52,12 +61,13 @@ clean: testclean
testclean
:
testclean
:
rm
-fv
*
~
*
.output test8.o test9
rm
-fv
*
~
*
.output test8.o test9
tests
:
$(TESTS)
testModuleMaker
:
ModuleMaker
testModuleMaker
:
ModuleMaker
echo
&&
echo
"Testing ModuleMaker (expect 5)...
\n
"
echo
&&
echo
"Testing ModuleMaker (expect 5)...
\n
"
@
./ModuleMaker
>
ModuleMaker.bc
@
./ModuleMaker
>
ModuleMaker.bc
@
lli ModuleMaker.bc
||
echo
$$
?
@
lli ModuleMaker.bc
||
echo
$$
?
# WARNING: testFibonacci broken (with LLVM and clang 3.7.1)
testFibonacci
:
fibonacci
testFibonacci
:
fibonacci
echo
&&
echo
"
\n
===================> Testing fibonacci (expect 46368)...
\n
"
echo
&&
echo
"
\n
===================> Testing fibonacci (expect 46368)...
\n
"
-
./fibonacci
-
./fibonacci
...
@@ -97,7 +107,3 @@ test9: toy9 tests/test9.kal
...
@@ -97,7 +107,3 @@ test9: toy9 tests/test9.kal
-
./toy9 <tests/test9.kal |& clang
-x
ir -
-o
test9
-
./toy9 <tests/test9.kal |& clang
-x
ir -
-o
test9
-
./test9
-
./test9
# WARNING: test9 removed since broken (with LLVM and clang <= 3.9)
# NOTE: fibonacci added BACK to tests since it's working again!
tests
:
testModuleMaker testFibonacci test2 test3 test4 test5 test6 test7 test8
This diff is collapsed.
Click to expand it.
LLVM/cplusplus/tests/test9.kal
+
1
−
1
View file @
7c15aefe
...
@@ -4,4 +4,4 @@ def fib(x)
...
@@ -4,4 +4,4 @@ def fib(x)
else
else
fib(x-1)+fib(x-2);
fib(x-1)+fib(x-2);
fib(
10
)
fib(
2
)
This diff is collapsed.
Click to expand it.
LLVM/cplusplus/toy9.cpp
+
1
−
1
View file @
7c15aefe
...
@@ -802,7 +802,7 @@ static std::unique_ptr<FunctionAST> ParseTopLevelExpr() {
...
@@ -802,7 +802,7 @@ static std::unique_ptr<FunctionAST> ParseTopLevelExpr() {
SourceLocation
FnLoc
=
CurLoc
;
SourceLocation
FnLoc
=
CurLoc
;
if
(
auto
E
=
ParseExpression
())
{
if
(
auto
E
=
ParseExpression
())
{
// Make an anonymous proto.
// Make an anonymous proto.
auto
Proto
=
std
::
make_unique
<
PrototypeAST
>
(
FnLoc
,
"__anon_expr"
,
auto
Proto
=
std
::
make_unique
<
PrototypeAST
>
(
FnLoc
,
"main"
,
//
"__anon_expr",
std
::
vector
<
std
::
string
>
());
std
::
vector
<
std
::
string
>
());
return
std
::
make_unique
<
FunctionAST
>
(
std
::
move
(
Proto
),
std
::
move
(
E
));
return
std
::
make_unique
<
FunctionAST
>
(
std
::
move
(
Proto
),
std
::
move
(
E
));
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment