bagel99 / esl Goto Github PK
View Code? Open in Web Editor NEWCompiler for a new programming language: Embedded Systems Language (ESL).
License: BSD 3-Clause "New" or "Revised" License
Compiler for a new programming language: Embedded Systems Language (ESL).
License: BSD 3-Clause "New" or "Revised" License
// pointer arithmetic generates bad llvm IR
proc test(arg: @[]_byte) : @[]_byte
{
return arg + 2;
}
➜ issues git:(master) ✗ ../src/eslc2 -L9.0.0 -m x86-64 02_pointer_arithmetic.esl > out.ll
➜ issues git:(master) ✗ ../src/llvm -m x86-64 -I out.ll
/usr/local/opt/llvm/bin/opt: out.ll:9:11: error: invalid operand type for instruction
%1 = add [0 x i8]* %0, inttoptr(i64 2 to [0 x i8]*)
^
The build instructions aren't entirely clear ('make' vs 'make boot'), but in
either case the resulting assembly language is rejected by the OS X assembler
(it looks like it's intended for the binutils assembler...).
How should esl be built for OS X?
Original issue reported on code.google.com by [email protected]
on 2 Dec 2012 at 8:45
What is the expected output? What do you see instead?
ESLProgrammingLanguage.pdf [2014-01-02]
Page Number: 15
operator _man is incorrect it may be _max
Original issue reported on code.google.com by [email protected]
on 6 Aug 2014 at 11:15
I thought I'd give the system a spin, and tried compiling from source. From this, I hit three snags, fixed with the patch below.
First, llvm is in the home directory of the account I use. Second, the test for ARCH failed, made more robust below. Third, there was a complaint about relocation due to the default of Ubuntu's system gcc, also fixed.
Here is the patch:
diff --git a/src/Makefile b/src/Makefile
index 5bbcf65..fcecb67 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -40,16 +40,16 @@ boot: eslc0 eslc1 eslc2 eslc3
eslc-x86-64: $(SRC)
./eslc2 -m x86-64 main.esl >main.ll
- $(LLVM) -m x86-64 $(LLVMFLAGS) main.ll
+ $(LLVM) -p -m x86-64 $(LLVMFLAGS) main.ll
$(GCC) -o eslc-x86-64 main.s
eslc-x86: $(SRC)
./eslc2 -m x86 main.esl >main.ll
- $(LLVM) -m x86 $(LLVMFLAGS) main.ll
+ $(LLVM) -p -m x86 $(LLVMFLAGS) main.ll
$(GCC) -m32 -o eslc-x86 main.s
main-start.s: $(BOOT)
- $(LLVM) -m $(ARCH) $(LLVMFLAGS) $(BOOT)
+ $(LLVM) -p -m $(ARCH) $(LLVMFLAGS) $(BOOT)
mv main-start-$(ARCH).s main-start.s
eslc0: main-start.s
@@ -57,17 +57,17 @@ eslc0: main-start.s
eslc1: main.esl eslc0
./eslc0 $(ESLCFLAGS) -m $(ARCH) main.esl >main.ll
- $(LLVM) -m $(ARCH) $(LLVMFLAGS) main.ll
+ $(LLVM) -p -m $(ARCH) $(LLVMFLAGS) main.ll
$(GCC) $(CFLAGS) -o eslc1 main.s
eslc2: main.esl eslc1
./eslc1 $(ESLCFLAGS) -m $(ARCH) main.esl >main.ll
- $(LLVM) -m $(ARCH) $(LLVMFLAGS) main.ll
+ $(LLVM) -p -m $(ARCH) $(LLVMFLAGS) main.ll
$(GCC) $(CFLAGS) -o eslc2 main.s
eslc3: main.esl eslc2
./eslc2 $(ESLCFLAGS) -m $(ARCH) main.esl >main.ll
- $(LLVM) -m $(ARCH) $(LLVMFLAGS) main.ll
+ $(LLVM) -p -m $(ARCH) $(LLVMFLAGS) main.ll
$(GCC) $(CFLAGS) -o eslc3 main.s
start:
diff --git a/src/llvm b/src/llvm
index 59341bc..2c1a3fe 100755
--- a/src/llvm
+++ b/src/llvm
@@ -15,6 +15,9 @@ then
elif [ -x /usr/local/bin/llc ]
then
LLVM=/usr/local/bin
+elif [ -x $HOME/bin/llc ]
+then
+ LLVM=$HOME/bin/llc
else
echo "Can't find LLVM executable llc in /bin or /usr/bin or /usr/local/bin or /usr/local/opt/llvm/bin!"
echo "If it is somewhere else, fix the script 'llvm'."
@@ -25,17 +28,19 @@ ARCH=
INLINE=
OPT=-O3 #default
TRIPLE=
-while getopts "Im:O:V" flags
+OPTS=""
+while getopts "Im:O:Vp" flags
do
case $flags in
I) INLINE="-disable-inlining" ;; # disable inlining
m) ARCH=$OPTARG ;;
O) OPT="-O$OPTARG" ;;
+ p) OPTS="$OPTS --relocation-model=pic" ;;
V) $LLVM/llc --version | sed -n -e 's/.*LLVM version \([0-9.]*\).*/\1/p'; exit 0 ;;
*) echo "bad flag"; exit 1 ;;
esac
done
-if [ "$ARCH" == "" ]
+if [ x"$ARCH" = "x" ]
then # target same as host
ARCH=`uname -m`
fi
@@ -54,5 +59,5 @@ shift $(($OPTIND-1))
file=$1
j=`basename $file .ll`
$LLVM/opt ${OPT} ${INLINE} -o - $file | \
-$LLVM/llc ${DEBUG} -march=${ARCH} ${TRIPLE} ${CPU} ${ATTR} ${OPT} -asm-verbose=0 -o ${j}.s
+$LLVM/llc ${DEBUG} ${OPTS} -march=${ARCH} ${TRIPLE} ${CPU} ${ATTR} ${OPT} -asm-verbose=0 -o ${j}.s
Applies to 7bfc758 using llvm 3.7.0 built from SVN.
A couple of problems; first is the header in main-start-x86-64.ll, for OS X the first couple of lines should be:
target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-apple-macosx10.11.0"
Unfortunately even after fixing this up, eslc0 segfaults:
./eslc0 -L3.7.0 -m x86-64 main.esl >main1.ll
/bin/sh: line 1: 63609 Segmentation fault: 11 ./eslc0 -L3.7.0 -m x86-64 main.esl > main1.ll
I'm not sure how to debug this further, but I'd be glad to help if I can.
Will there be support for Renesas RL78 series? I'm interested in using clang and possibly even esl with these chips. Thank you.
// we can declare a range type using constants in the same namespace
const one = 1; const ten = 10;
type range_ok: one..ten;
// but we can't do it with constants out of a package
package limits { const rstart = 1; const rend = 10; }
var start: _int = limits.rstart; // works as an initializer
type range_fail: limits.rstart..limits.rend; // ... but not as range anchors
gives:
# ../src/eslc2 -L9.0.0 -m x86-64 01_range_from_package.esl > out.ll
./01_range_from_package.esl:8: Error: Undefined identifier: rstart
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.