Compare commits
4 commits
21a45b06cf
...
136e3f74a0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
136e3f74a0 | ||
|
|
a1795d9b1f | ||
|
|
6d08db2933 | ||
|
|
bb602043d2 |
3 changed files with 67 additions and 14 deletions
|
|
@ -68,5 +68,27 @@ Running benchmarks.prog
|
||||||
exp() 10K 00:00:32
|
exp() 10K 00:00:32
|
||||||
cos() 10K 00:00:06
|
cos() 10K 00:00:06
|
||||||
|
|
||||||
Running benchmarks.prog
|
|
||||||
|
Arty-A7-35T
|
||||||
|
76.92MHz, 64KB SRAM, 256MB DRAM, 16B instruction cache
|
||||||
|
running in DRAM (except corelib, stdlib, runtime)
|
||||||
|
|
||||||
|
Running benchmarks.prog
|
||||||
|
empty loop 10M 00:00:16
|
||||||
|
write variable 10M 00:00:17
|
||||||
|
read variable 10M 00:00:19
|
||||||
|
integer addition 10M 00:00:24
|
||||||
|
real addition 1M 00:00:30
|
||||||
|
integer multiplication 1M 00:01:14
|
||||||
|
real multiplication 1M 00:01:05
|
||||||
|
integer division 1M 00:01:53
|
||||||
|
real division 1M 00:01:13
|
||||||
|
string indexing 1M 00:00:41
|
||||||
|
string iteration 1M 00:00:21
|
||||||
|
new/dispose 1k 1M 00:00:25
|
||||||
|
new/dispose 128k 1M 00:00:26
|
||||||
|
array copy 1k 10K 00:00:03
|
||||||
|
array copy 128k 1K 00:00:48
|
||||||
|
exp() 10K 00:00:32
|
||||||
|
cos() 10K 00:00:06
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -111,7 +111,7 @@ begin
|
||||||
emitIns2('BRANCH','@+2'); (* NOP, to make alignment explicit *)
|
emitIns2('BRANCH','@+2'); (* NOP, to make alignment explicit *)
|
||||||
emitIns('.CPOOL'); (* header/prologue + 2 constants is 32 bytes *)
|
emitIns('.CPOOL'); (* header/prologue + 2 constants is 32 bytes *)
|
||||||
|
|
||||||
if useStdlib then
|
if useStdlib and not useStandalone then
|
||||||
begin
|
begin
|
||||||
writeln(outfile, '%include "stdlib.lsym"');
|
writeln(outfile, '%include "stdlib.lsym"');
|
||||||
writeln(outfile, '%incbin "stdlib.lib"');
|
writeln(outfile, '%incbin "stdlib.lib"');
|
||||||
|
|
@ -312,7 +312,12 @@ begin
|
||||||
emitArrayConsts;
|
emitArrayConsts;
|
||||||
|
|
||||||
if useStandalone then
|
if useStandalone then
|
||||||
emitInclude('corelib.s')
|
begin
|
||||||
|
emitInclude('corelib.s');
|
||||||
|
emitInclude('runtime.s');
|
||||||
|
emitInclude('float32.s');
|
||||||
|
emitInclude('stdlib.s');
|
||||||
|
end
|
||||||
else
|
else
|
||||||
emitInclude('coreloader.lsym');
|
emitInclude('coreloader.lsym');
|
||||||
|
|
||||||
|
|
@ -1059,6 +1064,7 @@ end;
|
||||||
*)
|
*)
|
||||||
procedure emitProcedureCall(aProc: ProcRef);
|
procedure emitProcedureCall(aProc: ProcRef);
|
||||||
var procLabel: IdentString;
|
var procLabel: IdentString;
|
||||||
|
i:integer;
|
||||||
begin
|
begin
|
||||||
(* pass pointer to stackframe of caller for nested procedures *)
|
(* pass pointer to stackframe of caller for nested procedures *)
|
||||||
if aProc^.isNested then
|
if aProc^.isNested then
|
||||||
|
|
@ -1069,9 +1075,17 @@ begin
|
||||||
if aProc^.level > curProcedure^.level then
|
if aProc^.level > curProcedure^.level then
|
||||||
emitIns2('LOADREG','FP')
|
emitIns2('LOADREG','FP')
|
||||||
else
|
else
|
||||||
(* TODO: calling nested aProc with a lower nesting level.
|
begin
|
||||||
need to chase a chain of old BP pointers. *)
|
(* Calling nested aProc with a lower nesting level.
|
||||||
errorExit2('internal error: outward call of nested aProc not implemented', '');
|
Need to chase a chain of old BP pointers. *)
|
||||||
|
emitIns2('LOADREG', 'BP');
|
||||||
|
(* BP points to the stackframe of the outer procedure,
|
||||||
|
@BP contains the stackframe of the procedure one step further
|
||||||
|
outwards, and so on.
|
||||||
|
*)
|
||||||
|
for i := aProc^.level + 1 to curProcedure^.level do
|
||||||
|
emitIns('LOADI');
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
emitFpAdjust(-curProcedure^.tempsSize);
|
emitFpAdjust(-curProcedure^.tempsSize);
|
||||||
|
|
@ -1250,7 +1264,7 @@ begin
|
||||||
(* nothing to do *)
|
(* nothing to do *)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
if amount <= MaxTinyOffset then
|
if (amount > 0) and (amount <= MaxTinyOffset) then
|
||||||
emitIns2Int('INC', amount)
|
emitIns2Int('INC', amount)
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
|
|
@ -1266,7 +1280,7 @@ begin
|
||||||
(* nothing to do *)
|
(* nothing to do *)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
if amount <= MaxTinyOffset then
|
if (amount > 0) and (amount <= MaxTinyOffset) then
|
||||||
emitIns2Int('DEC', amount)
|
emitIns2Int('DEC', amount)
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
|
|
|
||||||
|
|
@ -2186,7 +2186,7 @@ begin
|
||||||
if ch = '!' then
|
if ch = '!' then
|
||||||
(* special comment till end of line *)
|
(* special comment till end of line *)
|
||||||
begin
|
begin
|
||||||
while not (nextChar = #13) do (* nothing *);
|
while not (nextChar in [#13, #10]) do (* nothing *);
|
||||||
readNextToken;
|
readNextToken;
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
|
@ -2456,10 +2456,7 @@ begin
|
||||||
begin
|
begin
|
||||||
digits := curToken.tokenText;
|
digits := curToken.tokenText;
|
||||||
if matchTokenOrNot(MinusToken) then
|
if matchTokenOrNot(MinusToken) then
|
||||||
begin
|
|
||||||
readNextToken;
|
|
||||||
digits := digits + curToken.tokenText;
|
digits := digits + curToken.tokenText;
|
||||||
end;
|
|
||||||
parseInteger := integerFromString(digits);
|
parseInteger := integerFromString(digits);
|
||||||
end;
|
end;
|
||||||
readNextToken;
|
readNextToken;
|
||||||
|
|
@ -2812,6 +2809,8 @@ begin
|
||||||
|
|
||||||
if checkToken(CommaToken) then
|
if checkToken(CommaToken) then
|
||||||
begin
|
begin
|
||||||
|
(* TODO: handle comma syntax for indexing a char
|
||||||
|
from an array of strings *)
|
||||||
if elType.baseType <> ArrayType then
|
if elType.baseType <> ArrayType then
|
||||||
errorExit2('invalid array subscript for', name)
|
errorExit2('invalid array subscript for', name)
|
||||||
end;
|
end;
|
||||||
|
|
@ -3231,10 +3230,22 @@ begin
|
||||||
readNextToken;
|
readNextToken;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
(* Handle an array range part. Very similar to parseInteger
|
||||||
|
but additionally handles Boolean, Enum and Char types which
|
||||||
|
can be used for array indices *)
|
||||||
procedure getRangePart(var value:integer; var typeReturn: TypeSpec);
|
procedure getRangePart(var value:integer; var typeReturn: TypeSpec);
|
||||||
var cnst: ConstRef;
|
var cnst: ConstRef;
|
||||||
|
negate:boolean;
|
||||||
|
digits: string[12];
|
||||||
begin
|
begin
|
||||||
setBaseType(typeReturn, NoType);
|
setBaseType(typeReturn, NoType);
|
||||||
|
negate := false;
|
||||||
|
|
||||||
|
if checkToken(MinusToken) then
|
||||||
|
begin
|
||||||
|
negate := true;
|
||||||
|
readNextToken;
|
||||||
|
end;
|
||||||
|
|
||||||
if checkToken(IdentToken) then
|
if checkToken(IdentToken) then
|
||||||
begin
|
begin
|
||||||
|
|
@ -3268,7 +3279,11 @@ begin
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
setBaseType(typeReturn, IntegerType);
|
setBaseType(typeReturn, IntegerType);
|
||||||
value := parseInteger;
|
digits := curToken.tokenText;
|
||||||
|
if negate then
|
||||||
|
insert('-', digits, 1);
|
||||||
|
value := integerFromString(digits);
|
||||||
|
readNextToken;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
@ -3433,9 +3448,9 @@ begin
|
||||||
if savedType.baseType = NoType then
|
if savedType.baseType = NoType then
|
||||||
savedType := elementType;
|
savedType := elementType;
|
||||||
emitLoadConstantInt(cnst^.intValue);
|
emitLoadConstantInt(cnst^.intValue);
|
||||||
|
readNextToken;
|
||||||
end;
|
end;
|
||||||
emitAddToSet;
|
emitAddToSet;
|
||||||
readNextToken;
|
|
||||||
end
|
end
|
||||||
else if checkToken(NumberToken) then
|
else if checkToken(NumberToken) then
|
||||||
begin
|
begin
|
||||||
|
|
@ -3999,6 +4014,8 @@ begin
|
||||||
begin
|
begin
|
||||||
readNextToken;
|
readNextToken;
|
||||||
length := parseInteger;
|
length := parseInteger;
|
||||||
|
if length < 1 then
|
||||||
|
errorExit2('invalid string length', '');
|
||||||
matchToken(RBracketToken);
|
matchToken(RBracketToken);
|
||||||
end;
|
end;
|
||||||
typSpec.size := getStringMemSize(length);
|
typSpec.size := getStringMemSize(length);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue