Compare commits
145 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
6ed4adb0ed | ||
|
f16c24363c | ||
|
fd7e68573c | ||
|
f1873f0794 | ||
|
a01d98e584 | ||
|
c7a53a5be6 | ||
|
4633631d7e | ||
|
100608e0ac | ||
|
35a0b36a0d | ||
|
5470db3a5f | ||
|
d6802f3cb9 | ||
|
5b4e0c2b55 | ||
|
8175fae67a | ||
|
13c90eb542 | ||
|
f98665c577 | ||
|
8843f3feba | ||
|
514cf59398 | ||
|
03c133cd48 | ||
|
880abea32e | ||
|
fc9a8f2a89 | ||
|
40c467d958 | ||
|
4bde6385b8 | ||
|
688ef958e3 | ||
|
6da7223472 | ||
|
a1d4bc8375 | ||
|
197e2a91be | ||
|
4d9d628b67 | ||
|
f720feebbf | ||
|
6076808f5e | ||
|
0af17f0f40 | ||
|
81e5321bfc | ||
|
27d3666285 | ||
|
c6b794db3a | ||
|
1fa4c39a20 | ||
|
0ba148b6bb | ||
|
65540da3f7 | ||
|
e660757824 | ||
|
05a6d16dde | ||
|
79ec9af3f2 | ||
|
8f37df448f | ||
|
d710a71ba0 | ||
|
8dd211b662 | ||
|
398ed22b09 | ||
|
6f1da4335b | ||
|
c86dc364b1 | ||
|
70eb7a5eab | ||
|
c1cd2ba57e | ||
|
00da0ef87d | ||
|
be9abbf510 | ||
|
0b72e6b2f2 | ||
|
6ea39d7bfa | ||
|
c0abe031ee | ||
|
fe667863b2 | ||
|
e514e05dc8 | ||
|
d978d0a483 | ||
|
37cacdafa7 | ||
|
78e3696663 | ||
|
a0215a4f21 | ||
|
2310416c46 | ||
|
52db653ec1 | ||
|
6fe76e478f | ||
|
ba05ec743d | ||
|
05ef25a61e | ||
|
b26cc4ede7 | ||
|
8dc5f703e8 | ||
|
c05d7e47f4 | ||
|
9dc8489693 | ||
|
f443c97f70 | ||
|
4837ceb73f | ||
|
42299c9406 | ||
|
850bbfc31a | ||
|
1e95f51469 | ||
|
e525e5d62e | ||
|
18deb8846d | ||
|
34ce9afeae | ||
|
d0411b7d52 | ||
|
34fda8c9b5 | ||
|
b4a357e44f | ||
|
2b224f262b | ||
|
3c306e0899 | ||
|
e82ab0c7ca | ||
|
983064c694 | ||
|
9230d95bad | ||
|
8b0790588b | ||
|
0a9c43757a | ||
|
fccfe35c4f | ||
|
064fed63f5 | ||
|
f43f471124 | ||
|
f99abb32e2 | ||
|
18f044e90c | ||
|
5b961c031c | ||
|
500cce511f | ||
|
885d6ff706 | ||
|
efc182ce27 | ||
|
06ef87fe63 | ||
|
f3d8251072 | ||
|
0d5efc90ed | ||
|
30b8e4e970 | ||
|
3da1ddf5da | ||
|
bfdd1b85fb | ||
|
686d468d32 | ||
|
23b15678cd | ||
|
d1054abd90 | ||
|
d358c8359b | ||
|
9e9494ebf9 | ||
|
015ada7a33 | ||
|
12e832ebd3 | ||
|
e327d2a148 | ||
|
366f9686dd | ||
|
a2927401bc | ||
|
bbb339d641 | ||
|
8e76334c20 | ||
|
739f1e2161 | ||
|
4ee6ca5b94 | ||
|
347898ea53 | ||
|
6caed58be4 | ||
|
c4185832ba | ||
|
2b0994b086 | ||
|
f9acbc152d | ||
|
3eed21567e | ||
|
f3370cb149 | ||
|
494fb97e49 | ||
|
bd8786af0b | ||
|
f0a7499814 | ||
|
da4a90b724 | ||
|
96a9109915 | ||
|
f5a33edcf4 | ||
|
1bd98bdeb2 | ||
|
e4696a6539 | ||
|
74350d6133 | ||
|
cbf86b2e8f | ||
|
cb757dfaf9 | ||
|
5ad94d01d4 | ||
|
cdba71b353 | ||
|
01d187cf83 | ||
|
ab06ce74c5 | ||
|
1e2b227113 | ||
|
9d5dbe67fe | ||
|
9a409ca347 | ||
|
449acece05 | ||
|
ee3f6fc4a5 | ||
|
e95b51609c | ||
|
323589a484 | ||
|
33f4b25f28 | ||
|
538d965636 |
|
@ -4,7 +4,7 @@ Oscar64 is a C/C++ cross compiler running on a modern system (such as a Windows
|
||||||
|
|
||||||
The purpose of this compiler is to eliminate the need to write 6502 assembler code to achieve high code density and fast execution speed. It continues to improve with all the games, demos and tools written by it. It supports disk overlays and banked cartridges for larger projects.
|
The purpose of this compiler is to eliminate the need to write 6502 assembler code to achieve high code density and fast execution speed. It continues to improve with all the games, demos and tools written by it. It supports disk overlays and banked cartridges for larger projects.
|
||||||
|
|
||||||
The C64 executes 418 dhrystone V2.2 iteration per second, when compiled with Oscar64 and -O3 (which shows that the ancient dhrystone benchmark is no match to an optimizing compiler).
|
The C64 executes 442 dhrystone V2.2 iteration per second, when compiled with Oscar64 and -O3 (which shows that the ancient dhrystone benchmark is no match to an optimizing compiler).
|
||||||
|
|
||||||
[Full reference manual](oscar64.md)
|
[Full reference manual](oscar64.md)
|
||||||
[Additional samples and tutorials](https://github.com/drmortalwombat/OscarTutorials)
|
[Additional samples and tutorials](https://github.com/drmortalwombat/OscarTutorials)
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
rem @echo off
|
rem @echo off
|
||||||
|
|
||||||
|
@call :test rolrortest.cpp
|
||||||
|
@if %errorlevel% neq 0 goto :error
|
||||||
|
|
||||||
@call :test bitfields.cpp
|
@call :test bitfields.cpp
|
||||||
@if %errorlevel% neq 0 goto :error
|
@if %errorlevel% neq 0 goto :error
|
||||||
|
|
||||||
|
@ -15,6 +18,9 @@ rem @echo off
|
||||||
@call :testh opp_vector.cpp
|
@call :testh opp_vector.cpp
|
||||||
@if %errorlevel% neq 0 goto :error
|
@if %errorlevel% neq 0 goto :error
|
||||||
|
|
||||||
|
@call :testh opp_static_vector.cpp
|
||||||
|
@if %errorlevel% neq 0 goto :error
|
||||||
|
|
||||||
@call :testh opp_vector_string.cpp
|
@call :testh opp_vector_string.cpp
|
||||||
@if %errorlevel% neq 0 goto :error
|
@if %errorlevel% neq 0 goto :error
|
||||||
|
|
||||||
|
@ -33,7 +39,7 @@ rem @echo off
|
||||||
@call :testh opp_list.cpp
|
@call :testh opp_list.cpp
|
||||||
@if %errorlevel% neq 0 goto :error
|
@if %errorlevel% neq 0 goto :error
|
||||||
|
|
||||||
@call :testh opp_functional.cpp
|
@call :testn opp_functional.cpp
|
||||||
@if %errorlevel% neq 0 goto :error
|
@if %errorlevel% neq 0 goto :error
|
||||||
|
|
||||||
@call :testh operatoroverload.cpp
|
@call :testh operatoroverload.cpp
|
||||||
|
@ -51,7 +57,7 @@ rem @echo off
|
||||||
@call :testh constructortest.cpp
|
@call :testh constructortest.cpp
|
||||||
@if %errorlevel% neq 0 goto :error
|
@if %errorlevel% neq 0 goto :error
|
||||||
|
|
||||||
@call :testh copyconstructor.cpp
|
@call :testn copyconstructor.cpp
|
||||||
@if %errorlevel% neq 0 goto :error
|
@if %errorlevel% neq 0 goto :error
|
||||||
|
|
||||||
@call :testh copyassign.cpp
|
@call :testh copyassign.cpp
|
||||||
|
@ -274,6 +280,15 @@ exit /b %errorlevel%
|
||||||
..\bin\oscar64 -e -O2 -n -dHEAPCHECK %~1
|
..\bin\oscar64 -e -O2 -n -dHEAPCHECK %~1
|
||||||
@if %errorlevel% neq 0 goto :error
|
@if %errorlevel% neq 0 goto :error
|
||||||
|
|
||||||
|
..\bin\oscar64 -e -O2 -xz -Oz -n %~1
|
||||||
|
@if %errorlevel% neq 0 goto :error
|
||||||
|
|
||||||
|
..\bin\oscar64 -e -O2 -Oo -n %~1
|
||||||
|
@if %errorlevel% neq 0 goto :error
|
||||||
|
|
||||||
|
..\bin\oscar64 -e -O2 -Ox -n %~1
|
||||||
|
@if %errorlevel% neq 0 goto :error
|
||||||
|
|
||||||
..\bin\oscar64 -e -O0 -bc %~1
|
..\bin\oscar64 -e -O0 -bc %~1
|
||||||
@if %errorlevel% neq 0 goto :error
|
@if %errorlevel% neq 0 goto :error
|
||||||
|
|
||||||
|
@ -334,6 +349,9 @@ exit /b %errorlevel%
|
||||||
..\bin\oscar64 -e -O2 -Oo -n %~1
|
..\bin\oscar64 -e -O2 -Oo -n %~1
|
||||||
@if %errorlevel% neq 0 goto :error
|
@if %errorlevel% neq 0 goto :error
|
||||||
|
|
||||||
|
..\bin\oscar64 -e -O2 -Ox -n %~1
|
||||||
|
@if %errorlevel% neq 0 goto :error
|
||||||
|
|
||||||
@exit /b 0
|
@exit /b 0
|
||||||
|
|
||||||
:testb
|
:testb
|
||||||
|
@ -376,4 +394,7 @@ exit /b %errorlevel%
|
||||||
..\bin\oscar64 -e -O2 -Oo -n %~1
|
..\bin\oscar64 -e -O2 -Oo -n %~1
|
||||||
@if %errorlevel% neq 0 goto :error
|
@if %errorlevel% neq 0 goto :error
|
||||||
|
|
||||||
|
..\bin\oscar64 -e -O2 -Ox -n %~1
|
||||||
|
@if %errorlevel% neq 0 goto :error
|
||||||
|
|
||||||
@exit /b 0
|
@exit /b 0
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
int t, n;
|
int t, n;
|
||||||
|
|
||||||
|
@ -161,7 +162,7 @@ void test_return_value(void)
|
||||||
C2 c(test_ret_v());
|
C2 c(test_ret_v());
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(n == 4 && t == 0);
|
assert(n == 6 && t == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_return_reference(void)
|
void test_return_reference(void)
|
||||||
|
@ -184,7 +185,7 @@ void test_retparam_value(void)
|
||||||
test_param_fv(test_ret_v());
|
test_param_fv(test_ret_v());
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(n == 4 && t == 0);
|
assert(n == 6 && t == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_retparam_reference(void)
|
void test_retparam_reference(void)
|
||||||
|
@ -200,7 +201,6 @@ void test_retparam_reference(void)
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
#if 0
|
|
||||||
test_dcopy_init();
|
test_dcopy_init();
|
||||||
test_copy_init();
|
test_copy_init();
|
||||||
test_minit();
|
test_minit();
|
||||||
|
@ -208,9 +208,8 @@ int main(void)
|
||||||
test_param_value();
|
test_param_value();
|
||||||
test_param_ref();
|
test_param_ref();
|
||||||
test_return_value();
|
test_return_value();
|
||||||
#endif
|
|
||||||
test_retparam_value();
|
test_retparam_value();
|
||||||
// test_retparam_reference();
|
test_retparam_reference();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
|
@ -50,5 +50,11 @@ autorefreturn: autorefreturn.cpp
|
||||||
$(OSCAR64_CC) -e -Os -n $<
|
$(OSCAR64_CC) -e -Os -n $<
|
||||||
$(OSCAR64_CC) -e -O3 -n $<
|
$(OSCAR64_CC) -e -O3 -n $<
|
||||||
|
|
||||||
|
copyconstructor: copyconstructor.cpp
|
||||||
|
$(OSCAR64_CC) -e -O2 -n $<
|
||||||
|
$(OSCAR64_CC) -e -O0 -n $<
|
||||||
|
$(OSCAR64_CC) -e -Os -n $<
|
||||||
|
$(OSCAR64_CC) -e -O3 -n $<
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
@$(RM) *.asm *.bcs *.int *.lbl *.map *.prg
|
@$(RM) *.asm *.bcs *.int *.lbl *.map *.prg
|
||||||
|
|
|
@ -0,0 +1,78 @@
|
||||||
|
#include <opp/static_vector.h>
|
||||||
|
#include <opp/algorithm.h>
|
||||||
|
#include <assert.h>
|
||||||
|
#include <opp/iostream.h>
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
opp::static_vector<int, 20> a;
|
||||||
|
|
||||||
|
for(int i=0; i<10; i++)
|
||||||
|
a.push_back(i);
|
||||||
|
|
||||||
|
int s = 0;
|
||||||
|
for(int i=0; i<a.size(); i++)
|
||||||
|
s += a[i];
|
||||||
|
|
||||||
|
assert(s == 45);
|
||||||
|
|
||||||
|
for(int i=0; i<5; i++)
|
||||||
|
a.erase(i);
|
||||||
|
|
||||||
|
s = 0;
|
||||||
|
for(int i=0; i<a.size(); i++)
|
||||||
|
s += a[i];
|
||||||
|
|
||||||
|
assert(s == 1 + 3 + 5 + 7 + 9);
|
||||||
|
|
||||||
|
opp::static_vector<int, 100> v;
|
||||||
|
|
||||||
|
for(int i=0; i<10; i++)
|
||||||
|
v.push_back(i);
|
||||||
|
|
||||||
|
assert(v.size() == 10);
|
||||||
|
v.insert(0, 20);
|
||||||
|
assert(v.size() == 11);
|
||||||
|
v.insert(6, 21);
|
||||||
|
assert(v.size() == 12);
|
||||||
|
v.insert(12, 22);
|
||||||
|
|
||||||
|
int * fi = opp::find(v.begin(), v.end(), 21);
|
||||||
|
|
||||||
|
fi = v.insert(fi, 30);
|
||||||
|
fi = v.insert(fi, 31);
|
||||||
|
fi = v.insert(fi, 32);
|
||||||
|
|
||||||
|
assert(v.size() == 16);
|
||||||
|
assert(v[0] == 20);
|
||||||
|
assert(v[15] == 22);
|
||||||
|
assert(v[8] == 32);
|
||||||
|
|
||||||
|
fi = opp::find(v.begin(), v.end(), 32);
|
||||||
|
|
||||||
|
for(int i=0; i<30; i++)
|
||||||
|
{
|
||||||
|
fi = v.insert(fi, i + 40);
|
||||||
|
}
|
||||||
|
|
||||||
|
assert(v.size() == 46);
|
||||||
|
assert(v[28] == 60);
|
||||||
|
|
||||||
|
v.erase(10, 10);
|
||||||
|
|
||||||
|
for(int i : v)
|
||||||
|
opp::cout << i << ", ";
|
||||||
|
opp::cout << "\n";
|
||||||
|
|
||||||
|
assert(v.size() == 36);
|
||||||
|
assert(v[18] == 60);
|
||||||
|
|
||||||
|
v.assign(42, 11);
|
||||||
|
|
||||||
|
assert(v.size() == 42);
|
||||||
|
assert(v[0] == 11);
|
||||||
|
assert(v[15] == 11);
|
||||||
|
assert(v[41] == 11);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -64,5 +64,15 @@ int main(void)
|
||||||
opp::cout << i << ", ";
|
opp::cout << i << ", ";
|
||||||
opp::cout << "\n";
|
opp::cout << "\n";
|
||||||
|
|
||||||
|
assert(v.size() == 36);
|
||||||
|
assert(v[18] == 60);
|
||||||
|
|
||||||
|
v.assign(42, 11);
|
||||||
|
|
||||||
|
assert(v.size() == 42);
|
||||||
|
assert(v[0] == 11);
|
||||||
|
assert(v[15] == 11);
|
||||||
|
assert(v[41] == 11);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,76 @@
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
|
__noinline unsigned long rollright32(unsigned long a) {
|
||||||
|
unsigned long tmp = a & 1;
|
||||||
|
return ( a >> 1) + (tmp << 31);
|
||||||
|
}
|
||||||
|
|
||||||
|
__noinline unsigned rollright16(unsigned a) {
|
||||||
|
unsigned tmp = a & 1;
|
||||||
|
return ( a >> 1) + (tmp << 15);
|
||||||
|
}
|
||||||
|
|
||||||
|
__noinline char rollright8(char a) {
|
||||||
|
char tmp = a & 1;
|
||||||
|
return ( a >> 1) + (tmp << 7);
|
||||||
|
}
|
||||||
|
|
||||||
|
__noinline unsigned long rollleft32(unsigned long a) {
|
||||||
|
unsigned long tmp = (a >> 31) & 1;
|
||||||
|
return ( a << 1) + tmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
__noinline unsigned rollleft16(unsigned a) {
|
||||||
|
unsigned tmp = (a >> 15) & 1;
|
||||||
|
return ( a << 1) + tmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
__noinline char rollleft8(char a) {
|
||||||
|
char tmp = (a >> 7) & 1;
|
||||||
|
return ( a << 1) + tmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
unsigned long lv = 0x12345678ul;
|
||||||
|
unsigned val = 0x1234;
|
||||||
|
char c=0x12;
|
||||||
|
|
||||||
|
unsigned long lvt[33];
|
||||||
|
unsigned valt[17];
|
||||||
|
char ct[9];
|
||||||
|
|
||||||
|
lvt[0] = lv;
|
||||||
|
valt[0] = val;
|
||||||
|
ct[0] = c;
|
||||||
|
|
||||||
|
assert(rollleft8(rollright8(c)) == c);
|
||||||
|
assert(rollleft16(rollright16(val)) == val);
|
||||||
|
assert(rollleft32(rollright32(lv)) == lv);
|
||||||
|
|
||||||
|
for(int i=0; i<32; i++)
|
||||||
|
lvt[i + 1] = rollright32(lvt[i]);
|
||||||
|
for(int i=0; i<16; i++)
|
||||||
|
valt[i + 1] = rollright16(valt[i]);
|
||||||
|
for(int i=0; i<8; i++)
|
||||||
|
ct[i + 1] = rollright8(ct[i]);
|
||||||
|
|
||||||
|
for(int i=0; i<=32; i++)
|
||||||
|
{
|
||||||
|
assert(lvt[32 - i] == lv);
|
||||||
|
lv = rollleft32(lv);
|
||||||
|
}
|
||||||
|
|
||||||
|
for(int i=0; i<=16; i++)
|
||||||
|
{
|
||||||
|
assert(valt[16 - i] == val);
|
||||||
|
val = rollleft16(val);
|
||||||
|
}
|
||||||
|
|
||||||
|
for(int i=0; i<=8; i++)
|
||||||
|
{
|
||||||
|
assert(ct[8 - i] == c);
|
||||||
|
c = rollleft8(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -63,6 +63,33 @@ bool nge(long a, long b)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
inline bool ieq(long a, long b)
|
||||||
|
{
|
||||||
|
return a == b;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool ilt(long a, long b)
|
||||||
|
{
|
||||||
|
return a < b;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool igt(long a, long b)
|
||||||
|
{
|
||||||
|
return a > b;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool ile(long a, long b)
|
||||||
|
{
|
||||||
|
return a <= b;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool ige(long a, long b)
|
||||||
|
{
|
||||||
|
return a >= b;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool beqz(long a)
|
bool beqz(long a)
|
||||||
{
|
{
|
||||||
return a == 0;
|
return a == 0;
|
||||||
|
@ -188,7 +215,71 @@ bool nge1(long a)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cmp(long a, long b)
|
bool beqm(long a)
|
||||||
|
{
|
||||||
|
return a == -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool bltm(long a)
|
||||||
|
{
|
||||||
|
return a < -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool bgtm(long a)
|
||||||
|
{
|
||||||
|
return a > -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool blem(long a)
|
||||||
|
{
|
||||||
|
return a <= -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool bgem(long a)
|
||||||
|
{
|
||||||
|
return a >= -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
bool neqm(long a)
|
||||||
|
{
|
||||||
|
return a == -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma native(neqm)
|
||||||
|
|
||||||
|
bool nltm(long a)
|
||||||
|
{
|
||||||
|
return a < -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma native(nltm)
|
||||||
|
|
||||||
|
bool ngtm(long a)
|
||||||
|
{
|
||||||
|
return a > -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma native(ngtm)
|
||||||
|
|
||||||
|
bool nlem(long a)
|
||||||
|
{
|
||||||
|
return a <= -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma native(nlem)
|
||||||
|
|
||||||
|
bool ngem(long a)
|
||||||
|
{
|
||||||
|
return a >= -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma native(ngem)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void cmpc(long a, long b)
|
||||||
{
|
{
|
||||||
bool beqf = beq(a, b), bltf = blt(a, b), bgtf = bgt(a, b), blef = ble(a, b), bgef = bge(a, b);
|
bool beqf = beq(a, b), bltf = blt(a, b), bgtf = bgt(a, b), blef = ble(a, b), bgef = bge(a, b);
|
||||||
bool neqf = neq(a, b), nltf = nlt(a, b), ngtf = ngt(a, b), nlef = nle(a, b), ngef = nge(a, b);
|
bool neqf = neq(a, b), nltf = nlt(a, b), ngtf = ngt(a, b), nlef = nle(a, b), ngef = nge(a, b);
|
||||||
|
@ -203,6 +294,27 @@ void cmp(long a, long b)
|
||||||
assert(bgef == ngef);
|
assert(bgef == ngef);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void cmpi(long a, long b)
|
||||||
|
{
|
||||||
|
bool ieqf = ieq(a, b), iltf = ilt(a, b), igtf = igt(a, b), ilef = ile(a, b), igef = ige(a, b);
|
||||||
|
bool neqf = neq(a, b), nltf = nlt(a, b), ngtf = ngt(a, b), nlef = nle(a, b), ngef = nge(a, b);
|
||||||
|
|
||||||
|
printf("INLINE %ld, %ld : EQ %d LT %d GT %d\r", a, b, ieqf, iltf, igtf);
|
||||||
|
printf("NATIVE %ld, %ld : EQ %d LT %d GT %d\r", a, b, neqf, nltf, ngtf);
|
||||||
|
|
||||||
|
assert(ieqf == neqf);
|
||||||
|
assert(iltf == nltf);
|
||||||
|
assert(igtf == ngtf);
|
||||||
|
assert(ilef == nlef);
|
||||||
|
assert(igef == ngef);
|
||||||
|
}
|
||||||
|
|
||||||
|
void cmp(long a, long b)
|
||||||
|
{
|
||||||
|
cmpc(a, b);
|
||||||
|
cmpi(a, b);
|
||||||
|
}
|
||||||
|
|
||||||
void cmpz(long a)
|
void cmpz(long a)
|
||||||
{
|
{
|
||||||
bool beqf = beqz(a), bltf = bltz(a), bgtf = bgtz(a), blef = blez(a), bgef = bgez(a);
|
bool beqf = beqz(a), bltf = bltz(a), bgtf = bgtz(a), blef = blez(a), bgef = bgez(a);
|
||||||
|
@ -233,6 +345,21 @@ void cmp1(long a)
|
||||||
assert(bgef == ngef);
|
assert(bgef == ngef);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void cmpm(long a)
|
||||||
|
{
|
||||||
|
bool beqf = beqm(a), bltf = bltm(a), bgtf = bgtm(a), blef = blem(a), bgef = bgem(a);
|
||||||
|
bool neqf = neqm(a), nltf = nltm(a), ngtf = ngtm(a), nlef = nlem(a), ngef = ngem(a);
|
||||||
|
|
||||||
|
printf("BYTE %ld, 1 : EQ %d LT %d GT %d LE %d GE %d\r", a, beqf, bltf, bgtf, blef, bgef);
|
||||||
|
printf("NATIVE %ld, 1 : EQ %d LT %d GT %d LE %d GE %d\r", a, neqf, nltf, ngtf, nlef, ngef);
|
||||||
|
|
||||||
|
assert(beqf == neqf);
|
||||||
|
assert(bltf == nltf);
|
||||||
|
assert(bgtf == ngtf);
|
||||||
|
assert(blef == nlef);
|
||||||
|
assert(bgef == ngef);
|
||||||
|
}
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
cmp( 0, 1);
|
cmp( 0, 1);
|
||||||
|
@ -327,6 +454,10 @@ int main(void)
|
||||||
cmp1(256);
|
cmp1(256);
|
||||||
cmp1(10000);
|
cmp1(10000);
|
||||||
cmp1(20000);
|
cmp1(20000);
|
||||||
|
cmp1(1000000l);
|
||||||
|
cmp1(2000000l);
|
||||||
|
cmp1(100000000l);
|
||||||
|
cmp1(200000000l);
|
||||||
cmp1(-1);
|
cmp1(-1);
|
||||||
cmp1(-2);
|
cmp1(-2);
|
||||||
cmp1(-3);
|
cmp1(-3);
|
||||||
|
@ -334,6 +465,34 @@ int main(void)
|
||||||
cmp1(-256);
|
cmp1(-256);
|
||||||
cmp1(-10000);
|
cmp1(-10000);
|
||||||
cmp1(-20000);
|
cmp1(-20000);
|
||||||
|
cmp1(-1000000l);
|
||||||
|
cmp1(-2000000l);
|
||||||
|
cmp1(-100000000l);
|
||||||
|
cmp1(-200000000l);
|
||||||
|
|
||||||
|
cmpm(0);
|
||||||
|
cmpm(1);
|
||||||
|
cmpm(2);
|
||||||
|
cmpm(3);
|
||||||
|
cmpm(255);
|
||||||
|
cmpm(256);
|
||||||
|
cmpm(10000);
|
||||||
|
cmpm(20000);
|
||||||
|
cmpm(1000000l);
|
||||||
|
cmpm(2000000l);
|
||||||
|
cmpm(100000000l);
|
||||||
|
cmpm(200000000l);
|
||||||
|
cmpm(-1);
|
||||||
|
cmpm(-2);
|
||||||
|
cmpm(-3);
|
||||||
|
cmpm(-255);
|
||||||
|
cmpm(-256);
|
||||||
|
cmpm(-10000);
|
||||||
|
cmpm(-20000);
|
||||||
|
cmpm(-1000000l);
|
||||||
|
cmpm(-2000000l);
|
||||||
|
cmpm(-100000000l);
|
||||||
|
cmpm(-200000000l);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ enum SIDFXState
|
||||||
SIDFX_WAIT
|
SIDFX_WAIT
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct SIDFXChannel
|
__striped static struct SIDFXChannel
|
||||||
{
|
{
|
||||||
const SIDFX * volatile com;
|
const SIDFX * volatile com;
|
||||||
byte delay, priority;
|
byte delay, priority;
|
||||||
|
@ -27,6 +27,7 @@ void sidfx_init(void)
|
||||||
channels[i].com = nullptr;
|
channels[i].com = nullptr;
|
||||||
channels[i].state = SIDFX_IDLE;
|
channels[i].state = SIDFX_IDLE;
|
||||||
channels[i].priority = 0;
|
channels[i].priority = 0;
|
||||||
|
channels[i].delay = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,6 +36,11 @@ bool sidfx_idle(byte chn)
|
||||||
return channels[chn].state == SIDFX_IDLE;
|
return channels[chn].state == SIDFX_IDLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char sidfx_cnt(byte chn)
|
||||||
|
{
|
||||||
|
return channels[chn].cnt;
|
||||||
|
}
|
||||||
|
|
||||||
void sidfx_play(byte chn, const SIDFX * fx, byte cnt)
|
void sidfx_play(byte chn, const SIDFX * fx, byte cnt)
|
||||||
{
|
{
|
||||||
SIDFXState ns = channels[chn].state;
|
SIDFXState ns = channels[chn].state;
|
||||||
|
@ -47,6 +53,7 @@ void sidfx_play(byte chn, const SIDFX * fx, byte cnt)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
channels[chn].state = SIDFX_IDLE;
|
channels[chn].state = SIDFX_IDLE;
|
||||||
|
channels[chn].delay = 1;
|
||||||
|
|
||||||
channels[chn].com = fx;
|
channels[chn].com = fx;
|
||||||
channels[chn].cnt = cnt - 1;
|
channels[chn].cnt = cnt - 1;
|
||||||
|
@ -59,30 +66,58 @@ void sidfx_stop(byte chn)
|
||||||
{
|
{
|
||||||
channels[chn].com = nullptr;
|
channels[chn].com = nullptr;
|
||||||
if (channels[chn].state != SIDFX_IDLE)
|
if (channels[chn].state != SIDFX_IDLE)
|
||||||
|
{
|
||||||
channels[chn].state = SIDFX_RESET_0;
|
channels[chn].state = SIDFX_RESET_0;
|
||||||
|
channels[chn].delay = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void sidfx_loop_ch(byte ch)
|
inline void sidfx_loop_ch(byte ch)
|
||||||
{
|
{
|
||||||
|
if (channels[ch].state)
|
||||||
|
{
|
||||||
|
const SIDFX * com = channels[ch].com;
|
||||||
|
|
||||||
|
channels[ch].delay--;
|
||||||
|
if (channels[ch].delay)
|
||||||
|
{
|
||||||
|
if (com->dfreq)
|
||||||
|
{
|
||||||
|
channels[ch].freq += com->dfreq;
|
||||||
|
sid.voices[ch].freq = channels[ch].freq;
|
||||||
|
}
|
||||||
|
if (com->dpwm)
|
||||||
|
{
|
||||||
|
channels[ch].pwm += com->dpwm;
|
||||||
|
sid.voices[ch].pwm = channels[ch].pwm;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
while (!channels[ch].delay)
|
||||||
|
{
|
||||||
switch (channels[ch].state)
|
switch (channels[ch].state)
|
||||||
{
|
{
|
||||||
case SIDFX_IDLE:
|
case SIDFX_IDLE:
|
||||||
|
channels[ch].delay = 1;
|
||||||
break;
|
break;
|
||||||
case SIDFX_RESET_0:
|
case SIDFX_RESET_0:
|
||||||
sid.voices[ch].ctrl = 0;
|
sid.voices[ch].ctrl = 0;
|
||||||
sid.voices[ch].attdec = 0;
|
sid.voices[ch].attdec = 0;
|
||||||
sid.voices[ch].susrel = 0;
|
sid.voices[ch].susrel = 0;
|
||||||
|
if (com)
|
||||||
channels[ch].state = SIDFX_READY;
|
channels[ch].state = SIDFX_READY;
|
||||||
|
else
|
||||||
|
channels[ch].state = SIDFX_IDLE;
|
||||||
|
channels[ch].delay = 1;
|
||||||
break;
|
break;
|
||||||
case SIDFX_RESET_1:
|
case SIDFX_RESET_1:
|
||||||
sid.voices[ch].ctrl = SID_CTRL_TEST;
|
sid.voices[ch].ctrl = SID_CTRL_TEST;
|
||||||
|
sid.voices[ch].ctrl = 0;
|
||||||
|
sid.voices[ch].attdec = 0;
|
||||||
|
sid.voices[ch].susrel = 0;
|
||||||
channels[ch].state = SIDFX_READY;
|
channels[ch].state = SIDFX_READY;
|
||||||
break;
|
break;
|
||||||
case SIDFX_READY:
|
case SIDFX_READY:
|
||||||
{
|
|
||||||
const SIDFX * com = channels[ch].com;
|
|
||||||
if (com)
|
|
||||||
{
|
|
||||||
channels[ch].freq = com->freq;
|
channels[ch].freq = com->freq;
|
||||||
channels[ch].pwm = com->pwm;
|
channels[ch].pwm = com->pwm;
|
||||||
|
|
||||||
|
@ -92,38 +127,34 @@ inline void sidfx_loop_ch(byte ch)
|
||||||
sid.voices[ch].susrel = com->susrel;
|
sid.voices[ch].susrel = com->susrel;
|
||||||
sid.voices[ch].ctrl = com->ctrl;
|
sid.voices[ch].ctrl = com->ctrl;
|
||||||
|
|
||||||
|
if (com->ctrl & SID_CTRL_GATE)
|
||||||
|
{
|
||||||
channels[ch].delay = com->time1;
|
channels[ch].delay = com->time1;
|
||||||
channels[ch].state = SIDFX_PLAY;
|
channels[ch].state = SIDFX_PLAY;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
channels[ch].state = SIDFX_IDLE;
|
{
|
||||||
|
channels[ch].delay = com->time0;
|
||||||
|
channels[ch].state = SIDFX_PLAY;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SIDFX_PLAY:
|
case SIDFX_PLAY:
|
||||||
{
|
if (com->time0)
|
||||||
const SIDFX * com = channels[ch].com;
|
|
||||||
if (com->dfreq)
|
|
||||||
{
|
|
||||||
channels[ch].freq += com->dfreq;
|
|
||||||
sid.voices[ch].freq = channels[ch].freq;
|
|
||||||
}
|
|
||||||
if (com->dpwm)
|
|
||||||
{
|
|
||||||
channels[ch].pwm += com->dpwm;
|
|
||||||
sid.voices[ch].pwm = channels[ch].pwm;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (channels[ch].delay)
|
|
||||||
channels[ch].delay--;
|
|
||||||
else if (com->time0)
|
|
||||||
{
|
{
|
||||||
sid.voices[ch].ctrl = com->ctrl & ~SID_CTRL_GATE;
|
sid.voices[ch].ctrl = com->ctrl & ~SID_CTRL_GATE;
|
||||||
channels[ch].delay = com->time0;
|
channels[ch].delay = com->time0 - 1;
|
||||||
channels[ch].state = SIDFX_WAIT;
|
channels[ch].state = SIDFX_WAIT;
|
||||||
}
|
}
|
||||||
else if (channels[ch].cnt)
|
else if (channels[ch].cnt)
|
||||||
{
|
{
|
||||||
|
char sr = com->susrel & 0xf0;
|
||||||
com++;
|
com++;
|
||||||
|
char ctrl = com->ctrl;
|
||||||
|
if ((com->attdec & 0xef) == 0 && (ctrl & SID_CTRL_GATE) && (com->susrel & 0xf0) > sr)
|
||||||
|
{
|
||||||
|
sid.voices[ch].ctrl = ctrl & ~SID_CTRL_GATE;
|
||||||
|
sid.voices[ch].ctrl = ctrl | SID_CTRL_GATE;
|
||||||
|
}
|
||||||
channels[ch].cnt--;
|
channels[ch].cnt--;
|
||||||
channels[ch].com = com;
|
channels[ch].com = com;
|
||||||
channels[ch].priority = com->priority;
|
channels[ch].priority = com->priority;
|
||||||
|
@ -131,46 +162,31 @@ inline void sidfx_loop_ch(byte ch)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
channels[ch].com = nullptr;
|
com = nullptr;
|
||||||
channels[ch].state = SIDFX_RESET_0;
|
channels[ch].state = SIDFX_RESET_0;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case SIDFX_WAIT:
|
case SIDFX_WAIT:
|
||||||
{
|
if (channels[ch].cnt)
|
||||||
const SIDFX * com = channels[ch].com;
|
|
||||||
if (com->dfreq)
|
|
||||||
{
|
|
||||||
channels[ch].freq += com->dfreq;
|
|
||||||
sid.voices[ch].freq = channels[ch].freq;
|
|
||||||
}
|
|
||||||
if (com->dpwm)
|
|
||||||
{
|
|
||||||
channels[ch].pwm += com->dpwm;
|
|
||||||
sid.voices[ch].pwm = channels[ch].pwm;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (channels[ch].delay)
|
|
||||||
channels[ch].delay--;
|
|
||||||
else if (channels[ch].cnt)
|
|
||||||
{
|
{
|
||||||
com++;
|
com++;
|
||||||
channels[ch].cnt--;
|
channels[ch].cnt--;
|
||||||
channels[ch].com = com;
|
channels[ch].com = com;
|
||||||
channels[ch].priority = com->priority;
|
channels[ch].priority = com->priority;
|
||||||
if (com->time0)
|
if (com->ctrl & SID_CTRL_GATE)
|
||||||
channels[ch].state = SIDFX_RESET_0;
|
channels[ch].state = SIDFX_RESET_0;
|
||||||
else
|
else
|
||||||
channels[ch].state = SIDFX_READY;
|
channels[ch].state = SIDFX_READY;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
channels[ch].com = nullptr;
|
com = nullptr;
|
||||||
channels[ch].state = SIDFX_RESET_0;
|
channels[ch].state = SIDFX_RESET_0;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void sidfx_loop_2(void)
|
void sidfx_loop_2(void)
|
||||||
|
|
|
@ -20,6 +20,8 @@ inline void sidfx_play(byte chn, const SIDFX * fx, byte cnt);
|
||||||
|
|
||||||
void sidfx_stop(byte chn);
|
void sidfx_stop(byte chn);
|
||||||
|
|
||||||
|
char sidfx_cnt(byte chn);
|
||||||
|
|
||||||
void sidfx_loop(void);
|
void sidfx_loop(void);
|
||||||
|
|
||||||
void sidfx_loop_2(void);
|
void sidfx_loop_2(void);
|
||||||
|
|
|
@ -69,7 +69,7 @@ BANKINLINE bool krnio_open(char fnum, char device, char channel)
|
||||||
{
|
{
|
||||||
krnio_pstatus[fnum] = KRNIO_OK;
|
krnio_pstatus[fnum] = KRNIO_OK;
|
||||||
|
|
||||||
return __asm
|
return char(__asm
|
||||||
{
|
{
|
||||||
lda #0
|
lda #0
|
||||||
sta accu
|
sta accu
|
||||||
|
@ -94,8 +94,7 @@ BANKINLINE bool krnio_open(char fnum, char device, char channel)
|
||||||
|
|
||||||
BANKOUT
|
BANKOUT
|
||||||
E2:
|
E2:
|
||||||
};
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma native(krnio_open)
|
#pragma native(krnio_open)
|
||||||
|
@ -131,7 +130,7 @@ BANKINLINE krnioerr krnio_status(void)
|
||||||
|
|
||||||
BANKINLINE bool krnio_load(char fnum, char device, char channel)
|
BANKINLINE bool krnio_load(char fnum, char device, char channel)
|
||||||
{
|
{
|
||||||
return __asm
|
return char(__asm
|
||||||
{
|
{
|
||||||
BANKIN
|
BANKIN
|
||||||
lda fnum
|
lda fnum
|
||||||
|
@ -149,14 +148,14 @@ BANKINLINE bool krnio_load(char fnum, char device, char channel)
|
||||||
rol
|
rol
|
||||||
eor #1
|
eor #1
|
||||||
sta accu
|
sta accu
|
||||||
};
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma native(krnio_load)
|
#pragma native(krnio_load)
|
||||||
|
|
||||||
BANKINLINE bool krnio_save(char device, const char* start, const char* end)
|
BANKINLINE bool krnio_save(char device, const char* start, const char* end)
|
||||||
{
|
{
|
||||||
return __asm
|
return char(__asm
|
||||||
{
|
{
|
||||||
BANKIN
|
BANKIN
|
||||||
lda #0
|
lda #0
|
||||||
|
@ -175,14 +174,14 @@ BANKINLINE bool krnio_save(char device, const char* start, const char* end)
|
||||||
rol
|
rol
|
||||||
eor #1
|
eor #1
|
||||||
sta accu
|
sta accu
|
||||||
};
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma native(krnio_save)
|
#pragma native(krnio_save)
|
||||||
|
|
||||||
BANKINLINE bool krnio_chkout(char fnum)
|
BANKINLINE bool krnio_chkout(char fnum)
|
||||||
{
|
{
|
||||||
return __asm
|
return char(__asm
|
||||||
{
|
{
|
||||||
BANKIN
|
BANKIN
|
||||||
ldx fnum
|
ldx fnum
|
||||||
|
@ -193,14 +192,14 @@ BANKINLINE bool krnio_chkout(char fnum)
|
||||||
rol
|
rol
|
||||||
eor #1
|
eor #1
|
||||||
sta accu
|
sta accu
|
||||||
};
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma native(krnio_chkout)
|
#pragma native(krnio_chkout)
|
||||||
|
|
||||||
BANKINLINE bool krnio_chkin(char fnum)
|
BANKINLINE bool krnio_chkin(char fnum)
|
||||||
{
|
{
|
||||||
return __asm
|
return char(__asm
|
||||||
{
|
{
|
||||||
BANKIN
|
BANKIN
|
||||||
ldx fnum
|
ldx fnum
|
||||||
|
@ -211,7 +210,7 @@ BANKINLINE bool krnio_chkin(char fnum)
|
||||||
rol
|
rol
|
||||||
eor #1
|
eor #1
|
||||||
sta accu
|
sta accu
|
||||||
};
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma native(krnio_chkin)
|
#pragma native(krnio_chkin)
|
||||||
|
@ -230,14 +229,14 @@ BANKINLINE void krnio_clrchn(void)
|
||||||
|
|
||||||
BANKINLINE bool krnio_chrout(char ch)
|
BANKINLINE bool krnio_chrout(char ch)
|
||||||
{
|
{
|
||||||
return __asm
|
return char(__asm
|
||||||
{
|
{
|
||||||
BANKIN
|
BANKIN
|
||||||
lda ch
|
lda ch
|
||||||
jsr $ffd2 // chrout
|
jsr $ffd2 // chrout
|
||||||
sta accu
|
sta accu
|
||||||
BANKOUT
|
BANKOUT
|
||||||
};
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma native(krnio_chrout)
|
#pragma native(krnio_chrout)
|
||||||
|
@ -422,7 +421,7 @@ int krnio_gets(char fnum, char * data, int num)
|
||||||
|
|
||||||
if (krnio_chkin(fnum))
|
if (krnio_chkin(fnum))
|
||||||
{
|
{
|
||||||
krnioerr err;
|
krnioerr err = KRNIO_OK;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
int ch;
|
int ch;
|
||||||
while (i + 1 < num)
|
while (i + 1 < num)
|
||||||
|
|
|
@ -5,16 +5,16 @@
|
||||||
#include <c64/asm6502.h>
|
#include <c64/asm6502.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
volatile char npos = 1, tpos = 0;
|
|
||||||
volatile byte rirq_count;
|
volatile byte rirq_count;
|
||||||
|
static byte rirq_pcount;
|
||||||
|
|
||||||
byte rasterIRQRows[NUM_IRQS + 1];
|
byte rasterIRQRows[NUM_IRQS + 1];
|
||||||
byte rasterIRQIndex[NUM_IRQS + 1];
|
byte rasterIRQIndex[NUM_IRQS + 1]; // Sort order of interrupt index, offset by one
|
||||||
#ifdef ZPAGE_IRQS
|
#ifdef ZPAGE_IRQS
|
||||||
__zeropage
|
__zeropage
|
||||||
#endif
|
#endif
|
||||||
byte rasterIRQNext[NUM_IRQS + 1];
|
byte rasterIRQNext[NUM_IRQS + 1]; // Rasterline of interrupt, terminated by 0xff
|
||||||
byte rasterIRQLow[NUM_IRQS];
|
byte rasterIRQLow[NUM_IRQS]; // Address of interrupt code
|
||||||
byte rasterIRQHigh[NUM_IRQS];
|
byte rasterIRQHigh[NUM_IRQS];
|
||||||
|
|
||||||
#ifdef ZPAGE_IRQS
|
#ifdef ZPAGE_IRQS
|
||||||
|
@ -22,26 +22,25 @@ __zeropage
|
||||||
#endif
|
#endif
|
||||||
byte nextIRQ;
|
byte nextIRQ;
|
||||||
|
|
||||||
__asm irq0
|
// nextIRQ is the index of the next expected IRQ, or $ff if no IRQ is scheduled
|
||||||
|
|
||||||
|
__asm rirq_isr_ram_io
|
||||||
{
|
{
|
||||||
sta plra + 1
|
|
||||||
stx plrx + 1
|
stx plrx + 1
|
||||||
sty plry + 1
|
|
||||||
kentry:
|
|
||||||
asl $d019
|
|
||||||
|
|
||||||
ldx nextIRQ
|
ldx nextIRQ
|
||||||
|
bmi exi
|
||||||
|
|
||||||
|
sta plra + 1
|
||||||
|
sty plry + 1
|
||||||
|
|
||||||
l1:
|
l1:
|
||||||
lda rasterIRQNext, x
|
lda rasterIRQNext, x
|
||||||
cmp #$ff
|
|
||||||
beq e1
|
|
||||||
|
|
||||||
ldy rasterIRQIndex + 1, x
|
ldy rasterIRQIndex + 1, x
|
||||||
tax
|
ldx rasterIRQLow, y
|
||||||
lda rasterIRQLow, y
|
stx ji + 1
|
||||||
sta ji + 1
|
ldx rasterIRQHigh, y
|
||||||
lda rasterIRQHigh, y
|
stx ji + 2
|
||||||
sta ji + 2
|
|
||||||
|
|
||||||
ji:
|
ji:
|
||||||
jsr $0000
|
jsr $0000
|
||||||
|
@ -49,48 +48,105 @@ ji:
|
||||||
inc nextIRQ
|
inc nextIRQ
|
||||||
ldx nextIRQ
|
ldx nextIRQ
|
||||||
|
|
||||||
lda rasterIRQNext, x
|
ldy rasterIRQNext, x
|
||||||
cmp #$ff
|
|
||||||
|
asl $d019
|
||||||
|
|
||||||
|
cpy #$ff
|
||||||
beq e2
|
beq e2
|
||||||
// carry is cleared at this point
|
|
||||||
|
|
||||||
tay
|
|
||||||
sbc #2
|
|
||||||
cmp $d012
|
|
||||||
bcc l1
|
|
||||||
|
|
||||||
exd:
|
|
||||||
dey
|
dey
|
||||||
ex:
|
|
||||||
sty $d012
|
sty $d012
|
||||||
|
dey
|
||||||
|
cpy $d012
|
||||||
|
bcc l1
|
||||||
|
|
||||||
plry:
|
plry:
|
||||||
ldy #0
|
ldy #0
|
||||||
plrx:
|
|
||||||
ldx #0
|
|
||||||
plra:
|
plra:
|
||||||
lda #0
|
lda #0
|
||||||
|
plrx:
|
||||||
|
ldx #0
|
||||||
rti
|
rti
|
||||||
|
|
||||||
|
exi:
|
||||||
|
asl $d019
|
||||||
|
jmp plrx
|
||||||
|
|
||||||
|
// No more interrupts to service
|
||||||
e2:
|
e2:
|
||||||
|
|
||||||
ldx npos
|
|
||||||
stx tpos
|
|
||||||
inc rirq_count
|
inc rirq_count
|
||||||
tay
|
|
||||||
|
|
||||||
bit $d011
|
ldy rasterIRQNext
|
||||||
bpl ex
|
dey
|
||||||
|
sty $d012
|
||||||
e1:
|
|
||||||
ldx #0
|
ldx #0
|
||||||
stx nextIRQ
|
stx nextIRQ
|
||||||
ldy rasterIRQNext
|
beq plry
|
||||||
jmp exd
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
__asm irq2
|
__asm rirq_isr_io
|
||||||
|
{
|
||||||
|
pha
|
||||||
|
txa
|
||||||
|
pha
|
||||||
|
tya
|
||||||
|
pha
|
||||||
|
kentry:
|
||||||
|
|
||||||
|
ldx nextIRQ
|
||||||
|
bmi exi
|
||||||
|
l1:
|
||||||
|
lda rasterIRQNext, x
|
||||||
|
ldy rasterIRQIndex + 1, x
|
||||||
|
ldx rasterIRQLow, y
|
||||||
|
stx ji + 1
|
||||||
|
ldx rasterIRQHigh, y
|
||||||
|
stx ji + 2
|
||||||
|
|
||||||
|
ji:
|
||||||
|
jsr $0000
|
||||||
|
|
||||||
|
inc nextIRQ
|
||||||
|
ldx nextIRQ
|
||||||
|
|
||||||
|
ldy rasterIRQNext, x
|
||||||
|
|
||||||
|
asl $d019
|
||||||
|
|
||||||
|
cpy #$ff
|
||||||
|
beq e2
|
||||||
|
|
||||||
|
dey
|
||||||
|
sty $d012
|
||||||
|
dey
|
||||||
|
cpy $d012
|
||||||
|
bcc l1
|
||||||
|
|
||||||
|
exd:
|
||||||
|
pla
|
||||||
|
tay
|
||||||
|
pla
|
||||||
|
tax
|
||||||
|
pla
|
||||||
|
rti
|
||||||
|
|
||||||
|
exi:
|
||||||
|
asl $d019
|
||||||
|
jmp exd
|
||||||
|
|
||||||
|
e2:
|
||||||
|
inc rirq_count
|
||||||
|
|
||||||
|
ldy rasterIRQNext
|
||||||
|
dey
|
||||||
|
sty $d012
|
||||||
|
ldx #0
|
||||||
|
stx nextIRQ
|
||||||
|
beq exd
|
||||||
|
}
|
||||||
|
|
||||||
|
__asm rirq_isr_noio
|
||||||
{
|
{
|
||||||
pha
|
pha
|
||||||
txa
|
txa
|
||||||
|
@ -104,20 +160,15 @@ kentry:
|
||||||
lda #$35
|
lda #$35
|
||||||
sta $01
|
sta $01
|
||||||
|
|
||||||
asl $d019
|
|
||||||
|
|
||||||
ldx nextIRQ
|
ldx nextIRQ
|
||||||
|
bmi exi
|
||||||
l1:
|
l1:
|
||||||
lda rasterIRQNext, x
|
lda rasterIRQNext, x
|
||||||
cmp #$ff
|
|
||||||
beq e1
|
|
||||||
|
|
||||||
ldy rasterIRQIndex + 1, x
|
ldy rasterIRQIndex + 1, x
|
||||||
tax
|
ldx rasterIRQLow, y
|
||||||
lda rasterIRQLow, y
|
stx ji + 1
|
||||||
sta ji + 1
|
ldx rasterIRQHigh, y
|
||||||
lda rasterIRQHigh, y
|
stx ji + 2
|
||||||
sta ji + 2
|
|
||||||
|
|
||||||
ji:
|
ji:
|
||||||
jsr $0000
|
jsr $0000
|
||||||
|
@ -125,21 +176,20 @@ ji:
|
||||||
inc nextIRQ
|
inc nextIRQ
|
||||||
ldx nextIRQ
|
ldx nextIRQ
|
||||||
|
|
||||||
lda rasterIRQNext, x
|
ldy rasterIRQNext, x
|
||||||
cmp #$ff
|
|
||||||
beq e2
|
asl $d019
|
||||||
// carry is cleared at this point
|
|
||||||
|
cpy #$ff
|
||||||
|
beq e2
|
||||||
|
|
||||||
tay
|
|
||||||
dey
|
dey
|
||||||
sbc #2
|
sty $d012
|
||||||
cmp $d012
|
dey
|
||||||
|
cpy $d012
|
||||||
bcc l1
|
bcc l1
|
||||||
|
|
||||||
sty $d012
|
exd:
|
||||||
|
|
||||||
ex:
|
|
||||||
|
|
||||||
pla
|
pla
|
||||||
sta $01
|
sta $01
|
||||||
|
|
||||||
|
@ -150,45 +200,35 @@ ex:
|
||||||
pla
|
pla
|
||||||
rti
|
rti
|
||||||
|
|
||||||
e2:
|
exi:
|
||||||
|
asl $d019
|
||||||
|
jmp exd
|
||||||
|
|
||||||
ldx npos
|
e2:
|
||||||
stx tpos
|
|
||||||
inc rirq_count
|
inc rirq_count
|
||||||
|
|
||||||
bit $d011
|
|
||||||
bmi e1
|
|
||||||
|
|
||||||
sta $d012
|
|
||||||
jmp ex
|
|
||||||
|
|
||||||
e1:
|
|
||||||
ldx #0
|
|
||||||
stx nextIRQ
|
|
||||||
ldy rasterIRQNext
|
ldy rasterIRQNext
|
||||||
dey
|
dey
|
||||||
sty $d012
|
sty $d012
|
||||||
jmp ex
|
ldx #0
|
||||||
|
stx nextIRQ
|
||||||
|
beq exd
|
||||||
}
|
}
|
||||||
|
|
||||||
__asm irq1
|
__asm rirq_isr_kernal_io
|
||||||
{
|
{
|
||||||
lda $d019
|
lda $d019
|
||||||
bpl ex2
|
bpl ex2
|
||||||
|
|
||||||
ldx nextIRQ
|
ldx nextIRQ
|
||||||
|
bmi exi
|
||||||
l1:
|
l1:
|
||||||
lda rasterIRQNext, x
|
lda rasterIRQNext, x
|
||||||
cmp #$ff
|
|
||||||
beq e1
|
|
||||||
|
|
||||||
ldy rasterIRQIndex + 1, x
|
ldy rasterIRQIndex + 1, x
|
||||||
tax
|
ldx rasterIRQLow, y
|
||||||
lda rasterIRQLow, y
|
stx ji + 1
|
||||||
sta ji + 1
|
ldx rasterIRQHigh, y
|
||||||
lda rasterIRQHigh, y
|
stx ji + 2
|
||||||
sta ji + 2
|
|
||||||
|
|
||||||
ji:
|
ji:
|
||||||
jsr $0000
|
jsr $0000
|
||||||
|
@ -197,45 +237,36 @@ jx:
|
||||||
inc nextIRQ
|
inc nextIRQ
|
||||||
ldx nextIRQ
|
ldx nextIRQ
|
||||||
|
|
||||||
lda rasterIRQNext, x
|
ldy rasterIRQNext, x
|
||||||
cmp #$ff
|
|
||||||
beq e2
|
|
||||||
|
|
||||||
tay
|
|
||||||
|
|
||||||
sec
|
|
||||||
sbc #4
|
|
||||||
cmp $d012
|
|
||||||
bcc l1
|
|
||||||
|
|
||||||
dey
|
|
||||||
sty $d012
|
|
||||||
w1:
|
|
||||||
jmp ex
|
|
||||||
|
|
||||||
e2:
|
|
||||||
ldx npos
|
|
||||||
stx tpos
|
|
||||||
inc rirq_count
|
|
||||||
|
|
||||||
bit $d011
|
|
||||||
bmi e1
|
|
||||||
|
|
||||||
sta $d012
|
|
||||||
|
|
||||||
jmp ex
|
|
||||||
|
|
||||||
e1:
|
|
||||||
ldx #0
|
|
||||||
stx nextIRQ
|
|
||||||
lda rasterIRQNext, x
|
|
||||||
sec
|
|
||||||
sbc #1
|
|
||||||
sta $d012
|
|
||||||
|
|
||||||
ex:
|
|
||||||
asl $d019
|
asl $d019
|
||||||
|
|
||||||
|
cpy #$ff
|
||||||
|
beq e2
|
||||||
|
|
||||||
|
dey
|
||||||
|
dey
|
||||||
|
sty $d012
|
||||||
|
dey
|
||||||
|
cpy $d012
|
||||||
|
bcc l1
|
||||||
|
|
||||||
|
exd:
|
||||||
|
jmp $ea81
|
||||||
|
|
||||||
|
exi:
|
||||||
|
asl $d019
|
||||||
|
jmp $ea81
|
||||||
|
|
||||||
|
e2:
|
||||||
|
inc rirq_count
|
||||||
|
|
||||||
|
ldy rasterIRQNext
|
||||||
|
dey
|
||||||
|
dey
|
||||||
|
sty $d012
|
||||||
|
ldx #0
|
||||||
|
stx nextIRQ
|
||||||
jmp $ea81
|
jmp $ea81
|
||||||
|
|
||||||
ex2:
|
ex2:
|
||||||
|
@ -244,7 +275,7 @@ ex2:
|
||||||
jmp $ea31
|
jmp $ea31
|
||||||
}
|
}
|
||||||
|
|
||||||
__asm irq3
|
__asm rirq_isr_kernal_noio
|
||||||
{
|
{
|
||||||
lda $01
|
lda $01
|
||||||
pha
|
pha
|
||||||
|
@ -255,17 +286,14 @@ __asm irq3
|
||||||
bpl ex2
|
bpl ex2
|
||||||
|
|
||||||
ldx nextIRQ
|
ldx nextIRQ
|
||||||
|
bmi exi
|
||||||
l1:
|
l1:
|
||||||
lda rasterIRQNext, x
|
lda rasterIRQNext, x
|
||||||
cmp #$ff
|
|
||||||
beq e1
|
|
||||||
|
|
||||||
ldy rasterIRQIndex + 1, x
|
ldy rasterIRQIndex + 1, x
|
||||||
tax
|
ldx rasterIRQLow, y
|
||||||
lda rasterIRQLow, y
|
stx ji + 1
|
||||||
sta ji + 1
|
ldx rasterIRQHigh, y
|
||||||
lda rasterIRQHigh, y
|
stx ji + 2
|
||||||
sta ji + 2
|
|
||||||
|
|
||||||
ji:
|
ji:
|
||||||
jsr $0000
|
jsr $0000
|
||||||
|
@ -274,49 +302,40 @@ jx:
|
||||||
inc nextIRQ
|
inc nextIRQ
|
||||||
ldx nextIRQ
|
ldx nextIRQ
|
||||||
|
|
||||||
lda rasterIRQNext, x
|
ldy rasterIRQNext, x
|
||||||
cmp #$ff
|
|
||||||
|
asl $d019
|
||||||
|
|
||||||
|
cpy #$ff
|
||||||
beq e2
|
beq e2
|
||||||
|
|
||||||
tay
|
dey
|
||||||
|
|
||||||
sec
|
|
||||||
sbc #4
|
|
||||||
cmp $d012
|
|
||||||
bcc l1
|
|
||||||
|
|
||||||
dey
|
dey
|
||||||
sty $d012
|
sty $d012
|
||||||
w1:
|
dey
|
||||||
jmp ex
|
cpy $d012
|
||||||
|
bcc l1
|
||||||
e2:
|
exd:
|
||||||
ldx npos
|
|
||||||
stx tpos
|
|
||||||
inc rirq_count
|
|
||||||
|
|
||||||
bit $d011
|
|
||||||
bmi e1
|
|
||||||
|
|
||||||
sta $d012
|
|
||||||
|
|
||||||
jmp ex
|
|
||||||
|
|
||||||
e1:
|
|
||||||
ldx #0
|
|
||||||
stx nextIRQ
|
|
||||||
lda rasterIRQNext, x
|
|
||||||
sec
|
|
||||||
sbc #1
|
|
||||||
sta $d012
|
|
||||||
|
|
||||||
ex:
|
|
||||||
asl $d019
|
|
||||||
pla
|
pla
|
||||||
sta $01
|
sta $01
|
||||||
|
|
||||||
jmp $ea81
|
jmp $ea81
|
||||||
|
|
||||||
|
exi:
|
||||||
|
asl $d019
|
||||||
|
jmp exd
|
||||||
|
|
||||||
|
e2:
|
||||||
|
inc rirq_count
|
||||||
|
|
||||||
|
ldy rasterIRQNext
|
||||||
|
dey
|
||||||
|
dey
|
||||||
|
sty $d012
|
||||||
|
ldx #0
|
||||||
|
stx nextIRQ
|
||||||
|
beq exd
|
||||||
|
|
||||||
ex2:
|
ex2:
|
||||||
LDA $DC0D
|
LDA $DC0D
|
||||||
cli
|
cli
|
||||||
|
@ -346,8 +365,8 @@ void rirq_build(RIRQCode * ic, byte size)
|
||||||
ic->size = size;
|
ic->size = size;
|
||||||
|
|
||||||
asm_im(ic->code + 0, ASM_LDY, 0);
|
asm_im(ic->code + 0, ASM_LDY, 0);
|
||||||
asm_im(ic->code + 2, ASM_LDA, 0);
|
asm_im(ic->code + 2, ASM_LDX, 0);
|
||||||
asm_ab(ic->code + 4, ASM_CPX, 0xd012);
|
asm_ab(ic->code + 4, ASM_CMP, 0xd012);
|
||||||
asm_rl(ic->code + 7, ASM_BCS, -5);
|
asm_rl(ic->code + 7, ASM_BCS, -5);
|
||||||
asm_ab(ic->code + 9, ASM_STY, 0x0000);
|
asm_ab(ic->code + 9, ASM_STY, 0x0000);
|
||||||
|
|
||||||
|
@ -361,7 +380,7 @@ void rirq_build(RIRQCode * ic, byte size)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
asm_ab(ic->code + 12, ASM_STA, 0x0000);
|
asm_ab(ic->code + 12, ASM_STX, 0x0000);
|
||||||
|
|
||||||
byte p = 15;
|
byte p = 15;
|
||||||
for(byte i=2; i<size; i++)
|
for(byte i=2; i<size; i++)
|
||||||
|
@ -481,7 +500,7 @@ void rirq_init_kernal(void)
|
||||||
sei
|
sei
|
||||||
}
|
}
|
||||||
|
|
||||||
*(void **)0x0314 = irq1;
|
*(void **)0x0314 = rirq_isr_kernal_io;
|
||||||
|
|
||||||
vic.intr_enable = 1;
|
vic.intr_enable = 1;
|
||||||
vic.ctrl1 &= 0x7f;
|
vic.ctrl1 &= 0x7f;
|
||||||
|
@ -489,7 +508,7 @@ void rirq_init_kernal(void)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void rirq_init_kernal_io(void)
|
void rirq_init_kernal_noio(void)
|
||||||
{
|
{
|
||||||
rirq_init_tables();
|
rirq_init_tables();
|
||||||
|
|
||||||
|
@ -498,7 +517,7 @@ void rirq_init_kernal_io(void)
|
||||||
sei
|
sei
|
||||||
}
|
}
|
||||||
|
|
||||||
*(void **)0x0314 = irq3;
|
*(void **)0x0314 = rirq_isr_kernal_noio;
|
||||||
|
|
||||||
vic.intr_enable = 1;
|
vic.intr_enable = 1;
|
||||||
vic.ctrl1 &= 0x7f;
|
vic.ctrl1 &= 0x7f;
|
||||||
|
@ -515,8 +534,8 @@ void rirq_init_crt(void)
|
||||||
sei
|
sei
|
||||||
}
|
}
|
||||||
|
|
||||||
*(void **)0x0314 = irq0.kentry;
|
*(void **)0x0314 = rirq_isr_io.kentry;
|
||||||
*(void **)0xfffe = irq0;
|
*(void **)0xfffe = rirq_isr_io;
|
||||||
|
|
||||||
vic.intr_enable = 1;
|
vic.intr_enable = 1;
|
||||||
vic.ctrl1 &= 0x7f;
|
vic.ctrl1 &= 0x7f;
|
||||||
|
@ -524,7 +543,7 @@ void rirq_init_crt(void)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void rirq_init_crt_io(void)
|
void rirq_init_crt_noio(void)
|
||||||
{
|
{
|
||||||
rirq_init_tables();
|
rirq_init_tables();
|
||||||
|
|
||||||
|
@ -533,8 +552,8 @@ void rirq_init_crt_io(void)
|
||||||
sei
|
sei
|
||||||
}
|
}
|
||||||
|
|
||||||
*(void **)0x0314 = irq2.kentry;
|
*(void **)0x0314 = rirq_isr_noio.kentry;
|
||||||
*(void **)0xfffe = irq2;
|
*(void **)0xfffe = rirq_isr_noio;
|
||||||
|
|
||||||
vic.intr_enable = 1;
|
vic.intr_enable = 1;
|
||||||
vic.ctrl1 &= 0x7f;
|
vic.ctrl1 &= 0x7f;
|
||||||
|
@ -551,7 +570,7 @@ void rirq_init_io(void)
|
||||||
sei
|
sei
|
||||||
}
|
}
|
||||||
|
|
||||||
*(void **)0xfffe = irq0;
|
*(void **)0xfffe = rirq_isr_ram_io;
|
||||||
|
|
||||||
vic.intr_enable = 1;
|
vic.intr_enable = 1;
|
||||||
vic.ctrl1 &= 0x7f;
|
vic.ctrl1 &= 0x7f;
|
||||||
|
@ -568,7 +587,7 @@ void rirq_init_memmap(void)
|
||||||
sei
|
sei
|
||||||
}
|
}
|
||||||
|
|
||||||
*(void **)0xfffe = irq2;
|
*(void **)0xfffe = rirq_isr_noio;
|
||||||
|
|
||||||
vic.intr_enable = 1;
|
vic.intr_enable = 1;
|
||||||
vic.ctrl1 &= 0x7f;
|
vic.ctrl1 &= 0x7f;
|
||||||
|
@ -586,12 +605,18 @@ void rirq_init(bool kernalIRQ)
|
||||||
|
|
||||||
void rirq_wait(void)
|
void rirq_wait(void)
|
||||||
{
|
{
|
||||||
while (tpos != npos) ;
|
char i0 = rirq_pcount;
|
||||||
npos++;
|
char i1;
|
||||||
|
do {
|
||||||
|
i1 = rirq_count;
|
||||||
|
} while (i0 == i1);
|
||||||
|
rirq_pcount = i1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void rirq_sort(bool inirq)
|
void rirq_sort(bool inirq)
|
||||||
{
|
{
|
||||||
|
// disable raster interrupts while sorting
|
||||||
|
nextIRQ = 0xff;
|
||||||
#if 1
|
#if 1
|
||||||
byte maxr = rasterIRQRows[rasterIRQIndex[1]];
|
byte maxr = rasterIRQRows[rasterIRQIndex[1]];
|
||||||
for(byte i = 2; i<NUM_IRQS + 1; i++)
|
for(byte i = 2; i<NUM_IRQS + 1; i++)
|
||||||
|
@ -639,15 +664,17 @@ void rirq_sort(bool inirq)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
npos++;
|
rirq_pcount = rirq_count;
|
||||||
if (inirq)
|
if (inirq)
|
||||||
nextIRQ = NUM_IRQS - 1;
|
nextIRQ = NUM_IRQS - 1;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
nextIRQ = 0;
|
byte yp = rasterIRQNext[0];
|
||||||
byte yp = rasterIRQNext[nextIRQ];
|
|
||||||
if (yp != 0xff)
|
if (yp != 0xff)
|
||||||
|
{
|
||||||
vic.raster = yp - 1;
|
vic.raster = yp - 1;
|
||||||
|
nextIRQ = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -662,6 +689,7 @@ void rirq_start(void)
|
||||||
lda #100
|
lda #100
|
||||||
sta $d012
|
sta $d012
|
||||||
|
|
||||||
|
asl $d019
|
||||||
cli
|
cli
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -154,7 +154,7 @@ void rirq_init_kernal(void);
|
||||||
|
|
||||||
// Raster IRQ through kernal, with IO range not always enabled
|
// Raster IRQ through kernal, with IO range not always enabled
|
||||||
// calls kernal continuation
|
// calls kernal continuation
|
||||||
void rirq_init_kernal_io(void);
|
void rirq_init_kernal_noio(void);
|
||||||
|
|
||||||
// Raster IRQ through RAM and ROM vector, with ROM disabled or not and IO range always enabled
|
// Raster IRQ through RAM and ROM vector, with ROM disabled or not and IO range always enabled
|
||||||
// does not call kernal continuation
|
// does not call kernal continuation
|
||||||
|
@ -162,7 +162,7 @@ void rirq_init_crt(void);
|
||||||
|
|
||||||
// Raster IRQ through RAM and ROM vector, with ROM disabled or not and IO range not always enabled
|
// Raster IRQ through RAM and ROM vector, with ROM disabled or not and IO range not always enabled
|
||||||
// does not call kernal continuation
|
// does not call kernal continuation
|
||||||
void rirq_init_crt_io(void);
|
void rirq_init_crt_noio(void);
|
||||||
|
|
||||||
// Raster IRQ through RAM vector, with ROM disabled and IO range always enabled
|
// Raster IRQ through RAM vector, with ROM disabled and IO range always enabled
|
||||||
// does not call kernal continuation
|
// does not call kernal continuation
|
||||||
|
@ -179,7 +179,7 @@ void rirq_start(void);
|
||||||
void rirq_stop(void);
|
void rirq_stop(void);
|
||||||
|
|
||||||
// Sort the raster IRQ, must be performed at the end of the frame after changing
|
// Sort the raster IRQ, must be performed at the end of the frame after changing
|
||||||
// the vertical position of one of the interrupt operatins.
|
// the vertical position of one of the interrupt operations.
|
||||||
// Set the inirq flag to true when calling this from an interrupt
|
// Set the inirq flag to true when calling this from an interrupt
|
||||||
void rirq_sort(bool inirq = false);
|
void rirq_sort(bool inirq = false);
|
||||||
|
|
||||||
|
|
|
@ -114,4 +114,21 @@ void vic_waitBelow(int line)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void vic_waitRange(char below, char above)
|
||||||
|
{
|
||||||
|
while (vic.ctrl1 & VIC_CTRL1_RST8)
|
||||||
|
;
|
||||||
|
|
||||||
|
if (vic.raster >= above)
|
||||||
|
{
|
||||||
|
while (!(vic.ctrl1 & VIC_CTRL1_RST8))
|
||||||
|
;
|
||||||
|
while (vic.ctrl1 & VIC_CTRL1_RST8)
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (vic.raster < below)
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
#pragma native(vic_waitLine)
|
#pragma native(vic_waitLine)
|
||||||
|
|
|
@ -118,6 +118,9 @@ void vic_waitLine(int line);
|
||||||
// wait for beam to be below a line
|
// wait for beam to be below a line
|
||||||
void vic_waitBelow(int line);
|
void vic_waitBelow(int line);
|
||||||
|
|
||||||
|
// wait for beam to be in a given range on screen
|
||||||
|
void vic_waitRange(char below, char above);
|
||||||
|
|
||||||
// reference to the VIC chip
|
// reference to the VIC chip
|
||||||
#define vic (*((struct VIC *)0xd000))
|
#define vic (*((struct VIC *)0xd000))
|
||||||
|
|
||||||
|
|
|
@ -224,11 +224,10 @@ void putpch(char c)
|
||||||
c ^= 0xa0;
|
c ^= 0xa0;
|
||||||
c ^= 0x20;
|
c ^= 0x20;
|
||||||
#else
|
#else
|
||||||
if (c >= 97)
|
|
||||||
c ^= 0x20;
|
c ^= 0x20;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (giocharmap == IOCHM_PETSCII_2)
|
if (giocharmap == IOCHM_PETSCII_1)
|
||||||
c &= 0xdf;
|
c &= 0xdf;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -756,6 +756,11 @@ __asm mul32
|
||||||
sta tmp + 6
|
sta tmp + 6
|
||||||
sta tmp + 7
|
sta tmp + 7
|
||||||
|
|
||||||
|
lda tmp + 3
|
||||||
|
ora tmp + 2
|
||||||
|
ora tmp + 1
|
||||||
|
beq WB
|
||||||
|
|
||||||
lda tmp + 0
|
lda tmp + 0
|
||||||
jsr WM
|
jsr WM
|
||||||
lda tmp + 1
|
lda tmp + 1
|
||||||
|
@ -773,6 +778,7 @@ WM:
|
||||||
stx accu + 1
|
stx accu + 1
|
||||||
sta accu
|
sta accu
|
||||||
rts
|
rts
|
||||||
|
WB: lda tmp + 0
|
||||||
W0:
|
W0:
|
||||||
sec
|
sec
|
||||||
ror
|
ror
|
||||||
|
|
|
@ -33,10 +33,15 @@ bool isfinite(float f);
|
||||||
#pragma intrinsic(sin)
|
#pragma intrinsic(sin)
|
||||||
#pragma intrinsic(cos)
|
#pragma intrinsic(cos)
|
||||||
#pragma intrinsic(tan)
|
#pragma intrinsic(tan)
|
||||||
|
#pragma intrinsic(atan)
|
||||||
|
#pragma intrinsic(atan2)
|
||||||
|
|
||||||
#pragma intrinsic(log)
|
#pragma intrinsic(log)
|
||||||
#pragma intrinsic(exp)
|
#pragma intrinsic(exp)
|
||||||
|
|
||||||
|
#pragma intrinsic(pow)
|
||||||
|
#pragma intrinsic(sqrt)
|
||||||
|
|
||||||
#pragma compile("math.c")
|
#pragma compile("math.c")
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include <new>
|
#include <new>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <opp/utility.h>
|
#include <opp/utility.h>
|
||||||
|
#include <oscar.h>
|
||||||
|
|
||||||
namespace opp {
|
namespace opp {
|
||||||
|
|
||||||
|
@ -11,8 +12,8 @@ template <class T, int N>
|
||||||
class static_vector
|
class static_vector
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
char _space[N * sizeof(T)];
|
|
||||||
enum { m = N } _size;
|
enum { m = N } _size;
|
||||||
|
char _space[N * sizeof(T)];
|
||||||
public:
|
public:
|
||||||
typedef T element_type;
|
typedef T element_type;
|
||||||
|
|
||||||
|
@ -20,23 +21,28 @@ public:
|
||||||
|
|
||||||
static_vector(size_t n) : _size(n)
|
static_vector(size_t n) : _size(n)
|
||||||
{
|
{
|
||||||
|
#ifdef CAPACITYCHECK
|
||||||
|
if (n > N) debugcrash();
|
||||||
|
#endif
|
||||||
T * data = (T*)_space;
|
T * data = (T*)_space;
|
||||||
for(size_t i=0; i<n; i++)
|
for(size_t i=0; i<n; i++)
|
||||||
new (data + i) T;
|
new (data + i) T();
|
||||||
}
|
}
|
||||||
|
|
||||||
static_vector(const static_vector & v)
|
static_vector(const static_vector & v)
|
||||||
: _size(v._size)
|
: _size(v._size)
|
||||||
{
|
{
|
||||||
|
size_t n = _size;
|
||||||
T * data = (T*)_space, * vdata = (T*)(v._space);
|
T * data = (T*)_space, * vdata = (T*)(v._space);
|
||||||
for(size_t i=0; i<_size; i++)
|
for(size_t i=0; i<n; i++)
|
||||||
new (data + i)T(vdata[i]);
|
new (data + i)T(vdata[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
~static_vector(void)
|
~static_vector(void)
|
||||||
{
|
{
|
||||||
T * data = (T*)_space;
|
T * data = (T*)_space;
|
||||||
for(size_t i=0; i<_size; i++)
|
size_t n = _size;
|
||||||
|
for(size_t i=0; i<n; i++)
|
||||||
data[i].~T();
|
data[i].~T();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,10 +51,12 @@ public:
|
||||||
if (this != &v)
|
if (this != &v)
|
||||||
{
|
{
|
||||||
T * data = (T*)_space, * vdata = (T*)(v._space);
|
T * data = (T*)_space, * vdata = (T*)(v._space);
|
||||||
for(size_t i=0; i<_size; i++)
|
size_t n = _size;
|
||||||
|
for(size_t i=0; i<n; i++)
|
||||||
data[i].~T();
|
data[i].~T();
|
||||||
_size = v._size;
|
_size = v._size;
|
||||||
for(size_t i=0; i<_size; i++)
|
n = _size;
|
||||||
|
for(size_t i=0; i<n; i++)
|
||||||
new (data + i)T(vdata[i]);
|
new (data + i)T(vdata[i]);
|
||||||
}
|
}
|
||||||
return *this;
|
return *this;
|
||||||
|
@ -69,6 +77,11 @@ public:
|
||||||
return _size == 0;
|
return _size == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool full(void) const
|
||||||
|
{
|
||||||
|
return _size == N;
|
||||||
|
}
|
||||||
|
|
||||||
size_t capacity(void) const
|
size_t capacity(void) const
|
||||||
{
|
{
|
||||||
return N;
|
return N;
|
||||||
|
@ -76,6 +89,8 @@ public:
|
||||||
|
|
||||||
void resize(size_t n);
|
void resize(size_t n);
|
||||||
|
|
||||||
|
void clear(void);
|
||||||
|
|
||||||
T & at(size_t at)
|
T & at(size_t at)
|
||||||
{
|
{
|
||||||
return ((T*)_space)[at];
|
return ((T*)_space)[at];
|
||||||
|
@ -166,6 +181,8 @@ public:
|
||||||
((T*)_space)[_size].~T();
|
((T*)_space)[_size].~T();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void assign(size_t count, const T & t);
|
||||||
|
|
||||||
void insert(size_t at, const T & t);
|
void insert(size_t at, const T & t);
|
||||||
|
|
||||||
void erase(size_t at, size_t n = 1);
|
void erase(size_t at, size_t n = 1);
|
||||||
|
@ -177,34 +194,50 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
template <class T, int N>
|
||||||
|
void static_vector<T, N>::clear(void)
|
||||||
|
{
|
||||||
|
T * data = (T*)_space;
|
||||||
|
for(size_t i=0; i<_size; i++)
|
||||||
|
data[i].~T();
|
||||||
|
_size = 0;
|
||||||
|
}
|
||||||
|
|
||||||
template <class T, int N>
|
template <class T, int N>
|
||||||
void static_vector<T, N>::resize(size_t n)
|
void static_vector<T, N>::resize(size_t n)
|
||||||
{
|
{
|
||||||
|
#ifdef CAPACITYCHECK
|
||||||
|
if (n > N) debugcrash();
|
||||||
|
#endif
|
||||||
T * data = (T*)_space;
|
T * data = (T*)_space;
|
||||||
if (n < _size)
|
if (n < _size)
|
||||||
{
|
{
|
||||||
for(size_t i=n; i<_size; i++)
|
for(size_t i=n; i<_size; i++)
|
||||||
data[i].~T();
|
data[i].~T();
|
||||||
_size = n;
|
|
||||||
}
|
}
|
||||||
else
|
else if (n > 0)
|
||||||
{
|
{
|
||||||
for(size_t i=_size; i<n; i++)
|
for(size_t i=_size; i<n; i++)
|
||||||
new(data + i)T;
|
new(data + i)T();
|
||||||
_size = n;
|
|
||||||
}
|
}
|
||||||
|
_size = n;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T, int N>
|
template <class T, int N>
|
||||||
void static_vector<T, N>::push_back(const T & t)
|
void static_vector<T, N>::push_back(const T & t)
|
||||||
{
|
{
|
||||||
|
#ifdef CAPACITYCHECK
|
||||||
|
if (_size >= N) debugcrash();
|
||||||
|
#endif
|
||||||
new ((T*)_space + _size++)T(t);
|
new ((T*)_space + _size++)T(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T, int N>
|
template <class T, int N>
|
||||||
void static_vector<T, N>::push_back(T && t)
|
void static_vector<T, N>::push_back(T && t)
|
||||||
{
|
{
|
||||||
|
#ifdef CAPACITYCHECK
|
||||||
|
if (_size >= N) debugcrash();
|
||||||
|
#endif
|
||||||
new ((T*)_space + _size++)T(t);
|
new ((T*)_space + _size++)T(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -212,14 +245,28 @@ template <class T, int N>
|
||||||
template <typename ...P>
|
template <typename ...P>
|
||||||
void static_vector<T, N>::emplace_back(const P&... p)
|
void static_vector<T, N>::emplace_back(const P&... p)
|
||||||
{
|
{
|
||||||
|
#ifdef CAPACITYCHECK
|
||||||
|
if (_size >= N) debugcrash();
|
||||||
|
#endif
|
||||||
new ((T*)_space + _size++)T(p...);
|
new ((T*)_space + _size++)T(p...);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <class T, int N>
|
||||||
|
void static_vector<T, N>::assign(size_t count, const T & t)
|
||||||
|
{
|
||||||
|
T * data = (T*)_space;
|
||||||
|
for(size_t i=0; i<_size; i++)
|
||||||
|
data[i].~T();
|
||||||
|
for(size_t i=0; i<count; i++)
|
||||||
|
new (data + i)T(t);
|
||||||
|
_size = count;
|
||||||
|
}
|
||||||
|
|
||||||
template <class T, int N>
|
template <class T, int N>
|
||||||
void static_vector<T, N>::insert(size_t at, const T & t)
|
void static_vector<T, N>::insert(size_t at, const T & t)
|
||||||
{
|
{
|
||||||
T * data = (T*)_space;
|
T * data = (T*)_space;
|
||||||
new (data + _size)T;
|
new (data + _size)T();
|
||||||
for(size_t i=_size; i>at; i--)
|
for(size_t i=_size; i>at; i--)
|
||||||
data[i] = move(data[i - 1]);
|
data[i] = move(data[i - 1]);
|
||||||
data[at] = t;
|
data[at] = t;
|
||||||
|
@ -240,9 +287,12 @@ void static_vector<T, N>::erase(size_t at, size_t n)
|
||||||
template <class T, int N>
|
template <class T, int N>
|
||||||
T * static_vector<T, N>::insert(T * at, const T & t)
|
T * static_vector<T, N>::insert(T * at, const T & t)
|
||||||
{
|
{
|
||||||
|
#ifdef CAPACITYCHECK
|
||||||
|
if (_size >= N) debugcrash();
|
||||||
|
#endif
|
||||||
T * data = (T*)_space;
|
T * data = (T*)_space;
|
||||||
T * dp = data + _size;
|
T * dp = data + _size;
|
||||||
new (dp)T;
|
new (dp)T();
|
||||||
while (dp != at)
|
while (dp != at)
|
||||||
{
|
{
|
||||||
dp--;
|
dp--;
|
||||||
|
|
|
@ -21,13 +21,14 @@ public:
|
||||||
vector(size_t n) : _data((T*)malloc(n * sizeof(T))), _size(n), _capacity(n)
|
vector(size_t n) : _data((T*)malloc(n * sizeof(T))), _size(n), _capacity(n)
|
||||||
{
|
{
|
||||||
for(size_t i=0; i<n; i++)
|
for(size_t i=0; i<n; i++)
|
||||||
new (_data + i) T;
|
new (_data + i) T();
|
||||||
}
|
}
|
||||||
|
|
||||||
vector(const vector & v)
|
vector(const vector & v)
|
||||||
: _data((T*)malloc(v._size * sizeof(T))), _size(v._size), _capacity(v._size)
|
: _data((T*)malloc(v._size * sizeof(T))), _size(v._size), _capacity(v._size)
|
||||||
{
|
{
|
||||||
for(size_t i=0; i<_size; i++)
|
size_t n = _size;
|
||||||
|
for(size_t i=0; i<n; i++)
|
||||||
new (_data + i)T(v._data[i]);
|
new (_data + i)T(v._data[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,14 +51,16 @@ public:
|
||||||
{
|
{
|
||||||
if (this != &v)
|
if (this != &v)
|
||||||
{
|
{
|
||||||
for(size_t i=0; i<_size; i++)
|
size_t n = _size;
|
||||||
|
for(size_t i=0; i<n; i++)
|
||||||
_data[i].~T();
|
_data[i].~T();
|
||||||
free(_data);
|
free(_data);
|
||||||
|
|
||||||
_data = (T*)malloc(v._size * sizeof(T));
|
_data = (T*)malloc(v._size * sizeof(T));
|
||||||
_size = v._size;
|
_size = v._size;
|
||||||
_capacity = v._size;
|
_capacity = v._size;
|
||||||
for(size_t i=0; i<_size; i++)
|
n = _size;
|
||||||
|
for(size_t i=0; i<n; i++)
|
||||||
new (_data + i)T(v._data[i]);
|
new (_data + i)T(v._data[i]);
|
||||||
}
|
}
|
||||||
return *this;
|
return *this;
|
||||||
|
@ -94,6 +97,8 @@ public:
|
||||||
return _capacity;
|
return _capacity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void clear(void);
|
||||||
|
|
||||||
void resize(size_t n);
|
void resize(size_t n);
|
||||||
|
|
||||||
void reserve(size_t n);
|
void reserve(size_t n);
|
||||||
|
@ -190,6 +195,8 @@ public:
|
||||||
_data[_size].~T();
|
_data[_size].~T();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void assign(size_t count, const T & t);
|
||||||
|
|
||||||
void insert(size_t at, const T & t);
|
void insert(size_t at, const T & t);
|
||||||
|
|
||||||
void erase(size_t at, size_t n = 1);
|
void erase(size_t at, size_t n = 1);
|
||||||
|
@ -204,7 +211,7 @@ protected:
|
||||||
|
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
void vector<T>::reserve(size_t n)
|
__noinline void vector<T>::reserve(size_t n)
|
||||||
{
|
{
|
||||||
if (n > _capacity)
|
if (n > _capacity)
|
||||||
{
|
{
|
||||||
|
@ -221,7 +228,15 @@ void vector<T>::reserve(size_t n)
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
void vector<T>::resize(size_t n)
|
void vector<T>::clear(void)
|
||||||
|
{
|
||||||
|
for(size_t i=0; i<_size; i++)
|
||||||
|
_data[i].~T();
|
||||||
|
_size = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
__noinline void vector<T>::resize(size_t n)
|
||||||
{
|
{
|
||||||
if (n < _size)
|
if (n < _size)
|
||||||
{
|
{
|
||||||
|
@ -232,7 +247,7 @@ void vector<T>::resize(size_t n)
|
||||||
else if (n < _capacity)
|
else if (n < _capacity)
|
||||||
{
|
{
|
||||||
for(size_t i=_size; i<n; i++)
|
for(size_t i=_size; i<n; i++)
|
||||||
new(_data + i)T;
|
new(_data + i)T();
|
||||||
_size = n;
|
_size = n;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -286,12 +301,27 @@ void vector<T>::emplace_back(const P&... p)
|
||||||
new (add_back())T(p...);
|
new (add_back())T(p...);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
void vector<T>::assign(size_t count, const T & t)
|
||||||
|
{
|
||||||
|
for(size_t i=0; i<_size; i++)
|
||||||
|
_data[i].~T();
|
||||||
|
if (count > _capacity)
|
||||||
|
{
|
||||||
|
_size = 0;
|
||||||
|
reserve(count);
|
||||||
|
}
|
||||||
|
for(size_t i=0; i<count; i++)
|
||||||
|
new (_data + i)T(t);
|
||||||
|
_size = count;
|
||||||
|
}
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
void vector<T>::insert(size_t at, const T & t)
|
void vector<T>::insert(size_t at, const T & t)
|
||||||
{
|
{
|
||||||
if (_size == _capacity)
|
if (_size == _capacity)
|
||||||
reserve(_size + 1 + (_size >> 1));
|
reserve(_size + 1 + (_size >> 1));
|
||||||
new (_data + _size)T;
|
new (_data + _size)T();
|
||||||
for(size_t i=_size; i>at; i--)
|
for(size_t i=_size; i>at; i--)
|
||||||
_data[i] = move(_data[i - 1]);
|
_data[i] = move(_data[i - 1]);
|
||||||
_data[at] = t;
|
_data[at] = t;
|
||||||
|
@ -318,7 +348,7 @@ T * vector<T>::insert(T * at, const T & t)
|
||||||
at = (T *)(f + unsigned(_data));
|
at = (T *)(f + unsigned(_data));
|
||||||
}
|
}
|
||||||
T * dp = _data + _size;
|
T * dp = _data + _size;
|
||||||
new (dp)T;
|
new (dp)T();
|
||||||
while (dp != at)
|
while (dp != at)
|
||||||
{
|
{
|
||||||
dp--;
|
dp--;
|
||||||
|
|
|
@ -129,3 +129,10 @@ __native const char * oscar_expand_lzo_buf(char * dp, const char * sp)
|
||||||
|
|
||||||
return sp + 1;
|
return sp + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void debugcrash(void)
|
||||||
|
{
|
||||||
|
__asm volatile {
|
||||||
|
byt $02
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -18,6 +18,8 @@ void breakpoint(void);
|
||||||
|
|
||||||
#pragma intrinsic(breakpoint)
|
#pragma intrinsic(breakpoint)
|
||||||
|
|
||||||
|
void debugcrash(void);
|
||||||
|
|
||||||
#pragma compile("oscar.c")
|
#pragma compile("oscar.c")
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -556,6 +556,17 @@ int sprintf(char * str, const char * fmt, ...)
|
||||||
return d - str;
|
return d - str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void vprintf(const char * fmt, va_list vlist)
|
||||||
|
{
|
||||||
|
char buff[50];
|
||||||
|
sformat(buff, fmt, (int *)vlist, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
int vsprintf(char * str, const char * fmt, va_list vlist)
|
||||||
|
{
|
||||||
|
char * d = sformat(str, fmt, (int *)vlist, false);
|
||||||
|
return d - str;
|
||||||
|
}
|
||||||
|
|
||||||
static inline bool isspace(char c)
|
static inline bool isspace(char c)
|
||||||
{
|
{
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
|
||||||
void putchar(char c);
|
void putchar(char c);
|
||||||
|
|
||||||
|
@ -18,6 +19,10 @@ void printf(const char * fmt, ...);
|
||||||
|
|
||||||
int sprintf(char * str, const char * fmt, ...);
|
int sprintf(char * str, const char * fmt, ...);
|
||||||
|
|
||||||
|
void vprintf(const char * fmt, va_list vlist);
|
||||||
|
|
||||||
|
int vsprintf(char * str, const char * fmt, va_list vlist);
|
||||||
|
|
||||||
int scanf(const char * fmt, ...);
|
int scanf(const char * fmt, ...);
|
||||||
|
|
||||||
int sscanf(const char * str, const char * fmt, ...);
|
int sscanf(const char * str, const char * fmt, ...);
|
||||||
|
|
|
@ -544,7 +544,7 @@ unsigned heapfree(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
struct Heap {
|
struct Heap {q
|
||||||
unsigned int size;
|
unsigned int size;
|
||||||
Heap * next;
|
Heap * next;
|
||||||
} * freeHeap;
|
} * freeHeap;
|
||||||
|
@ -667,6 +667,97 @@ void * calloc(int num, int size)
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void * realloc(void * ptr, unsigned size)
|
||||||
|
{
|
||||||
|
if (ptr)
|
||||||
|
{
|
||||||
|
#ifdef HEAPCHECK
|
||||||
|
Heap * pheap = (Heap *)((char *)ptr - 6);
|
||||||
|
Heap * eheap = pheap->next;
|
||||||
|
|
||||||
|
unsigned psize = (char *)eheap - (char *)pheap;
|
||||||
|
|
||||||
|
void * nptr = malloc(size);
|
||||||
|
memcpy(nptr, ptr, psize - 6);
|
||||||
|
free(ptr);
|
||||||
|
return nptr;
|
||||||
|
#else
|
||||||
|
unsigned nsize = (size + 5) & ~3;
|
||||||
|
|
||||||
|
// Get heap info
|
||||||
|
Heap * pheap = (Heap *)((char *)ptr - 2);
|
||||||
|
Heap * eheap = pheap->next;
|
||||||
|
|
||||||
|
unsigned psize = (char *)eheap - (char *)pheap;
|
||||||
|
|
||||||
|
Heap * h = HeapNode.next;
|
||||||
|
Heap * hp = &HeapNode;
|
||||||
|
while (h && h < pheap)
|
||||||
|
{
|
||||||
|
hp = h;
|
||||||
|
h = h->next;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nsize <= psize)
|
||||||
|
{
|
||||||
|
// check if we should free some memory
|
||||||
|
if (nsize + sizeof(HeapNode) < psize)
|
||||||
|
{
|
||||||
|
Heap * nheap = (Heap *)((char *)pheap + nsize);
|
||||||
|
pheap->next = nheap;
|
||||||
|
|
||||||
|
if (h == eheap)
|
||||||
|
{
|
||||||
|
nheap->end = h->end;
|
||||||
|
nheap->next = h->next;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
nheap->end = eheap;
|
||||||
|
nheap->next = h;
|
||||||
|
}
|
||||||
|
|
||||||
|
hp->next = nheap;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ptr;
|
||||||
|
}
|
||||||
|
else if (h == eheap)
|
||||||
|
{
|
||||||
|
// Free space after this
|
||||||
|
|
||||||
|
// Check if enough space if extending
|
||||||
|
unsigned xsize = (char *)h->end - (char *)pheap;
|
||||||
|
if (xsize >= nsize)
|
||||||
|
{
|
||||||
|
if (xsize > nsize + sizeof(HeapNode))
|
||||||
|
{
|
||||||
|
Heap * nheap = (Heap *)((char *)pheap + nsize);
|
||||||
|
pheap->next = nheap;
|
||||||
|
nheap->end = h->end;
|
||||||
|
nheap->next = h->next;
|
||||||
|
hp->next = nheap;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pheap->next = h->end;
|
||||||
|
hp->next = h->next;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void * nptr = malloc(size);
|
||||||
|
memcpy(nptr, ptr, psize - 2);
|
||||||
|
free(ptr);
|
||||||
|
return nptr;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return malloc(size);
|
||||||
|
}
|
||||||
|
|
||||||
static unsigned seed = 31232;
|
static unsigned seed = 31232;
|
||||||
|
|
||||||
unsigned int rand(void)
|
unsigned int rand(void)
|
||||||
|
|
|
@ -45,6 +45,8 @@ void free(void * ptr);
|
||||||
|
|
||||||
void * calloc(int num, int size);
|
void * calloc(int num, int size);
|
||||||
|
|
||||||
|
void * realloc(void * ptr, unsigned size);
|
||||||
|
|
||||||
unsigned heapfree(void);
|
unsigned heapfree(void);
|
||||||
|
|
||||||
unsigned int rand(void);
|
unsigned int rand(void);
|
||||||
|
|
|
@ -38,7 +38,7 @@ else
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
||||||
all: --prep-build-dir compiler samples tests
|
all: compiler samples check
|
||||||
|
|
||||||
|
|
||||||
$(srcdir)/%.o: $(project_dir)/oscar64/%.cpp
|
$(srcdir)/%.o: $(project_dir)/oscar64/%.cpp
|
||||||
|
@ -56,7 +56,7 @@ $(srcdir)/%.d: $(project_dir)/oscar64/%.cpp
|
||||||
$(RM) $@.$$$$
|
$(RM) $@.$$$$
|
||||||
|
|
||||||
|
|
||||||
compiler: $(objects)
|
compiler: --prep-build-dir $(objects)
|
||||||
@$(MKDIR_PARENT) $(srcdir)
|
@$(MKDIR_PARENT) $(srcdir)
|
||||||
@echo "Linking compiler..."
|
@echo "Linking compiler..."
|
||||||
$(CXX) $(CPPFLAGS) $(objects) $(linklibs) -o $(project_dir)/bin/oscar64
|
$(CXX) $(CPPFLAGS) $(objects) $(linklibs) -o $(project_dir)/bin/oscar64
|
||||||
|
@ -85,7 +85,7 @@ samples: compiler
|
||||||
@$(MAKE) -C $(project_dir)/samples all
|
@$(MAKE) -C $(project_dir)/samples all
|
||||||
|
|
||||||
|
|
||||||
tests: compiler
|
check: compiler
|
||||||
@$(MAKE) -C $(project_dir)/autotest all
|
@$(MAKE) -C $(project_dir)/autotest all
|
||||||
|
|
||||||
install: compiler
|
install: compiler
|
||||||
|
@ -93,16 +93,16 @@ install: compiler
|
||||||
@$(MKDIR_PARENT) $(DESTDIR)$(bindir)
|
@$(MKDIR_PARENT) $(DESTDIR)$(bindir)
|
||||||
$(INSTALL_PROGRAM) $(project_dir)/bin/oscar64 $(DESTDIR)$(bindir)
|
$(INSTALL_PROGRAM) $(project_dir)/bin/oscar64 $(DESTDIR)$(bindir)
|
||||||
@$(MKDIR_PARENT) $(DESTDIR)$(includedir)/oscar64/{audio,c64,c128,cx16,gfx,nes,opp,plus4,vic20}
|
@$(MKDIR_PARENT) $(DESTDIR)$(includedir)/oscar64/{audio,c64,c128,cx16,gfx,nes,opp,plus4,vic20}
|
||||||
$(INSTALL_DATA) $(project_dir)/include/*.{h,c} $(DESTDIR)$(includedir)/oscar64
|
$(INSTALL_DATA) $(wildcard $(project_dir)/include/*.h $(project_dir)/include/*.c) $(DESTDIR)$(includedir)/oscar64
|
||||||
$(INSTALL_DATA) $(project_dir)/include/audio/*.{h,c} $(DESTDIR)$(includedir)/oscar64/audio
|
$(INSTALL_DATA) $(wildcard $(project_dir)/include/audio/*.h $(project_dir)/include/audio/*.c) $(DESTDIR)$(includedir)/oscar64/audio
|
||||||
$(INSTALL_DATA) $(project_dir)/include/c64/*.{h,c} $(DESTDIR)$(includedir)/oscar64/c64
|
$(INSTALL_DATA) $(wildcard $(project_dir)/include/c64/*.h $(project_dir)/include/c64/*.c) $(DESTDIR)$(includedir)/oscar64/c64
|
||||||
$(INSTALL_DATA) $(project_dir)/include/c128/*.{h,c} $(DESTDIR)$(includedir)/oscar64/c128
|
$(INSTALL_DATA) $(wildcard $(project_dir)/include/c128/*.h $(project_dir)/include/c128/*.c) $(DESTDIR)$(includedir)/oscar64/c128
|
||||||
$(INSTALL_DATA) $(project_dir)/include/cx16/*.{h,c} $(DESTDIR)$(includedir)/oscar64/cx16
|
$(INSTALL_DATA) $(wildcard $(project_dir)/include/cx16/*.h $(project_dir)/include/cx16/*.c) $(DESTDIR)$(includedir)/oscar64/cx16
|
||||||
$(INSTALL_DATA) $(project_dir)/include/gfx/*.{h,c} $(DESTDIR)$(includedir)/oscar64/gfx
|
$(INSTALL_DATA) $(wildcard $(project_dir)/include/gfx/*.h $(project_dir)/include/gfx/*.c) $(DESTDIR)$(includedir)/oscar64/gfx
|
||||||
$(INSTALL_DATA) $(project_dir)/include/nes/*.{h,c} $(DESTDIR)$(includedir)/oscar64/nes
|
$(INSTALL_DATA) $(wildcard $(project_dir)/include/nes/*.h $(project_dir)/include/nes/*.c) $(DESTDIR)$(includedir)/oscar64/nes
|
||||||
$(INSTALL_DATA) $(project_dir)/include/opp/*.{h,cpp} $(DESTDIR)$(includedir)/oscar64/opp
|
$(INSTALL_DATA) $(wildcard $(project_dir)/include/opp/*.h $(project_dir)/include/opp/*.cpp) $(DESTDIR)$(includedir)/oscar64/opp
|
||||||
$(INSTALL_DATA) $(project_dir)/include/plus4/*.{h,c} $(DESTDIR)$(includedir)/oscar64/plus4
|
$(INSTALL_DATA) $(wildcard $(project_dir)/include/plus4/*.h $(project_dir)/include/plus4/*.c) $(DESTDIR)$(includedir)/oscar64/plus4
|
||||||
$(INSTALL_DATA) $(project_dir)/include/vic20/*.{h,c} $(DESTDIR)$(includedir)/oscar64/vic20
|
$(INSTALL_DATA) $(wildcard $(project_dir)/include/vic20/*.h $(project_dir)/include/vic20/*.c) $(DESTDIR)$(includedir)/oscar64/vic20
|
||||||
|
|
||||||
|
|
||||||
uninstall:
|
uninstall:
|
||||||
|
|
21
oscar64.md
21
oscar64.md
|
@ -28,7 +28,7 @@ In the end, it turned out that the native code is not only significantly faster
|
||||||
|
|
||||||
## Limits and Errors
|
## Limits and Errors
|
||||||
|
|
||||||
There are still several open areas, but most targets have been reached. The current Dhrystone performance is 94 iterations per second with byte code (10993) and 405 iterations with native code (9173 Bytes). This clearly shows that Dhrystone is not a valid benchmark for optimizing compilers, because it puts the 6502 on par with a 4MHz 8088 or 68k, which it clearly is not.
|
There are still several open areas, but most targets have been reached. The current Dhrystone performance is 94 iterations per second with byte code (10993) and 442 iterations with native code (8952 Bytes). This clearly shows that Dhrystone is not a valid benchmark for optimizing compilers, because it puts the 6502 on par with a 4MHz 8088 or 68k, which it clearly is not.
|
||||||
|
|
||||||
### Language
|
### Language
|
||||||
|
|
||||||
|
@ -110,6 +110,7 @@ The compiler is command line driven, and creates an executable .prg file.
|
||||||
* -v : verbose output for diagnostics
|
* -v : verbose output for diagnostics
|
||||||
* -v2 : more verbose output
|
* -v2 : more verbose output
|
||||||
* -i : additional include paths
|
* -i : additional include paths
|
||||||
|
* -ii : set default include path
|
||||||
* -o : optional output file name
|
* -o : optional output file name
|
||||||
* -rt : alternative runtime library, replaces the crt.c (or empty for none)
|
* -rt : alternative runtime library, replaces the crt.c (or empty for none)
|
||||||
* -e : execute the result in the integrated emulator
|
* -e : execute the result in the integrated emulator
|
||||||
|
@ -129,6 +130,7 @@ The compiler is command line driven, and creates an executable .prg file.
|
||||||
* -Oz : enable auto placement of global variables in zero page (part of O3)
|
* -Oz : enable auto placement of global variables in zero page (part of O3)
|
||||||
* -Op : optimize constant parameters
|
* -Op : optimize constant parameters
|
||||||
* -Oo : optimize size using "outliner" (extract repeated code sequences into functions)
|
* -Oo : optimize size using "outliner" (extract repeated code sequences into functions)
|
||||||
|
* -Ox : optimize pointer arithmetic by blocking shorter arrays to not cross page boundaries
|
||||||
* -g : create source level debug info and add source line numbers to asm listing
|
* -g : create source level debug info and add source line numbers to asm listing
|
||||||
* -gp : create source level debug info and add source line numbers to asm listing and static profile data
|
* -gp : create source level debug info and add source line numbers to asm listing and static profile data
|
||||||
* -tf : target format, may be prg, crt or bin
|
* -tf : target format, may be prg, crt or bin
|
||||||
|
@ -175,6 +177,7 @@ A list of source files can be provided.
|
||||||
* nes_mmc3 : Nintendo entertainment system, MMC3, 512K PROM, 256K CROM
|
* nes_mmc3 : Nintendo entertainment system, MMC3, 512K PROM, 256K CROM
|
||||||
* atari : Atari 8bit systems, (0x2000..0xbc00)
|
* atari : Atari 8bit systems, (0x2000..0xbc00)
|
||||||
* x16 : Commander X16, (0x0800..0x9f00)
|
* x16 : Commander X16, (0x0800..0x9f00)
|
||||||
|
* mega65 : Mega 65, (0x2000..0xc000)
|
||||||
|
|
||||||
### C64 Cartridge formats
|
### C64 Cartridge formats
|
||||||
|
|
||||||
|
@ -334,6 +337,17 @@ The .asm file is a great resource when debugging from within e.g. the VICE monit
|
||||||
|
|
||||||
The compiler has various extensions to simplify developing for the C64.
|
The compiler has various extensions to simplify developing for the C64.
|
||||||
|
|
||||||
|
## Pragmas
|
||||||
|
|
||||||
|
Warnings can be turned on or off using the warning pragma. The scope of the pragma is currently global in most cases, so if it is turned off at some place, it is off everywhere.
|
||||||
|
|
||||||
|
#pragma warning(disable: 2000,2001)
|
||||||
|
|
||||||
|
A message can be displayed during compilation with the message pragma
|
||||||
|
|
||||||
|
#pragma message("Hello User")
|
||||||
|
|
||||||
|
|
||||||
## Embedding binary data
|
## Embedding binary data
|
||||||
|
|
||||||
The compiler supports the #embed preprocessor directive to import binary data. It converts a section of an external binary file into a sequence of numbers that can be placed into an initializer of an array.
|
The compiler supports the #embed preprocessor directive to import binary data. It converts a section of an external binary file into a sequence of numbers that can be placed into an initializer of an array.
|
||||||
|
@ -737,6 +751,11 @@ Regions can also be used to place assets such as character sets at fixed locatio
|
||||||
|
|
||||||
The #pragma data(), #pragma code() and #pragma bss() control the placement of the generated objects into sections other than the default sections.
|
The #pragma data(), #pragma code() and #pragma bss() control the placement of the generated objects into sections other than the default sections.
|
||||||
|
|
||||||
|
A global variable or function can be aligned on a given power of two start with the align pragma. This is most useful if a page crossing is problematic. The compiler may also be able to generate more efficient code, if a larger variable is page aligned.
|
||||||
|
|
||||||
|
#pragma align(myvar, 8)
|
||||||
|
#pragma align(myfunc, 256)
|
||||||
|
|
||||||
### Additional BSS sections
|
### Additional BSS sections
|
||||||
|
|
||||||
Additional bss sections can be defined on request.
|
Additional bss sections can be defined on request.
|
||||||
|
|
|
@ -421,11 +421,13 @@ protected:
|
||||||
array = a2;
|
array = a2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (int i = size; i < to; i++) array[i] = T{};
|
||||||
|
|
||||||
size = to;
|
size = to;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename F>
|
template<typename F>
|
||||||
void Parition(const F & f, int l, int r)
|
void Partition(const F & f, int l, int r)
|
||||||
{
|
{
|
||||||
if (r > l + 1)
|
if (r > l + 1)
|
||||||
{
|
{
|
||||||
|
@ -442,8 +444,8 @@ protected:
|
||||||
}
|
}
|
||||||
array[pi] = p;
|
array[pi] = p;
|
||||||
|
|
||||||
Parition(f, l, pi);
|
Partition(f, l, pi);
|
||||||
Parition(f, pi + 1, r);
|
Partition(f, pi + 1, r);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public:
|
public:
|
||||||
|
@ -618,10 +620,22 @@ public:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Fill(const T& t)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < size; i++)
|
||||||
|
array[i] = t;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Clear(void)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < size; i++)
|
||||||
|
array[i] = T{};
|
||||||
|
}
|
||||||
|
|
||||||
template<typename F>
|
template<typename F>
|
||||||
void Sort(const F & f)
|
void Sort(const F & f)
|
||||||
{
|
{
|
||||||
Parition(f, 0, size);
|
Partition(f, 0, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
__forceinline T& operator[](int n)
|
__forceinline T& operator[](int n)
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
class BitVector
|
class BitVector
|
||||||
{
|
{
|
||||||
|
|
|
@ -3461,11 +3461,14 @@ ByteCode ByteCodeBasicBlock::RelationalOperator(InterCodeProcedure* proc, const
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (ins->mSrc[1].mTemp < 0)
|
if (ins->mSrc[1].mTemp < 0)
|
||||||
|
{
|
||||||
|
if (ins->mSrc[1].mType == IT_INT16 || ins->mSrc[1].mMemory == IM_ABSOLUTE)
|
||||||
{
|
{
|
||||||
ByteCodeInstruction lins(BC_LOAD_REG_16);
|
ByteCodeInstruction lins(BC_LOAD_REG_16);
|
||||||
lins.mRegister = BC_REG_TMP + proc->mTempOffset[ins->mSrc[0].mTemp];
|
lins.mRegister = BC_REG_TMP + proc->mTempOffset[ins->mSrc[0].mTemp];
|
||||||
lins.mRegisterFinal = ins->mSrc[0].mFinal;
|
lins.mRegisterFinal = ins->mSrc[0].mFinal;
|
||||||
mIns.Push(lins);
|
mIns.Push(lins);
|
||||||
|
|
||||||
if (csigned)
|
if (csigned)
|
||||||
{
|
{
|
||||||
ByteCodeInstruction cins(BC_BINOP_CMPSI_16);
|
ByteCodeInstruction cins(BC_BINOP_CMPSI_16);
|
||||||
|
@ -3479,7 +3482,36 @@ ByteCode ByteCodeBasicBlock::RelationalOperator(InterCodeProcedure* proc, const
|
||||||
mIns.Push(cins);
|
mIns.Push(cins);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ByteCodeInstruction bins(BC_LEA_ABS);
|
||||||
|
bins.mRegister = BC_REG_ACCU;
|
||||||
|
bins.mLinkerObject = ins->mSrc[1].mLinkerObject;
|
||||||
|
bins.mValue = int(ins->mSrc[1].mIntConst);
|
||||||
|
bins.mRelocate = true;
|
||||||
|
mIns.Push(bins);
|
||||||
|
|
||||||
|
if (csigned)
|
||||||
|
{
|
||||||
|
ByteCodeInstruction cins(BC_BINOP_CMPSR_16);
|
||||||
|
cins.mRegister = BC_REG_TMP + proc->mTempOffset[ins->mSrc[0].mTemp];
|
||||||
|
cins.mRegisterFinal = ins->mSrc[0].mFinal;
|
||||||
|
mIns.Push(cins);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ByteCodeInstruction cins(BC_BINOP_CMPUR_16);
|
||||||
|
cins.mRegister = BC_REG_TMP + proc->mTempOffset[ins->mSrc[0].mTemp];
|
||||||
|
cins.mRegisterFinal = ins->mSrc[0].mFinal;
|
||||||
|
mIns.Push(cins);
|
||||||
|
}
|
||||||
|
|
||||||
|
code = TransposeBranchCondition(code);
|
||||||
|
}
|
||||||
|
}
|
||||||
else if (ins->mSrc[0].mTemp < 0)
|
else if (ins->mSrc[0].mTemp < 0)
|
||||||
|
{
|
||||||
|
if (ins->mSrc[0].mType == IT_INT16 || ins->mSrc[0].mMemory == IM_ABSOLUTE)
|
||||||
{
|
{
|
||||||
ByteCodeInstruction lins(BC_LOAD_REG_16);
|
ByteCodeInstruction lins(BC_LOAD_REG_16);
|
||||||
lins.mRegister = BC_REG_TMP + proc->mTempOffset[ins->mSrc[1].mTemp];
|
lins.mRegister = BC_REG_TMP + proc->mTempOffset[ins->mSrc[1].mTemp];
|
||||||
|
@ -3552,6 +3584,31 @@ ByteCode ByteCodeBasicBlock::RelationalOperator(InterCodeProcedure* proc, const
|
||||||
code = TransposeBranchCondition(code);
|
code = TransposeBranchCondition(code);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
ByteCodeInstruction bins(BC_LEA_ABS);
|
||||||
|
bins.mRegister = BC_REG_ACCU;
|
||||||
|
bins.mLinkerObject = ins->mSrc[0].mLinkerObject;
|
||||||
|
bins.mValue = int(ins->mSrc[0].mIntConst);
|
||||||
|
bins.mRelocate = true;
|
||||||
|
mIns.Push(bins);
|
||||||
|
|
||||||
|
if (csigned)
|
||||||
|
{
|
||||||
|
ByteCodeInstruction cins(BC_BINOP_CMPSR_16);
|
||||||
|
cins.mRegister = BC_REG_TMP + proc->mTempOffset[ins->mSrc[1].mTemp];
|
||||||
|
cins.mRegisterFinal = ins->mSrc[1].mFinal;
|
||||||
|
mIns.Push(cins);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ByteCodeInstruction cins(BC_BINOP_CMPUR_16);
|
||||||
|
cins.mRegister = BC_REG_TMP + proc->mTempOffset[ins->mSrc[1].mTemp];
|
||||||
|
cins.mRegisterFinal = ins->mSrc[1].mFinal;
|
||||||
|
mIns.Push(cins);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
ByteCodeInstruction lins(BC_LOAD_REG_16);
|
ByteCodeInstruction lins(BC_LOAD_REG_16);
|
||||||
lins.mRegister = BC_REG_TMP + proc->mTempOffset[ins->mSrc[0].mTemp];
|
lins.mRegister = BC_REG_TMP + proc->mTempOffset[ins->mSrc[0].mTemp];
|
||||||
|
|
|
@ -523,6 +523,12 @@ bool Compiler::GenerateCode(void)
|
||||||
{
|
{
|
||||||
switch (mTargetMachine)
|
switch (mTargetMachine)
|
||||||
{
|
{
|
||||||
|
case TMACH_MEGA65:
|
||||||
|
if (mCompilerOptions & COPT_NATIVE)
|
||||||
|
regionStartup = mLinker->AddRegion(identStartup, 0x2001, 0x2080);
|
||||||
|
else
|
||||||
|
regionStartup = mLinker->AddRegion(identStartup, 0x2001, 0x2100);
|
||||||
|
break;
|
||||||
case TMACH_C64:
|
case TMACH_C64:
|
||||||
case TMACH_X16:
|
case TMACH_X16:
|
||||||
if (mCompilerOptions & COPT_NATIVE)
|
if (mCompilerOptions & COPT_NATIVE)
|
||||||
|
@ -625,6 +631,9 @@ bool Compiler::GenerateCode(void)
|
||||||
{
|
{
|
||||||
switch (mTargetMachine)
|
switch (mTargetMachine)
|
||||||
{
|
{
|
||||||
|
case TMACH_MEGA65:
|
||||||
|
regionBytecode = mLinker->AddRegion(identBytecode, 0x2100, 0x2200);
|
||||||
|
break;
|
||||||
case TMACH_C64:
|
case TMACH_C64:
|
||||||
case TMACH_X16:
|
case TMACH_X16:
|
||||||
regionBytecode = mLinker->AddRegion(identBytecode, 0x0900, 0x0a00);
|
regionBytecode = mLinker->AddRegion(identBytecode, 0x0900, 0x0a00);
|
||||||
|
@ -686,6 +695,9 @@ bool Compiler::GenerateCode(void)
|
||||||
{
|
{
|
||||||
switch (mTargetMachine)
|
switch (mTargetMachine)
|
||||||
{
|
{
|
||||||
|
case TMACH_MEGA65:
|
||||||
|
regionMain = mLinker->AddRegion(identMain, 0x2300, 0xc000);
|
||||||
|
break;
|
||||||
case TMACH_C64:
|
case TMACH_C64:
|
||||||
regionMain = mLinker->AddRegion(identMain, 0x0a00, 0xa000);
|
regionMain = mLinker->AddRegion(identMain, 0x0a00, 0xa000);
|
||||||
break;
|
break;
|
||||||
|
@ -737,6 +749,14 @@ bool Compiler::GenerateCode(void)
|
||||||
{
|
{
|
||||||
switch (mTargetMachine)
|
switch (mTargetMachine)
|
||||||
{
|
{
|
||||||
|
case TMACH_MEGA65:
|
||||||
|
// TODO: Disable M65 cartridges for now.
|
||||||
|
//
|
||||||
|
// if (mCompilerOptions & (COPT_TARGET_CRT8 | COPT_TARGET_CRT16))
|
||||||
|
// regionMain = mLinker->AddRegion(identMain, 0x2666, 0xff00);
|
||||||
|
// else
|
||||||
|
regionMain = mLinker->AddRegion(identMain, 0x2080, 0xc000);
|
||||||
|
break;
|
||||||
case TMACH_C64:
|
case TMACH_C64:
|
||||||
|
|
||||||
if (mCompilerOptions & (COPT_TARGET_CRT8 | COPT_TARGET_CRT16))
|
if (mCompilerOptions & (COPT_TARGET_CRT8 | COPT_TARGET_CRT16))
|
||||||
|
@ -1045,7 +1065,10 @@ bool Compiler::GenerateCode(void)
|
||||||
for (int i = 0; i < mNativeCodeGenerator->mProcedures.Size(); i++)
|
for (int i = 0; i < mNativeCodeGenerator->mProcedures.Size(); i++)
|
||||||
{
|
{
|
||||||
if (mCompilerOptions & COPT_VERBOSE2)
|
if (mCompilerOptions & COPT_VERBOSE2)
|
||||||
|
{
|
||||||
|
if (mNativeCodeGenerator->mProcedures[i]->mInterProc)
|
||||||
printf("Assemble native code <%s>\n", mNativeCodeGenerator->mProcedures[i]->mInterProc->mIdent->mString);
|
printf("Assemble native code <%s>\n", mNativeCodeGenerator->mProcedures[i]->mInterProc->mIdent->mString);
|
||||||
|
}
|
||||||
mNativeCodeGenerator->mProcedures[i]->Assemble();
|
mNativeCodeGenerator->mProcedures[i]->Assemble();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,7 @@ static const uint64 COPT_OPTIMIZE_CONST_PARAMS = 1ULL << 9;
|
||||||
static const uint64 COPT_OPTIMIZE_MERGE_CALLS = 1ULL << 10;
|
static const uint64 COPT_OPTIMIZE_MERGE_CALLS = 1ULL << 10;
|
||||||
static const uint64 COPT_OPTIMIZE_GLOBAL = 1ULL << 11;
|
static const uint64 COPT_OPTIMIZE_GLOBAL = 1ULL << 11;
|
||||||
static const uint64 COPT_OPTIMIZE_OUTLINE = 1ULL << 12;
|
static const uint64 COPT_OPTIMIZE_OUTLINE = 1ULL << 12;
|
||||||
|
static const uint64 COPT_OPTIMIZE_PAGE_CROSSING = 1ULL << 13;
|
||||||
|
|
||||||
static const uint64 COPT_OPTIMIZE_CODE_SIZE = 1ULL << 16;
|
static const uint64 COPT_OPTIMIZE_CODE_SIZE = 1ULL << 16;
|
||||||
static const uint64 COPT_NATIVE = 1ULL << 17;
|
static const uint64 COPT_NATIVE = 1ULL << 17;
|
||||||
|
@ -78,7 +79,8 @@ enum TargetMachine
|
||||||
TMACH_NES_MMC1,
|
TMACH_NES_MMC1,
|
||||||
TMACH_NES_MMC3,
|
TMACH_NES_MMC3,
|
||||||
TMACH_ATARI,
|
TMACH_ATARI,
|
||||||
TMACH_X16
|
TMACH_X16,
|
||||||
|
TMACH_MEGA65
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -651,6 +651,7 @@ Expression* ConstexprInterpreter::EvalConstructor(Expression* exp)
|
||||||
{
|
{
|
||||||
mProcType = exp->mLeft->mDecType;
|
mProcType = exp->mLeft->mDecType;
|
||||||
|
|
||||||
|
Expression* pex = exp->mRight;
|
||||||
Declaration* cdec = exp->mLeft->mDecType->mParams;
|
Declaration* cdec = exp->mLeft->mDecType->mParams;
|
||||||
|
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
|
@ -659,6 +660,28 @@ Expression* ConstexprInterpreter::EvalConstructor(Expression* exp)
|
||||||
mParams[pos].PutPtr(Value(&mResult));
|
mParams[pos].PutPtr(Value(&mResult));
|
||||||
pos = 2;
|
pos = 2;
|
||||||
|
|
||||||
|
if (pex->mType == EX_LIST)
|
||||||
|
pex = pex->mRight;
|
||||||
|
else
|
||||||
|
pex = nullptr;
|
||||||
|
cdec = cdec->mNext;
|
||||||
|
|
||||||
|
while (pex && pex->mType == EX_LIST)
|
||||||
|
{
|
||||||
|
if (!AddParam(pos, pex->mLeft, cdec))
|
||||||
|
return exp;
|
||||||
|
|
||||||
|
pex = pex->mRight;
|
||||||
|
if (cdec)
|
||||||
|
cdec = cdec->mNext;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pex)
|
||||||
|
{
|
||||||
|
if (!AddParam(pos, pex, cdec))
|
||||||
|
return exp;
|
||||||
|
}
|
||||||
|
|
||||||
mHeap = new ExpandingArray<Value*>();
|
mHeap = new ExpandingArray<Value*>();
|
||||||
|
|
||||||
Execute(exp->mLeft->mDecValue->mValue);
|
Execute(exp->mLeft->mDecValue->mValue);
|
||||||
|
@ -1174,6 +1197,26 @@ ConstexprInterpreter::Value ConstexprInterpreter::EvalCall(Expression* exp, Cons
|
||||||
mResult = Value(exp->mLocation, TheFloatTypeDeclaration);
|
mResult = Value(exp->mLocation, TheFloatTypeDeclaration);
|
||||||
mResult.PutFloat(::exp(mParams[0].GetFloat()));
|
mResult.PutFloat(::exp(mParams[0].GetFloat()));
|
||||||
}
|
}
|
||||||
|
else if (!strcmp(iname->mString, "sqrt"))
|
||||||
|
{
|
||||||
|
mResult = Value(exp->mLocation, TheFloatTypeDeclaration);
|
||||||
|
mResult.PutFloat(::sqrt(mParams[0].GetFloat()));
|
||||||
|
}
|
||||||
|
else if (!strcmp(iname->mString, "atan"))
|
||||||
|
{
|
||||||
|
mResult = Value(exp->mLocation, TheFloatTypeDeclaration);
|
||||||
|
mResult.PutFloat(::atan(mParams[0].GetFloat()));
|
||||||
|
}
|
||||||
|
else if (!strcmp(iname->mString, "atan2"))
|
||||||
|
{
|
||||||
|
mResult = Value(exp->mLocation, TheFloatTypeDeclaration);
|
||||||
|
mResult.PutFloat(::atan2(mParams[0].GetFloat(), mParams[1].GetFloat()));
|
||||||
|
}
|
||||||
|
else if (!strcmp(iname->mString, "pow"))
|
||||||
|
{
|
||||||
|
mResult = Value(exp->mLocation, TheFloatTypeDeclaration);
|
||||||
|
mResult.PutFloat(::pow(mParams[0].GetFloat(), mParams[1].GetFloat()));
|
||||||
|
}
|
||||||
else
|
else
|
||||||
mErrors->Error(exp->mLeft->mDecValue->mLocation, EERR_OBJECT_NOT_FOUND, "Unknown intrinsic function", iname);
|
mErrors->Error(exp->mLeft->mDecValue->mLocation, EERR_OBJECT_NOT_FOUND, "Unknown intrinsic function", iname);
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,6 +31,17 @@ DeclarationScope::~DeclarationScope(void)
|
||||||
delete[] mHash;
|
delete[] mHash;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DeclarationScope* DeclarationScope::Clone(void) const
|
||||||
|
{
|
||||||
|
DeclarationScope* scope = new DeclarationScope(mParent, mLevel, mName);
|
||||||
|
for (int i = 0; i < mHashSize; i++)
|
||||||
|
{
|
||||||
|
if (mHash[i].mIdent)
|
||||||
|
scope->Insert(mHash[i].mIdent, mHash[i].mDec);
|
||||||
|
}
|
||||||
|
return scope;
|
||||||
|
}
|
||||||
|
|
||||||
const Ident* DeclarationScope::Mangle(const Ident* ident) const
|
const Ident* DeclarationScope::Mangle(const Ident* ident) const
|
||||||
{
|
{
|
||||||
if (mName && ident)
|
if (mName && ident)
|
||||||
|
@ -145,7 +156,7 @@ void DeclarationScope::End(const Location& loc)
|
||||||
}
|
}
|
||||||
|
|
||||||
Expression::Expression(const Location& loc, ExpressionType type)
|
Expression::Expression(const Location& loc, ExpressionType type)
|
||||||
: mLocation(loc), mEndLocation(loc), mType(type), mLeft(nullptr), mRight(nullptr), mConst(false), mDecType(nullptr), mDecValue(nullptr), mToken(TK_NONE)
|
: mLocation(loc), mEndLocation(loc), mType(type), mLeft(nullptr), mRight(nullptr), mConst(false), mDecType(nullptr), mDecValue(nullptr), mToken(TK_NONE), mFlags(0)
|
||||||
{
|
{
|
||||||
static uint32 gUID = 0;
|
static uint32 gUID = 0;
|
||||||
mUID = gUID++;
|
mUID = gUID++;
|
||||||
|
@ -263,6 +274,9 @@ void Expression::Dump(int ident) const
|
||||||
case EX_FOR:
|
case EX_FOR:
|
||||||
printf("FOR");
|
printf("FOR");
|
||||||
break;
|
break;
|
||||||
|
case EX_FORBODY:
|
||||||
|
printf("FORBODY");
|
||||||
|
break;
|
||||||
case EX_DO:
|
case EX_DO:
|
||||||
printf("DO");
|
printf("DO");
|
||||||
break;
|
break;
|
||||||
|
@ -491,6 +505,15 @@ Expression* Expression::LogicInvertExpression(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Expression::ReplaceVariable(Declaration* pvar, Declaration* nvar)
|
||||||
|
{
|
||||||
|
if (mLeft) mLeft->ReplaceVariable(pvar, nvar);
|
||||||
|
if (mRight) mRight->ReplaceVariable(pvar, nvar);
|
||||||
|
|
||||||
|
if (mType == EX_VARIABLE && mDecValue == pvar)
|
||||||
|
mDecValue = nvar;
|
||||||
|
}
|
||||||
|
|
||||||
Expression* Expression::ToAlternateThis(Declaration* pthis, Declaration* nthis)
|
Expression* Expression::ToAlternateThis(Declaration* pthis, Declaration* nthis)
|
||||||
{
|
{
|
||||||
Expression* left = mLeft ? mLeft->ToAlternateThis(pthis, nthis) : nullptr;
|
Expression* left = mLeft ? mLeft->ToAlternateThis(pthis, nthis) : nullptr;
|
||||||
|
@ -1021,6 +1044,20 @@ Expression* Expression::ConstantFold(Errors * errors, LinkerSection * dataSectio
|
||||||
ex->mDecType = dec->mBase;
|
ex->mDecType = dec->mBase;
|
||||||
return ex;
|
return ex;
|
||||||
}
|
}
|
||||||
|
else if (mLeft->mDecValue->mType == DT_CONST_ADDRESS && mRight->mDecValue->mType == DT_CONST_ADDRESS && mToken == TK_SUB)
|
||||||
|
{
|
||||||
|
if (mLeft->mDecType->mType == DT_TYPE_POINTER && mRight->mDecType->mType == DT_TYPE_POINTER &&
|
||||||
|
mLeft->mDecType->mBase->IsConstSame(mRight->mDecType->mBase))
|
||||||
|
{
|
||||||
|
Expression* ex = new Expression(mLocation, EX_CONSTANT);
|
||||||
|
Declaration* dec = new Declaration(mLocation, DT_CONST_INTEGER);
|
||||||
|
dec->mBase = TheSignedIntTypeDeclaration;
|
||||||
|
dec->mInteger = (mLeft->mDecValue->mInteger - mRight->mDecValue->mInteger) / mLeft->mDecType->mBase->mSize;
|
||||||
|
ex->mDecValue = dec;
|
||||||
|
ex->mDecType = dec->mBase;
|
||||||
|
return ex;
|
||||||
|
}
|
||||||
|
}
|
||||||
#if 0
|
#if 0
|
||||||
else if (mLeft->mDecValue->mType == DT_CONST_POINTER && mRight->mDecValue->mType == DT_CONST_INTEGER && (mToken == TK_ADD || mToken == TK_SUB))
|
else if (mLeft->mDecValue->mType == DT_CONST_POINTER && mRight->mDecValue->mType == DT_CONST_INTEGER && (mToken == TK_ADD || mToken == TK_SUB))
|
||||||
{
|
{
|
||||||
|
@ -1156,7 +1193,7 @@ Expression* Expression::ConstantFold(Errors * errors, LinkerSection * dataSectio
|
||||||
return ex;
|
return ex;
|
||||||
}
|
}
|
||||||
else if (mType == EX_BINARY && mToken == TK_ADD && mLeft->mType == EX_VARIABLE && mLeft->mDecValue->mType == DT_VARIABLE && (mLeft->mDecValue->mFlags & DTF_CONST) &&
|
else if (mType == EX_BINARY && mToken == TK_ADD && mLeft->mType == EX_VARIABLE && mLeft->mDecValue->mType == DT_VARIABLE && (mLeft->mDecValue->mFlags & DTF_CONST) &&
|
||||||
mLeft->mDecValue && mRight->mDecValue && mLeft->mDecValue->mValue->mType == EX_CONSTANT &&
|
mLeft->mDecValue && mRight->mDecValue && mLeft->mDecValue->mValue && mLeft->mDecValue->mValue->mType == EX_CONSTANT &&
|
||||||
mLeft->mDecType->mType == DT_TYPE_POINTER && mRight->mType == EX_CONSTANT && mRight->mDecValue->mType == DT_CONST_INTEGER)
|
mLeft->mDecType->mType == DT_TYPE_POINTER && mRight->mType == EX_CONSTANT && mRight->mDecValue->mType == DT_CONST_INTEGER)
|
||||||
{
|
{
|
||||||
mLeft = mLeft->mDecValue->mValue;
|
mLeft = mLeft->mDecValue->mValue;
|
||||||
|
@ -1222,6 +1259,10 @@ Expression* Expression::ConstantFold(Errors * errors, LinkerSection * dataSectio
|
||||||
ex->mDecType = mDecType;
|
ex->mDecType = mDecType;
|
||||||
return ex;
|
return ex;
|
||||||
}
|
}
|
||||||
|
else if (mType == EX_VARIABLE && mDecType->IsSimpleType() && (mDecValue->mFlags & DTF_CONST) && mDecValue->mValue && mDecValue->mValue->mType == EX_INITIALIZATION && mDecValue->mValue->mRight->mType == EX_CONSTANT)
|
||||||
|
{
|
||||||
|
return mDecValue->mValue->mRight;
|
||||||
|
}
|
||||||
else if (mType == EX_CALL && mLeft->mType == EX_CONSTANT && (mLeft->mDecValue->mFlags & DTF_INTRINSIC) && mRight && mRight->mType == EX_CONSTANT)
|
else if (mType == EX_CALL && mLeft->mType == EX_CONSTANT && (mLeft->mDecValue->mFlags & DTF_INTRINSIC) && mRight && mRight->mType == EX_CONSTANT)
|
||||||
{
|
{
|
||||||
Declaration* decf = mLeft->mDecValue, * decp = mRight->mDecValue;
|
Declaration* decf = mLeft->mDecValue, * decp = mRight->mDecValue;
|
||||||
|
@ -1230,6 +1271,7 @@ Expression* Expression::ConstantFold(Errors * errors, LinkerSection * dataSectio
|
||||||
if (decp->mType == DT_CONST_FLOAT || decp->mType == DT_CONST_INTEGER)
|
if (decp->mType == DT_CONST_FLOAT || decp->mType == DT_CONST_INTEGER)
|
||||||
{
|
{
|
||||||
double d = decp->mType == DT_CONST_FLOAT ? decp->mNumber : decp->mInteger;
|
double d = decp->mType == DT_CONST_FLOAT ? decp->mNumber : decp->mInteger;
|
||||||
|
double e = 0.0;
|
||||||
|
|
||||||
bool check = false;
|
bool check = false;
|
||||||
|
|
||||||
|
@ -1249,6 +1291,10 @@ Expression* Expression::ConstantFold(Errors * errors, LinkerSection * dataSectio
|
||||||
d = log(d);
|
d = log(d);
|
||||||
else if (!strcmp(iname->mString, "exp"))
|
else if (!strcmp(iname->mString, "exp"))
|
||||||
d = exp(d);
|
d = exp(d);
|
||||||
|
else if (!strcmp(iname->mString, "sqrt"))
|
||||||
|
d = sqrt(d);
|
||||||
|
else if (!strcmp(iname->mString, "atan"))
|
||||||
|
d = atan(d);
|
||||||
else
|
else
|
||||||
return this;
|
return this;
|
||||||
|
|
||||||
|
@ -1261,6 +1307,36 @@ Expression* Expression::ConstantFold(Errors * errors, LinkerSection * dataSectio
|
||||||
return ex;
|
return ex;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (mType == EX_CALL && mLeft->mType == EX_CONSTANT && (mLeft->mDecValue->mFlags & DTF_INTRINSIC) && mRight &&
|
||||||
|
mRight->mType == EX_LIST && mRight->mLeft->mType == EX_CONSTANT && mRight->mRight->mType == EX_CONSTANT)
|
||||||
|
{
|
||||||
|
Declaration* decf = mLeft->mDecValue, * decp1 = mRight->mLeft->mDecValue, * decp2 = mRight->mRight->mDecValue;
|
||||||
|
const Ident* iname = decf->mQualIdent;
|
||||||
|
|
||||||
|
if ((decp1->mType == DT_CONST_FLOAT || decp1->mType == DT_CONST_INTEGER) &&
|
||||||
|
(decp2->mType == DT_CONST_FLOAT || decp2->mType == DT_CONST_INTEGER))
|
||||||
|
{
|
||||||
|
double d1 = decp1->mType == DT_CONST_FLOAT ? decp1->mNumber : decp1->mInteger;
|
||||||
|
double d2 = decp2->mType == DT_CONST_FLOAT ? decp2->mNumber : decp2->mInteger;
|
||||||
|
|
||||||
|
bool check = false;
|
||||||
|
|
||||||
|
if (!strcmp(iname->mString, "pow"))
|
||||||
|
d1 = pow(d1, d2);
|
||||||
|
else if (!strcmp(iname->mString, "atan2"))
|
||||||
|
d1 = atan2(d1, d2);
|
||||||
|
else
|
||||||
|
return this;
|
||||||
|
|
||||||
|
Expression* ex = new Expression(mLocation, EX_CONSTANT);
|
||||||
|
Declaration* dec = new Declaration(mLocation, DT_CONST_FLOAT);
|
||||||
|
dec->mBase = TheFloatTypeDeclaration;
|
||||||
|
dec->mNumber = d1;
|
||||||
|
ex->mDecValue = dec;
|
||||||
|
ex->mDecType = dec->mBase;
|
||||||
|
return ex;
|
||||||
|
}
|
||||||
|
}
|
||||||
else if (mType == EX_CALL && mLeft->mType == EX_CONSTANT && (mLeft->mDecValue->mFlags & DTF_CONSTEXPR) && dataSection)
|
else if (mType == EX_CALL && mLeft->mType == EX_CONSTANT && (mLeft->mDecValue->mFlags & DTF_CONSTEXPR) && dataSection)
|
||||||
{
|
{
|
||||||
ConstexprInterpreter cinter(mLocation, errors, dataSection);
|
ConstexprInterpreter cinter(mLocation, errors, dataSection);
|
||||||
|
@ -1285,6 +1361,7 @@ Declaration::Declaration(const Location& loc, DecType type)
|
||||||
mConst(nullptr), mMutable(nullptr), mVolatile(nullptr),
|
mConst(nullptr), mMutable(nullptr), mVolatile(nullptr),
|
||||||
mDefaultConstructor(nullptr), mDestructor(nullptr), mCopyConstructor(nullptr), mCopyAssignment(nullptr), mMoveConstructor(nullptr), mMoveAssignment(nullptr),
|
mDefaultConstructor(nullptr), mDestructor(nullptr), mCopyConstructor(nullptr), mCopyAssignment(nullptr), mMoveConstructor(nullptr), mMoveAssignment(nullptr),
|
||||||
mVectorConstructor(nullptr), mVectorDestructor(nullptr), mVectorCopyConstructor(nullptr), mVectorCopyAssignment(nullptr),
|
mVectorConstructor(nullptr), mVectorDestructor(nullptr), mVectorCopyConstructor(nullptr), mVectorCopyAssignment(nullptr),
|
||||||
|
mVectorMoveConstructor(nullptr), mVectorMoveAssignment(nullptr),
|
||||||
mVTable(nullptr), mTemplate(nullptr), mForwardParam(nullptr), mForwardCall(nullptr),
|
mVTable(nullptr), mTemplate(nullptr), mForwardParam(nullptr), mForwardCall(nullptr),
|
||||||
mVarIndex(-1), mLinkerObject(nullptr), mCallers(nullptr), mCalled(nullptr), mAlignment(1), mFriends(nullptr),
|
mVarIndex(-1), mLinkerObject(nullptr), mCallers(nullptr), mCalled(nullptr), mAlignment(1), mFriends(nullptr),
|
||||||
mInteger(0), mNumber(0), mMinValue(-0x80000000LL), mMaxValue(0x7fffffffLL), mFastCallBase(0), mFastCallSize(0), mStride(0), mStripe(1),
|
mInteger(0), mNumber(0), mMinValue(-0x80000000LL), mMaxValue(0x7fffffffLL), mFastCallBase(0), mFastCallSize(0), mStride(0), mStripe(1),
|
||||||
|
@ -1409,6 +1486,51 @@ Declaration* Declaration::ConstCast(Declaration* ntype)
|
||||||
pdec->mSize = 2;
|
pdec->mSize = 2;
|
||||||
return pdec;
|
return pdec;
|
||||||
}
|
}
|
||||||
|
else if (mType == DT_VARIABLE && mBase->mType == DT_TYPE_ARRAY)
|
||||||
|
{
|
||||||
|
Expression* ex = new Expression(mLocation, EX_VARIABLE);
|
||||||
|
ex->mDecType = mBase;
|
||||||
|
ex->mDecValue = this;
|
||||||
|
|
||||||
|
Declaration* pdec = this->Clone();
|
||||||
|
pdec->mType = DT_CONST_POINTER;
|
||||||
|
pdec->mValue = ex;
|
||||||
|
pdec->mBase = ntype;
|
||||||
|
pdec->mSize = 2;
|
||||||
|
|
||||||
|
return pdec;
|
||||||
|
}
|
||||||
|
else if (mType == DT_VARIABLE_REF)
|
||||||
|
{
|
||||||
|
Declaration* vtype = mBase->mBase;
|
||||||
|
while (vtype && vtype->mType == DT_TYPE_STRUCT)
|
||||||
|
{
|
||||||
|
Declaration* dec = vtype->mParams;
|
||||||
|
while (dec && dec->mOffset != mOffset)
|
||||||
|
dec = dec->mNext;
|
||||||
|
if (dec)
|
||||||
|
vtype = dec->mBase;
|
||||||
|
else
|
||||||
|
vtype = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (vtype && vtype->mType == DT_TYPE_ARRAY)
|
||||||
|
{
|
||||||
|
Expression* ex = new Expression(mLocation, EX_VARIABLE);
|
||||||
|
ex->mDecType = mBase->mBase;
|
||||||
|
ex->mDecValue = this;
|
||||||
|
|
||||||
|
Declaration* pdec = this->Clone();
|
||||||
|
pdec->mType = DT_CONST_POINTER;
|
||||||
|
pdec->mValue = ex;
|
||||||
|
pdec->mBase = ntype;
|
||||||
|
pdec->mSize = 2;
|
||||||
|
|
||||||
|
return pdec;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return this;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -1554,7 +1676,9 @@ const Ident* Declaration::FullIdent(void)
|
||||||
Declaration* dec = mBase->mParams;
|
Declaration* dec = mBase->mParams;
|
||||||
while (dec)
|
while (dec)
|
||||||
{
|
{
|
||||||
tident = tident->Mangle(dec->mBase->MangleIdent()->mString);
|
const Ident* mident = dec->mBase->MangleIdent();
|
||||||
|
if (mident)
|
||||||
|
tident = tident->Mangle(mident->mString);
|
||||||
dec = dec->mNext;
|
dec = dec->mNext;
|
||||||
if (dec)
|
if (dec)
|
||||||
tident = tident->Mangle(",");
|
tident = tident->Mangle(",");
|
||||||
|
@ -1690,26 +1814,31 @@ const Ident* Declaration::MangleIdent(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
dec = dec->mNext;
|
dec = dec->mNext;
|
||||||
if (dec)
|
if (mMangleIdent && dec)
|
||||||
mMangleIdent = mMangleIdent->Mangle(",");
|
mMangleIdent = mMangleIdent->Mangle(",");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
mMangleIdent = Ident::Unique("void");
|
mMangleIdent = Ident::Unique("void");
|
||||||
}
|
}
|
||||||
else
|
else if (mQualIdent)
|
||||||
mMangleIdent = mQualIdent;
|
mMangleIdent = mQualIdent;
|
||||||
|
else
|
||||||
|
mMangleIdent = mIdent;
|
||||||
|
|
||||||
if (mTemplate)
|
if (mTemplate)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mMangleIdent)
|
||||||
|
{
|
||||||
if (mFlags & DTF_CONST)
|
if (mFlags & DTF_CONST)
|
||||||
mMangleIdent = mMangleIdent->PreMangle("const ");
|
mMangleIdent = mMangleIdent->PreMangle("const ");
|
||||||
if (mFlags & DTF_VOLATILE)
|
if (mFlags & DTF_VOLATILE)
|
||||||
mMangleIdent = mMangleIdent->PreMangle("volatile ");
|
mMangleIdent = mMangleIdent->PreMangle("volatile ");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return mMangleIdent;
|
return mMangleIdent;
|
||||||
}
|
}
|
||||||
|
@ -1769,19 +1898,8 @@ Declaration* Declaration::ExpandTemplate(DeclarationScope* scope)
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Declaration::ResolveTemplate(Expression* pexp, Declaration* tdec)
|
bool Declaration::ResolveTemplateParameterList(Expression* pexp, Declaration* pdec, bool preliminary)
|
||||||
{
|
{
|
||||||
Declaration* pdec = tdec->mBase->mParams;
|
|
||||||
|
|
||||||
// Insert partially resolved templates
|
|
||||||
Declaration* ptdec = tdec->mTemplate->mParams;
|
|
||||||
while (ptdec)
|
|
||||||
{
|
|
||||||
if (ptdec->mBase)
|
|
||||||
mScope->Insert(ptdec->mIdent, ptdec->mBase);
|
|
||||||
ptdec = ptdec->mNext;
|
|
||||||
}
|
|
||||||
|
|
||||||
Declaration* phead = nullptr, * ptail = nullptr;
|
Declaration* phead = nullptr, * ptail = nullptr;
|
||||||
int pcnt = 0;
|
int pcnt = 0;
|
||||||
|
|
||||||
|
@ -1817,7 +1935,7 @@ bool Declaration::ResolveTemplate(Expression* pexp, Declaration* tdec)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!ResolveTemplate(ex->mDecType, pdec->mBase))
|
if (!ResolveTemplate(ex->mDecType, pdec->mBase, false, preliminary))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
pdec = pdec->mNext;
|
pdec = pdec->mNext;
|
||||||
|
@ -1831,6 +1949,9 @@ bool Declaration::ResolveTemplate(Expression* pexp, Declaration* tdec)
|
||||||
{
|
{
|
||||||
if (pdec->mType == DT_PACK_ARGUMENT)
|
if (pdec->mType == DT_PACK_ARGUMENT)
|
||||||
{
|
{
|
||||||
|
if (preliminary)
|
||||||
|
return true;
|
||||||
|
|
||||||
Declaration* tpdec = new Declaration(pdec->mLocation, DT_PACK_TYPE);
|
Declaration* tpdec = new Declaration(pdec->mLocation, DT_PACK_TYPE);
|
||||||
if (pdec->mBase->mType == DT_TYPE_REFERENCE)
|
if (pdec->mBase->mType == DT_TYPE_REFERENCE)
|
||||||
tpdec->mIdent = pdec->mBase->mBase->mIdent;
|
tpdec->mIdent = pdec->mBase->mBase->mIdent;
|
||||||
|
@ -1844,6 +1965,25 @@ bool Declaration::ResolveTemplate(Expression* pexp, Declaration* tdec)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Declaration::ResolveTemplate(Expression* pexp, Declaration* tdec)
|
||||||
|
{
|
||||||
|
Declaration* pdec = tdec->mBase->mParams;
|
||||||
|
|
||||||
|
// Insert partially resolved templates
|
||||||
|
Declaration* ptdec = tdec->mTemplate->mParams;
|
||||||
|
while (ptdec)
|
||||||
|
{
|
||||||
|
if (ptdec->mBase)
|
||||||
|
mScope->Insert(ptdec->mIdent, ptdec->mBase);
|
||||||
|
ptdec = ptdec->mNext;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!ResolveTemplateParameterList(pexp, pdec, true) || !ResolveTemplateParameterList(pexp, pdec, false))
|
||||||
|
return false;
|
||||||
|
|
||||||
Declaration* ppdec = nullptr;
|
Declaration* ppdec = nullptr;
|
||||||
ptdec = tdec->mTemplate->mParams;
|
ptdec = tdec->mTemplate->mParams;
|
||||||
while (ptdec)
|
while (ptdec)
|
||||||
|
@ -1886,7 +2026,7 @@ bool Declaration::CanResolveTemplate(Expression* pexp, Declaration* tdec)
|
||||||
|
|
||||||
if (pdec)
|
if (pdec)
|
||||||
{
|
{
|
||||||
if (!ResolveTemplate(ex->mDecType, pdec->mBase))
|
if (!ResolveTemplate(ex->mDecType, pdec->mBase, false, false))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (pdec->mType != DT_PACK_ARGUMENT)
|
if (pdec->mType != DT_PACK_ARGUMENT)
|
||||||
|
@ -1902,19 +2042,19 @@ bool Declaration::CanResolveTemplate(Expression* pexp, Declaration* tdec)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Declaration::ResolveTemplate(Declaration* fdec, Declaration* tdec)
|
bool Declaration::ResolveTemplate(Declaration* fdec, Declaration* tdec, bool same, bool preliminary)
|
||||||
{
|
{
|
||||||
if (tdec->IsSame(fdec))
|
if (tdec->IsSame(fdec))
|
||||||
return true;
|
return true;
|
||||||
else if (fdec->IsReference())
|
else if (fdec->IsReference())
|
||||||
return ResolveTemplate(fdec->mBase, tdec);
|
return ResolveTemplate(fdec->mBase, tdec, same, preliminary);
|
||||||
else if (tdec->mType == DT_TYPE_FUNCTION)
|
else if (tdec->mType == DT_TYPE_FUNCTION)
|
||||||
{
|
{
|
||||||
if (fdec->mType == DT_TYPE_FUNCTION)
|
if (fdec->mType == DT_TYPE_FUNCTION)
|
||||||
{
|
{
|
||||||
if (fdec->mBase)
|
if (fdec->mBase)
|
||||||
{
|
{
|
||||||
if (!tdec->mBase || !ResolveTemplate(fdec->mBase, tdec->mBase))
|
if (!tdec->mBase || !ResolveTemplate(fdec->mBase, tdec->mBase, true, preliminary))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else if (tdec->mBase)
|
else if (tdec->mBase)
|
||||||
|
@ -1953,7 +2093,7 @@ bool Declaration::ResolveTemplate(Declaration* fdec, Declaration* tdec)
|
||||||
if (!fpdec)
|
if (!fpdec)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!ResolveTemplate(fpdec->mBase, tpdec->mBase))
|
if (!ResolveTemplate(fpdec->mBase, tpdec->mBase, true, preliminary))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
fpdec = fpdec->mNext;
|
fpdec = fpdec->mNext;
|
||||||
|
@ -1969,16 +2109,16 @@ bool Declaration::ResolveTemplate(Declaration* fdec, Declaration* tdec)
|
||||||
}
|
}
|
||||||
else if (tdec->mType == DT_TYPE_REFERENCE)
|
else if (tdec->mType == DT_TYPE_REFERENCE)
|
||||||
{
|
{
|
||||||
return ResolveTemplate(fdec, tdec->mBase);
|
return ResolveTemplate(fdec, tdec->mBase, true, preliminary);
|
||||||
}
|
}
|
||||||
else if (tdec->mType == DT_TYPE_RVALUEREF)
|
else if (tdec->mType == DT_TYPE_RVALUEREF)
|
||||||
{
|
{
|
||||||
return ResolveTemplate(fdec, tdec->mBase);
|
return ResolveTemplate(fdec, tdec->mBase, true, preliminary);
|
||||||
}
|
}
|
||||||
else if (tdec->mType == DT_TYPE_POINTER)
|
else if (tdec->mType == DT_TYPE_POINTER)
|
||||||
{
|
{
|
||||||
if (fdec->mType == DT_TYPE_POINTER || fdec->mType == DT_TYPE_ARRAY)
|
if (fdec->mType == DT_TYPE_POINTER || fdec->mType == DT_TYPE_ARRAY)
|
||||||
return ResolveTemplate(fdec->mBase, tdec->mBase);
|
return ResolveTemplate(fdec->mBase, tdec->mBase, true, preliminary);
|
||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1998,10 +2138,12 @@ bool Declaration::ResolveTemplate(Declaration* fdec, Declaration* tdec)
|
||||||
if (pdec->mType == DT_TYPE_STRUCT)
|
if (pdec->mType == DT_TYPE_STRUCT)
|
||||||
pdec = pdec->mScope->Lookup(tdec->mIdent);
|
pdec = pdec->mScope->Lookup(tdec->mIdent);
|
||||||
}
|
}
|
||||||
|
else if (preliminary && !same)
|
||||||
|
return true;
|
||||||
else
|
else
|
||||||
pdec = mScope->Insert(tdec->mIdent, fdec);
|
pdec = mScope->Insert(tdec->mIdent, fdec);
|
||||||
|
|
||||||
if (pdec && !pdec->IsSame(fdec))
|
if (pdec && !(same ? pdec->IsSame(fdec) : pdec->CanAssign(fdec)))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -2042,6 +2184,21 @@ bool Declaration::ResolveTemplate(Declaration* fdec, Declaration* tdec)
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
else if (tdec->mType == DT_TYPE_ARRAY && fdec->mType == DT_TYPE_ARRAY && tdec->mTemplate && tdec->mBase->IsConstSame(fdec->mBase))
|
||||||
|
{
|
||||||
|
Declaration* ifdec = new Declaration(fdec->mLocation, DT_CONST_INTEGER);
|
||||||
|
ifdec->mBase = TheSignedIntTypeDeclaration;
|
||||||
|
ifdec->mSize = 2;
|
||||||
|
ifdec->mInteger = fdec->mSize / fdec->mBase->mSize;
|
||||||
|
|
||||||
|
Declaration * ipdec = mScope->Insert(tdec->mTemplate->mIdent, ifdec);
|
||||||
|
if (ipdec && !ipdec->IsSame(ifdec))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (tdec->mType == DT_TYPE_STRUCT && fdec->mType == DT_TYPE_STRUCT && tdec->mTemplate)
|
else if (tdec->mType == DT_TYPE_STRUCT && fdec->mType == DT_TYPE_STRUCT && tdec->mTemplate)
|
||||||
{
|
{
|
||||||
|
@ -2107,13 +2264,27 @@ bool Declaration::ResolveTemplate(Declaration* fdec, Declaration* tdec)
|
||||||
tpdec = tpdec->mNext;
|
tpdec = tpdec->mNext;
|
||||||
}
|
}
|
||||||
|
|
||||||
return !fpdec && !tpdec;
|
if (fpdec)
|
||||||
|
return false;
|
||||||
|
else if (!tpdec)
|
||||||
|
return true;
|
||||||
|
else if (tpdec->mBase->mType == DT_PACK_TEMPLATE)
|
||||||
|
{
|
||||||
|
Declaration*tppack = new Declaration(tpdec->mLocation, DT_PACK_TYPE);
|
||||||
|
Declaration* pdec = mScope->Insert(tpdec->mBase->mIdent, tppack);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ftdec = ftdec->mNext;
|
ftdec = ftdec->mNext;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
else if (!same && tdec->CanAssign(fdec))
|
||||||
|
return true;
|
||||||
else
|
else
|
||||||
return tdec->IsSame(fdec);
|
return tdec->IsSame(fdec);
|
||||||
}
|
}
|
||||||
|
@ -2245,6 +2416,7 @@ Declaration* Declaration::ToStriped(int stripe)
|
||||||
ndec->mVectorConstructor = mVectorConstructor ? mVectorConstructor->ToAlternateThis(pndec, 2) : nullptr;
|
ndec->mVectorConstructor = mVectorConstructor ? mVectorConstructor->ToAlternateThis(pndec, 2) : nullptr;
|
||||||
ndec->mVectorDestructor = mVectorDestructor ? mVectorDestructor->ToAlternateThis(pndec, 2) : nullptr;
|
ndec->mVectorDestructor = mVectorDestructor ? mVectorDestructor->ToAlternateThis(pndec, 2) : nullptr;
|
||||||
ndec->mVectorCopyConstructor = mVectorCopyConstructor ? mVectorCopyConstructor->ToAlternateThis(pndec, 2) : nullptr;
|
ndec->mVectorCopyConstructor = mVectorCopyConstructor ? mVectorCopyConstructor->ToAlternateThis(pndec, 2) : nullptr;
|
||||||
|
ndec->mVectorMoveConstructor = mVectorMoveConstructor ? mVectorMoveConstructor->ToAlternateThis(pndec, 2) : nullptr;
|
||||||
}
|
}
|
||||||
else if (mType == DT_TYPE_FUNCTION)
|
else if (mType == DT_TYPE_FUNCTION)
|
||||||
{
|
{
|
||||||
|
@ -2312,6 +2484,7 @@ Declaration* Declaration::ToVolatileType(void)
|
||||||
ndec->mVectorConstructor = mVectorConstructor;
|
ndec->mVectorConstructor = mVectorConstructor;
|
||||||
ndec->mVectorDestructor = mVectorDestructor;
|
ndec->mVectorDestructor = mVectorDestructor;
|
||||||
ndec->mVectorCopyConstructor = mVectorCopyConstructor;
|
ndec->mVectorCopyConstructor = mVectorCopyConstructor;
|
||||||
|
ndec->mVectorMoveConstructor = mVectorMoveConstructor;
|
||||||
ndec->mVTable = mVTable;
|
ndec->mVTable = mVTable;
|
||||||
|
|
||||||
mVolatile = ndec;
|
mVolatile = ndec;
|
||||||
|
@ -2331,6 +2504,9 @@ Declaration* Declaration::ToConstType(void)
|
||||||
ndec->mSize = mSize;
|
ndec->mSize = mSize;
|
||||||
ndec->mStride = mStride;
|
ndec->mStride = mStride;
|
||||||
ndec->mStripe = mStripe;
|
ndec->mStripe = mStripe;
|
||||||
|
if (mType == DT_TYPE_ARRAY)
|
||||||
|
ndec->mBase = mBase->ToConstType();
|
||||||
|
else
|
||||||
ndec->mBase = mBase;
|
ndec->mBase = mBase;
|
||||||
ndec->mBits = mBits;
|
ndec->mBits = mBits;
|
||||||
ndec->mShift = mShift;
|
ndec->mShift = mShift;
|
||||||
|
@ -2348,6 +2524,7 @@ Declaration* Declaration::ToConstType(void)
|
||||||
ndec->mVectorConstructor = mVectorConstructor;
|
ndec->mVectorConstructor = mVectorConstructor;
|
||||||
ndec->mVectorDestructor = mVectorDestructor;
|
ndec->mVectorDestructor = mVectorDestructor;
|
||||||
ndec->mVectorCopyConstructor = mVectorCopyConstructor;
|
ndec->mVectorCopyConstructor = mVectorCopyConstructor;
|
||||||
|
ndec->mVectorMoveConstructor = mVectorMoveConstructor;
|
||||||
ndec->mVTable = mVTable;
|
ndec->mVTable = mVTable;
|
||||||
|
|
||||||
ndec->mMutable = this;
|
ndec->mMutable = this;
|
||||||
|
@ -2400,7 +2577,7 @@ Declaration* Declaration::ToMutableType(void)
|
||||||
ndec->mBase = mBase;
|
ndec->mBase = mBase;
|
||||||
ndec->mBits = mBits;
|
ndec->mBits = mBits;
|
||||||
ndec->mShift = mShift;
|
ndec->mShift = mShift;
|
||||||
ndec->mFlags = mFlags | DTF_CONST;
|
ndec->mFlags = mFlags & ~DTF_CONST;
|
||||||
ndec->mScope = mScope;
|
ndec->mScope = mScope;
|
||||||
ndec->mParams = mParams;
|
ndec->mParams = mParams;
|
||||||
ndec->mIdent = mIdent;
|
ndec->mIdent = mIdent;
|
||||||
|
@ -2414,6 +2591,7 @@ Declaration* Declaration::ToMutableType(void)
|
||||||
ndec->mVectorConstructor = mVectorConstructor;
|
ndec->mVectorConstructor = mVectorConstructor;
|
||||||
ndec->mVectorDestructor = mVectorDestructor;
|
ndec->mVectorDestructor = mVectorDestructor;
|
||||||
ndec->mVectorCopyConstructor = mVectorCopyConstructor;
|
ndec->mVectorCopyConstructor = mVectorCopyConstructor;
|
||||||
|
ndec->mVectorMoveConstructor = mVectorMoveConstructor;
|
||||||
ndec->mVTable = mVTable;
|
ndec->mVTable = mVTable;
|
||||||
|
|
||||||
ndec->mConst = this;
|
ndec->mConst = this;
|
||||||
|
@ -2743,6 +2921,9 @@ bool Declaration::IsSame(const Declaration* dec) const
|
||||||
if (mType != dec->mType)
|
if (mType != dec->mType)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
if ((mFlags & (DTF_SIGNED | DTF_CONST | DTF_VOLATILE)) != (dec->mFlags & (DTF_SIGNED | DTF_CONST | DTF_VOLATILE)))
|
||||||
|
return false;
|
||||||
|
|
||||||
if (!(mFlags & dec->mFlags & DTF_DEFINED) && mType == DT_TYPE_STRUCT)
|
if (!(mFlags & dec->mFlags & DTF_DEFINED) && mType == DT_TYPE_STRUCT)
|
||||||
return mIdent == dec->mIdent;
|
return mIdent == dec->mIdent;
|
||||||
|
|
||||||
|
@ -2751,9 +2932,6 @@ bool Declaration::IsSame(const Declaration* dec) const
|
||||||
if (mStripe != dec->mStripe)
|
if (mStripe != dec->mStripe)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if ((mFlags & (DTF_SIGNED | DTF_CONST | DTF_VOLATILE)) != (dec->mFlags & (DTF_SIGNED | DTF_CONST | DTF_VOLATILE)))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (mType == DT_CONST_INTEGER)
|
if (mType == DT_CONST_INTEGER)
|
||||||
return mInteger == dec->mInteger;
|
return mInteger == dec->mInteger;
|
||||||
else if (mType == DT_TYPE_INTEGER)
|
else if (mType == DT_TYPE_INTEGER)
|
||||||
|
@ -2800,7 +2978,7 @@ bool Declaration::IsSame(const Declaration* dec) const
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (mType == DT_TYPE_TEMPLATE)
|
else if (mType == DT_TYPE_TEMPLATE || mType == DT_PACK_TEMPLATE)
|
||||||
{
|
{
|
||||||
return mIdent == dec->mIdent;
|
return mIdent == dec->mIdent;
|
||||||
}
|
}
|
||||||
|
@ -2933,7 +3111,7 @@ bool Declaration::CanAssign(const Declaration* fromType) const
|
||||||
if (mScope == fromType->mScope || (mIdent == fromType->mIdent && mSize == fromType->mSize))
|
if (mScope == fromType->mScope || (mIdent == fromType->mIdent && mSize == fromType->mSize))
|
||||||
return true;
|
return true;
|
||||||
if (fromType->mBase)
|
if (fromType->mBase)
|
||||||
return this->CanAssign(fromType->mBase);
|
return this->CanAssign(fromType->mBase->mBase);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else if (mType == DT_TYPE_ARRAY && fromType->mType == DT_TYPE_ARRAY)
|
else if (mType == DT_TYPE_ARRAY && fromType->mType == DT_TYPE_ARRAY)
|
||||||
|
@ -3000,6 +3178,52 @@ bool Declaration::IsIndexed(void) const
|
||||||
return mType == DT_TYPE_ARRAY || mType == DT_TYPE_POINTER;
|
return mType == DT_TYPE_ARRAY || mType == DT_TYPE_POINTER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Declaration::ContainsArray(void) const
|
||||||
|
{
|
||||||
|
if (mType == DT_TYPE_ARRAY)
|
||||||
|
return true;
|
||||||
|
else if (mType == DT_TYPE_STRUCT)
|
||||||
|
{
|
||||||
|
Declaration* p = mParams;
|
||||||
|
while (p)
|
||||||
|
{
|
||||||
|
if (p->mType == DT_ELEMENT && p->mBase->ContainsArray())
|
||||||
|
return true;
|
||||||
|
p = p->mNext;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Declaration::IsShortIntStruct(void) const
|
||||||
|
{
|
||||||
|
if (mType == DT_TYPE_STRUCT && mSize <= 4 && !mDestructor && !mCopyConstructor)
|
||||||
|
{
|
||||||
|
Declaration* em = mParams;
|
||||||
|
while (em)
|
||||||
|
{
|
||||||
|
if (em->mType == DT_ELEMENT && em->mBase->IsIntegerType() && em->mBits == 0)
|
||||||
|
em = em->mNext;
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// if (strcmp(mIdent->mString, "connection")) return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Declaration::HasConstructor(void) const
|
||||||
|
{
|
||||||
|
return mType == DT_TYPE_STRUCT && mScope && mScope->Lookup(mIdent->PreMangle("+"));
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Declaration::IsComplexStruct(void) const
|
||||||
|
{
|
||||||
|
return mType == DT_TYPE_STRUCT && !IsShortIntStruct();
|
||||||
|
}
|
||||||
|
|
||||||
bool Declaration::IsSimpleType(void) const
|
bool Declaration::IsSimpleType(void) const
|
||||||
{
|
{
|
||||||
|
@ -3019,6 +3243,7 @@ Declaration* TheVoidFunctionTypeDeclaration, * TheConstVoidValueDeclaration;
|
||||||
Declaration* TheCharPointerTypeDeclaration, * TheConstCharPointerTypeDeclaration;
|
Declaration* TheCharPointerTypeDeclaration, * TheConstCharPointerTypeDeclaration;
|
||||||
Expression* TheVoidExpression;
|
Expression* TheVoidExpression;
|
||||||
Declaration* TheNullptrConstDeclaration, * TheZeroIntegerConstDeclaration, * TheZeroFloatConstDeclaration, * TheNullPointerTypeDeclaration;
|
Declaration* TheNullptrConstDeclaration, * TheZeroIntegerConstDeclaration, * TheZeroFloatConstDeclaration, * TheNullPointerTypeDeclaration;
|
||||||
|
Declaration* TheTrueConstDeclaration, * TheFalseConstDeclaration;
|
||||||
|
|
||||||
void InitDeclarations(void)
|
void InitDeclarations(void)
|
||||||
{
|
{
|
||||||
|
@ -3120,4 +3345,13 @@ void InitDeclarations(void)
|
||||||
TheZeroFloatConstDeclaration->mBase = TheFloatTypeDeclaration;
|
TheZeroFloatConstDeclaration->mBase = TheFloatTypeDeclaration;
|
||||||
TheZeroFloatConstDeclaration->mSize = 4;
|
TheZeroFloatConstDeclaration->mSize = 4;
|
||||||
|
|
||||||
|
TheTrueConstDeclaration = new Declaration(noloc, DT_CONST_INTEGER);
|
||||||
|
TheTrueConstDeclaration->mBase = TheBoolTypeDeclaration;
|
||||||
|
TheTrueConstDeclaration->mSize = 1;
|
||||||
|
TheTrueConstDeclaration->mInteger = 1;
|
||||||
|
|
||||||
|
TheFalseConstDeclaration = new Declaration(noloc, DT_CONST_INTEGER);
|
||||||
|
TheFalseConstDeclaration->mBase = TheBoolTypeDeclaration;
|
||||||
|
TheFalseConstDeclaration->mSize = 1;
|
||||||
|
TheFalseConstDeclaration->mInteger = 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -127,6 +127,7 @@ static const uint64 DTF_FPARAM_UNUSED = (1ULL << 49);
|
||||||
static const uint64 DTF_DEPRECATED = (1ULL << 50);
|
static const uint64 DTF_DEPRECATED = (1ULL << 50);
|
||||||
static const uint64 DTF_FUNC_NO_RETURN = (1ULL << 51);
|
static const uint64 DTF_FUNC_NO_RETURN = (1ULL << 51);
|
||||||
static const uint64 DTF_PLACED = (1ULL << 52);
|
static const uint64 DTF_PLACED = (1ULL << 52);
|
||||||
|
static const uint64 DTF_NO_PAGE_CROSS = (1ULL << 53);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -166,6 +167,8 @@ public:
|
||||||
ScopeLevel mLevel;
|
ScopeLevel mLevel;
|
||||||
const Ident * mName;
|
const Ident * mName;
|
||||||
|
|
||||||
|
DeclarationScope* Clone(void) const;
|
||||||
|
|
||||||
DeclarationScope* mParent;
|
DeclarationScope* mParent;
|
||||||
protected:
|
protected:
|
||||||
struct Entry
|
struct Entry
|
||||||
|
@ -215,6 +218,7 @@ enum ExpressionType
|
||||||
EX_IF,
|
EX_IF,
|
||||||
EX_ELSE,
|
EX_ELSE,
|
||||||
EX_FOR,
|
EX_FOR,
|
||||||
|
EX_FORBODY,
|
||||||
EX_DO,
|
EX_DO,
|
||||||
EX_SCOPE,
|
EX_SCOPE,
|
||||||
EX_BREAK,
|
EX_BREAK,
|
||||||
|
@ -242,6 +246,12 @@ enum ExpressionType
|
||||||
EX_AGGREGATE
|
EX_AGGREGATE
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static const uint32 ANAFL_LHS = (1U << 0);
|
||||||
|
static const uint32 ANAFL_RHS = (1U << 1);
|
||||||
|
static const uint32 ANAFL_ASSIGN = (1U << 2);
|
||||||
|
static const uint32 ANAFL_ALIAS = (1U << 3);
|
||||||
|
|
||||||
|
|
||||||
class Expression
|
class Expression
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -258,6 +268,7 @@ public:
|
||||||
AsmInsType mAsmInsType;
|
AsmInsType mAsmInsType;
|
||||||
AsmInsMode mAsmInsMode;
|
AsmInsMode mAsmInsMode;
|
||||||
bool mConst;
|
bool mConst;
|
||||||
|
uint32 mFlags;
|
||||||
|
|
||||||
Expression* LogicInvertExpression(void);
|
Expression* LogicInvertExpression(void);
|
||||||
Expression* ConstantFold(Errors * errors, LinkerSection* dataSection, Linker * linker = nullptr);
|
Expression* ConstantFold(Errors * errors, LinkerSection* dataSection, Linker * linker = nullptr);
|
||||||
|
@ -266,6 +277,8 @@ public:
|
||||||
Expression* ListAppend(Expression* lexp);
|
Expression* ListAppend(Expression* lexp);
|
||||||
Expression* ToAlternateThis(Declaration* pthis, Declaration* nthis);
|
Expression* ToAlternateThis(Declaration* pthis, Declaration* nthis);
|
||||||
|
|
||||||
|
void ReplaceVariable(Declaration* pvar, Declaration* nvar);
|
||||||
|
|
||||||
bool IsSame(const Expression* exp) const;
|
bool IsSame(const Expression* exp) const;
|
||||||
bool IsRValue(void) const;
|
bool IsRValue(void) const;
|
||||||
bool IsLValue(void) const;
|
bool IsLValue(void) const;
|
||||||
|
@ -289,7 +302,7 @@ public:
|
||||||
Token mToken;
|
Token mToken;
|
||||||
Declaration * mBase, * mParams, * mParamPack, * mNext, * mPrev, * mConst, * mMutable, * mVolatile;
|
Declaration * mBase, * mParams, * mParamPack, * mNext, * mPrev, * mConst, * mMutable, * mVolatile;
|
||||||
Declaration * mDefaultConstructor, * mDestructor, * mCopyConstructor, * mCopyAssignment, * mMoveConstructor, * mMoveAssignment;
|
Declaration * mDefaultConstructor, * mDestructor, * mCopyConstructor, * mCopyAssignment, * mMoveConstructor, * mMoveAssignment;
|
||||||
Declaration * mVectorConstructor, * mVectorDestructor, * mVectorCopyConstructor, * mVectorCopyAssignment;
|
Declaration * mVectorConstructor, * mVectorDestructor, * mVectorCopyConstructor, * mVectorCopyAssignment, * mVectorMoveConstructor, * mVectorMoveAssignment;
|
||||||
Declaration * mVTable, * mClass, * mTemplate;
|
Declaration * mVTable, * mClass, * mTemplate;
|
||||||
Declaration * mForwardParam, * mForwardCall;
|
Declaration * mForwardParam, * mForwardCall;
|
||||||
|
|
||||||
|
@ -331,6 +344,10 @@ public:
|
||||||
bool IsSimpleType(void) const;
|
bool IsSimpleType(void) const;
|
||||||
bool IsReference(void) const;
|
bool IsReference(void) const;
|
||||||
bool IsIndexed(void) const;
|
bool IsIndexed(void) const;
|
||||||
|
bool ContainsArray(void) const;
|
||||||
|
bool IsShortIntStruct(void) const;
|
||||||
|
bool IsComplexStruct(void) const;
|
||||||
|
bool HasConstructor(void) const;
|
||||||
|
|
||||||
void SetDefined(void);
|
void SetDefined(void);
|
||||||
|
|
||||||
|
@ -361,8 +378,9 @@ public:
|
||||||
DecType ValueType(void) const;
|
DecType ValueType(void) const;
|
||||||
|
|
||||||
bool CanResolveTemplate(Expression* pexp, Declaration* tdec);
|
bool CanResolveTemplate(Expression* pexp, Declaration* tdec);
|
||||||
bool ResolveTemplate(Declaration* fdec, Declaration * tdec);
|
bool ResolveTemplate(Declaration* fdec, Declaration * tdec, bool same, bool preliminary);
|
||||||
bool ResolveTemplate(Expression* pexp, Declaration* tdec);
|
bool ResolveTemplate(Expression* pexp, Declaration* tdec);
|
||||||
|
bool ResolveTemplateParameterList(Expression* pexp, Declaration* pdec, bool preliminary);
|
||||||
|
|
||||||
Declaration* ExpandTemplate(DeclarationScope* scope);
|
Declaration* ExpandTemplate(DeclarationScope* scope);
|
||||||
|
|
||||||
|
@ -380,5 +398,6 @@ extern Declaration* TheBoolTypeDeclaration, * TheFloatTypeDeclaration, * TheVoid
|
||||||
extern Declaration* TheVoidFunctionTypeDeclaration, * TheConstVoidValueDeclaration;
|
extern Declaration* TheVoidFunctionTypeDeclaration, * TheConstVoidValueDeclaration;
|
||||||
extern Declaration* TheCharPointerTypeDeclaration, * TheConstCharPointerTypeDeclaration;
|
extern Declaration* TheCharPointerTypeDeclaration, * TheConstCharPointerTypeDeclaration;
|
||||||
extern Declaration* TheNullptrConstDeclaration, * TheZeroIntegerConstDeclaration, * TheZeroFloatConstDeclaration, * TheNullPointerTypeDeclaration;
|
extern Declaration* TheNullptrConstDeclaration, * TheZeroIntegerConstDeclaration, * TheZeroFloatConstDeclaration, * TheNullPointerTypeDeclaration;
|
||||||
|
extern Declaration* TheTrueConstDeclaration, * TheFalseConstDeclaration;
|
||||||
extern Expression* TheVoidExpression;
|
extern Expression* TheVoidExpression;
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
Errors::Errors(void)
|
Errors::Errors(void)
|
||||||
: mErrorCount(0), mMinLevel(EINFO_GENERIC)
|
: mErrorCount(0), mMinLevel(EINFO_GENERIC), mDisabled(EERR_GENERIC)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ void Errors::Error(const Location& loc, ErrorID eid, const char* msg, const Iden
|
||||||
|
|
||||||
void Errors::Error(const Location& loc, ErrorID eid, const char* msg, const char* info1, const char * info2)
|
void Errors::Error(const Location& loc, ErrorID eid, const char* msg, const char* info1, const char * info2)
|
||||||
{
|
{
|
||||||
if (eid >= mMinLevel)
|
if (eid >= mMinLevel && !(eid < EERR_GENERIC && mDisabled[eid]))
|
||||||
{
|
{
|
||||||
const char* level = "info";
|
const char* level = "info";
|
||||||
if (eid >= EERR_GENERIC)
|
if (eid >= EERR_GENERIC)
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "NumberSet.h"
|
||||||
|
|
||||||
|
|
||||||
class Location
|
class Location
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -10,7 +13,11 @@ public:
|
||||||
Location() : mFileName(nullptr), mLine(0), mColumn(0), mFrom(nullptr) {}
|
Location() : mFileName(nullptr), mLine(0), mColumn(0), mFrom(nullptr) {}
|
||||||
Location(const Location& loc, const Location* from)
|
Location(const Location& loc, const Location* from)
|
||||||
: mFileName(loc.mFileName), mLine(loc.mLine), mColumn(loc.mColumn), mFrom(from)
|
: mFileName(loc.mFileName), mLine(loc.mLine), mColumn(loc.mColumn), mFrom(from)
|
||||||
{}
|
{
|
||||||
|
static volatile int k;
|
||||||
|
if (from)
|
||||||
|
k = from->mLine;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class Ident;
|
class Ident;
|
||||||
|
@ -120,9 +127,13 @@ enum ErrorID
|
||||||
EERR_INVALID_CLASS_INITIALIZER,
|
EERR_INVALID_CLASS_INITIALIZER,
|
||||||
EERR_CALL_OF_DELETED_FUNCTION,
|
EERR_CALL_OF_DELETED_FUNCTION,
|
||||||
|
|
||||||
|
EERR_STATIC_ASSERT,
|
||||||
|
|
||||||
EFATAL_GENERIC = 4000,
|
EFATAL_GENERIC = 4000,
|
||||||
EFATAL_OUT_OF_MEMORY,
|
EFATAL_OUT_OF_MEMORY,
|
||||||
EFATAL_MACRO_EXPANSION_DEPTH,
|
EFATAL_MACRO_EXPANSION_DEPTH,
|
||||||
|
|
||||||
|
ERROR_MAX = 5000
|
||||||
};
|
};
|
||||||
|
|
||||||
class Errors
|
class Errors
|
||||||
|
@ -135,6 +146,7 @@ public:
|
||||||
int mErrorCount;
|
int mErrorCount;
|
||||||
ErrorID mMinLevel;
|
ErrorID mMinLevel;
|
||||||
|
|
||||||
|
NumberSet mDisabled;
|
||||||
|
|
||||||
void Error(const Location& loc, ErrorID eid, const char* msg, const Ident* info1, const Ident* info2 = nullptr);
|
void Error(const Location& loc, ErrorID eid, const char* msg, const Ident* info1, const Ident* info2 = nullptr);
|
||||||
void Error(const Location& loc, ErrorID eid, const char* msg, const char* info1 = nullptr, const char* info2 = nullptr);
|
void Error(const Location& loc, ErrorID eid, const char* msg, const char* info1 = nullptr, const char* info2 = nullptr);
|
||||||
|
|
|
@ -393,7 +393,7 @@ void GlobalAnalyzer::CheckFastcall(Declaration* procDec, bool head)
|
||||||
|
|
||||||
if (procDec->mValue && procDec->mValue->mType == EX_DISPATCH)
|
if (procDec->mValue && procDec->mValue->mType == EX_DISPATCH)
|
||||||
{
|
{
|
||||||
Declaration* maxf = nullptr;
|
Declaration* maxf = nullptr, * reff = nullptr;
|
||||||
|
|
||||||
bool stackCall = false;
|
bool stackCall = false;
|
||||||
|
|
||||||
|
@ -402,7 +402,10 @@ void GlobalAnalyzer::CheckFastcall(Declaration* procDec, bool head)
|
||||||
Declaration* cf = procDec->mCalled[i];
|
Declaration* cf = procDec->mCalled[i];
|
||||||
|
|
||||||
if (cf->mBase->mFlags & DTF_STACKCALL)
|
if (cf->mBase->mFlags & DTF_STACKCALL)
|
||||||
|
{
|
||||||
stackCall = true;
|
stackCall = true;
|
||||||
|
reff = cf;
|
||||||
|
}
|
||||||
|
|
||||||
if (!maxf)
|
if (!maxf)
|
||||||
maxf = cf;
|
maxf = cf;
|
||||||
|
@ -410,6 +413,9 @@ void GlobalAnalyzer::CheckFastcall(Declaration* procDec, bool head)
|
||||||
maxf = cf;
|
maxf = cf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!reff)
|
||||||
|
reff = maxf;
|
||||||
|
|
||||||
for (int i = 0; i < procDec->mCalled.Size(); i++)
|
for (int i = 0; i < procDec->mCalled.Size(); i++)
|
||||||
{
|
{
|
||||||
Declaration* cf = procDec->mCalled[i];
|
Declaration* cf = procDec->mCalled[i];
|
||||||
|
@ -420,9 +426,9 @@ void GlobalAnalyzer::CheckFastcall(Declaration* procDec, bool head)
|
||||||
cf->mBase->mFlags |= DTF_STACKCALL;
|
cf->mBase->mFlags |= DTF_STACKCALL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cf != maxf)
|
if (cf != reff)
|
||||||
{
|
{
|
||||||
Declaration* fp = cf->mBase->mParams, * mp = maxf->mBase->mParams;
|
Declaration* fp = cf->mBase->mParams, * mp = reff->mBase->mParams;
|
||||||
while (fp)
|
while (fp)
|
||||||
{
|
{
|
||||||
fp->mVarIndex = mp->mVarIndex;
|
fp->mVarIndex = mp->mVarIndex;
|
||||||
|
@ -431,10 +437,11 @@ void GlobalAnalyzer::CheckFastcall(Declaration* procDec, bool head)
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(!mp);
|
assert(!mp);
|
||||||
|
|
||||||
cf->mBase->mFastCallBase = cf->mFastCallBase = maxf->mBase->mFastCallBase;
|
|
||||||
cf->mBase->mFastCallSize = cf->mFastCallSize = maxf->mBase->mFastCallSize;
|
cf->mBase->mFastCallSize = cf->mFastCallSize = maxf->mBase->mFastCallSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (cf != maxf)
|
||||||
|
cf->mBase->mFastCallBase = cf->mFastCallBase = maxf->mBase->mFastCallBase;
|
||||||
}
|
}
|
||||||
|
|
||||||
procDec->mFastCallBase = procDec->mBase->mFastCallBase;
|
procDec->mFastCallBase = procDec->mBase->mFastCallBase;
|
||||||
|
@ -474,7 +481,7 @@ void GlobalAnalyzer::CheckFastcall(Declaration* procDec, bool head)
|
||||||
fplimit += 256;
|
fplimit += 256;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (procDec->mBase->mBase->mType == DT_TYPE_STRUCT)
|
if (procDec->mBase->mBase->IsComplexStruct())
|
||||||
{
|
{
|
||||||
if (nbase < numfpzero && nbase + 2 > numfpzero)
|
if (nbase < numfpzero && nbase + 2 > numfpzero)
|
||||||
nbase = numfpzero;
|
nbase = numfpzero;
|
||||||
|
@ -658,7 +665,7 @@ void GlobalAnalyzer::AnalyzeProcedure(Expression* cexp, Expression* exp, Declara
|
||||||
if (mCompilerOptions & COPT_OPTIMIZE_CONST_EXPRESSIONS)
|
if (mCompilerOptions & COPT_OPTIMIZE_CONST_EXPRESSIONS)
|
||||||
dec->mFlags |= DTF_FUNC_CONSTEXPR;
|
dec->mFlags |= DTF_FUNC_CONSTEXPR;
|
||||||
dec->mFlags |= DTF_FUNC_PURE;
|
dec->mFlags |= DTF_FUNC_PURE;
|
||||||
Analyze(exp, dec, false, false);
|
Analyze(exp, dec, 0);
|
||||||
|
|
||||||
Declaration* pdec = dec->mBase->mParams;
|
Declaration* pdec = dec->mBase->mParams;
|
||||||
int vi = 0;
|
int vi = 0;
|
||||||
|
@ -678,7 +685,7 @@ void GlobalAnalyzer::AnalyzeProcedure(Expression* cexp, Expression* exp, Declara
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mErrors->Error(dec->mLocation, EERR_UNDEFINED_OBJECT, "Calling undefined function", dec->mQualIdent);
|
mErrors->Error(dec->mLocation, EERR_UNDEFINED_OBJECT, "Calling undefined function", dec->FullIdent());
|
||||||
if (cexp)
|
if (cexp)
|
||||||
mErrors->Error(cexp->mLocation, EINFO_CALLED_FROM, "Called from here");
|
mErrors->Error(cexp->mLocation, EINFO_CALLED_FROM, "Called from here");
|
||||||
|
|
||||||
|
@ -754,7 +761,7 @@ void GlobalAnalyzer::AnalyzeGlobalVariable(Declaration* dec)
|
||||||
|
|
||||||
if (dec->mValue)
|
if (dec->mValue)
|
||||||
{
|
{
|
||||||
Analyze(dec->mValue, dec, false, false);
|
Analyze(dec->mValue, dec, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -764,17 +771,19 @@ void GlobalAnalyzer::AnalyzeInit(Declaration* mdec)
|
||||||
while (mdec)
|
while (mdec)
|
||||||
{
|
{
|
||||||
if (mdec->mValue)
|
if (mdec->mValue)
|
||||||
RegisterProc(Analyze(mdec->mValue, mdec, false, false));
|
RegisterProc(Analyze(mdec->mValue, mdec, 0));
|
||||||
else if (mdec->mParams)
|
else if (mdec->mParams)
|
||||||
AnalyzeInit(mdec->mParams);
|
AnalyzeInit(mdec->mParams);
|
||||||
mdec = mdec->mNext;
|
mdec = mdec->mNext;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Declaration * GlobalAnalyzer::Analyze(Expression* exp, Declaration* procDec, bool lhs, bool aliasing)
|
Declaration * GlobalAnalyzer::Analyze(Expression* exp, Declaration* procDec, uint32 flags)
|
||||||
{
|
{
|
||||||
Declaration* ldec, * rdec;
|
Declaration* ldec, * rdec;
|
||||||
|
|
||||||
|
exp->mFlags = flags;
|
||||||
|
|
||||||
switch (exp->mType)
|
switch (exp->mType)
|
||||||
{
|
{
|
||||||
case EX_ERROR:
|
case EX_ERROR:
|
||||||
|
@ -792,7 +801,7 @@ Declaration * GlobalAnalyzer::Analyze(Expression* exp, Declaration* procDec, boo
|
||||||
}
|
}
|
||||||
else if (exp->mDecValue->mType == DT_CONST_POINTER)
|
else if (exp->mDecValue->mType == DT_CONST_POINTER)
|
||||||
{
|
{
|
||||||
ldec = Analyze(exp->mDecValue->mValue, procDec, true, true);
|
ldec = Analyze(exp->mDecValue->mValue, procDec, ANAFL_LHS | ANAFL_ALIAS);
|
||||||
if (ldec->mType == DT_VARIABLE)
|
if (ldec->mType == DT_VARIABLE)
|
||||||
ldec->mFlags |= DTF_VAR_ALIASING;
|
ldec->mFlags |= DTF_VAR_ALIASING;
|
||||||
RegisterProc(ldec);
|
RegisterProc(ldec);
|
||||||
|
@ -816,7 +825,7 @@ Declaration * GlobalAnalyzer::Analyze(Expression* exp, Declaration* procDec, boo
|
||||||
if (mCompilerOptions & COPT_DEBUGINFO)
|
if (mCompilerOptions & COPT_DEBUGINFO)
|
||||||
exp->mDecValue->mReferences.Push(exp);
|
exp->mDecValue->mReferences.Push(exp);
|
||||||
|
|
||||||
if (aliasing)
|
if (flags & ANAFL_ALIAS)
|
||||||
{
|
{
|
||||||
Declaration* dec = exp->mDecValue;
|
Declaration* dec = exp->mDecValue;
|
||||||
while (dec->mType == DT_VARIABLE_REF)
|
while (dec->mType == DT_VARIABLE_REF)
|
||||||
|
@ -833,14 +842,14 @@ Declaration * GlobalAnalyzer::Analyze(Expression* exp, Declaration* procDec, boo
|
||||||
if (!(type->mFlags & DTF_CONST))
|
if (!(type->mFlags & DTF_CONST))
|
||||||
procDec->mFlags &= ~DTF_FUNC_CONSTEXPR;
|
procDec->mFlags &= ~DTF_FUNC_CONSTEXPR;
|
||||||
|
|
||||||
if (lhs)
|
if (flags & ANAFL_LHS)
|
||||||
procDec->mFlags &= ~DTF_FUNC_PURE;
|
procDec->mFlags &= ~DTF_FUNC_PURE;
|
||||||
|
|
||||||
AnalyzeGlobalVariable(exp->mDecValue);
|
AnalyzeGlobalVariable(exp->mDecValue);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (lhs)
|
if (flags & ANAFL_LHS)
|
||||||
exp->mDecValue->mFlags |= DTF_VAR_ADDRESS;
|
exp->mDecValue->mFlags |= DTF_VAR_ADDRESS;
|
||||||
|
|
||||||
if (!(exp->mDecValue->mFlags & DTF_ANALYZED))
|
if (!(exp->mDecValue->mFlags & DTF_ANALYZED))
|
||||||
|
@ -854,8 +863,8 @@ Declaration * GlobalAnalyzer::Analyze(Expression* exp, Declaration* procDec, boo
|
||||||
case EX_ASSIGNMENT:
|
case EX_ASSIGNMENT:
|
||||||
procDec->mComplexity += 5 * exp->mLeft->mDecType->mSize;
|
procDec->mComplexity += 5 * exp->mLeft->mDecType->mSize;
|
||||||
|
|
||||||
ldec = Analyze(exp->mLeft, procDec, true, false);
|
ldec = Analyze(exp->mLeft, procDec, ANAFL_LHS | ANAFL_RHS);
|
||||||
rdec = Analyze(exp->mRight, procDec, false, false);
|
rdec = Analyze(exp->mRight, procDec, ANAFL_RHS);
|
||||||
if (exp->mLeft->mType == EX_VARIABLE && exp->mRight->mType == EX_CALL && exp->mLeft->mDecType->mType == DT_TYPE_STRUCT)
|
if (exp->mLeft->mType == EX_VARIABLE && exp->mRight->mType == EX_CALL && exp->mLeft->mDecType->mType == DT_TYPE_STRUCT)
|
||||||
exp->mLeft->mDecValue->mFlags |= DTF_VAR_ALIASING;
|
exp->mLeft->mDecValue->mFlags |= DTF_VAR_ALIASING;
|
||||||
RegisterProc(rdec);
|
RegisterProc(rdec);
|
||||||
|
@ -864,33 +873,33 @@ Declaration * GlobalAnalyzer::Analyze(Expression* exp, Declaration* procDec, boo
|
||||||
case EX_BINARY:
|
case EX_BINARY:
|
||||||
procDec->mComplexity += 10 * exp->mDecType->mSize;
|
procDec->mComplexity += 10 * exp->mDecType->mSize;
|
||||||
|
|
||||||
ldec = Analyze(exp->mLeft, procDec, lhs, false);
|
ldec = Analyze(exp->mLeft, procDec, flags & ~ANAFL_ALIAS);
|
||||||
rdec = Analyze(exp->mRight, procDec, lhs, false);
|
rdec = Analyze(exp->mRight, procDec, flags & ~ANAFL_ALIAS);
|
||||||
return ldec;
|
return ldec;
|
||||||
|
|
||||||
case EX_RELATIONAL:
|
case EX_RELATIONAL:
|
||||||
procDec->mComplexity += 10 * exp->mLeft->mDecType->mSize;
|
procDec->mComplexity += 10 * exp->mLeft->mDecType->mSize;
|
||||||
|
|
||||||
ldec = Analyze(exp->mLeft, procDec, false, false);
|
ldec = Analyze(exp->mLeft, procDec, ANAFL_RHS);
|
||||||
rdec = Analyze(exp->mRight, procDec, false, false);
|
rdec = Analyze(exp->mRight, procDec, ANAFL_RHS);
|
||||||
return TheBoolTypeDeclaration;
|
return TheBoolTypeDeclaration;
|
||||||
|
|
||||||
case EX_PREINCDEC:
|
case EX_PREINCDEC:
|
||||||
procDec->mComplexity += 10 * exp->mLeft->mDecType->mSize;
|
procDec->mComplexity += 10 * exp->mLeft->mDecType->mSize;
|
||||||
|
|
||||||
return Analyze(exp->mLeft, procDec, true, false);
|
return Analyze(exp->mLeft, procDec, ANAFL_LHS | ANAFL_RHS);
|
||||||
case EX_PREFIX:
|
case EX_PREFIX:
|
||||||
if (exp->mToken == TK_BINARY_AND)
|
if (exp->mToken == TK_BINARY_AND)
|
||||||
{
|
{
|
||||||
ldec = Analyze(exp->mLeft, procDec, true, true);
|
ldec = Analyze(exp->mLeft, procDec, ANAFL_LHS | ANAFL_ALIAS);
|
||||||
if (ldec->mType == DT_VARIABLE)
|
if (ldec->mType == DT_VARIABLE)
|
||||||
ldec->mFlags |= DTF_VAR_ALIASING;
|
ldec->mFlags |= DTF_VAR_ALIASING;
|
||||||
}
|
}
|
||||||
else if (exp->mToken == TK_MUL)
|
else if (exp->mToken == TK_MUL)
|
||||||
{
|
{
|
||||||
ldec = Analyze(exp->mLeft, procDec, false, false);
|
ldec = Analyze(exp->mLeft, procDec, 0);
|
||||||
procDec->mFlags &= ~DTF_FUNC_CONSTEXPR;
|
procDec->mFlags &= ~DTF_FUNC_CONSTEXPR;
|
||||||
if (lhs)
|
if (flags & ANAFL_LHS)
|
||||||
procDec->mFlags &= ~DTF_FUNC_PURE;
|
procDec->mFlags &= ~DTF_FUNC_PURE;
|
||||||
|
|
||||||
return exp->mDecType;
|
return exp->mDecType;
|
||||||
|
@ -906,7 +915,7 @@ Declaration * GlobalAnalyzer::Analyze(Expression* exp, Declaration* procDec, boo
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
procDec->mComplexity += 10 * exp->mLeft->mDecType->mSize;
|
procDec->mComplexity += 10 * exp->mLeft->mDecType->mSize;
|
||||||
return Analyze(exp->mLeft, procDec, false, false);
|
return Analyze(exp->mLeft, procDec, 0);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case EX_POSTFIX:
|
case EX_POSTFIX:
|
||||||
|
@ -915,31 +924,31 @@ Declaration * GlobalAnalyzer::Analyze(Expression* exp, Declaration* procDec, boo
|
||||||
case EX_POSTINCDEC:
|
case EX_POSTINCDEC:
|
||||||
procDec->mComplexity += 10 * exp->mLeft->mDecType->mSize;
|
procDec->mComplexity += 10 * exp->mLeft->mDecType->mSize;
|
||||||
|
|
||||||
return Analyze(exp->mLeft, procDec, true, false);
|
return Analyze(exp->mLeft, procDec, ANAFL_LHS | ANAFL_RHS);
|
||||||
case EX_INDEX:
|
case EX_INDEX:
|
||||||
procDec->mComplexity += 10 * exp->mRight->mDecType->mSize;
|
procDec->mComplexity += 10 * exp->mRight->mDecType->mSize;
|
||||||
|
|
||||||
ldec = Analyze(exp->mLeft, procDec, lhs, false);
|
ldec = Analyze(exp->mLeft, procDec, flags & ~ANAFL_ALIAS);
|
||||||
if (ldec->mType == DT_VARIABLE || ldec->mType == DT_ARGUMENT)
|
if (ldec->mType == DT_VARIABLE || ldec->mType == DT_ARGUMENT)
|
||||||
{
|
{
|
||||||
ldec = ldec->mBase;
|
ldec = ldec->mBase;
|
||||||
if (ldec->mType == DT_TYPE_POINTER)
|
if (ldec->mType == DT_TYPE_POINTER)
|
||||||
{
|
{
|
||||||
if (lhs)
|
if (flags & ANAFL_LHS)
|
||||||
procDec->mFlags &= ~DTF_FUNC_PURE;
|
procDec->mFlags &= ~DTF_FUNC_PURE;
|
||||||
procDec->mFlags &= ~DTF_FUNC_CONSTEXPR;
|
procDec->mFlags &= ~DTF_FUNC_CONSTEXPR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
rdec = Analyze(exp->mRight, procDec, false, false);
|
rdec = Analyze(exp->mRight, procDec, 0);
|
||||||
if (ldec->mBase)
|
if (ldec->mBase)
|
||||||
return ldec->mBase;
|
return ldec->mBase;
|
||||||
break;
|
break;
|
||||||
case EX_QUALIFY:
|
case EX_QUALIFY:
|
||||||
Analyze(exp->mLeft, procDec, lhs, aliasing);
|
Analyze(exp->mLeft, procDec, flags);
|
||||||
return exp->mDecValue->mBase;
|
return exp->mDecValue->mBase;
|
||||||
case EX_DISPATCH:
|
case EX_DISPATCH:
|
||||||
procDec->mFlags |= DTF_PREVENT_INLINE;
|
procDec->mFlags |= DTF_PREVENT_INLINE;
|
||||||
Analyze(exp->mLeft, procDec, lhs, false);
|
Analyze(exp->mLeft, procDec, flags & ~ANAFL_ALIAS);
|
||||||
// RegisterCall(procDec, exp->mLeft->mDecType);
|
// RegisterCall(procDec, exp->mLeft->mDecType);
|
||||||
break;
|
break;
|
||||||
case EX_VCALL:
|
case EX_VCALL:
|
||||||
|
@ -950,7 +959,7 @@ Declaration * GlobalAnalyzer::Analyze(Expression* exp, Declaration* procDec, boo
|
||||||
case EX_INLINE:
|
case EX_INLINE:
|
||||||
procDec->mComplexity += 10;
|
procDec->mComplexity += 10;
|
||||||
|
|
||||||
ldec = Analyze(exp->mLeft, procDec, false, false);
|
ldec = Analyze(exp->mLeft, procDec, 0);
|
||||||
if ((ldec->mFlags & DTF_INTRINSIC) && !ldec->mValue)
|
if ((ldec->mFlags & DTF_INTRINSIC) && !ldec->mValue)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -1037,7 +1046,7 @@ Declaration * GlobalAnalyzer::Analyze(Expression* exp, Declaration* procDec, boo
|
||||||
if (pex->mType == EX_CALL && IsStackParam(pex->mDecType) && !(pdec && (pdec->mBase->mType == DT_TYPE_REFERENCE || pdec->mBase->mType == DT_TYPE_RVALUEREF)))
|
if (pex->mType == EX_CALL && IsStackParam(pex->mDecType) && !(pdec && (pdec->mBase->mType == DT_TYPE_REFERENCE || pdec->mBase->mType == DT_TYPE_RVALUEREF)))
|
||||||
ldec->mBase->mFlags |= DTF_STACKCALL;
|
ldec->mBase->mFlags |= DTF_STACKCALL;
|
||||||
|
|
||||||
RegisterProc(Analyze(pex, procDec, pdec && pdec->mBase->IsReference(), false));
|
RegisterProc(Analyze(pex, procDec, (pdec && pdec->mBase->IsReference()) ? ANAFL_LHS : 0));
|
||||||
|
|
||||||
if (pdec)
|
if (pdec)
|
||||||
pdec = pdec->mNext;
|
pdec = pdec->mNext;
|
||||||
|
@ -1051,12 +1060,12 @@ Declaration * GlobalAnalyzer::Analyze(Expression* exp, Declaration* procDec, boo
|
||||||
break;
|
break;
|
||||||
case EX_LIST:
|
case EX_LIST:
|
||||||
case EX_COMMA:
|
case EX_COMMA:
|
||||||
RegisterProc(Analyze(exp->mLeft, procDec, false, false));
|
RegisterProc(Analyze(exp->mLeft, procDec, 0));
|
||||||
return Analyze(exp->mRight, procDec, false, false);
|
return Analyze(exp->mRight, procDec, 0);
|
||||||
case EX_RETURN:
|
case EX_RETURN:
|
||||||
if (exp->mLeft)
|
if (exp->mLeft)
|
||||||
{
|
{
|
||||||
RegisterProc(Analyze(exp->mLeft, procDec, procDec->mBase->mBase->IsReference(), false));
|
RegisterProc(Analyze(exp->mLeft, procDec, procDec->mBase->mBase->IsReference() ? ANAFL_LHS : 0));
|
||||||
if (procDec->mBase->mBase && procDec->mBase->mBase->mType == DT_TYPE_STRUCT && procDec->mBase->mBase->mCopyConstructor)
|
if (procDec->mBase->mBase && procDec->mBase->mBase->mType == DT_TYPE_STRUCT && procDec->mBase->mBase->mCopyConstructor)
|
||||||
{
|
{
|
||||||
if (procDec->mBase->mBase->mMoveConstructor)
|
if (procDec->mBase->mBase->mMoveConstructor)
|
||||||
|
@ -1077,47 +1086,47 @@ Declaration * GlobalAnalyzer::Analyze(Expression* exp, Declaration* procDec, boo
|
||||||
if (exp->mType == EX_SEQUENCE)
|
if (exp->mType == EX_SEQUENCE)
|
||||||
{
|
{
|
||||||
if (exp->mLeft)
|
if (exp->mLeft)
|
||||||
ldec = Analyze(exp->mLeft, procDec, false, false);
|
ldec = Analyze(exp->mLeft, procDec, 0);
|
||||||
exp = exp->mRight;
|
exp = exp->mRight;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return Analyze(exp, procDec, false, false);
|
return Analyze(exp, procDec, 0);
|
||||||
|
|
||||||
} while (exp);
|
} while (exp);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EX_SCOPE:
|
case EX_SCOPE:
|
||||||
Analyze(exp->mLeft, procDec, false, false);
|
Analyze(exp->mLeft, procDec, 0);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EX_CONSTRUCT:
|
case EX_CONSTRUCT:
|
||||||
if (exp->mLeft->mLeft)
|
if (exp->mLeft->mLeft)
|
||||||
Analyze(exp->mLeft->mLeft, procDec, false, false);
|
Analyze(exp->mLeft->mLeft, procDec, 0);
|
||||||
if (exp->mLeft->mRight)
|
if (exp->mLeft->mRight)
|
||||||
Analyze(exp->mLeft->mRight, procDec, false, false);
|
Analyze(exp->mLeft->mRight, procDec, 0);
|
||||||
if (exp->mRight)
|
if (exp->mRight)
|
||||||
return Analyze(exp->mRight, procDec, false, false);
|
return Analyze(exp->mRight, procDec, 0);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EX_CLEANUP:
|
case EX_CLEANUP:
|
||||||
Analyze(exp->mRight, procDec, false, false);
|
Analyze(exp->mRight, procDec, 0);
|
||||||
return Analyze(exp->mLeft, procDec, lhs, false);
|
return Analyze(exp->mLeft, procDec, flags & ~ANAFL_ALIAS);
|
||||||
|
|
||||||
case EX_WHILE:
|
case EX_WHILE:
|
||||||
procDec->mFlags &= ~DTF_FUNC_CONSTEXPR;
|
procDec->mFlags &= ~DTF_FUNC_CONSTEXPR;
|
||||||
|
|
||||||
procDec->mComplexity += 20;
|
procDec->mComplexity += 20;
|
||||||
|
|
||||||
ldec = Analyze(exp->mLeft, procDec, false, false);
|
ldec = Analyze(exp->mLeft, procDec, 0);
|
||||||
rdec = Analyze(exp->mRight, procDec, false, false);
|
rdec = Analyze(exp->mRight, procDec, 0);
|
||||||
break;
|
break;
|
||||||
case EX_IF:
|
case EX_IF:
|
||||||
procDec->mComplexity += 20;
|
procDec->mComplexity += 20;
|
||||||
|
|
||||||
ldec = Analyze(exp->mLeft, procDec, false, false);
|
ldec = Analyze(exp->mLeft, procDec, 0);
|
||||||
rdec = Analyze(exp->mRight->mLeft, procDec, false, false);
|
rdec = Analyze(exp->mRight->mLeft, procDec, 0);
|
||||||
if (exp->mRight->mRight)
|
if (exp->mRight->mRight)
|
||||||
rdec = Analyze(exp->mRight->mRight, procDec, false, false);
|
rdec = Analyze(exp->mRight->mRight, procDec, 0);
|
||||||
break;
|
break;
|
||||||
case EX_ELSE:
|
case EX_ELSE:
|
||||||
break;
|
break;
|
||||||
|
@ -1127,18 +1136,23 @@ Declaration * GlobalAnalyzer::Analyze(Expression* exp, Declaration* procDec, boo
|
||||||
procDec->mComplexity += 30;
|
procDec->mComplexity += 30;
|
||||||
|
|
||||||
if (exp->mLeft->mRight)
|
if (exp->mLeft->mRight)
|
||||||
ldec = Analyze(exp->mLeft->mRight, procDec, false, false);
|
ldec = Analyze(exp->mLeft->mRight, procDec, 0);
|
||||||
if (exp->mLeft->mLeft->mLeft)
|
if (exp->mLeft->mLeft->mLeft)
|
||||||
ldec = Analyze(exp->mLeft->mLeft->mLeft, procDec, false, false);
|
ldec = Analyze(exp->mLeft->mLeft->mLeft, procDec, 0);
|
||||||
rdec = Analyze(exp->mRight, procDec, false, false);
|
rdec = Analyze(exp->mRight, procDec, 0);
|
||||||
if (exp->mLeft->mLeft->mRight)
|
if (exp->mLeft->mLeft->mRight)
|
||||||
ldec = Analyze(exp->mLeft->mLeft->mRight, procDec, false, false);
|
ldec = Analyze(exp->mLeft->mLeft->mRight, procDec, 0);
|
||||||
|
break;
|
||||||
|
case EX_FORBODY:
|
||||||
|
ldec = Analyze(exp->mLeft, procDec, 0);
|
||||||
|
if (exp->mRight)
|
||||||
|
Analyze(exp->mRight, procDec, 0);
|
||||||
break;
|
break;
|
||||||
case EX_DO:
|
case EX_DO:
|
||||||
procDec->mComplexity += 20;
|
procDec->mComplexity += 20;
|
||||||
|
|
||||||
ldec = Analyze(exp->mLeft, procDec, false, false);
|
ldec = Analyze(exp->mLeft, procDec, 0);
|
||||||
rdec = Analyze(exp->mRight, procDec, false, false);
|
rdec = Analyze(exp->mRight, procDec, 0);
|
||||||
break;
|
break;
|
||||||
case EX_BREAK:
|
case EX_BREAK:
|
||||||
case EX_CONTINUE:
|
case EX_CONTINUE:
|
||||||
|
@ -1147,18 +1161,18 @@ Declaration * GlobalAnalyzer::Analyze(Expression* exp, Declaration* procDec, boo
|
||||||
case EX_TYPE:
|
case EX_TYPE:
|
||||||
break;
|
break;
|
||||||
case EX_TYPECAST:
|
case EX_TYPECAST:
|
||||||
return Analyze(exp->mLeft, procDec, false, false);
|
return Analyze(exp->mLeft, procDec, 0);
|
||||||
break;
|
break;
|
||||||
case EX_LOGICAL_AND:
|
case EX_LOGICAL_AND:
|
||||||
ldec = Analyze(exp->mLeft, procDec, false, false);
|
ldec = Analyze(exp->mLeft, procDec, 0);
|
||||||
rdec = Analyze(exp->mRight, procDec, false, false);
|
rdec = Analyze(exp->mRight, procDec, 0);
|
||||||
break;
|
break;
|
||||||
case EX_LOGICAL_OR:
|
case EX_LOGICAL_OR:
|
||||||
ldec = Analyze(exp->mLeft, procDec, false, false);
|
ldec = Analyze(exp->mLeft, procDec, 0);
|
||||||
rdec = Analyze(exp->mRight, procDec, false, false);
|
rdec = Analyze(exp->mRight, procDec, 0);
|
||||||
break;
|
break;
|
||||||
case EX_LOGICAL_NOT:
|
case EX_LOGICAL_NOT:
|
||||||
ldec = Analyze(exp->mLeft, procDec, false, false);
|
ldec = Analyze(exp->mLeft, procDec, 0);
|
||||||
break;
|
break;
|
||||||
case EX_ASSEMBLER:
|
case EX_ASSEMBLER:
|
||||||
procDec->mFlags |= DTF_FUNC_ASSEMBLER;
|
procDec->mFlags |= DTF_FUNC_ASSEMBLER;
|
||||||
|
@ -1169,14 +1183,14 @@ Declaration * GlobalAnalyzer::Analyze(Expression* exp, Declaration* procDec, boo
|
||||||
case EX_UNDEFINED:
|
case EX_UNDEFINED:
|
||||||
break;
|
break;
|
||||||
case EX_SWITCH:
|
case EX_SWITCH:
|
||||||
ldec = Analyze(exp->mLeft, procDec, false, false);
|
ldec = Analyze(exp->mLeft, procDec, 0);
|
||||||
exp = exp->mRight;
|
exp = exp->mRight;
|
||||||
while (exp)
|
while (exp)
|
||||||
{
|
{
|
||||||
procDec->mComplexity += 10;
|
procDec->mComplexity += 10;
|
||||||
|
|
||||||
if (exp->mLeft->mRight)
|
if (exp->mLeft->mRight)
|
||||||
rdec = Analyze(exp->mLeft->mRight, procDec, false, false);
|
rdec = Analyze(exp->mLeft->mRight, procDec, 0);
|
||||||
exp = exp->mRight;
|
exp = exp->mRight;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -1187,9 +1201,9 @@ Declaration * GlobalAnalyzer::Analyze(Expression* exp, Declaration* procDec, boo
|
||||||
case EX_CONDITIONAL:
|
case EX_CONDITIONAL:
|
||||||
procDec->mComplexity += exp->mDecType->mSize * 10;
|
procDec->mComplexity += exp->mDecType->mSize * 10;
|
||||||
|
|
||||||
ldec = Analyze(exp->mLeft, procDec, false, false);
|
ldec = Analyze(exp->mLeft, procDec, 0);
|
||||||
RegisterProc(Analyze(exp->mRight->mLeft, procDec, lhs, aliasing));
|
RegisterProc(Analyze(exp->mRight->mLeft, procDec, flags));
|
||||||
RegisterProc(Analyze(exp->mRight->mRight, procDec, lhs, aliasing));
|
RegisterProc(Analyze(exp->mRight->mRight, procDec, flags));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@ protected:
|
||||||
int CallerInvokes(Declaration* called);
|
int CallerInvokes(Declaration* called);
|
||||||
int CallerInvokes(Declaration* caller, Declaration* called);
|
int CallerInvokes(Declaration* caller, Declaration* called);
|
||||||
|
|
||||||
Declaration* Analyze(Expression* exp, Declaration* procDec, bool lhs, bool aliasing);
|
Declaration* Analyze(Expression* exp, Declaration* procDec, uint32 flags);
|
||||||
|
|
||||||
bool IsStackParam(const Declaration* pdec) const;
|
bool IsStackParam(const Declaration* pdec) const;
|
||||||
bool MarkCycle(Declaration* rootDec, Declaration* procDec);
|
bool MarkCycle(Declaration* rootDec, Declaration* procDec);
|
||||||
|
|
|
@ -60,7 +60,7 @@ void GlobalOptimizer::Reset(void)
|
||||||
mFunctions.SetSize(0);
|
mFunctions.SetSize(0);
|
||||||
mGlobalVariables.SetSize(0);
|
mGlobalVariables.SetSize(0);
|
||||||
mCalledFunctions.SetSize(0);
|
mCalledFunctions.SetSize(0);
|
||||||
mCalledFunctions.SetSize(0);
|
mCallingFunctions.SetSize(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GlobalOptimizer::PropagateParamCommas(Expression*& fexp, Expression*& exp)
|
void GlobalOptimizer::PropagateParamCommas(Expression*& fexp, Expression*& exp)
|
||||||
|
@ -275,15 +275,23 @@ bool GlobalOptimizer::ReplaceGlobalConst(Expression* exp)
|
||||||
{
|
{
|
||||||
if (exp->mType == EX_VARIABLE && (exp->mDecValue->mFlags & (DTF_GLOBAL | DTF_STATIC)) && !(exp->mDecValue->mOptFlags & (OPTF_VAR_MODIFIED | OPTF_VAR_ADDRESS)) && exp->mDecValue->mValue)
|
if (exp->mType == EX_VARIABLE && (exp->mDecValue->mFlags & (DTF_GLOBAL | DTF_STATIC)) && !(exp->mDecValue->mOptFlags & (OPTF_VAR_MODIFIED | OPTF_VAR_ADDRESS)) && exp->mDecValue->mValue)
|
||||||
{
|
{
|
||||||
|
|
||||||
Expression* cexp = exp->mDecValue->mValue;
|
Expression* cexp = exp->mDecValue->mValue;
|
||||||
if (cexp->mType == EX_CONSTANT &&
|
if (cexp->mType == EX_CONSTANT)
|
||||||
(cexp->mDecValue->mType == DT_CONST_ADDRESS || cexp->mDecValue->mType == DT_CONST_INTEGER ||
|
{
|
||||||
cexp->mDecValue->mType == DT_CONST_POINTER || cexp->mDecValue->mType == DT_CONST_FLOAT))
|
|
||||||
|
if (cexp->mDecValue->mType == DT_CONST_ADDRESS || cexp->mDecValue->mType == DT_CONST_INTEGER ||
|
||||||
|
cexp->mDecValue->mType == DT_CONST_POINTER || cexp->mDecValue->mType == DT_CONST_FLOAT)
|
||||||
{
|
{
|
||||||
exp->mType = EX_CONSTANT;
|
exp->mType = EX_CONSTANT;
|
||||||
exp->mDecValue = cexp->mDecValue->ConstCast(exp->mDecType);
|
exp->mDecValue = cexp->mDecValue->ConstCast(exp->mDecType);
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
|
else if (exp->mDecValue->mBase->mType == DT_TYPE_STRUCT)
|
||||||
|
{
|
||||||
|
exp->mDecValue->mBase = exp->mDecValue->mBase->ToConstType();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ReplaceGlobalConst(exp->mLeft))
|
if (ReplaceGlobalConst(exp->mLeft))
|
||||||
|
@ -333,7 +341,7 @@ bool GlobalOptimizer::Optimize(void)
|
||||||
|
|
||||||
if (!(func->mOptFlags & OPTF_FUNC_VARIABLE) && !(func->mBase->mFlags & DTF_VIRTUAL))
|
if (!(func->mOptFlags & OPTF_FUNC_VARIABLE) && !(func->mBase->mFlags & DTF_VIRTUAL))
|
||||||
{
|
{
|
||||||
if (!(func->mOptFlags & OPTF_VAR_USED) && func->mBase->mBase && (func->mBase->mBase->IsSimpleType() || func->mBase->mBase->IsReference()))
|
if (!(func->mOptFlags & (OPTF_VAR_USED | OPTF_VAR_ADDRESS)) && func->mBase->mBase && (func->mBase->mBase->IsSimpleType() || func->mBase->mBase->IsReference()))
|
||||||
{
|
{
|
||||||
#if DUMP_OPTS
|
#if DUMP_OPTS
|
||||||
printf("Remove return value\n");
|
printf("Remove return value\n");
|
||||||
|
@ -454,7 +462,7 @@ void GlobalOptimizer::AnalyzeProcedure(Expression* exp, Declaration* procDec)
|
||||||
Analyze(exp, procDec, false);
|
Analyze(exp, procDec, false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
mErrors->Error(procDec->mLocation, EERR_UNDEFINED_OBJECT, "Calling undefined function", procDec->mQualIdent);
|
mErrors->Error(procDec->mLocation, EERR_UNDEFINED_OBJECT, "Calling undefined function", procDec->FullIdent());
|
||||||
|
|
||||||
procDec->mOptFlags &= ~OPTF_ANALYZING;
|
procDec->mOptFlags &= ~OPTF_ANALYZING;
|
||||||
}
|
}
|
||||||
|
@ -606,9 +614,6 @@ void GlobalOptimizer::RegisterProc(Declaration* to)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static const uint32 ANAFL_LHS = (1U << 0);
|
|
||||||
static const uint32 ANAFL_RHS = (1U << 1);
|
|
||||||
|
|
||||||
Declaration* GlobalOptimizer::Analyze(Expression* exp, Declaration* procDec, uint32 flags)
|
Declaration* GlobalOptimizer::Analyze(Expression* exp, Declaration* procDec, uint32 flags)
|
||||||
{
|
{
|
||||||
Declaration* ldec, * rdec;
|
Declaration* ldec, * rdec;
|
||||||
|
@ -654,6 +659,8 @@ Declaration* GlobalOptimizer::Analyze(Expression* exp, Declaration* procDec, uin
|
||||||
exp->mDecValue->mOptFlags |= OPTF_VAR_USED;
|
exp->mDecValue->mOptFlags |= OPTF_VAR_USED;
|
||||||
if (flags & ANAFL_LHS)
|
if (flags & ANAFL_LHS)
|
||||||
exp->mDecValue->mOptFlags |= OPTF_VAR_ADDRESS;
|
exp->mDecValue->mOptFlags |= OPTF_VAR_ADDRESS;
|
||||||
|
if (exp->mDecValue->mBase->IsReference() && (flags & ANAFL_ASSIGN))
|
||||||
|
exp->mDecValue->mOptFlags |= OPTF_VAR_USED;
|
||||||
|
|
||||||
if (exp->mDecValue->mType == DT_ARGUMENT && (flags & ANAFL_LHS))
|
if (exp->mDecValue->mType == DT_ARGUMENT && (flags & ANAFL_LHS))
|
||||||
{
|
{
|
||||||
|
@ -665,7 +672,12 @@ Declaration* GlobalOptimizer::Analyze(Expression* exp, Declaration* procDec, uin
|
||||||
case EX_INITIALIZATION:
|
case EX_INITIALIZATION:
|
||||||
case EX_ASSIGNMENT:
|
case EX_ASSIGNMENT:
|
||||||
if (exp->mToken == TK_ASSIGN)
|
if (exp->mToken == TK_ASSIGN)
|
||||||
|
{
|
||||||
|
if (exp->mType == EX_ASSIGNMENT)
|
||||||
|
ldec = Analyze(exp->mLeft, procDec, ANAFL_LHS | ANAFL_ASSIGN | flags);
|
||||||
|
else
|
||||||
ldec = Analyze(exp->mLeft, procDec, ANAFL_LHS | flags);
|
ldec = Analyze(exp->mLeft, procDec, ANAFL_LHS | flags);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
ldec = Analyze(exp->mLeft, procDec, ANAFL_LHS | ANAFL_RHS | flags);
|
ldec = Analyze(exp->mLeft, procDec, ANAFL_LHS | ANAFL_RHS | flags);
|
||||||
|
|
||||||
|
@ -813,6 +825,22 @@ Declaration* GlobalOptimizer::Analyze(Expression* exp, Declaration* procDec, uin
|
||||||
pdec->mOptFlags |= OPTF_VAR_CONST;
|
pdec->mOptFlags |= OPTF_VAR_CONST;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (pex->mType == EX_VARIABLE && pdec->mBase->mType == DT_TYPE_POINTER && pex->mDecType->mType == DT_TYPE_ARRAY && (pex->mDecValue->mFlags & (DTF_GLOBAL | DTF_STATIC)) && pdec->mBase->CanAssign(pex->mDecType))
|
||||||
|
{
|
||||||
|
if (pdec->mOptFlags & OPTF_VAR_CONST)
|
||||||
|
{
|
||||||
|
if (pdec->mValue->mType != EX_VARIABLE || pdec->mValue->mDecValue != pex->mDecValue)
|
||||||
|
{
|
||||||
|
pdec->mOptFlags |= OPTF_VAR_NOCONST;
|
||||||
|
pdec->mOptFlags &= ~OPTF_VAR_CONST;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pdec->mValue = pex;
|
||||||
|
pdec->mOptFlags |= OPTF_VAR_CONST;
|
||||||
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
pdec->mOptFlags |= OPTF_VAR_NOCONST;
|
pdec->mOptFlags |= OPTF_VAR_NOCONST;
|
||||||
|
@ -958,6 +986,11 @@ Declaration* GlobalOptimizer::Analyze(Expression* exp, Declaration* procDec, uin
|
||||||
if (exp->mLeft->mLeft->mRight)
|
if (exp->mLeft->mLeft->mRight)
|
||||||
ldec = Analyze(exp->mLeft->mLeft->mRight, procDec, 0);
|
ldec = Analyze(exp->mLeft->mLeft->mRight, procDec, 0);
|
||||||
break;
|
break;
|
||||||
|
case EX_FORBODY:
|
||||||
|
ldec = Analyze(exp->mLeft, procDec, 0);
|
||||||
|
if (exp->mRight)
|
||||||
|
rdec = Analyze(exp->mRight, procDec, 0);
|
||||||
|
break;
|
||||||
case EX_DO:
|
case EX_DO:
|
||||||
ldec = Analyze(exp->mRight, procDec, 0);
|
ldec = Analyze(exp->mRight, procDec, 0);
|
||||||
rdec = Analyze(exp->mLeft, procDec, ANAFL_RHS);
|
rdec = Analyze(exp->mLeft, procDec, ANAFL_RHS);
|
||||||
|
|
|
@ -47,7 +47,7 @@ const Ident* Ident::Unique(const char* str)
|
||||||
|
|
||||||
const Ident* Ident::PreMangle(const char* str) const
|
const Ident* Ident::PreMangle(const char* str) const
|
||||||
{
|
{
|
||||||
char buffer[200];
|
char buffer[1000];
|
||||||
strcpy_s(buffer, str);
|
strcpy_s(buffer, str);
|
||||||
strcat_s(buffer, mString);
|
strcat_s(buffer, mString);
|
||||||
return Unique(buffer);
|
return Unique(buffer);
|
||||||
|
@ -55,14 +55,14 @@ const Ident* Ident::PreMangle(const char* str) const
|
||||||
|
|
||||||
const Ident* Ident::Unique(const char* str, int id)
|
const Ident* Ident::Unique(const char* str, int id)
|
||||||
{
|
{
|
||||||
char buffer[200];
|
char buffer[1000];
|
||||||
sprintf_s(buffer, "%s#%d", str, id);
|
sprintf_s(buffer, "%s#%d", str, id);
|
||||||
return Unique(buffer);
|
return Unique(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
const Ident* Ident::Mangle(const char* str) const
|
const Ident* Ident::Mangle(const char* str) const
|
||||||
{
|
{
|
||||||
char buffer[200];
|
char buffer[1000];
|
||||||
strcpy_s(buffer, mString);
|
strcpy_s(buffer, mString);
|
||||||
strcat_s(buffer, str);
|
strcat_s(buffer, str);
|
||||||
return Unique(buffer);
|
return Unique(buffer);
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -169,6 +169,7 @@ public:
|
||||||
} mMinState, mMaxState;
|
} mMinState, mMaxState;
|
||||||
|
|
||||||
bool Same(const IntegerValueRange& range) const;
|
bool Same(const IntegerValueRange& range) const;
|
||||||
|
bool Weaker(const IntegerValueRange& range) const;
|
||||||
bool Merge(const IntegerValueRange& range, bool head, bool initial);
|
bool Merge(const IntegerValueRange& range, bool head, bool initial);
|
||||||
void Expand(const IntegerValueRange& range);
|
void Expand(const IntegerValueRange& range);
|
||||||
void Union(const IntegerValueRange& range);
|
void Union(const IntegerValueRange& range);
|
||||||
|
@ -198,7 +199,7 @@ public:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
typedef GrowingArray<IntegerValueRange> GrowingIntegerValueRangeArray;
|
typedef ExpandingArray<IntegerValueRange> GrowingIntegerValueRangeArray;
|
||||||
|
|
||||||
class ValueSet
|
class ValueSet
|
||||||
{
|
{
|
||||||
|
@ -380,7 +381,7 @@ public:
|
||||||
InterCodeBasicBlock * mTrueJump, * mFalseJump, * mLoopPrefix, * mDominator;
|
InterCodeBasicBlock * mTrueJump, * mFalseJump, * mLoopPrefix, * mDominator;
|
||||||
GrowingInstructionArray mInstructions;
|
GrowingInstructionArray mInstructions;
|
||||||
|
|
||||||
bool mVisited, mInPath, mLoopHead, mChecked, mConditionBlockTrue, mUnreachable, mLoopPath, mValueRangeValid;
|
bool mVisited, mInPath, mLoopHead, mChecked, mConditionBlockTrue, mUnreachable, mLoopPath, mValueRangeValid, mPatched, mLoopDebug;
|
||||||
mutable int mMark;
|
mutable int mMark;
|
||||||
|
|
||||||
NumberSet mLocalUsedTemps, mLocalModifiedTemps;
|
NumberSet mLocalUsedTemps, mLocalModifiedTemps;
|
||||||
|
@ -429,8 +430,9 @@ public:
|
||||||
|
|
||||||
void CollectEntries(void);
|
void CollectEntries(void);
|
||||||
void CollectEntryBlocks(InterCodeBasicBlock* from);
|
void CollectEntryBlocks(InterCodeBasicBlock* from);
|
||||||
void GenerateTraces(bool expand, bool compact);
|
void GenerateTraces(int expand, bool compact);
|
||||||
void BuildDominatorTree(InterCodeBasicBlock * from);
|
void BuildDominatorTree(InterCodeBasicBlock * from);
|
||||||
|
bool StripLoopHead(void);
|
||||||
|
|
||||||
bool MergeSameConditionTraces(void);
|
bool MergeSameConditionTraces(void);
|
||||||
|
|
||||||
|
@ -448,6 +450,7 @@ public:
|
||||||
void CollectConstTemps(GrowingInstructionPtrArray& ctemps, NumberSet& assignedTemps);
|
void CollectConstTemps(GrowingInstructionPtrArray& ctemps, NumberSet& assignedTemps);
|
||||||
bool PropagateConstTemps(const GrowingInstructionPtrArray& ctemps);
|
bool PropagateConstTemps(const GrowingInstructionPtrArray& ctemps);
|
||||||
bool ForwardConstTemps(const GrowingInstructionPtrArray& ctemps);
|
bool ForwardConstTemps(const GrowingInstructionPtrArray& ctemps);
|
||||||
|
bool PropagateConstCompareResults(void);
|
||||||
|
|
||||||
bool EarlyBranchElimination(const GrowingInstructionPtrArray& ctemps);
|
bool EarlyBranchElimination(const GrowingInstructionPtrArray& ctemps);
|
||||||
|
|
||||||
|
@ -517,6 +520,8 @@ public:
|
||||||
void PerformMachineSpecificValueUsageCheck(const GrowingInstructionPtrArray& tvalue, FastNumberSet& tvalid, const GrowingVariableArray& staticVars, const GrowingInterCodeProcedurePtrArray& staticProcs, FastNumberSet& fsingle);
|
void PerformMachineSpecificValueUsageCheck(const GrowingInstructionPtrArray& tvalue, FastNumberSet& tvalid, const GrowingVariableArray& staticVars, const GrowingInterCodeProcedurePtrArray& staticProcs, FastNumberSet& fsingle);
|
||||||
bool EliminateDeadBranches(void);
|
bool EliminateDeadBranches(void);
|
||||||
|
|
||||||
|
bool EliminateIntegerSumAliasTemps(const GrowingInstructionPtrArray& tvalue);
|
||||||
|
|
||||||
bool MergeIndexedLoadStore(const GrowingInstructionPtrArray& tvalue);
|
bool MergeIndexedLoadStore(const GrowingInstructionPtrArray& tvalue);
|
||||||
bool SimplifyIntegerNumeric(const GrowingInstructionPtrArray& tvalue, int& spareTemps);
|
bool SimplifyIntegerNumeric(const GrowingInstructionPtrArray& tvalue, int& spareTemps);
|
||||||
bool SimplifyPointerOffsets(void);
|
bool SimplifyPointerOffsets(void);
|
||||||
|
@ -636,14 +641,20 @@ public:
|
||||||
void PushMoveOutOfLoop(void);
|
void PushMoveOutOfLoop(void);
|
||||||
bool MoveConditionOutOfLoop(void);
|
bool MoveConditionOutOfLoop(void);
|
||||||
void SingleLoopCountZeroCheck(void);
|
void SingleLoopCountZeroCheck(void);
|
||||||
|
void InnerLoopCountZeroCheck(void);
|
||||||
bool PostDecLoopOptimization(void);
|
bool PostDecLoopOptimization(void);
|
||||||
|
bool Flatten2DLoop(void);
|
||||||
|
|
||||||
void PropagateMemoryAliasingInfo(const GrowingInstructionPtrArray& tvalue);
|
void PropagateMemoryAliasingInfo(const GrowingInstructionPtrArray& tvalue, bool loops);
|
||||||
void RemoveUnusedMallocs(void);
|
void RemoveUnusedMallocs(void);
|
||||||
|
|
||||||
bool PullStoreUpToConstAddress(void);
|
bool PullStoreUpToConstAddress(void);
|
||||||
|
|
||||||
bool CollectSingleHeadLoopBody(InterCodeBasicBlock* head, InterCodeBasicBlock* tail, GrowingArray<InterCodeBasicBlock*>& body);
|
bool CollectSingleHeadLoopBody(InterCodeBasicBlock* head, InterCodeBasicBlock* tail, ExpandingArray<InterCodeBasicBlock*>& body);
|
||||||
|
|
||||||
|
bool CollectGenericLoop(ExpandingArray<InterCodeBasicBlock*>& lblocks);
|
||||||
|
bool CollectSingleEntryGenericLoop(ExpandingArray<InterCodeBasicBlock*>& lblocks);
|
||||||
|
void CollectReachable(ExpandingArray<InterCodeBasicBlock*>& lblock);
|
||||||
|
|
||||||
bool SingleTailLoopOptimization(const NumberSet& aliasedParams, const GrowingVariableArray& staticVars);
|
bool SingleTailLoopOptimization(const NumberSet& aliasedParams, const GrowingVariableArray& staticVars);
|
||||||
bool MergeLoopTails(void);
|
bool MergeLoopTails(void);
|
||||||
|
@ -651,6 +662,7 @@ public:
|
||||||
bool ChangeTrueJump(InterCodeBasicBlock* block);
|
bool ChangeTrueJump(InterCodeBasicBlock* block);
|
||||||
bool ChangeFalseJump(InterCodeBasicBlock* block);
|
bool ChangeFalseJump(InterCodeBasicBlock* block);
|
||||||
|
|
||||||
|
InterCodeBasicBlock* CheckIsSimpleIntRangeBranch(const GrowingIntegerValueRangeArray & irange);
|
||||||
InterCodeBasicBlock* CheckIsConstBranch(const GrowingInstructionPtrArray& cins);
|
InterCodeBasicBlock* CheckIsConstBranch(const GrowingInstructionPtrArray& cins);
|
||||||
bool ShortcutConstBranches(const GrowingInstructionPtrArray& cins);
|
bool ShortcutConstBranches(const GrowingInstructionPtrArray& cins);
|
||||||
bool ShortcutDuplicateBranches(void);
|
bool ShortcutDuplicateBranches(void);
|
||||||
|
@ -701,6 +713,7 @@ protected:
|
||||||
GrowingIntegerValueRangeArray mLocalValueRange, mReverseValueRange;
|
GrowingIntegerValueRangeArray mLocalValueRange, mReverseValueRange;
|
||||||
|
|
||||||
void ResetVisited(void);
|
void ResetVisited(void);
|
||||||
|
void ResetPatched(void);
|
||||||
void ResetEntryBlocks(void);
|
void ResetEntryBlocks(void);
|
||||||
public:
|
public:
|
||||||
InterCodeBasicBlock * mEntryBlock;
|
InterCodeBasicBlock * mEntryBlock;
|
||||||
|
@ -762,7 +775,7 @@ public:
|
||||||
void Disassemble(const char* name, bool dumpSets = false);
|
void Disassemble(const char* name, bool dumpSets = false);
|
||||||
protected:
|
protected:
|
||||||
void BuildLocalAliasTable(void);
|
void BuildLocalAliasTable(void);
|
||||||
void BuildTraces(bool expand, bool dominators = true, bool compact = false);
|
void BuildTraces(int expand, bool dominators = true, bool compact = false);
|
||||||
void TrimBlocks(void);
|
void TrimBlocks(void);
|
||||||
void EarlyBranchElimination(void);
|
void EarlyBranchElimination(void);
|
||||||
void BuildDataFlowSets(void);
|
void BuildDataFlowSets(void);
|
||||||
|
@ -785,6 +798,7 @@ protected:
|
||||||
void SingleBlockLoopPointerToByte(FastNumberSet& activeSet);
|
void SingleBlockLoopPointerToByte(FastNumberSet& activeSet);
|
||||||
void SingleBlockLoopSinking(FastNumberSet& activeSet);
|
void SingleBlockLoopSinking(FastNumberSet& activeSet);
|
||||||
void MergeIndexedLoadStore(void);
|
void MergeIndexedLoadStore(void);
|
||||||
|
void EliminateIntegerSumAliasTemps(void);
|
||||||
void EliminateAliasValues();
|
void EliminateAliasValues();
|
||||||
void LoadStoreForwarding(InterMemory paramMemory);
|
void LoadStoreForwarding(InterMemory paramMemory);
|
||||||
void ReduceRecursionTempSpilling(InterMemory paramMemory);
|
void ReduceRecursionTempSpilling(InterMemory paramMemory);
|
||||||
|
@ -804,7 +818,7 @@ protected:
|
||||||
void CheckUsedDefinedTemps(void);
|
void CheckUsedDefinedTemps(void);
|
||||||
void WarnUsedUndefinedVariables(void);
|
void WarnUsedUndefinedVariables(void);
|
||||||
void WarnInvalidValueRanges(void);
|
void WarnInvalidValueRanges(void);
|
||||||
void PropagateMemoryAliasingInfo(void);
|
void PropagateMemoryAliasingInfo(bool loops);
|
||||||
void MoveConditionsOutOfLoop(void);
|
void MoveConditionsOutOfLoop(void);
|
||||||
void ShortcutConstBranches(void);
|
void ShortcutConstBranches(void);
|
||||||
void ShortcutDuplicateBranches(void);
|
void ShortcutDuplicateBranches(void);
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
InterCodeGenerator::InterCodeGenerator(Errors* errors, Linker* linker)
|
InterCodeGenerator::InterCodeGenerator(Errors* errors, Linker* linker)
|
||||||
: mErrors(errors), mLinker(linker), mCompilerOptions(COPT_DEFAULT)
|
: mErrors(errors), mLinker(linker), mCompilerOptions(COPT_DEFAULT)
|
||||||
{
|
{
|
||||||
|
mMainInitBlock = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
InterCodeGenerator::~InterCodeGenerator(void)
|
InterCodeGenerator::~InterCodeGenerator(void)
|
||||||
|
@ -12,6 +12,16 @@ InterCodeGenerator::~InterCodeGenerator(void)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline InterType InterTypeOfSize(int size)
|
||||||
|
{
|
||||||
|
if (size <= 1)
|
||||||
|
return IT_INT8;
|
||||||
|
else if (size <= 2)
|
||||||
|
return IT_INT16;
|
||||||
|
else
|
||||||
|
return IT_INT32;
|
||||||
|
}
|
||||||
|
|
||||||
static inline InterType InterTypeOf(const Declaration* dec)
|
static inline InterType InterTypeOf(const Declaration* dec)
|
||||||
{
|
{
|
||||||
switch (dec->mType)
|
switch (dec->mType)
|
||||||
|
@ -51,7 +61,7 @@ InterCodeGenerator::ExValue InterCodeGenerator::ToValue(InterCodeProcedure* proc
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
InterCodeGenerator::ExValue InterCodeGenerator::Dereference(InterCodeProcedure* proc, Expression* exp, InterCodeBasicBlock*& block, InlineMapper* inlineMapper, ExValue v, int level)
|
InterCodeGenerator::ExValue InterCodeGenerator::Dereference(InterCodeProcedure* proc, Expression* exp, InterCodeBasicBlock*& block, InlineMapper* inlineMapper, ExValue v, int level, int limit)
|
||||||
{
|
{
|
||||||
while (v.mReference > level)
|
while (v.mReference > level)
|
||||||
{
|
{
|
||||||
|
@ -72,11 +82,19 @@ InterCodeGenerator::ExValue InterCodeGenerator::Dereference(InterCodeProcedure*
|
||||||
ins->mSrc[0].mStride = v.mReference == 1 ? v.mType->mStripe : 1;
|
ins->mSrc[0].mStride = v.mReference == 1 ? v.mType->mStripe : 1;
|
||||||
|
|
||||||
|
|
||||||
if (v.mReference == 1 && v.mType->mType == DT_TYPE_ENUM && !v.mBits)
|
if (v.mReference == 1)
|
||||||
|
{
|
||||||
|
if (v.mType->mType == DT_TYPE_ENUM && !v.mBits)
|
||||||
{
|
{
|
||||||
ins->mDst.mRange.LimitMin(v.mType->mMinValue);
|
ins->mDst.mRange.LimitMin(v.mType->mMinValue);
|
||||||
ins->mDst.mRange.LimitMax(v.mType->mMaxValue);
|
ins->mDst.mRange.LimitMax(v.mType->mMaxValue);
|
||||||
}
|
}
|
||||||
|
else if (v.mType->mType == DT_TYPE_INTEGER && !v.mBits && limit > 0)
|
||||||
|
{
|
||||||
|
ins->mDst.mRange.LimitMin(0);
|
||||||
|
ins->mDst.mRange.LimitMax(limit - 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (v.mType->mFlags & DTF_VOLATILE)
|
if (v.mType->mFlags & DTF_VOLATILE)
|
||||||
ins->mVolatile = true;
|
ins->mVolatile = true;
|
||||||
|
@ -770,7 +788,10 @@ void InterCodeGenerator::InitGlobalVariable(InterCodeModule * mod, Declaration*
|
||||||
decb = decb->mBase;
|
decb = decb->mBase;
|
||||||
|
|
||||||
if (decb && decb->mStripe != 1)
|
if (decb && decb->mStripe != 1)
|
||||||
|
{
|
||||||
AddGlobalVariableRanges(var->mLinkerObject, decb, 0, nullptr);
|
AddGlobalVariableRanges(var->mLinkerObject, decb, 0, nullptr);
|
||||||
|
var->mLinkerObject->mStripe = decb->mStripe;
|
||||||
|
}
|
||||||
|
|
||||||
Declaration* type = dec->mBase;
|
Declaration* type = dec->mBase;
|
||||||
while (type->mType == DT_TYPE_ARRAY)
|
while (type->mType == DT_TYPE_ARRAY)
|
||||||
|
@ -779,6 +800,16 @@ void InterCodeGenerator::InitGlobalVariable(InterCodeModule * mod, Declaration*
|
||||||
var->mLinkerObject->mFlags |= LOBJF_CONST;
|
var->mLinkerObject->mFlags |= LOBJF_CONST;
|
||||||
if (dec->mFlags & DTF_ZEROPAGE)
|
if (dec->mFlags & DTF_ZEROPAGE)
|
||||||
var->mLinkerObject->mFlags |= LOBJF_ZEROPAGE;
|
var->mLinkerObject->mFlags |= LOBJF_ZEROPAGE;
|
||||||
|
if (dec->mFlags & DTF_NO_PAGE_CROSS)
|
||||||
|
var->mLinkerObject->mFlags |= LOBJF_NEVER_CROSS | LOBJF_NO_CROSS;
|
||||||
|
if (mCompilerOptions & COPT_OPTIMIZE_PAGE_CROSSING)
|
||||||
|
{
|
||||||
|
if (dec->mSize <= 256 && dec->mSize > 1)
|
||||||
|
{
|
||||||
|
if (dec->mBase->ContainsArray())
|
||||||
|
var->mLinkerObject->mFlags |= LOBJF_NEVER_CROSS | LOBJF_NO_CROSS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var->mIndex = mod->mGlobalVars.Size();
|
var->mIndex = mod->mGlobalVars.Size();
|
||||||
var->mDeclaration = dec;
|
var->mDeclaration = dec;
|
||||||
|
@ -872,7 +903,7 @@ void InterCodeGenerator::TranslateAssembler(InterCodeModule* mod, Declaration *
|
||||||
cexp = cexp->mRight;
|
cexp = cexp->mRight;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if remapping of lables due to operand address size change
|
// Check if remapping of labels due to operand address size change
|
||||||
if (osize != rsize)
|
if (osize != rsize)
|
||||||
{
|
{
|
||||||
adec->mBase->mScope->Iterate([=](const Ident* ident, Declaration* dec) {
|
adec->mBase->mScope->Iterate([=](const Ident* ident, Declaration* dec) {
|
||||||
|
@ -1638,7 +1669,7 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateInline(Declaration* pro
|
||||||
mErrors->Error(exp->mLeft->mLocation, EERR_NOT_AN_LVALUE, "Not an addressable expression");
|
mErrors->Error(exp->mLeft->mLocation, EERR_NOT_AN_LVALUE, "Not an addressable expression");
|
||||||
|
|
||||||
if (vp.mTemp != vr.mTemp)
|
if (vp.mTemp != vr.mTemp)
|
||||||
CopyStructSimple(proc, exp, block, inlineMapper, vp, vr);
|
CopyStruct(proc, exp, block, vp, vr, inlineMapper, false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1649,12 +1680,15 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateInline(Declaration* pro
|
||||||
else if (vr.mType->IsReference() && !(pdec && pdec->mBase->IsReference()))
|
else if (vr.mType->IsReference() && !(pdec && pdec->mBase->IsReference()))
|
||||||
{
|
{
|
||||||
vr.mReference++;
|
vr.mReference++;
|
||||||
|
vr.mType = vr.mType->mBase;
|
||||||
vr = Dereference(proc, texp, block, inlineMapper, vr);
|
vr = Dereference(proc, texp, block, inlineMapper, vr);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
vr = Dereference(proc, texp, block, inlineMapper, vr);
|
vr = Dereference(proc, texp, block, inlineMapper, vr);
|
||||||
|
|
||||||
if (pdec)
|
if (pdec && (pdec->mFlags & DTF_FPARAM_UNUSED) && vr.mType->mType == DT_TYPE_VOID)
|
||||||
|
;
|
||||||
|
else if (pdec)
|
||||||
{
|
{
|
||||||
if (pdec->mBase->mType == DT_TYPE_POINTER && vr.mType->mType == DT_TYPE_INTEGER)
|
if (pdec->mBase->mType == DT_TYPE_POINTER && vr.mType->mType == DT_TYPE_INTEGER)
|
||||||
{
|
{
|
||||||
|
@ -1908,6 +1942,7 @@ void InterCodeGenerator::CopyStruct(InterCodeProcedure* proc, Expression* exp, I
|
||||||
nmapper.mReturn = new InterCodeBasicBlock(proc);
|
nmapper.mReturn = new InterCodeBasicBlock(proc);
|
||||||
nmapper.mVarIndex = proc->mNumLocals;
|
nmapper.mVarIndex = proc->mNumLocals;
|
||||||
nmapper.mConstExpr = false;
|
nmapper.mConstExpr = false;
|
||||||
|
nmapper.mLocation = new Location(MapLocation(exp, inlineMapper));
|
||||||
proc->mNumLocals += ccdec->mNumVars;
|
proc->mNumLocals += ccdec->mNumVars;
|
||||||
if (inlineMapper)
|
if (inlineMapper)
|
||||||
nmapper.mDepth = inlineMapper->mDepth + 1;
|
nmapper.mDepth = inlineMapper->mDepth + 1;
|
||||||
|
@ -2196,13 +2231,13 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration*
|
||||||
if (dec->mBase->mFlags & DTF_SIGNED)
|
if (dec->mBase->mFlags & DTF_SIGNED)
|
||||||
{
|
{
|
||||||
if (dec->mInteger < -128 || dec->mInteger > 127)
|
if (dec->mInteger < -128 || dec->mInteger > 127)
|
||||||
mErrors->Error(dec->mLocation, EWARN_CONSTANT_TRUNCATED, "Integer constant truncated");
|
mErrors->Error(exp->mLocation, EWARN_CONSTANT_TRUNCATED, "Integer constant truncated");
|
||||||
ins->mConst.mIntConst = int8(dec->mInteger);
|
ins->mConst.mIntConst = int8(dec->mInteger);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (dec->mInteger < 0 || dec->mInteger > 255)
|
if (dec->mInteger < 0 || dec->mInteger > 255)
|
||||||
mErrors->Error(dec->mLocation, EWARN_CONSTANT_TRUNCATED, "Unsigned integer constant truncated");
|
mErrors->Error(exp->mLocation, EWARN_CONSTANT_TRUNCATED, "Unsigned integer constant truncated");
|
||||||
ins->mConst.mIntConst = uint8(dec->mInteger);
|
ins->mConst.mIntConst = uint8(dec->mInteger);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2211,13 +2246,13 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration*
|
||||||
if (dec->mBase->mFlags & DTF_SIGNED)
|
if (dec->mBase->mFlags & DTF_SIGNED)
|
||||||
{
|
{
|
||||||
if (dec->mInteger < -32768 || dec->mInteger > 32767)
|
if (dec->mInteger < -32768 || dec->mInteger > 32767)
|
||||||
mErrors->Error(dec->mLocation, EWARN_CONSTANT_TRUNCATED, "Integer constant truncated");
|
mErrors->Error(exp->mLocation, EWARN_CONSTANT_TRUNCATED, "Integer constant truncated");
|
||||||
ins->mConst.mIntConst = int16(dec->mInteger);
|
ins->mConst.mIntConst = int16(dec->mInteger);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (dec->mInteger < 0 || dec->mInteger > 65535)
|
if (dec->mInteger < 0 || dec->mInteger > 65535)
|
||||||
mErrors->Error(dec->mLocation, EWARN_CONSTANT_TRUNCATED, "Unsigned integer constant truncated");
|
mErrors->Error(exp->mLocation, EWARN_CONSTANT_TRUNCATED, "Unsigned integer constant truncated");
|
||||||
ins->mConst.mIntConst = uint16(dec->mInteger);
|
ins->mConst.mIntConst = uint16(dec->mInteger);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2226,13 +2261,13 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration*
|
||||||
if (dec->mBase->mFlags & DTF_SIGNED)
|
if (dec->mBase->mFlags & DTF_SIGNED)
|
||||||
{
|
{
|
||||||
if (dec->mInteger < -2147483648LL || dec->mInteger > 2147483647LL)
|
if (dec->mInteger < -2147483648LL || dec->mInteger > 2147483647LL)
|
||||||
mErrors->Error(dec->mLocation, EWARN_CONSTANT_TRUNCATED, "Integer constant truncated");
|
mErrors->Error(exp->mLocation, EWARN_CONSTANT_TRUNCATED, "Integer constant truncated");
|
||||||
ins->mConst.mIntConst = int32(dec->mInteger);
|
ins->mConst.mIntConst = int32(dec->mInteger);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (dec->mInteger < 0 || dec->mInteger > 4294967296LL)
|
if (dec->mInteger < 0 || dec->mInteger > 4294967296LL)
|
||||||
mErrors->Error(dec->mLocation, EWARN_CONSTANT_TRUNCATED, "Unsigned integer constant truncated");
|
mErrors->Error(exp->mLocation, EWARN_CONSTANT_TRUNCATED, "Unsigned integer constant truncated");
|
||||||
ins->mConst.mIntConst = uint32(dec->mInteger);
|
ins->mConst.mIntConst = uint32(dec->mInteger);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2693,6 +2728,9 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration*
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Declaration * otype = vll.mType;
|
Declaration * otype = vll.mType;
|
||||||
|
if (vll.mType->mType == DT_TYPE_BOOL && vr.mType->mType == DT_TYPE_BOOL)
|
||||||
|
otype = TheUnsignedCharTypeDeclaration;
|
||||||
|
|
||||||
#if 1
|
#if 1
|
||||||
if ((exp->mRight->mType != EX_CONSTANT || (exp->mToken != TK_ASSIGN_ADD && exp->mToken != TK_ASSIGN_SUB && exp->mToken != TK_ASSIGN_AND && exp->mToken != TK_ASSIGN_OR)) && otype->mSize < 2)
|
if ((exp->mRight->mType != EX_CONSTANT || (exp->mToken != TK_ASSIGN_ADD && exp->mToken != TK_ASSIGN_SUB && exp->mToken != TK_ASSIGN_AND && exp->mToken != TK_ASSIGN_OR)) && otype->mSize < 2)
|
||||||
#else
|
#else
|
||||||
|
@ -2805,6 +2843,7 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration*
|
||||||
}
|
}
|
||||||
|
|
||||||
vl = Dereference(proc, exp, block, inlineMapper, vl, vl.mType->mType == DT_TYPE_POINTER ? 0 : 1);
|
vl = Dereference(proc, exp, block, inlineMapper, vl, vl.mType->mType == DT_TYPE_POINTER ? 0 : 1);
|
||||||
|
|
||||||
vr = Dereference(proc, exp, block, inlineMapper, vr);
|
vr = Dereference(proc, exp, block, inlineMapper, vr);
|
||||||
|
|
||||||
if (vl.mType->mType != DT_TYPE_ARRAY && vl.mType->mType != DT_TYPE_POINTER)
|
if (vl.mType->mType != DT_TYPE_ARRAY && vl.mType->mType != DT_TYPE_POINTER)
|
||||||
|
@ -2839,6 +2878,11 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration*
|
||||||
ains->mSrc[1].mMemory = IM_INDIRECT;
|
ains->mSrc[1].mMemory = IM_INDIRECT;
|
||||||
ains->mSrc[0].mType = IT_INT16;
|
ains->mSrc[0].mType = IT_INT16;
|
||||||
ains->mSrc[0].mTemp = mins->mDst.mTemp;
|
ains->mSrc[0].mTemp = mins->mDst.mTemp;
|
||||||
|
if (vl.mType->mType == DT_TYPE_ARRAY && vl.mType->mSize > vl.mType->mBase->mSize && (exp->mFlags & ANAFL_RHS))
|
||||||
|
{
|
||||||
|
ains->mSrc[0].mRange.LimitMin(0);
|
||||||
|
ains->mSrc[0].mRange.LimitMax(vl.mType->mSize);
|
||||||
|
}
|
||||||
ains->mSrc[1].mType = IT_POINTER;
|
ains->mSrc[1].mType = IT_POINTER;
|
||||||
ains->mSrc[1].mTemp = vl.mTemp;
|
ains->mSrc[1].mTemp = vl.mTemp;
|
||||||
ains->mDst.mType = IT_POINTER;
|
ains->mDst.mType = IT_POINTER;
|
||||||
|
@ -2905,7 +2949,7 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration*
|
||||||
ptype->mSize = 2;
|
ptype->mSize = 2;
|
||||||
ptype->mStride = vl.mType->mStride;
|
ptype->mStride = vl.mType->mStride;
|
||||||
vl.mReference = 0;
|
vl.mReference = 0;
|
||||||
vl.mType = exp->mDecType; // ptype;
|
vl.mType = ptype;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vr.mType->mType == DT_TYPE_POINTER)
|
if (vr.mType->mType == DT_TYPE_POINTER)
|
||||||
|
@ -2967,7 +3011,7 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration*
|
||||||
ins->mDst.mTemp = proc->AddTemporary(ins->mDst.mType);
|
ins->mDst.mTemp = proc->AddTemporary(ins->mDst.mType);
|
||||||
block->Append(ins);
|
block->Append(ins);
|
||||||
}
|
}
|
||||||
else if (vr.mType->mType == DT_TYPE_POINTER && vr.mType->mBase->IsConstSame(vl.mType->mBase))
|
else if ((vr.mType->mType == DT_TYPE_POINTER || vr.mType->mType == DT_TYPE_ARRAY) && (vl.mType->mType == DT_TYPE_POINTER || vl.mType->mType == DT_TYPE_ARRAY) && vr.mType->mBase->IsConstSame(vl.mType->mBase))
|
||||||
{
|
{
|
||||||
if (exp->mToken == TK_SUB)
|
if (exp->mToken == TK_SUB)
|
||||||
{
|
{
|
||||||
|
@ -3030,6 +3074,8 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration*
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
mErrors->Error(exp->mLocation, EERR_INCOMPATIBLE_OPERATOR, "Invalid pointer operation");
|
mErrors->Error(exp->mLocation, EERR_INCOMPATIBLE_OPERATOR, "Invalid pointer operation");
|
||||||
|
|
||||||
|
vl.mType = exp->mDecType;
|
||||||
}
|
}
|
||||||
else if (vr.mType->mType == DT_TYPE_POINTER || vr.mType->mType == DT_TYPE_ARRAY)
|
else if (vr.mType->mType == DT_TYPE_POINTER || vr.mType->mType == DT_TYPE_ARRAY)
|
||||||
{
|
{
|
||||||
|
@ -3555,6 +3601,8 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration*
|
||||||
else
|
else
|
||||||
dtype = TheSignedIntTypeDeclaration;
|
dtype = TheSignedIntTypeDeclaration;
|
||||||
}
|
}
|
||||||
|
else if (vl.mType->mSize == 1 && vr.mType->mSize == 1 && ((vr.mType->mFlags & DTF_SIGNED) || (vl.mType->mFlags & DTF_SIGNED)))
|
||||||
|
dtype = TheSignedIntTypeDeclaration;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (vl.mType->mSize == 4 || vr.mType->mSize == 4)
|
if (vl.mType->mSize == 4 || vr.mType->mSize == 4)
|
||||||
|
@ -3682,6 +3730,18 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration*
|
||||||
else if (!strcmp(iname->mString, "exp"))
|
else if (!strcmp(iname->mString, "exp"))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
else if (!strcmp(iname->mString, "sqrt"))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
else if (!strcmp(iname->mString, "atan"))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
else if (!strcmp(iname->mString, "pow"))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
else if (!strcmp(iname->mString, "atan2"))
|
||||||
|
{
|
||||||
|
}
|
||||||
else if (!strcmp(iname->mString, "breakpoint"))
|
else if (!strcmp(iname->mString, "breakpoint"))
|
||||||
{
|
{
|
||||||
InterInstruction* ins = new InterInstruction(MapLocation(exp, inlineMapper), IC_BREAKPOINT);
|
InterInstruction* ins = new InterInstruction(MapLocation(exp, inlineMapper), IC_BREAKPOINT);
|
||||||
|
@ -3900,6 +3960,7 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration*
|
||||||
exp->mLeft->mDecValue->mType == DT_CONST_FUNCTION &&
|
exp->mLeft->mDecValue->mType == DT_CONST_FUNCTION &&
|
||||||
((mCompilerOptions & COPT_OPTIMIZE_INLINE) || (exp->mLeft->mDecValue->mFlags & DTF_FORCE_INLINE)) &&
|
((mCompilerOptions & COPT_OPTIMIZE_INLINE) || (exp->mLeft->mDecValue->mFlags & DTF_FORCE_INLINE)) &&
|
||||||
!(inlineMapper && inlineMapper->mDepth > 10) &&
|
!(inlineMapper && inlineMapper->mDepth > 10) &&
|
||||||
|
!(exp->mLeft->mDecValue->mFlags & DTF_PREVENT_INLINE) &&
|
||||||
exp->mType != EX_VCALL;
|
exp->mType != EX_VCALL;
|
||||||
bool doInline = false, inlineConstexpr = false;
|
bool doInline = false, inlineConstexpr = false;
|
||||||
|
|
||||||
|
@ -3982,7 +4043,7 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration*
|
||||||
Declaration * decResult = nullptr;
|
Declaration * decResult = nullptr;
|
||||||
GrowingArray<InterInstruction*> defins(nullptr);
|
GrowingArray<InterInstruction*> defins(nullptr);
|
||||||
|
|
||||||
if (ftype->mBase->mType == DT_TYPE_STRUCT)
|
if (ftype->mBase->IsComplexStruct())
|
||||||
{
|
{
|
||||||
int ttemp;
|
int ttemp;
|
||||||
if (lrexp)
|
if (lrexp)
|
||||||
|
@ -4266,7 +4327,12 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration*
|
||||||
|
|
||||||
cins->mSrc[0].mType = IT_POINTER;
|
cins->mSrc[0].mType = IT_POINTER;
|
||||||
cins->mSrc[0].mTemp = vl.mTemp;
|
cins->mSrc[0].mTemp = vl.mTemp;
|
||||||
if (ftype->mBase->mType != DT_TYPE_VOID && ftype->mBase->mType != DT_TYPE_STRUCT)
|
if (ftype->mBase->IsShortIntStruct())
|
||||||
|
{
|
||||||
|
cins->mDst.mType = InterTypeOfSize(ftype->mBase->mSize);
|
||||||
|
cins->mDst.mTemp = proc->AddTemporary(cins->mDst.mType);
|
||||||
|
}
|
||||||
|
else if (ftype->mBase->mType != DT_TYPE_VOID && ftype->mBase->mType != DT_TYPE_STRUCT)
|
||||||
{
|
{
|
||||||
cins->mDst.mType = InterTypeOf(ftype->mBase);
|
cins->mDst.mType = InterTypeOf(ftype->mBase);
|
||||||
cins->mDst.mTemp = proc->AddTemporary(cins->mDst.mType);
|
cins->mDst.mTemp = proc->AddTemporary(cins->mDst.mType);
|
||||||
|
@ -4289,7 +4355,114 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration*
|
||||||
block->Append(xins);
|
block->Append(xins);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (decResult)
|
if (ftype->mBase->IsShortIntStruct())
|
||||||
|
{
|
||||||
|
int ttemp;
|
||||||
|
if (lrexp)
|
||||||
|
{
|
||||||
|
ttemp = lrexp->mTemp;
|
||||||
|
|
||||||
|
decResult = lrexp->mType;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int nindex = proc->mNumLocals++;
|
||||||
|
|
||||||
|
Declaration* vdec = new Declaration(exp->mLocation, DT_VARIABLE);
|
||||||
|
|
||||||
|
vdec->mVarIndex = nindex;
|
||||||
|
vdec->mBase = ftype->mBase;
|
||||||
|
vdec->mSize = ftype->mBase->mSize;
|
||||||
|
|
||||||
|
decResult = vdec;
|
||||||
|
|
||||||
|
InterInstruction* vins = new InterInstruction(MapLocation(exp, inlineMapper), IC_CONSTANT);
|
||||||
|
vins->mDst.mType = IT_POINTER;
|
||||||
|
vins->mDst.mTemp = proc->AddTemporary(IT_POINTER);
|
||||||
|
vins->mConst.mType = IT_POINTER;
|
||||||
|
vins->mConst.mMemory = IM_LOCAL;
|
||||||
|
vins->mConst.mVarIndex = nindex;
|
||||||
|
vins->mConst.mOperandSize = ftype->mBase->mSize;
|
||||||
|
block->Append(vins);
|
||||||
|
|
||||||
|
ttemp = vins->mDst.mTemp;
|
||||||
|
}
|
||||||
|
// Unmarshall result from return value into struct
|
||||||
|
|
||||||
|
Declaration* dec = ftype->mBase->mParams;
|
||||||
|
while (dec)
|
||||||
|
{
|
||||||
|
if (dec->mType == DT_ELEMENT)
|
||||||
|
{
|
||||||
|
InterInstruction* oins = new InterInstruction(MapLocation(exp, inlineMapper), IC_CONSTANT);
|
||||||
|
oins->mDst.mType = IT_INT16;
|
||||||
|
oins->mDst.mTemp = proc->AddTemporary(IT_INT16);
|
||||||
|
oins->mConst.mType = IT_INT16;
|
||||||
|
oins->mConst.mIntConst = dec->mOffset;
|
||||||
|
block->Append(oins);
|
||||||
|
|
||||||
|
InterInstruction* ains = new InterInstruction(MapLocation(exp, inlineMapper), IC_LEA);
|
||||||
|
ains->mSrc[1].mMemory = IM_INDIRECT;
|
||||||
|
ains->mSrc[1].mType = IT_POINTER;
|
||||||
|
ains->mSrc[1].mTemp = ttemp;
|
||||||
|
ains->mSrc[0] = oins->mDst;
|
||||||
|
ains->mDst.mType = IT_POINTER;
|
||||||
|
ains->mDst.mMemory = IM_INDIRECT;
|
||||||
|
ains->mDst.mTemp = proc->AddTemporary(IT_POINTER);
|
||||||
|
ains->mDst.mOperandSize = dec->mSize;
|
||||||
|
ains->mNumOperands = 2;
|
||||||
|
block->Append(ains);
|
||||||
|
|
||||||
|
InterInstruction* csins = new InterInstruction(MapLocation(exp, inlineMapper), IC_CONSTANT);
|
||||||
|
csins->mDst.mType = IT_INT8;
|
||||||
|
csins->mDst.mTemp = proc->AddTemporary(csins->mDst.mType);
|
||||||
|
csins->mConst.mType = IT_INT8;
|
||||||
|
csins->mConst.mIntConst = 8 * dec->mOffset;
|
||||||
|
csins->mNumOperands = 0;
|
||||||
|
block->Append(csins);
|
||||||
|
|
||||||
|
InterInstruction* asins = new InterInstruction(MapLocation(exp, inlineMapper), IC_CONSTANT);
|
||||||
|
asins->mDst.mType = cins->mDst.mType;
|
||||||
|
asins->mDst.mTemp = proc->AddTemporary(csins->mDst.mType);
|
||||||
|
asins->mConst.mType = cins->mDst.mType;
|
||||||
|
asins->mConst.mIntConst = (1ll << 8 * dec->mSize) - 1;
|
||||||
|
asins->mNumOperands = 0;
|
||||||
|
block->Append(asins);
|
||||||
|
|
||||||
|
InterInstruction* shins = new InterInstruction(MapLocation(exp, inlineMapper), IC_BINARY_OPERATOR);
|
||||||
|
shins->mOperator = IA_SHR;
|
||||||
|
shins->mDst.mType = cins->mDst.mType;
|
||||||
|
shins->mDst.mTemp = proc->AddTemporary(shins->mDst.mType);
|
||||||
|
shins->mSrc[1] = cins->mDst;
|
||||||
|
shins->mSrc[0] = csins->mDst;
|
||||||
|
shins->mNumOperands = 2;
|
||||||
|
block->Append(shins);
|
||||||
|
|
||||||
|
InterInstruction* andins = new InterInstruction(MapLocation(exp, inlineMapper), IC_BINARY_OPERATOR);
|
||||||
|
andins->mOperator = IA_AND;
|
||||||
|
andins->mDst.mType = cins->mDst.mType;
|
||||||
|
andins->mDst.mTemp = proc->AddTemporary(andins->mDst.mType);
|
||||||
|
andins->mSrc[0] = asins->mDst;
|
||||||
|
andins->mSrc[1] = shins->mDst;
|
||||||
|
andins->mNumOperands = 2;
|
||||||
|
block->Append(andins);
|
||||||
|
|
||||||
|
InterInstruction* sins = new InterInstruction(MapLocation(exp, inlineMapper), IC_STORE);
|
||||||
|
sins->mSrc[0].mTemp = andins->mDst.mTemp;
|
||||||
|
sins->mSrc[0].mType = InterTypeOf(dec->mBase);
|
||||||
|
sins->mSrc[1] = ains->mDst;
|
||||||
|
sins->mNumOperands = 2;
|
||||||
|
block->Append(sins);
|
||||||
|
}
|
||||||
|
dec = dec->mNext;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (lrexp)
|
||||||
|
return *lrexp;
|
||||||
|
|
||||||
|
return ExValue(ftype->mBase, ttemp, 1);
|
||||||
|
}
|
||||||
|
else if (decResult)
|
||||||
{
|
{
|
||||||
if (lrexp)
|
if (lrexp)
|
||||||
return *lrexp;
|
return *lrexp;
|
||||||
|
@ -4354,6 +4527,8 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration*
|
||||||
vins->mDst.mType = IT_POINTER;
|
vins->mDst.mType = IT_POINTER;
|
||||||
vins->mDst.mTemp = proc->AddTemporary(ins->mDst.mType);
|
vins->mDst.mTemp = proc->AddTemporary(ins->mDst.mType);
|
||||||
|
|
||||||
|
bool reference = false;
|
||||||
|
|
||||||
Declaration* vdec = refvars[i];
|
Declaration* vdec = refvars[i];
|
||||||
if (vdec->mType == DT_ARGUMENT)
|
if (vdec->mType == DT_ARGUMENT)
|
||||||
{
|
{
|
||||||
|
@ -4387,18 +4562,28 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration*
|
||||||
vins->mConst.mIntConst = vdec->mOffset;
|
vins->mConst.mIntConst = vdec->mOffset;
|
||||||
if (inlineMapper)
|
if (inlineMapper)
|
||||||
vins->mConst.mVarIndex += inlineMapper->mVarIndex;
|
vins->mConst.mVarIndex += inlineMapper->mVarIndex;
|
||||||
|
|
||||||
|
if (vdec->mBase->mType == DT_TYPE_ARRAY || vdec->mBase->mType == DT_TYPE_STRUCT)
|
||||||
|
reference = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
block->Append(vins);
|
block->Append(vins);
|
||||||
|
|
||||||
InterInstruction* lins = new InterInstruction(MapLocation(exp, inlineMapper), IC_LOAD);
|
InterInstruction* lins;
|
||||||
|
if (reference)
|
||||||
|
lins = vins;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
lins = new InterInstruction(MapLocation(exp, inlineMapper), IC_LOAD);
|
||||||
|
lins->mDst.mType = InterTypeOf(vdec->mBase);
|
||||||
|
lins->mNumOperands = 1;
|
||||||
lins->mSrc[0].mMemory = IM_INDIRECT;
|
lins->mSrc[0].mMemory = IM_INDIRECT;
|
||||||
lins->mSrc[0].mType = IT_POINTER;
|
lins->mSrc[0].mType = IT_POINTER;
|
||||||
lins->mSrc[0].mTemp = vins->mDst.mTemp;
|
lins->mSrc[0].mTemp = vins->mDst.mTemp;
|
||||||
lins->mDst.mType = InterTypeOf(vdec->mBase);
|
|
||||||
lins->mDst.mTemp = proc->AddTemporary(lins->mDst.mType);
|
lins->mDst.mTemp = proc->AddTemporary(lins->mDst.mType);
|
||||||
lins->mSrc[0].mOperandSize = vdec->mSize;
|
lins->mSrc[0].mOperandSize = vdec->mSize;
|
||||||
block->Append(lins);
|
block->Append(lins);
|
||||||
|
}
|
||||||
|
|
||||||
if (jins->mNumOperands >= 32)
|
if (jins->mNumOperands >= 32)
|
||||||
mErrors->Error(exp->mLocation, EERR_ASSEMBLER_LIMIT, "Maximum number of variables in assembler block exceeded", vdec->mIdent);
|
mErrors->Error(exp->mLocation, EERR_ASSEMBLER_LIMIT, "Maximum number of variables in assembler block exceeded", vdec->mIdent);
|
||||||
|
@ -4491,9 +4676,130 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration*
|
||||||
ins->mNumOperands = 1;
|
ins->mNumOperands = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (!inlineMapper && procType->mBase->IsShortIntStruct())
|
||||||
|
{
|
||||||
|
vr = TranslateExpression(procType, proc, block, exp->mLeft, destack, gotos, breakBlock, continueBlock, inlineMapper);
|
||||||
|
|
||||||
|
if (vr.mType->IsReference())
|
||||||
|
{
|
||||||
|
vr.mReference++;
|
||||||
|
vr.mType = vr.mType->mBase;
|
||||||
|
}
|
||||||
|
|
||||||
|
vr = Dereference(proc, exp, block, inlineMapper, vr, 1);
|
||||||
|
|
||||||
|
if (!procType->mBase || procType->mBase->mType == DT_TYPE_VOID)
|
||||||
|
mErrors->Error(exp->mLocation, EERR_INVALID_RETURN, "Function has void return type");
|
||||||
|
else if (!procType->mBase->CanAssign(vr.mType))
|
||||||
|
mErrors->Error(exp->mLocation, EERR_INVALID_RETURN, "Cannot return incompatible type");
|
||||||
|
else if (vr.mReference != 1)
|
||||||
|
mErrors->Error(exp->mLocation, EERR_INVALID_RETURN, "Non addressable object");
|
||||||
|
|
||||||
|
// Build marshalled struct into single long
|
||||||
|
InterInstruction* pins = new InterInstruction(MapLocation(exp, inlineMapper), IC_CONSTANT);
|
||||||
|
pins->mDst.mType = InterTypeOfSize(procType->mBase->mSize);
|
||||||
|
pins->mDst.mTemp = proc->AddTemporary(pins->mDst.mType);
|
||||||
|
pins->mConst.mType = pins->mDst.mType;
|
||||||
|
pins->mConst.mIntConst = 0;
|
||||||
|
block->Append(pins);
|
||||||
|
|
||||||
|
Declaration* dec = procType->mBase->mParams;
|
||||||
|
while (dec)
|
||||||
|
{
|
||||||
|
if (dec->mType == DT_ELEMENT)
|
||||||
|
{
|
||||||
|
InterInstruction * oins = new InterInstruction(MapLocation(exp, inlineMapper), IC_CONSTANT);
|
||||||
|
oins->mDst.mType = IT_INT16;
|
||||||
|
oins->mDst.mTemp = proc->AddTemporary(IT_INT16);
|
||||||
|
oins->mConst.mType = IT_INT16;
|
||||||
|
oins->mConst.mIntConst = dec->mOffset;
|
||||||
|
block->Append(oins);
|
||||||
|
|
||||||
|
InterInstruction * ains = new InterInstruction(MapLocation(exp, inlineMapper), IC_LEA);
|
||||||
|
ains->mSrc[1].mMemory = IM_INDIRECT;
|
||||||
|
ains->mSrc[1].mType = IT_POINTER;
|
||||||
|
ains->mSrc[1].mTemp = vr.mTemp;
|
||||||
|
ains->mSrc[0] = oins->mDst;
|
||||||
|
ains->mDst.mType = IT_POINTER;
|
||||||
|
ains->mDst.mMemory = IM_INDIRECT;
|
||||||
|
ains->mDst.mTemp = proc->AddTemporary(IT_POINTER);
|
||||||
|
ains->mDst.mOperandSize = dec->mSize;
|
||||||
|
ains->mNumOperands = 2;
|
||||||
|
block->Append(ains);
|
||||||
|
|
||||||
|
InterInstruction* lins = new InterInstruction(MapLocation(exp, inlineMapper), IC_LOAD);
|
||||||
|
lins->mSrc[0] = ains->mDst;
|
||||||
|
lins->mDst.mType = InterTypeOf(dec->mBase);
|
||||||
|
lins->mDst.mTemp = proc->AddTemporary(lins->mDst.mType);
|
||||||
|
lins->mNumOperands = 1;
|
||||||
|
block->Append(lins);
|
||||||
|
|
||||||
|
if (pins->mDst.mType == IT_INT32)
|
||||||
|
{
|
||||||
|
if (dec->mSize < 4)
|
||||||
|
{
|
||||||
|
InterInstruction* xins = new InterInstruction(MapLocation(exp, inlineMapper), IC_CONVERSION_OPERATOR);
|
||||||
|
xins->mOperator = dec->mSize == 1 ? IA_EXT8TO32U : IA_EXT16TO32U;
|
||||||
|
xins->mSrc[0] = lins->mDst;
|
||||||
|
xins->mDst.mType = InterTypeOf(dec->mBase);
|
||||||
|
xins->mDst.mTemp = proc->AddTemporary(pins->mDst.mType);
|
||||||
|
xins->mNumOperands = 1;
|
||||||
|
block->Append(xins);
|
||||||
|
lins = xins;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (pins->mDst.mType == IT_INT16)
|
||||||
|
{
|
||||||
|
if (dec->mSize < 2)
|
||||||
|
{
|
||||||
|
InterInstruction* xins = new InterInstruction(MapLocation(exp, inlineMapper), IC_CONVERSION_OPERATOR);
|
||||||
|
xins->mOperator = IA_EXT8TO16U;
|
||||||
|
xins->mSrc[0] = lins->mDst;
|
||||||
|
xins->mDst.mType = InterTypeOf(dec->mBase);
|
||||||
|
xins->mDst.mTemp = proc->AddTemporary(pins->mDst.mType);
|
||||||
|
xins->mNumOperands = 1;
|
||||||
|
block->Append(xins);
|
||||||
|
lins = xins;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
InterInstruction* csins = new InterInstruction(MapLocation(exp, inlineMapper), IC_CONSTANT);
|
||||||
|
csins->mDst.mType = IT_INT8;
|
||||||
|
csins->mDst.mTemp = proc->AddTemporary(csins->mDst.mType);
|
||||||
|
csins->mConst.mType = IT_INT8;
|
||||||
|
csins->mConst.mIntConst = 8 * dec->mOffset;
|
||||||
|
csins->mNumOperands = 0;
|
||||||
|
block->Append(csins);
|
||||||
|
|
||||||
|
InterInstruction* sins = new InterInstruction(MapLocation(exp, inlineMapper), IC_BINARY_OPERATOR);
|
||||||
|
sins->mOperator = IA_SHL;
|
||||||
|
sins->mDst.mType = pins->mDst.mType;
|
||||||
|
sins->mDst.mTemp = proc->AddTemporary(sins->mDst.mType);
|
||||||
|
sins->mSrc[1] = lins->mDst;
|
||||||
|
sins->mSrc[0] = csins->mDst;
|
||||||
|
sins->mNumOperands = 2;
|
||||||
|
block->Append(sins);
|
||||||
|
|
||||||
|
InterInstruction* orins = new InterInstruction(MapLocation(exp, inlineMapper), IC_BINARY_OPERATOR);
|
||||||
|
orins->mOperator = IA_OR;
|
||||||
|
orins->mDst.mType = pins->mDst.mType;
|
||||||
|
orins->mDst.mTemp = proc->AddTemporary(orins->mDst.mType);
|
||||||
|
orins->mSrc[0] = pins->mDst;
|
||||||
|
orins->mSrc[1] = sins->mDst;
|
||||||
|
orins->mNumOperands = 2;
|
||||||
|
block->Append(orins);
|
||||||
|
|
||||||
|
pins = orins;
|
||||||
|
}
|
||||||
|
dec = dec->mNext;
|
||||||
|
}
|
||||||
|
|
||||||
|
ins->mCode = IC_RETURN_VALUE;
|
||||||
|
ins->mSrc[0] = pins->mDst;
|
||||||
|
ins->mNumOperands = 1;
|
||||||
|
}
|
||||||
else if (procType->mBase->mType == DT_TYPE_STRUCT)
|
else if (procType->mBase->mType == DT_TYPE_STRUCT)
|
||||||
{
|
{
|
||||||
|
|
||||||
InterInstruction* ains = new InterInstruction(MapLocation(exp, inlineMapper), IC_CONSTANT);
|
InterInstruction* ains = new InterInstruction(MapLocation(exp, inlineMapper), IC_CONSTANT);
|
||||||
|
|
||||||
if (inlineMapper)
|
if (inlineMapper)
|
||||||
|
@ -4563,101 +4869,6 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration*
|
||||||
bool moving = exp->mLeft->IsRValue() || exp->mLeft->mType == EX_VARIABLE && !(exp->mLeft->mDecValue->mFlags & (DTF_STATIC | DTF_GLOBAL)) && exp->mLeft->mDecType->mType != DT_TYPE_REFERENCE;
|
bool moving = exp->mLeft->IsRValue() || exp->mLeft->mType == EX_VARIABLE && !(exp->mLeft->mDecValue->mFlags & (DTF_STATIC | DTF_GLOBAL)) && exp->mLeft->mDecType->mType != DT_TYPE_REFERENCE;
|
||||||
|
|
||||||
CopyStruct(proc, exp, block, rvr, vr, inlineMapper, moving);
|
CopyStruct(proc, exp, block, rvr, vr, inlineMapper, moving);
|
||||||
#if 0
|
|
||||||
if (procType->mBase->mCopyConstructor)
|
|
||||||
{
|
|
||||||
Declaration* ccdec = procType->mBase->mCopyConstructor;
|
|
||||||
if (ccdec->mBase->mFlags & DTF_FASTCALL)
|
|
||||||
{
|
|
||||||
if (!ccdec->mLinkerObject)
|
|
||||||
this->TranslateProcedure(proc->mModule, ccdec->mValue, ccdec);
|
|
||||||
|
|
||||||
InterInstruction* psins = new InterInstruction(MapLocation(exp, inlineMapper), IC_CONSTANT);
|
|
||||||
psins->mDst.mType = IT_POINTER;
|
|
||||||
psins->mDst.mTemp = proc->AddTemporary(IT_POINTER);
|
|
||||||
psins->mConst.mVarIndex = 0;
|
|
||||||
psins->mConst.mIntConst = 0;
|
|
||||||
psins->mConst.mOperandSize = 2;
|
|
||||||
if (procType->mFlags & DTF_FASTCALL)
|
|
||||||
{
|
|
||||||
psins->mConst.mMemory = IM_FPARAM;
|
|
||||||
psins->mConst.mVarIndex += ccdec->mBase->mFastCallBase;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
psins->mConst.mMemory = IM_PARAM;
|
|
||||||
block->Append(psins);
|
|
||||||
|
|
||||||
InterInstruction* ssins = new InterInstruction(MapLocation(exp, inlineMapper), IC_STORE);
|
|
||||||
ssins->mSrc[0] = ains->mDst;
|
|
||||||
ssins->mSrc[1] = psins->mDst;
|
|
||||||
block->Append(ssins);
|
|
||||||
|
|
||||||
InterInstruction* plins = new InterInstruction(MapLocation(exp, inlineMapper), IC_CONSTANT);
|
|
||||||
plins->mDst.mType = IT_POINTER;
|
|
||||||
plins->mDst.mTemp = proc->AddTemporary(IT_POINTER);
|
|
||||||
plins->mConst.mVarIndex = 2;
|
|
||||||
plins->mConst.mIntConst = 0;
|
|
||||||
plins->mConst.mOperandSize = 2;
|
|
||||||
if (procType->mFlags & DTF_FASTCALL)
|
|
||||||
{
|
|
||||||
plins->mConst.mMemory = IM_FPARAM;
|
|
||||||
plins->mConst.mVarIndex += ccdec->mBase->mFastCallBase;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
plins->mConst.mMemory = IM_PARAM;
|
|
||||||
block->Append(plins);
|
|
||||||
|
|
||||||
InterInstruction* slins = new InterInstruction(MapLocation(exp, inlineMapper), IC_STORE);
|
|
||||||
slins->mSrc[0].mType = IT_POINTER;
|
|
||||||
slins->mSrc[0].mTemp = vr.mTemp;
|
|
||||||
slins->mSrc[0].mMemory = IM_INDIRECT;
|
|
||||||
slins->mSrc[0].mOperandSize = procType->mBase->mSize;
|
|
||||||
slins->mSrc[0].mStride = vr.mType->mStripe;
|
|
||||||
slins->mSrc[1] = plins->mDst;
|
|
||||||
block->Append(slins);
|
|
||||||
|
|
||||||
proc->AddCalledFunction(proc->mModule->mProcedures[ccdec->mVarIndex]);
|
|
||||||
|
|
||||||
InterInstruction* pcins = new InterInstruction(MapLocation(exp, inlineMapper), IC_CONSTANT);
|
|
||||||
pcins->mDst.mType = IT_POINTER;
|
|
||||||
pcins->mDst.mTemp = proc->AddTemporary(IT_POINTER);
|
|
||||||
pcins->mConst.mType = IT_POINTER;
|
|
||||||
pcins->mConst.mVarIndex = ccdec->mVarIndex;
|
|
||||||
pcins->mConst.mIntConst = 0;
|
|
||||||
pcins->mConst.mOperandSize = 2;
|
|
||||||
pcins->mConst.mMemory = IM_GLOBAL;
|
|
||||||
pcins->mConst.mLinkerObject = ccdec->mLinkerObject;
|
|
||||||
block->Append(pcins);
|
|
||||||
|
|
||||||
InterInstruction* cins = new InterInstruction(MapLocation(exp, inlineMapper), IC_CALL);
|
|
||||||
if (ccdec->mFlags & DTF_NATIVE)
|
|
||||||
cins->mCode = IC_CALL_NATIVE;
|
|
||||||
else
|
|
||||||
cins->mCode = IC_CALL;
|
|
||||||
cins->mSrc[0] = pcins->mDst;
|
|
||||||
cins->mNumOperands = 1;
|
|
||||||
|
|
||||||
block->Append(cins);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
InterInstruction* cins = new InterInstruction(MapLocation(exp, inlineMapper), IC_COPY);
|
|
||||||
cins->mSrc[0].mType = IT_POINTER;
|
|
||||||
cins->mSrc[0].mTemp = vr.mTemp;
|
|
||||||
cins->mSrc[0].mMemory = IM_INDIRECT;
|
|
||||||
cins->mSrc[0].mOperandSize = procType->mBase->mSize;
|
|
||||||
cins->mSrc[0].mStride = vr.mType->mStripe;
|
|
||||||
|
|
||||||
cins->mSrc[1].mOperandSize = procType->mBase->mSize;
|
|
||||||
cins->mSrc[1].mType = IT_POINTER;
|
|
||||||
cins->mSrc[1].mTemp = ains->mDst.mTemp;
|
|
||||||
cins->mSrc[1].mMemory = IM_INDIRECT;
|
|
||||||
|
|
||||||
cins->mConst.mOperandSize = procType->mBase->mSize;
|
|
||||||
block->Append(cins);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -4965,13 +5176,32 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration*
|
||||||
vl = TranslateExpression(procType, proc, tblock, exp->mRight->mLeft, destack, gotos, breakBlock, continueBlock, inlineMapper);
|
vl = TranslateExpression(procType, proc, tblock, exp->mRight->mLeft, destack, gotos, breakBlock, continueBlock, inlineMapper);
|
||||||
vr = TranslateExpression(procType, proc, fblock, exp->mRight->mRight, destack, gotos, breakBlock, continueBlock, inlineMapper);
|
vr = TranslateExpression(procType, proc, fblock, exp->mRight->mRight, destack, gotos, breakBlock, continueBlock, inlineMapper);
|
||||||
|
|
||||||
int ttemp;
|
int ttemp, tref = 0;
|
||||||
InterType ttype, stypel, styper;
|
InterType ttype;
|
||||||
|
|
||||||
|
Declaration* dtype = exp->mDecType;
|
||||||
|
|
||||||
|
if (dtype->IsReference())
|
||||||
|
{
|
||||||
|
vl = Dereference(proc, exp, block, inlineMapper, vl, 1);
|
||||||
|
vr = Dereference(proc, exp, block, inlineMapper, vr, 1);
|
||||||
|
tref = 1;
|
||||||
|
|
||||||
|
dtype = dtype->mBase;
|
||||||
|
ttype = IT_POINTER;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
InterType stypel, styper;
|
||||||
|
|
||||||
|
if (vl.mType->IsReference())
|
||||||
|
vl = ToValue(proc, exp, block, inlineMapper, vl);
|
||||||
|
if (vr.mType->IsReference())
|
||||||
|
vr = ToValue(proc, exp, block, inlineMapper, vr);
|
||||||
|
|
||||||
stypel = InterTypeOf(vl.mType);
|
stypel = InterTypeOf(vl.mType);
|
||||||
styper = InterTypeOf(vr.mType);
|
styper = InterTypeOf(vr.mType);
|
||||||
|
|
||||||
Declaration* dtype;
|
|
||||||
if (stypel == IT_POINTER || styper == IT_POINTER)
|
if (stypel == IT_POINTER || styper == IT_POINTER)
|
||||||
{
|
{
|
||||||
if (vl.mType->mType == DT_TYPE_ARRAY)
|
if (vl.mType->mType == DT_TYPE_ARRAY)
|
||||||
|
@ -4984,6 +5214,8 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration*
|
||||||
else
|
else
|
||||||
vr = Dereference(proc, exp, fblock, inlineMapper, vr);
|
vr = Dereference(proc, exp, fblock, inlineMapper, vr);
|
||||||
|
|
||||||
|
if (vl.mType->mBase && vr.mType->mBase)
|
||||||
|
{
|
||||||
if (vl.mType->mBase->IsSubType(vr.mType->mBase))
|
if (vl.mType->mBase->IsSubType(vr.mType->mBase))
|
||||||
dtype = vr.mType;
|
dtype = vr.mType;
|
||||||
else if (vr.mType->mBase->IsSubType(vl.mType->mBase))
|
else if (vr.mType->mBase->IsSubType(vl.mType->mBase))
|
||||||
|
@ -4993,6 +5225,12 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration*
|
||||||
mErrors->Error(exp->mLocation, EERR_INCOMPATIBLE_OPERATOR, "Incompatible conditional types");
|
mErrors->Error(exp->mLocation, EERR_INCOMPATIBLE_OPERATOR, "Incompatible conditional types");
|
||||||
dtype = vl.mType;
|
dtype = vl.mType;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mErrors->Error(exp->mLocation, EERR_INCOMPATIBLE_OPERATOR, "Incompatible conditional types");
|
||||||
|
dtype = vl.mType;
|
||||||
|
}
|
||||||
|
|
||||||
Declaration* ntype = new Declaration(dtype->mLocation, DT_TYPE_POINTER);
|
Declaration* ntype = new Declaration(dtype->mLocation, DT_TYPE_POINTER);
|
||||||
ntype->mBase = dtype->mBase;
|
ntype->mBase = dtype->mBase;
|
||||||
|
@ -5025,6 +5263,7 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration*
|
||||||
vl = CoerceType(proc, exp, tblock, inlineMapper, vl, dtype);
|
vl = CoerceType(proc, exp, tblock, inlineMapper, vl, dtype);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (ttype != IT_NONE)
|
if (ttype != IT_NONE)
|
||||||
{
|
{
|
||||||
|
@ -5074,7 +5313,7 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration*
|
||||||
|
|
||||||
block = eblock;
|
block = eblock;
|
||||||
|
|
||||||
return ExValue(dtype, ttemp);
|
return ExValue(dtype, ttemp, tref);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -5099,6 +5338,9 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration*
|
||||||
|
|
||||||
InterInstruction * ins = new InterInstruction(MapLocation(exp, inlineMapper), IC_CONVERSION_OPERATOR);
|
InterInstruction * ins = new InterInstruction(MapLocation(exp, inlineMapper), IC_CONVERSION_OPERATOR);
|
||||||
|
|
||||||
|
if (vr.mType->IsReference() && !exp->mDecType->IsReference())
|
||||||
|
vr = ToValue(proc, exp, block, inlineMapper, vr);
|
||||||
|
|
||||||
if (exp->mDecType->mType == DT_TYPE_FLOAT && vr.mType->IsIntegerType())
|
if (exp->mDecType->mType == DT_TYPE_FLOAT && vr.mType->IsIntegerType())
|
||||||
{
|
{
|
||||||
vr = Dereference(proc, exp, block, inlineMapper, vr);
|
vr = Dereference(proc, exp, block, inlineMapper, vr);
|
||||||
|
@ -5395,6 +5637,37 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration*
|
||||||
return ExValue(TheVoidTypeDeclaration);
|
return ExValue(TheVoidTypeDeclaration);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case EX_FORBODY:
|
||||||
|
{
|
||||||
|
DestructStack* odestack = destack;
|
||||||
|
|
||||||
|
InterInstruction* jins0 = new InterInstruction(MapLocation(exp, inlineMapper), IC_JUMP);
|
||||||
|
InterInstruction* jins1 = new InterInstruction(MapLocation(exp, inlineMapper), IC_JUMP);
|
||||||
|
|
||||||
|
InterCodeBasicBlock* lblock = new InterCodeBasicBlock(proc);
|
||||||
|
InterCodeBasicBlock* cblock = new InterCodeBasicBlock(proc);
|
||||||
|
|
||||||
|
block->Append(jins0);
|
||||||
|
block->Close(lblock, nullptr);
|
||||||
|
|
||||||
|
DestructStack* idestack = destack;
|
||||||
|
|
||||||
|
vr = TranslateExpression(procType, proc, lblock, exp->mLeft, destack, gotos, breakBlock, BranchTarget(cblock, idestack), inlineMapper);
|
||||||
|
|
||||||
|
lblock->Append(jins1);
|
||||||
|
lblock->Close(cblock, nullptr);
|
||||||
|
|
||||||
|
UnwindDestructStack(procType, proc, cblock, destack, idestack, inlineMapper);
|
||||||
|
destack = idestack;
|
||||||
|
|
||||||
|
block = cblock;
|
||||||
|
|
||||||
|
exp = exp->mRight;
|
||||||
|
if (!exp)
|
||||||
|
return ExValue(TheVoidTypeDeclaration);
|
||||||
|
|
||||||
|
} break;
|
||||||
|
|
||||||
case EX_FOR:
|
case EX_FOR:
|
||||||
{
|
{
|
||||||
DestructStack* odestack = destack;
|
DestructStack* odestack = destack;
|
||||||
|
@ -5514,7 +5787,7 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration*
|
||||||
}
|
}
|
||||||
|
|
||||||
case EX_AGGREGATE:
|
case EX_AGGREGATE:
|
||||||
mErrors->Error(exp->mLocation, EERR_INVALID_INITIALIZER, "Unexpected aggreate");
|
mErrors->Error(exp->mLocation, EERR_INVALID_INITIALIZER, "Unexpected aggregate");
|
||||||
return ExValue(TheVoidTypeDeclaration);
|
return ExValue(TheVoidTypeDeclaration);
|
||||||
|
|
||||||
case EX_SWITCH:
|
case EX_SWITCH:
|
||||||
|
@ -5963,7 +6236,10 @@ InterCodeProcedure* InterCodeGenerator::TranslateProcedure(InterCodeModule * mod
|
||||||
proc->mNativeProcedure = true;
|
proc->mNativeProcedure = true;
|
||||||
|
|
||||||
if (dec->mFlags & DTF_INTERRUPT)
|
if (dec->mFlags & DTF_INTERRUPT)
|
||||||
|
{
|
||||||
proc->mInterrupt = true;
|
proc->mInterrupt = true;
|
||||||
|
proc->mCompilerOptions &= ~COPT_OPTIMIZE_OUTLINE;
|
||||||
|
}
|
||||||
|
|
||||||
if (dec->mFlags & DTF_HWINTERRUPT)
|
if (dec->mFlags & DTF_HWINTERRUPT)
|
||||||
proc->mHardwareInterrupt = true;
|
proc->mHardwareInterrupt = true;
|
||||||
|
@ -6036,7 +6312,12 @@ InterCodeProcedure* InterCodeGenerator::TranslateProcedure(InterCodeModule * mod
|
||||||
else
|
else
|
||||||
proc->mFastCallBase = BC_REG_FPARAMS_END - BC_REG_FPARAMS;
|
proc->mFastCallBase = BC_REG_FPARAMS_END - BC_REG_FPARAMS;
|
||||||
|
|
||||||
if (dec->mBase->mBase->mType != DT_TYPE_VOID && dec->mBase->mBase->mType != DT_TYPE_STRUCT)
|
if (dec->mBase->mBase->IsShortIntStruct())
|
||||||
|
{
|
||||||
|
proc->mValueReturn = true;
|
||||||
|
proc->mReturnType = IT_INT32;
|
||||||
|
}
|
||||||
|
else if (dec->mBase->mBase->mType != DT_TYPE_VOID && dec->mBase->mBase->mType != DT_TYPE_STRUCT)
|
||||||
{
|
{
|
||||||
proc->mValueReturn = true;
|
proc->mValueReturn = true;
|
||||||
proc->mReturnType = InterTypeOf(dec->mBase->mBase);
|
proc->mReturnType = InterTypeOf(dec->mBase->mBase);
|
||||||
|
@ -6112,7 +6393,7 @@ InterCodeProcedure* InterCodeGenerator::TranslateProcedure(InterCodeModule * mod
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
mErrors->Error(dec->mLocation, EERR_UNDEFINED_OBJECT, "Calling undefined function", dec->mQualIdent->mString);
|
mErrors->Error(dec->mLocation, EERR_UNDEFINED_OBJECT, "Calling undefined function", dec->FullIdent());
|
||||||
|
|
||||||
if (strcmp(proc->mIdent->mString, "main"))
|
if (strcmp(proc->mIdent->mString, "main"))
|
||||||
{
|
{
|
||||||
|
@ -6137,7 +6418,7 @@ InterCodeProcedure* InterCodeGenerator::TranslateProcedure(InterCodeModule * mod
|
||||||
|
|
||||||
void InterCodeGenerator::CompleteMainInit(void)
|
void InterCodeGenerator::CompleteMainInit(void)
|
||||||
{
|
{
|
||||||
if (mErrors->mErrorCount == 0)
|
if (mErrors->mErrorCount == 0 && mMainInitBlock)
|
||||||
{
|
{
|
||||||
InterInstruction* ins = new InterInstruction(mMainInitProc->mLocation, IC_JUMP);
|
InterInstruction* ins = new InterInstruction(mMainInitProc->mLocation, IC_JUMP);
|
||||||
mMainInitBlock->Append(ins);
|
mMainInitBlock->Append(ins);
|
||||||
|
|
|
@ -94,12 +94,12 @@ protected:
|
||||||
void BuildSwitchTree(InterCodeProcedure* proc, Expression* exp, InterCodeBasicBlock* block, InlineMapper * inlineMapper, ExValue v, const SwitchNodeArray& nodes, int left, int right, int vleft, int vright, InterCodeBasicBlock* dblock);
|
void BuildSwitchTree(InterCodeProcedure* proc, Expression* exp, InterCodeBasicBlock* block, InlineMapper * inlineMapper, ExValue v, const SwitchNodeArray& nodes, int left, int right, int vleft, int vright, InterCodeBasicBlock* dblock);
|
||||||
|
|
||||||
ExValue ToValue(InterCodeProcedure* proc, Expression* exp, InterCodeBasicBlock*& block, InlineMapper* inlineMapper, ExValue v);
|
ExValue ToValue(InterCodeProcedure* proc, Expression* exp, InterCodeBasicBlock*& block, InlineMapper* inlineMapper, ExValue v);
|
||||||
ExValue Dereference(InterCodeProcedure* proc, Expression* exp, InterCodeBasicBlock*& block, InlineMapper* inlineMapper, ExValue v, int level = 0);
|
ExValue Dereference(InterCodeProcedure* proc, Expression* exp, InterCodeBasicBlock*& block, InlineMapper* inlineMapper, ExValue v, int level = 0, int limit = 0);
|
||||||
ExValue CoerceType(InterCodeProcedure* proc, Expression* exp, InterCodeBasicBlock*& block, InlineMapper* inlineMapper, ExValue v, Declaration * type, bool checkTrunc = true);
|
ExValue CoerceType(InterCodeProcedure* proc, Expression* exp, InterCodeBasicBlock*& block, InlineMapper* inlineMapper, ExValue v, Declaration * type, bool checkTrunc = true);
|
||||||
ExValue TranslateExpression(Declaration * procType, InterCodeProcedure * proc, InterCodeBasicBlock*& block, Expression* exp, DestructStack*& destack, GotoNode*& gotos, const BranchTarget & breakBlock, const BranchTarget& continueBlock, InlineMapper * inlineMapper, ExValue * lrexp = nullptr);
|
ExValue TranslateExpression(Declaration * procType, InterCodeProcedure * proc, InterCodeBasicBlock*& block, Expression* exp, DestructStack*& destack, GotoNode*& gotos, const BranchTarget & breakBlock, const BranchTarget& continueBlock, InlineMapper * inlineMapper, ExValue * lrexp = nullptr);
|
||||||
void TranslateLogic(Declaration* procType, InterCodeProcedure* proc, InterCodeBasicBlock* block, InterCodeBasicBlock* tblock, InterCodeBasicBlock* fblock, Expression* exp, DestructStack*& destack, GotoNode*& gotos, InlineMapper* inlineMapper);
|
void TranslateLogic(Declaration* procType, InterCodeProcedure* proc, InterCodeBasicBlock* block, InterCodeBasicBlock* tblock, InterCodeBasicBlock* fblock, Expression* exp, DestructStack*& destack, GotoNode*& gotos, InlineMapper* inlineMapper);
|
||||||
ExValue TranslateInline(Declaration* procType, InterCodeProcedure* proc, InterCodeBasicBlock*& block, Expression* exp, const BranchTarget& breakBlock, const BranchTarget& continueBlock, InlineMapper* inlineMapper, bool inlineConstexpr, ExValue* lrexp);
|
ExValue TranslateInline(Declaration* procType, InterCodeProcedure* proc, InterCodeBasicBlock*& block, Expression* exp, const BranchTarget& breakBlock, const BranchTarget& continueBlock, InlineMapper* inlineMapper, bool inlineConstexpr, ExValue* lrexp);
|
||||||
void CopyStruct(InterCodeProcedure* proc, Expression* exp, InterCodeBasicBlock*& block, ExValue vl, ExValue vr, InlineMapper* inlineMapper, bool moving);
|
void CopyStruct (InterCodeProcedure* proc, Expression* exp, InterCodeBasicBlock*& block, ExValue vl, ExValue vr, InlineMapper* inlineMapper, bool moving);
|
||||||
void CopyStructSimple(InterCodeProcedure* proc, Expression* exp, InterCodeBasicBlock * block, InlineMapper* inlineMapper, ExValue vl, ExValue vr);
|
void CopyStructSimple(InterCodeProcedure* proc, Expression* exp, InterCodeBasicBlock * block, InlineMapper* inlineMapper, ExValue vl, ExValue vr);
|
||||||
void StoreValue(InterCodeProcedure* proc, Expression* exp, InterCodeBasicBlock*& block, InlineMapper* inlineMapper, ExValue vl, ExValue vr);
|
void StoreValue(InterCodeProcedure* proc, Expression* exp, InterCodeBasicBlock*& block, InlineMapper* inlineMapper, ExValue vl, ExValue vr);
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,7 @@ bool LinkerReference::operator!=(const LinkerReference& ref)
|
||||||
}
|
}
|
||||||
|
|
||||||
LinkerObject::LinkerObject(void)
|
LinkerObject::LinkerObject(void)
|
||||||
: mReferences(nullptr), mNumTemporaries(0), mSize(0), mAlignment(1), mStackSection(nullptr), mIdent(nullptr), mFullIdent(nullptr), mStartUsed(0x10000), mEndUsed(0x00000), mMemory(nullptr)
|
: mReferences(nullptr), mNumTemporaries(0), mSize(0), mStripe(0), mAlignment(1), mStackSection(nullptr), mIdent(nullptr), mFullIdent(nullptr), mStartUsed(0x10000), mEndUsed(0x00000), mMemory(nullptr)
|
||||||
, mPrefix(nullptr), mSuffix(nullptr), mProc(nullptr), mNativeProc(nullptr)
|
, mPrefix(nullptr), mSuffix(nullptr), mProc(nullptr), mNativeProc(nullptr)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
@ -650,7 +650,7 @@ bool LinkerRegion::Allocate(Linker * linker, LinkerObject* lobj, bool merge, boo
|
||||||
int start = (mFreeChunks[i].mStart + lobj->mAlignment - 1) & ~(lobj->mAlignment - 1);
|
int start = (mFreeChunks[i].mStart + lobj->mAlignment - 1) & ~(lobj->mAlignment - 1);
|
||||||
int end = start + lobj->mSize;
|
int end = start + lobj->mSize;
|
||||||
|
|
||||||
if (!(linker->mCompilerOptions & COPT_OPTIMIZE_CODE_SIZE) && (lobj->mFlags & LOBJF_NO_CROSS) && lobj->mSize <= 256 && (start & 0xff00) != ((end - 1) & 0xff00) && !(lobj->mSection->mFlags & LSECF_PACKED))
|
if (((lobj->mFlags & LOBJF_NEVER_CROSS) || !(linker->mCompilerOptions & COPT_OPTIMIZE_CODE_SIZE) && (lobj->mFlags & LOBJF_NO_CROSS) && !(lobj->mSection->mFlags & LSECF_PACKED)) && lobj->mSize <= 256 && (start & 0xff00) != ((end - 1) & 0xff00))
|
||||||
;
|
;
|
||||||
else if (end <= mFreeChunks[i].mEnd)
|
else if (end <= mFreeChunks[i].mEnd)
|
||||||
{
|
{
|
||||||
|
@ -702,7 +702,7 @@ bool LinkerRegion::Allocate(Linker * linker, LinkerObject* lobj, bool merge, boo
|
||||||
int start = (mStart + mUsed + lobj->mAlignment - 1) & ~(lobj->mAlignment - 1);
|
int start = (mStart + mUsed + lobj->mAlignment - 1) & ~(lobj->mAlignment - 1);
|
||||||
int end = start + lobj->mSize;
|
int end = start + lobj->mSize;
|
||||||
|
|
||||||
if (!(linker->mCompilerOptions & COPT_OPTIMIZE_CODE_SIZE) && !retry && (lobj->mFlags & LOBJF_NO_CROSS) && !(lobj->mFlags & LOBJF_FORCE_ALIGN) && lobj->mSize <= 256 && (start & 0xff00) != ((end - 1) & 0xff00) && !(lobj->mSection->mFlags & LSECF_PACKED))
|
if (((lobj->mFlags & LOBJF_NEVER_CROSS) || !(linker->mCompilerOptions & COPT_OPTIMIZE_CODE_SIZE) && !retry && (lobj->mFlags & LOBJF_NO_CROSS) && !(lobj->mSection->mFlags & LSECF_PACKED)) && !(lobj->mFlags & LOBJF_FORCE_ALIGN) && lobj->mSize <= 256 && (start & 0xff00) != ((end - 1) & 0xff00))
|
||||||
{
|
{
|
||||||
start = (start + 0x00ff) & 0xff00;
|
start = (start + 0x00ff) & 0xff00;
|
||||||
end = start + lobj->mSize;
|
end = start + lobj->mSize;
|
||||||
|
@ -1903,6 +1903,8 @@ bool Linker::WriteDbjFile(FILE* file)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const char hexchars[] = "0123456789abcdef";
|
||||||
|
|
||||||
bool Linker::WriteLblFile(const char* filename)
|
bool Linker::WriteLblFile(const char* filename)
|
||||||
{
|
{
|
||||||
FILE* file;
|
FILE* file;
|
||||||
|
@ -1916,7 +1918,28 @@ bool Linker::WriteLblFile(const char* filename)
|
||||||
if (obj->mFlags & LOBJF_REFERENCED)
|
if (obj->mFlags & LOBJF_REFERENCED)
|
||||||
{
|
{
|
||||||
if (obj->mIdent)
|
if (obj->mIdent)
|
||||||
fprintf(file, "al %04x .%s\n", obj->mAddress, obj->mIdent->mString);
|
{
|
||||||
|
char buffer[400];
|
||||||
|
char nbuffer[500];
|
||||||
|
|
||||||
|
strcpy_s(buffer, obj->mIdent->mString);
|
||||||
|
int i = 0, j = 0;
|
||||||
|
while (buffer[i])
|
||||||
|
{
|
||||||
|
if (buffer[i] >= '0' && buffer[i] <= '9' || buffer[i] >= 'a' && buffer[i] <= 'z' || buffer[i] >= 'A' && buffer[i] <= 'Z' || buffer[i] == '_' || buffer[i] == ':')
|
||||||
|
nbuffer[j++] = buffer[i];
|
||||||
|
else
|
||||||
|
{
|
||||||
|
nbuffer[j++] = '?';
|
||||||
|
nbuffer[j++] = hexchars[(buffer[i] >> 4) & 0x0f];
|
||||||
|
nbuffer[j++] = hexchars[buffer[i] & 0x0f];
|
||||||
|
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
nbuffer[j] = 0;
|
||||||
|
fprintf(file, "al %04x .%s\n", obj->mAddress, nbuffer);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -156,6 +156,7 @@ static const uint32 LOBJF_NO_CROSS = 0x00000080;
|
||||||
static const uint32 LOBJF_ZEROPAGE = 0x00000100;
|
static const uint32 LOBJF_ZEROPAGE = 0x00000100;
|
||||||
static const uint32 LOBJF_FORCE_ALIGN = 0x00000200;
|
static const uint32 LOBJF_FORCE_ALIGN = 0x00000200;
|
||||||
static const uint32 LOBJF_ZEROPAGESET = 0x00000400;
|
static const uint32 LOBJF_ZEROPAGESET = 0x00000400;
|
||||||
|
static const uint32 LOBJF_NEVER_CROSS = 0x00000800;
|
||||||
|
|
||||||
static const uint32 LOBJF_ARG_REG_A = 0x00001000;
|
static const uint32 LOBJF_ARG_REG_A = 0x00001000;
|
||||||
static const uint32 LOBJF_ARG_REG_X = 0x00002000;
|
static const uint32 LOBJF_ARG_REG_X = 0x00002000;
|
||||||
|
@ -163,6 +164,7 @@ static const uint32 LOBJF_ARG_REG_Y = 0x00004000;
|
||||||
|
|
||||||
static const uint32 LOBJF_RET_REG_A = 0x00010000;
|
static const uint32 LOBJF_RET_REG_A = 0x00010000;
|
||||||
static const uint32 LOBJF_RET_REG_X = 0x00020000;
|
static const uint32 LOBJF_RET_REG_X = 0x00020000;
|
||||||
|
static const uint32 LOBJF_RET_REG_Y = 0x00020000;
|
||||||
|
|
||||||
static const uint32 LOBJF_LOCAL_VAR = 0x00100000;
|
static const uint32 LOBJF_LOCAL_VAR = 0x00100000;
|
||||||
static const uint32 LOBJF_LOCAL_USED = 0x00200000;
|
static const uint32 LOBJF_LOCAL_USED = 0x00200000;
|
||||||
|
@ -190,7 +192,7 @@ public:
|
||||||
LinkerObjectType mType;
|
LinkerObjectType mType;
|
||||||
int mID, mMapID;
|
int mID, mMapID;
|
||||||
int mAddress, mRefAddress;
|
int mAddress, mRefAddress;
|
||||||
int mSize, mAlignment, mStartUsed, mEndUsed;
|
int mSize, mAlignment, mStripe, mStartUsed, mEndUsed;
|
||||||
LinkerSection * mSection;
|
LinkerSection * mSection;
|
||||||
LinkerRegion * mRegion;
|
LinkerRegion * mRegion;
|
||||||
uint8 * mData, * mMemory;
|
uint8 * mData, * mMemory;
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -135,18 +135,23 @@ static const uint32 NCIF_USE_CPU_REG_X = 0x00002000;
|
||||||
static const uint32 NCIF_USE_CPU_REG_Y = 0x00004000;
|
static const uint32 NCIF_USE_CPU_REG_Y = 0x00004000;
|
||||||
static const uint32 NCIF_USE_CPU_REG_C = 0x00008000;
|
static const uint32 NCIF_USE_CPU_REG_C = 0x00008000;
|
||||||
|
|
||||||
// use a 32bit zero page register indexed by X for JSR
|
static const uint32 NCIF_PROVIDE_CPU_REG_A = 0x00010000;
|
||||||
static const uint32 NCIF_USE_ZP_32_X = 0x00010000;
|
static const uint32 NCIF_PROVIDE_CPU_REG_X = 0x00020000;
|
||||||
static const uint32 NICF_USE_ZP_ADDR = 0x00020000;
|
static const uint32 NCIF_PROVIDE_CPU_REG_Y = 0x00040000;
|
||||||
static const uint32 NICF_USE_WORKREGS = 0x00040000;
|
static const uint32 NCIF_PROVIDE_CPU_REG_C = 0x00080000;
|
||||||
|
|
||||||
static const uint32 NCIF_BREAKPOINT = 0x00080000;
|
// use a 32bit zero page register indexed by X for JSR
|
||||||
|
static const uint32 NCIF_USE_ZP_32_X = 0x00100000;
|
||||||
|
static const uint32 NICF_USE_ZP_ADDR = 0x00200000;
|
||||||
|
static const uint32 NICF_USE_WORKREGS = 0x00400000;
|
||||||
|
|
||||||
|
static const uint32 NCIF_BREAKPOINT = 0x00800000;
|
||||||
|
|
||||||
class NativeCodeInstruction
|
class NativeCodeInstruction
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
NativeCodeInstruction(void);
|
NativeCodeInstruction(void);
|
||||||
NativeCodeInstruction(const InterInstruction * ins, AsmInsType type, AsmInsMode mode = ASMIM_IMPLIED, int64 address = 0, LinkerObject * linkerObject = nullptr, uint32 flags = NCIF_LOWER | NCIF_UPPER, int param = 0);
|
NativeCodeInstruction(const InterInstruction * ins, AsmInsType type, AsmInsMode mode = ASMIM_IMPLIED, int64 address = 0, LinkerObject * linkerObject = nullptr, uint32 flags = NCIF_LOWER | NCIF_UPPER, int param = 0, int minv = 0, int maxv = 255);
|
||||||
NativeCodeInstruction(const InterInstruction* ins, AsmInsType type, const NativeCodeInstruction & addr);
|
NativeCodeInstruction(const InterInstruction* ins, AsmInsType type, const NativeCodeInstruction & addr);
|
||||||
|
|
||||||
AsmInsType mType;
|
AsmInsType mType;
|
||||||
|
@ -157,11 +162,13 @@ public:
|
||||||
uint32 mLive;
|
uint32 mLive;
|
||||||
LinkerObject * mLinkerObject;
|
LinkerObject * mLinkerObject;
|
||||||
const InterInstruction * mIns;
|
const InterInstruction * mIns;
|
||||||
|
uint8 mMinVal, mMaxVal;
|
||||||
|
|
||||||
void Disassemble(FILE* file) const;
|
void Disassemble(FILE* file) const;
|
||||||
void DisassembleAddress(FILE* file) const;
|
void DisassembleAddress(FILE* file) const;
|
||||||
|
|
||||||
void CopyMode(const NativeCodeInstruction& ins);
|
void CopyMode(const NativeCodeInstruction& ins);
|
||||||
|
void CopyModeAndRange(const NativeCodeInstruction& ins);
|
||||||
|
|
||||||
void Assemble(NativeCodeBasicBlock* block);
|
void Assemble(NativeCodeBasicBlock* block);
|
||||||
void FilterRegUsage(NumberSet& requiredTemps, NumberSet& providedTemps);
|
void FilterRegUsage(NumberSet& requiredTemps, NumberSet& providedTemps);
|
||||||
|
@ -198,6 +205,7 @@ public:
|
||||||
bool UsesZeroPage(int address) const;
|
bool UsesZeroPage(int address) const;
|
||||||
bool ReferencesZeroPage(int address) const;
|
bool ReferencesZeroPage(int address) const;
|
||||||
|
|
||||||
|
bool SameLinkerObjectVariableRange(const NativeCodeInstruction& ins, bool sameXY = false) const;
|
||||||
|
|
||||||
bool ChangesGlobalMemory(void) const;
|
bool ChangesGlobalMemory(void) const;
|
||||||
bool UsesMemoryOf(const NativeCodeInstruction& ins) const;
|
bool UsesMemoryOf(const NativeCodeInstruction& ins) const;
|
||||||
|
@ -259,7 +267,7 @@ public:
|
||||||
ExpandingArray<NativeCodeBasicBlock*> mEntryBlocks;
|
ExpandingArray<NativeCodeBasicBlock*> mEntryBlocks;
|
||||||
|
|
||||||
int mOffset, mSize, mPlace, mNumEntries, mNumEntered, mFrameOffset, mTemp;
|
int mOffset, mSize, mPlace, mNumEntries, mNumEntered, mFrameOffset, mTemp;
|
||||||
bool mPlaced, mCopied, mKnownShortBranch, mBypassed, mAssembled, mNoFrame, mVisited, mLoopHead, mVisiting, mLocked, mPatched, mPatchFail, mPatchChecked, mPatchStart, mPatchLoop, mPatchLoopChanged, mPatchExit;
|
bool mPlaced, mCopied, mKnownShortBranch, mBypassed, mAssembled, mNoFrame, mVisited, mLoopHead, mVisiting, mLocked, mPatched, mPatchFail, mPatchChecked, mPatchUsed, mPatchStart, mPatchLoop, mPatchLoopChanged, mPatchExit;
|
||||||
bool mEntryRegA, mEntryRegX, mEntryRegY, mExitRegA, mExitRegX, mChecked;
|
bool mEntryRegA, mEntryRegX, mEntryRegY, mExitRegA, mExitRegX, mChecked;
|
||||||
NativeCodeBasicBlock * mDominator, * mSameBlock;
|
NativeCodeBasicBlock * mDominator, * mSameBlock;
|
||||||
|
|
||||||
|
@ -278,6 +286,7 @@ public:
|
||||||
NativeCodeInstruction mALSIns, mXLSIns, mYLSIns;
|
NativeCodeInstruction mALSIns, mXLSIns, mYLSIns;
|
||||||
|
|
||||||
void Disassemble(FILE* file);
|
void Disassemble(FILE* file);
|
||||||
|
void DisassembleBody(FILE* file);
|
||||||
|
|
||||||
NativeCodeInstruction DecodeNative(const InterInstruction* ins, LinkerObject * lobj, int& offset) const;
|
NativeCodeInstruction DecodeNative(const InterInstruction* ins, LinkerObject * lobj, int& offset) const;
|
||||||
|
|
||||||
|
@ -294,6 +303,7 @@ public:
|
||||||
int LeadsInto(NativeCodeBasicBlock* block, int dist);
|
int LeadsInto(NativeCodeBasicBlock* block, int dist);
|
||||||
NativeCodeBasicBlock* PlaceSequence(ExpandingArray<NativeCodeBasicBlock*>& placement, NativeCodeBasicBlock* block);
|
NativeCodeBasicBlock* PlaceSequence(ExpandingArray<NativeCodeBasicBlock*>& placement, NativeCodeBasicBlock* block);
|
||||||
void BuildPlacement(ExpandingArray<NativeCodeBasicBlock*>& placement);
|
void BuildPlacement(ExpandingArray<NativeCodeBasicBlock*>& placement);
|
||||||
|
void OptimizePlacement(void);
|
||||||
void InitialOffset(int& total);
|
void InitialOffset(int& total);
|
||||||
bool CalculateOffset(int& total, bool final);
|
bool CalculateOffset(int& total, bool final);
|
||||||
|
|
||||||
|
@ -318,6 +328,8 @@ public:
|
||||||
bool UsesZeroPage(int address, int from = 0, int to = 65536) const;
|
bool UsesZeroPage(int address, int from = 0, int to = 65536) const;
|
||||||
bool ReferencesZeroPage(int address, int from = 0, int to = 65536) const;
|
bool ReferencesZeroPage(int address, int from = 0, int to = 65536) const;
|
||||||
|
|
||||||
|
bool ChangesMemory(const NativeCodeInstruction& ins, int from = 0, int to = 65536) const;
|
||||||
|
bool ReferencesMemory(const NativeCodeInstruction& ins, int from = 0, int to = 65536) const;
|
||||||
|
|
||||||
bool RemoveNops(void);
|
bool RemoveNops(void);
|
||||||
bool PeepHoleOptimizer(int pass);
|
bool PeepHoleOptimizer(int pass);
|
||||||
|
@ -336,7 +348,7 @@ public:
|
||||||
bool PeepHoleOptimizerIterate(int pass);
|
bool PeepHoleOptimizerIterate(int pass);
|
||||||
bool PeepHoleOptimizerExits(int pass);
|
bool PeepHoleOptimizerExits(int pass);
|
||||||
|
|
||||||
void BlockSizeReduction(NativeCodeProcedure* proc, int xenter, int yenter);
|
void BlockSizeReduction(NativeCodeProcedure* proc, int xenter, int yenter, int center);
|
||||||
bool BlockSizeCopyReduction(NativeCodeProcedure* proc, int & si, int & di);
|
bool BlockSizeCopyReduction(NativeCodeProcedure* proc, int & si, int & di);
|
||||||
|
|
||||||
bool OptimizeSimpleLoopInvariant(NativeCodeProcedure* proc, bool full);
|
bool OptimizeSimpleLoopInvariant(NativeCodeProcedure* proc, bool full);
|
||||||
|
@ -349,6 +361,7 @@ public:
|
||||||
bool OptimizeSingleEntryLoop(NativeCodeProcedure* proc);
|
bool OptimizeSingleEntryLoop(NativeCodeProcedure* proc);
|
||||||
|
|
||||||
bool OptimizeSimpleLoop(NativeCodeProcedure* proc, bool full);
|
bool OptimizeSimpleLoop(NativeCodeProcedure* proc, bool full);
|
||||||
|
bool OptimizeSimpleForLoop(void);
|
||||||
bool SimpleLoopReversal(NativeCodeProcedure* proc);
|
bool SimpleLoopReversal(NativeCodeProcedure* proc);
|
||||||
bool OptimizeInnerLoop(NativeCodeProcedure* proc, NativeCodeBasicBlock* head, NativeCodeBasicBlock* tail, ExpandingArray<NativeCodeBasicBlock*>& blocks);
|
bool OptimizeInnerLoop(NativeCodeProcedure* proc, NativeCodeBasicBlock* head, NativeCodeBasicBlock* tail, ExpandingArray<NativeCodeBasicBlock*>& blocks);
|
||||||
bool OptimizeXYSimpleLoop(void);
|
bool OptimizeXYSimpleLoop(void);
|
||||||
|
@ -360,9 +373,11 @@ public:
|
||||||
bool OptimizeInnerLoops(NativeCodeProcedure* proc);
|
bool OptimizeInnerLoops(NativeCodeProcedure* proc);
|
||||||
NativeCodeBasicBlock* CollectInnerLoop(NativeCodeBasicBlock* head, ExpandingArray<NativeCodeBasicBlock*>& lblocks);
|
NativeCodeBasicBlock* CollectInnerLoop(NativeCodeBasicBlock* head, ExpandingArray<NativeCodeBasicBlock*>& lblocks);
|
||||||
|
|
||||||
bool OptimizeGenericLoop(NativeCodeProcedure* proc);
|
int CorrectXOffset(const InterInstruction * ins, int yoffset, int at);
|
||||||
bool CollectGenericLoop(NativeCodeProcedure* proc, ExpandingArray<NativeCodeBasicBlock*>& lblocks);
|
int CorrectYOffset(const InterInstruction * ins, int yoffset, int at);
|
||||||
bool CollectSingleEntryGenericLoop(NativeCodeProcedure* proc, ExpandingArray<NativeCodeBasicBlock*>& lblocks);
|
bool OptimizeGenericLoop(void);
|
||||||
|
bool CollectGenericLoop(ExpandingArray<NativeCodeBasicBlock*>& lblocks);
|
||||||
|
bool CollectSingleEntryGenericLoop(ExpandingArray<NativeCodeBasicBlock*>& lblocks);
|
||||||
void CollectReachable(ExpandingArray<NativeCodeBasicBlock*>& lblock);
|
void CollectReachable(ExpandingArray<NativeCodeBasicBlock*>& lblock);
|
||||||
|
|
||||||
bool OptimizeFindLoop(NativeCodeProcedure* proc);
|
bool OptimizeFindLoop(NativeCodeProcedure* proc);
|
||||||
|
@ -396,7 +411,7 @@ public:
|
||||||
NativeCodeBasicBlock* BinaryOperator(InterCodeProcedure* proc, NativeCodeProcedure* nproc, const InterInstruction * ins, const InterInstruction* sins1, const InterInstruction* sins0);
|
NativeCodeBasicBlock* BinaryOperator(InterCodeProcedure* proc, NativeCodeProcedure* nproc, const InterInstruction * ins, const InterInstruction* sins1, const InterInstruction* sins0);
|
||||||
void UnaryOperator(InterCodeProcedure* proc, NativeCodeProcedure* nproc, const InterInstruction * ins);
|
void UnaryOperator(InterCodeProcedure* proc, NativeCodeProcedure* nproc, const InterInstruction * ins);
|
||||||
void RelationalOperator(InterCodeProcedure* proc, const InterInstruction * ins, NativeCodeProcedure * nproc, NativeCodeBasicBlock* trueJump, NativeCodeBasicBlock * falseJump);
|
void RelationalOperator(InterCodeProcedure* proc, const InterInstruction * ins, NativeCodeProcedure * nproc, NativeCodeBasicBlock* trueJump, NativeCodeBasicBlock * falseJump);
|
||||||
void LoadEffectiveAddress(InterCodeProcedure* proc, const InterInstruction * ins, const InterInstruction* sins1, const InterInstruction* sins0, bool addrvalid);
|
void LoadEffectiveAddress(InterCodeProcedure* proc, const InterInstruction * ins, const InterInstruction* sins1, const InterInstruction* sins0, bool addrvalid, bool addrused = false);
|
||||||
void LoadStoreOpAbsolute2D(InterCodeProcedure* proc, const InterInstruction* lins1, const InterInstruction* lins2, const InterInstruction* mins);
|
void LoadStoreOpAbsolute2D(InterCodeProcedure* proc, const InterInstruction* lins1, const InterInstruction* lins2, const InterInstruction* mins);
|
||||||
void SignExtendAddImmediate(InterCodeProcedure* proc, const InterInstruction* xins, const InterInstruction* ains);
|
void SignExtendAddImmediate(InterCodeProcedure* proc, const InterInstruction* xins, const InterInstruction* ains);
|
||||||
void BinaryDivModPair(InterCodeProcedure* proc, NativeCodeProcedure* nproc, const InterInstruction* ins1, const InterInstruction* ins2);
|
void BinaryDivModPair(InterCodeProcedure* proc, NativeCodeProcedure* nproc, const InterInstruction* ins1, const InterInstruction* ins2);
|
||||||
|
@ -413,6 +428,7 @@ public:
|
||||||
|
|
||||||
void LoadByteIndexedValue(InterCodeProcedure* proc, const InterInstruction* iins, const InterInstruction* rins);
|
void LoadByteIndexedValue(InterCodeProcedure* proc, const InterInstruction* iins, const InterInstruction* rins);
|
||||||
void StoreByteIndexedValue(InterCodeProcedure* proc, const InterInstruction* iins, const InterInstruction* rins);
|
void StoreByteIndexedValue(InterCodeProcedure* proc, const InterInstruction* iins, const InterInstruction* rins);
|
||||||
|
void CopyByteIndexedValue(InterCodeProcedure* proc, const InterInstruction* riins, const InterInstruction* wiins, const InterInstruction* rins, const InterInstruction* wins);
|
||||||
|
|
||||||
void CallAssembler(InterCodeProcedure* proc, NativeCodeProcedure* nproc, const InterInstruction * ins);
|
void CallAssembler(InterCodeProcedure* proc, NativeCodeProcedure* nproc, const InterInstruction * ins);
|
||||||
void CallFunction(InterCodeProcedure* proc, NativeCodeProcedure* nproc, const InterInstruction * ins);
|
void CallFunction(InterCodeProcedure* proc, NativeCodeProcedure* nproc, const InterInstruction * ins);
|
||||||
|
@ -449,8 +465,6 @@ public:
|
||||||
bool MergeBasicBlocks(void);
|
bool MergeBasicBlocks(void);
|
||||||
bool RemoveJumpToBranch(void);
|
bool RemoveJumpToBranch(void);
|
||||||
|
|
||||||
void MarkLoopHead(void);
|
|
||||||
|
|
||||||
struct DominatorStacks
|
struct DominatorStacks
|
||||||
{
|
{
|
||||||
ExpandingArray< NativeCodeBasicBlock* > d1, d2;
|
ExpandingArray< NativeCodeBasicBlock* > d1, d2;
|
||||||
|
@ -525,6 +539,7 @@ public:
|
||||||
bool MoveTXADCDown(int at);
|
bool MoveTXADCDown(int at);
|
||||||
bool MoveTXALogicTAXDown(int at);
|
bool MoveTXALogicTAXDown(int at);
|
||||||
bool FoldShiftORAIntoLoadImmUp(int at);
|
bool FoldShiftORAIntoLoadImmUp(int at);
|
||||||
|
bool ReverseShiftByteOrder(int at);
|
||||||
|
|
||||||
bool FindAccuExitValue(int& at);
|
bool FindAccuExitValue(int& at);
|
||||||
bool MoveLoadXAbsUpCrossBlock(int at);
|
bool MoveLoadXAbsUpCrossBlock(int at);
|
||||||
|
@ -558,6 +573,7 @@ public:
|
||||||
bool CombineSameYtoX(int xpos, int ypos, int end);
|
bool CombineSameYtoX(int xpos, int ypos, int end);
|
||||||
|
|
||||||
bool FindImmediateStore(int at, int reg, const NativeCodeInstruction*& ains);
|
bool FindImmediateStore(int at, int reg, const NativeCodeInstruction*& ains);
|
||||||
|
int FindImmediateGlobalStore(int at, const NativeCodeInstruction& ins);
|
||||||
|
|
||||||
bool JoinXYCrossBlock(void);
|
bool JoinXYCrossBlock(void);
|
||||||
bool CanCombineSameXtoYCrossBlock(int from);
|
bool CanCombineSameXtoYCrossBlock(int from);
|
||||||
|
@ -594,6 +610,9 @@ public:
|
||||||
bool OffsetValueForwarding(const ValueNumberingDataSet & data);
|
bool OffsetValueForwarding(const ValueNumberingDataSet & data);
|
||||||
bool AbsoluteValueForwarding(const ExpandingArray<NativeCodeLoadStorePair>& npairs);
|
bool AbsoluteValueForwarding(const ExpandingArray<NativeCodeLoadStorePair>& npairs);
|
||||||
bool IndexXYValueForwarding(int xreg, int xoffset, int xvalue, int yreg, int yoffset, int yvalue);
|
bool IndexXYValueForwarding(int xreg, int xoffset, int xvalue, int yreg, int yoffset, int yvalue);
|
||||||
|
bool ReduceIndexXYZeroShuffle(NativeCodeBasicBlock* from, int xreg, int yreg);
|
||||||
|
bool CheckLoopIndexXRegisters(NativeCodeBasicBlock* head, int xreg);
|
||||||
|
bool CheckLoopIndexYRegisters(NativeCodeBasicBlock* head, int yreg);
|
||||||
|
|
||||||
void MarkLocalUsedLinkerObjects(void);
|
void MarkLocalUsedLinkerObjects(void);
|
||||||
bool RemoveLocalUnusedLinkerObjects(void);
|
bool RemoveLocalUnusedLinkerObjects(void);
|
||||||
|
@ -617,6 +636,8 @@ public:
|
||||||
bool HasTailSTXInto(int& addr, int& index, NativeCodeBasicBlock* tblock) const;
|
bool HasTailSTXInto(int& addr, int& index, NativeCodeBasicBlock* tblock) const;
|
||||||
bool HasTailSTYInto(int& addr, int& index, NativeCodeBasicBlock* tblock) const;
|
bool HasTailSTYInto(int& addr, int& index, NativeCodeBasicBlock* tblock) const;
|
||||||
|
|
||||||
|
bool HasTailSTAGlobal(NativeCodeInstruction & ins, int& index) const;
|
||||||
|
|
||||||
bool MayBeMovedBeforeBlock(int at);
|
bool MayBeMovedBeforeBlock(int at);
|
||||||
bool MayBeMovedBeforeBlock(int at, const NativeCodeInstruction & ins);
|
bool MayBeMovedBeforeBlock(int at, const NativeCodeInstruction & ins);
|
||||||
bool MayBeMovedBeforeBlock(int start, int end);
|
bool MayBeMovedBeforeBlock(int start, int end);
|
||||||
|
@ -782,10 +803,20 @@ public:
|
||||||
bool CheckPatchFailUse(void);
|
bool CheckPatchFailUse(void);
|
||||||
|
|
||||||
bool CheckPatchFailLoop(const NativeCodeBasicBlock* block, const NativeCodeBasicBlock* head, int reg, bool changed);
|
bool CheckPatchFailLoop(const NativeCodeBasicBlock* block, const NativeCodeBasicBlock* head, int reg, bool changed);
|
||||||
|
bool CheckPatchFailLoopPair(const NativeCodeBasicBlock* block, const NativeCodeBasicBlock* head, int reg, bool changed);
|
||||||
|
|
||||||
bool JoinSameBranch(NativeCodeBasicBlock* block);
|
bool JoinSameBranch(NativeCodeBasicBlock* block);
|
||||||
bool MergeSameBranch(void);
|
bool MergeSameBranch(void);
|
||||||
|
|
||||||
|
bool CheckBoolBitPropagation(const NativeCodeBasicBlock* block, int at, int reg);
|
||||||
|
bool PatchBoolBitPropagation(const NativeCodeBasicBlock* block, int at, int reg);
|
||||||
|
|
||||||
|
bool CollectRegBoolInstructionsForward(int reg, ExpandingArray<NativeCodeBasicBlock*>& cblocks, ExpandingArray<NativeCodeInstruction*>& lins);
|
||||||
|
bool CollectRegBoolInstructionsBackward(int reg, ExpandingArray<NativeCodeBasicBlock*>& cblocks, ExpandingArray<NativeCodeInstruction*>& lins);
|
||||||
|
|
||||||
|
bool CollectCheckRegOriginBlocks(int at, int reg, ExpandingArray<NativeCodeBasicBlock*>& lblocks, ExpandingArray<NativeCodeInstruction*>& lins);
|
||||||
|
bool PatchBitBoolConstOrigin(void);
|
||||||
|
|
||||||
// reg : base register pair to replace
|
// reg : base register pair to replace
|
||||||
// index: index register
|
// index: index register
|
||||||
// at : start position in block
|
// at : start position in block
|
||||||
|
@ -795,9 +826,20 @@ public:
|
||||||
bool CheckGlobalAddressSumYPointer(const NativeCodeBasicBlock * block, int reg, int index, int at, int yval);
|
bool CheckGlobalAddressSumYPointer(const NativeCodeBasicBlock * block, int reg, int index, int at, int yval);
|
||||||
bool PatchGlobalAddressSumYPointer(const NativeCodeBasicBlock* block, int reg, int index, int at, int yval, LinkerObject * lobj, int address, uint32 flags = NCIF_LOWER | NCIF_UPPER);
|
bool PatchGlobalAddressSumYPointer(const NativeCodeBasicBlock* block, int reg, int index, int at, int yval, LinkerObject * lobj, int address, uint32 flags = NCIF_LOWER | NCIF_UPPER);
|
||||||
|
|
||||||
|
// reg : register to replace
|
||||||
|
// at : start position in block
|
||||||
|
// ains : instruction loading original data
|
||||||
|
// cycles : max number of cycles saving
|
||||||
bool CheckSingleUseGlobalLoad(const NativeCodeBasicBlock* block, int reg, int at, const NativeCodeInstruction& ains, int cycles);
|
bool CheckSingleUseGlobalLoad(const NativeCodeBasicBlock* block, int reg, int at, const NativeCodeInstruction& ains, int cycles);
|
||||||
bool PatchSingleUseGlobalLoad(const NativeCodeBasicBlock* block, int reg, int at, const NativeCodeInstruction& ains);
|
bool PatchSingleUseGlobalLoad(const NativeCodeBasicBlock* block, int reg, int at, const NativeCodeInstruction& ains);
|
||||||
|
|
||||||
|
// rins : instruction storing the data
|
||||||
|
// at : start position in block
|
||||||
|
// ains : instruction loading original data
|
||||||
|
// cycles : max number of cycles saving
|
||||||
|
bool CheckSingleUseGlobalLoadStruct(const NativeCodeBasicBlock* block, const NativeCodeInstruction& rins, int at, const NativeCodeInstruction& ains, bool cleared, bool poisoned);
|
||||||
|
bool PatchSingleUseGlobalLoadStruct(const NativeCodeBasicBlock* block, const NativeCodeInstruction& rins, int at, const NativeCodeInstruction& ains);
|
||||||
|
|
||||||
// reg : base register pair to replace
|
// reg : base register pair to replace
|
||||||
// base: new base register
|
// base: new base register
|
||||||
// iins : indexing instruction
|
// iins : indexing instruction
|
||||||
|
|
1896
oscar64/Parser.cpp
1896
oscar64/Parser.cpp
File diff suppressed because it is too large
Load Diff
|
@ -11,6 +11,7 @@ public:
|
||||||
~Parser(void);
|
~Parser(void);
|
||||||
|
|
||||||
Parser* Clone(void);
|
Parser* Clone(void);
|
||||||
|
Parser * mParent;
|
||||||
|
|
||||||
DeclarationScope * mGlobals, * mScope, * mTemplateScope, * mCaptureScope;
|
DeclarationScope * mGlobals, * mScope, * mTemplateScope, * mCaptureScope;
|
||||||
int mLocalIndex;
|
int mLocalIndex;
|
||||||
|
@ -24,6 +25,8 @@ public:
|
||||||
uint64 mCompilerOptionStack[32];
|
uint64 mCompilerOptionStack[32];
|
||||||
int mCompilerOptionSP;
|
int mCompilerOptionSP;
|
||||||
|
|
||||||
|
Location FullLocation(const Location& loc);
|
||||||
|
|
||||||
void Parse(void);
|
void Parse(void);
|
||||||
protected:
|
protected:
|
||||||
bool ExpectToken(Token token);
|
bool ExpectToken(Token token);
|
||||||
|
@ -77,6 +80,7 @@ protected:
|
||||||
Expression* DefaultInitExpression(Expression* vexp);
|
Expression* DefaultInitExpression(Expression* vexp);
|
||||||
Expression* ParseVarInitExpression(Expression* lexp, bool inner = false);
|
Expression* ParseVarInitExpression(Expression* lexp, bool inner = false);
|
||||||
Expression* CloneVarInitExpression(Expression* vexp, Expression* iexp, Expression * qexp);
|
Expression* CloneVarInitExpression(Expression* vexp, Expression* iexp, Expression * qexp);
|
||||||
|
Expression* CopyElision(Expression* vexp, Expression* rexp);
|
||||||
|
|
||||||
Declaration* ParsePostfixDeclaration(void);
|
Declaration* ParsePostfixDeclaration(void);
|
||||||
Declaration* ReverseDeclaration(Declaration* odec, Declaration* bdec);
|
Declaration* ReverseDeclaration(Declaration* odec, Declaration* bdec);
|
||||||
|
@ -133,7 +137,10 @@ protected:
|
||||||
|
|
||||||
Declaration* ParseTypeID(bool tid, Declaration * bdec = nullptr);
|
Declaration* ParseTypeID(bool tid, Declaration * bdec = nullptr);
|
||||||
|
|
||||||
|
Expression* ParseConstruction(Declaration* type);
|
||||||
|
|
||||||
Expression* ParseCastExpression(Expression* exp);
|
Expression* ParseCastExpression(Expression* exp);
|
||||||
|
Expression* ParseIdentExpression(const Location & eloc, Declaration* dec, bool lhs, bool tid = false);
|
||||||
Expression* ParseSimpleExpression(bool lhs, bool tid = false);
|
Expression* ParseSimpleExpression(bool lhs, bool tid = false);
|
||||||
Expression* ParsePrefixExpression(bool lhs);
|
Expression* ParsePrefixExpression(bool lhs);
|
||||||
Expression* ParsePostfixExpression(bool lhs);
|
Expression* ParsePostfixExpression(bool lhs);
|
||||||
|
@ -155,6 +162,7 @@ protected:
|
||||||
Expression* ParseListExpression(bool lhs, Declaration * params = nullptr);
|
Expression* ParseListExpression(bool lhs, Declaration * params = nullptr);
|
||||||
|
|
||||||
Expression* ParseParenthesisExpression(void);
|
Expression* ParseParenthesisExpression(void);
|
||||||
|
void ParseStaticAssert(void);
|
||||||
|
|
||||||
Errors* mErrors;
|
Errors* mErrors;
|
||||||
Scanner* mScanner;
|
Scanner* mScanner;
|
||||||
|
|
|
@ -327,6 +327,16 @@ struct CTMHeader9
|
||||||
uint8 mColors[7];
|
uint8 mColors[7];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct CTTHeader9
|
||||||
|
{
|
||||||
|
uint8 mDispMode;
|
||||||
|
uint8 mColorMethod;
|
||||||
|
uint8 mFlags;
|
||||||
|
uint8 mFgridWidth[2], mFGridHeight[2];
|
||||||
|
char mFGridConfig;
|
||||||
|
uint8 mColors[6];
|
||||||
|
};
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
#pragma pack(push, 1)
|
#pragma pack(push, 1)
|
||||||
struct SPDHeader5
|
struct SPDHeader5
|
||||||
|
@ -486,6 +496,7 @@ void SourceFile::ReadCharPad(Errors* errors, const Location& location, SourceFil
|
||||||
CTMHeader ctmHeader;
|
CTMHeader ctmHeader;
|
||||||
CTMHeader8 ctmHeader8;
|
CTMHeader8 ctmHeader8;
|
||||||
CTMHeader9 ctmHeader9;
|
CTMHeader9 ctmHeader9;
|
||||||
|
CTTHeader9 cttHeader9;
|
||||||
uint16 ctmMarker, numChars, numTiles;
|
uint16 ctmMarker, numChars, numTiles;
|
||||||
char tileWidth, tileHeight;
|
char tileWidth, tileHeight;
|
||||||
|
|
||||||
|
@ -496,10 +507,20 @@ void SourceFile::ReadCharPad(Errors* errors, const Location& location, SourceFil
|
||||||
fread(&ctmHeader8, sizeof(CTMHeader8), 1, mFile);
|
fread(&ctmHeader8, sizeof(CTMHeader8), 1, mFile);
|
||||||
break;
|
break;
|
||||||
case 9:
|
case 9:
|
||||||
|
if (ctmHeader.mID[2] == 'T')
|
||||||
|
{
|
||||||
|
fread(&cttHeader9, sizeof(CTTHeader9), 1, mFile);
|
||||||
|
ctmHeader8.mDispMode = cttHeader9.mDispMode;
|
||||||
|
ctmHeader8.mColorMethod = cttHeader9.mColorMethod;
|
||||||
|
ctmHeader8.mFlags = cttHeader9.mFlags;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
fread(&ctmHeader9, sizeof(CTMHeader9), 1, mFile);
|
fread(&ctmHeader9, sizeof(CTMHeader9), 1, mFile);
|
||||||
ctmHeader8.mDispMode = ctmHeader9.mDispMode;
|
ctmHeader8.mDispMode = ctmHeader9.mDispMode;
|
||||||
ctmHeader8.mColorMethod = ctmHeader9.mColorMethod;
|
ctmHeader8.mColorMethod = ctmHeader9.mColorMethod;
|
||||||
ctmHeader8.mFlags = ctmHeader9.mFlags;
|
ctmHeader8.mFlags = ctmHeader9.mFlags;
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,6 +51,7 @@ const char* TokenNames[] =
|
||||||
"'extern'",
|
"'extern'",
|
||||||
"'inline'",
|
"'inline'",
|
||||||
"'__assume'",
|
"'__assume'",
|
||||||
|
"'static_assert'",
|
||||||
|
|
||||||
"__asm",
|
"__asm",
|
||||||
"__interrupt",
|
"__interrupt",
|
||||||
|
@ -821,6 +822,8 @@ void Scanner::NextPreToken(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (mToken == TK_PREP_IDENT)
|
else if (mToken == TK_PREP_IDENT)
|
||||||
|
{
|
||||||
|
if (mTokenIdent->mString[0])
|
||||||
{
|
{
|
||||||
Macro* def = nullptr;
|
Macro* def = nullptr;
|
||||||
if (mDefineArguments)
|
if (mDefineArguments)
|
||||||
|
@ -845,6 +848,12 @@ void Scanner::NextPreToken(void)
|
||||||
else
|
else
|
||||||
mErrors->Error(mLocation, EERR_INVALID_PREPROCESSOR, "Invalid preprocessor command", mTokenIdent);
|
mErrors->Error(mLocation, EERR_INVALID_PREPROCESSOR, "Invalid preprocessor command", mTokenIdent);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mToken = TK_HASH;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
else if (mToken == TK_PREP_UNDEF)
|
else if (mToken == TK_PREP_UNDEF)
|
||||||
{
|
{
|
||||||
NextRawToken();
|
NextRawToken();
|
||||||
|
@ -1116,14 +1125,15 @@ void Scanner::NextPreToken(void)
|
||||||
while (mTokenChar == ' ')
|
while (mTokenChar == ' ')
|
||||||
NextChar();
|
NextChar();
|
||||||
|
|
||||||
while (mTokenChar == '#' && mLine[mOffset] == '#')
|
if (mTokenChar == '#' && mLine[mOffset] == '#')
|
||||||
{
|
{
|
||||||
mOffset++;
|
|
||||||
NextChar();
|
|
||||||
|
|
||||||
char tkbase[256];
|
char tkbase[256];
|
||||||
strcpy_s(tkbase, mTokenIdent->mString);
|
strcpy_s(tkbase, mTokenIdent->mString);
|
||||||
|
|
||||||
|
do {
|
||||||
|
mOffset++;
|
||||||
|
NextChar();
|
||||||
|
|
||||||
ptrdiff_t n = 0;
|
ptrdiff_t n = 0;
|
||||||
char tkident[256];
|
char tkident[256];
|
||||||
while (IsIdentChar(mTokenChar))
|
while (IsIdentChar(mTokenChar))
|
||||||
|
@ -1152,9 +1162,32 @@ void Scanner::NextPreToken(void)
|
||||||
n--;
|
n--;
|
||||||
tkbase[n] = 0;
|
tkbase[n] = 0;
|
||||||
|
|
||||||
mTokenIdent = Ident::Unique(tkbase);
|
while (mTokenChar == ' ')
|
||||||
}
|
NextChar();
|
||||||
|
|
||||||
|
} while (mTokenChar == '#' && mLine[mOffset] == '#');
|
||||||
|
|
||||||
|
ptrdiff_t n = strlen(tkbase);
|
||||||
|
char* str = new char[n + 1];
|
||||||
|
strcpy_s(str, n + 1, tkbase);
|
||||||
|
|
||||||
|
MacroExpansion* ex = new MacroExpansion();
|
||||||
|
ex->mDefinedArguments = mDefineArguments;
|
||||||
|
|
||||||
|
ex->mLine = mLine;
|
||||||
|
ex->mOffset = mOffset;
|
||||||
|
ex->mLink = mMacroExpansion;
|
||||||
|
ex->mChar = mTokenChar;
|
||||||
|
|
||||||
|
mMacroExpansion = ex;
|
||||||
|
mMacroExpansionDepth++;
|
||||||
|
if (mMacroExpansionDepth > 1024)
|
||||||
|
mErrors->Error(mLocation, EFATAL_MACRO_EXPANSION_DEPTH, "Maximum macro expansion depth exceeded", mTokenIdent);
|
||||||
|
mLine = str;
|
||||||
|
mOffset = 0;
|
||||||
|
NextChar();
|
||||||
|
}
|
||||||
|
else
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1800,6 +1833,8 @@ void Scanner::NextRawToken(void)
|
||||||
mToken = TK_ASM;
|
mToken = TK_ASM;
|
||||||
else if (!strcmp(tkident, "__assume"))
|
else if (!strcmp(tkident, "__assume"))
|
||||||
mToken = TK_ASSUME;
|
mToken = TK_ASSUME;
|
||||||
|
else if (!strcmp(tkident, "static_assert"))
|
||||||
|
mToken = TK_STATIC_ASSERT;
|
||||||
else if (!strcmp(tkident, "__interrupt"))
|
else if (!strcmp(tkident, "__interrupt"))
|
||||||
mToken = TK_INTERRUPT;
|
mToken = TK_INTERRUPT;
|
||||||
else if (!strcmp(tkident, "__hwinterrupt"))
|
else if (!strcmp(tkident, "__hwinterrupt"))
|
||||||
|
@ -1979,7 +2014,7 @@ void Scanner::NextRawToken(void)
|
||||||
|
|
||||||
default:
|
default:
|
||||||
// dirty little hack to implement token preview, got to fix
|
// dirty little hack to implement token preview, got to fix
|
||||||
// this with an infinit preview sequence at one point
|
// this with an infinite preview sequence at one point
|
||||||
mUngetToken = mToken;
|
mUngetToken = mToken;
|
||||||
mToken = TK_OPERATOR;
|
mToken = TK_OPERATOR;
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -49,6 +49,7 @@ enum Token
|
||||||
TK_EXTERN,
|
TK_EXTERN,
|
||||||
TK_INLINE,
|
TK_INLINE,
|
||||||
TK_ASSUME,
|
TK_ASSUME,
|
||||||
|
TK_STATIC_ASSERT,
|
||||||
|
|
||||||
TK_ASM,
|
TK_ASM,
|
||||||
TK_INTERRUPT,
|
TK_INTERRUPT,
|
||||||
|
|
|
@ -76,7 +76,7 @@ int main2(int argc, const char** argv)
|
||||||
|
|
||||||
#else
|
#else
|
||||||
strcpy(strProductName, "oscar64");
|
strcpy(strProductName, "oscar64");
|
||||||
strcpy(strProductVersion, "1.31.259");
|
strcpy(strProductVersion, "1.31.261");
|
||||||
|
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
uint32_t length = sizeof(basePath);
|
uint32_t length = sizeof(basePath);
|
||||||
|
@ -111,38 +111,12 @@ int main2(int argc, const char** argv)
|
||||||
GrowingArray<const char*> dataFiles(nullptr);
|
GrowingArray<const char*> dataFiles(nullptr);
|
||||||
GrowingArray<bool> dataFileCompressed(false);
|
GrowingArray<bool> dataFileCompressed(false);
|
||||||
|
|
||||||
|
bool emulate = false, profile = false, customCRT = false;
|
||||||
|
int trace = 0;
|
||||||
|
|
||||||
compiler->mPreprocessor->AddPath(basePath);
|
compiler->mPreprocessor->AddPath(basePath);
|
||||||
strcpy_s(includePath, basePath);
|
strcpy_s(includePath, basePath);
|
||||||
{
|
strcat_s(includePath, "include");
|
||||||
FILE* crtFile;
|
|
||||||
char crtFileNamePath[FILENAME_MAX];
|
|
||||||
crtFileNamePath[FILENAME_MAX - 1] = '\0';
|
|
||||||
strcpy_s(crtFileNamePath, basePath);
|
|
||||||
strcat_s(crtFileNamePath, "include/crt.h");
|
|
||||||
|
|
||||||
if (!fopen_s(&crtFile, crtFileNamePath, "r"))
|
|
||||||
strcat_s(includePath, "include/");
|
|
||||||
else
|
|
||||||
{
|
|
||||||
strcpy_s(crtFileNamePath, basePath);
|
|
||||||
strcat_s(crtFileNamePath, "include/oscar64/crt.h");
|
|
||||||
|
|
||||||
if (!fopen_s(&crtFile, crtFileNamePath, "r"))
|
|
||||||
strcat_s(includePath, "include/oscar64/");
|
|
||||||
else
|
|
||||||
{
|
|
||||||
printf("Could not locate Oscar64 includes under %s\n", basePath);
|
|
||||||
return 20;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fclose(crtFile);
|
|
||||||
}
|
|
||||||
compiler->mPreprocessor->AddPath(includePath);
|
|
||||||
strcpy_s(crtPath, includePath);
|
|
||||||
strcat_s(crtPath, "crt.c");
|
|
||||||
|
|
||||||
bool emulate = false, profile = false;
|
|
||||||
int trace = 0;
|
|
||||||
|
|
||||||
targetPath[0] = 0;
|
targetPath[0] = 0;
|
||||||
diskPath[0] = 0;
|
diskPath[0] = 0;
|
||||||
|
@ -185,6 +159,10 @@ int main2(int argc, const char** argv)
|
||||||
{
|
{
|
||||||
compiler->mPreprocessor->AddPath(arg + 3);
|
compiler->mPreprocessor->AddPath(arg + 3);
|
||||||
}
|
}
|
||||||
|
else if (arg[1] == 'i' && arg[2] == 'i' && arg[3] == '=')
|
||||||
|
{
|
||||||
|
strcpy_s(includePath, arg + 4);
|
||||||
|
}
|
||||||
else if (arg[1] == 'f' && arg[2] == '=')
|
else if (arg[1] == 'f' && arg[2] == '=')
|
||||||
{
|
{
|
||||||
dataFiles.Push(arg + 3);
|
dataFiles.Push(arg + 3);
|
||||||
|
@ -206,6 +184,7 @@ int main2(int argc, const char** argv)
|
||||||
else if (arg[1] == 'r' && arg[2] == 't' && arg[3] == '=')
|
else if (arg[1] == 'r' && arg[2] == 't' && arg[3] == '=')
|
||||||
{
|
{
|
||||||
strcpy_s(crtPath, arg + 4);
|
strcpy_s(crtPath, arg + 4);
|
||||||
|
customCRT = true;
|
||||||
}
|
}
|
||||||
else if (arg[1] == 'd' && arg[2] == '6' && arg[3] == '4' && arg[4] == '=')
|
else if (arg[1] == 'd' && arg[2] == '6' && arg[3] == '4' && arg[4] == '=')
|
||||||
{
|
{
|
||||||
|
@ -253,6 +232,8 @@ int main2(int argc, const char** argv)
|
||||||
compiler->mCompilerOptions |= COPT_OPTIMIZE_ASSEMBLER;
|
compiler->mCompilerOptions |= COPT_OPTIMIZE_ASSEMBLER;
|
||||||
else if (arg[2] == 'i' && !arg[3])
|
else if (arg[2] == 'i' && !arg[3])
|
||||||
compiler->mCompilerOptions |= COPT_OPTIMIZE_AUTO_INLINE;
|
compiler->mCompilerOptions |= COPT_OPTIMIZE_AUTO_INLINE;
|
||||||
|
else if (arg[2] == 'i' && arg[3] == 'i' && !arg[4])
|
||||||
|
compiler->mCompilerOptions |= COPT_OPTIMIZE_AUTO_INLINE | COPT_OPTIMIZE_AUTO_INLINE_ALL;
|
||||||
else if (arg[2] == 'z' && !arg[3])
|
else if (arg[2] == 'z' && !arg[3])
|
||||||
compiler->mCompilerOptions |= COPT_OPTIMIZE_AUTO_ZEROPAGE;
|
compiler->mCompilerOptions |= COPT_OPTIMIZE_AUTO_ZEROPAGE;
|
||||||
else if (arg[2] == 'p' && !arg[3])
|
else if (arg[2] == 'p' && !arg[3])
|
||||||
|
@ -263,6 +244,8 @@ int main2(int argc, const char** argv)
|
||||||
compiler->mCompilerOptions |= COPT_OPTIMIZE_MERGE_CALLS;
|
compiler->mCompilerOptions |= COPT_OPTIMIZE_MERGE_CALLS;
|
||||||
else if (arg[2] == 'o' && !arg[3])
|
else if (arg[2] == 'o' && !arg[3])
|
||||||
compiler->mCompilerOptions |= COPT_OPTIMIZE_OUTLINE;
|
compiler->mCompilerOptions |= COPT_OPTIMIZE_OUTLINE;
|
||||||
|
else if (arg[2] == 'x' && !arg[3])
|
||||||
|
compiler->mCompilerOptions |= COPT_OPTIMIZE_PAGE_CROSSING;
|
||||||
else
|
else
|
||||||
compiler->mErrors->Error(loc, EERR_COMMAND_LINE, "Invalid command line argument", arg);
|
compiler->mErrors->Error(loc, EERR_COMMAND_LINE, "Invalid command line argument", arg);
|
||||||
}
|
}
|
||||||
|
@ -444,6 +427,12 @@ int main2(int argc, const char** argv)
|
||||||
compiler->mTargetMachine = TMACH_PLUS4;
|
compiler->mTargetMachine = TMACH_PLUS4;
|
||||||
compiler->AddDefine(Ident::Unique("__PLUS4__"), "1");
|
compiler->AddDefine(Ident::Unique("__PLUS4__"), "1");
|
||||||
}
|
}
|
||||||
|
else if (!strcmp(targetMachine, "mega65"))
|
||||||
|
{
|
||||||
|
strcpy_s(basicStart, "0x2001");
|
||||||
|
compiler->mTargetMachine = TMACH_MEGA65;
|
||||||
|
compiler->AddDefine(Ident::Unique("__MEGA65__"), "1");
|
||||||
|
}
|
||||||
else if (!strcmp(targetMachine, "x16"))
|
else if (!strcmp(targetMachine, "x16"))
|
||||||
{
|
{
|
||||||
strcpy_s(basicStart, "0x0801");
|
strcpy_s(basicStart, "0x0801");
|
||||||
|
@ -568,6 +557,35 @@ int main2(int argc, const char** argv)
|
||||||
|
|
||||||
// Add runtime module
|
// Add runtime module
|
||||||
|
|
||||||
|
compiler->mPreprocessor->AddPath(includePath);
|
||||||
|
|
||||||
|
if (!customCRT)
|
||||||
|
{
|
||||||
|
FILE* crtFile;
|
||||||
|
char crtFileNamePath[FILENAME_MAX];
|
||||||
|
crtFileNamePath[FILENAME_MAX - 1] = '\0';
|
||||||
|
strcpy_s(crtFileNamePath, includePath);
|
||||||
|
strcat_s(crtFileNamePath, "/crt.h");
|
||||||
|
|
||||||
|
if (fopen_s(&crtFile, crtFileNamePath, "r"))
|
||||||
|
{
|
||||||
|
strcpy_s(crtFileNamePath, basePath);
|
||||||
|
strcat_s(crtFileNamePath, "include/oscar64/crt.h");
|
||||||
|
|
||||||
|
if (!fopen_s(&crtFile, crtFileNamePath, "r"))
|
||||||
|
strcat_s(includePath, "include/oscar64/");
|
||||||
|
else
|
||||||
|
{
|
||||||
|
printf("Could not locate Oscar64 includes under %s\n", basePath);
|
||||||
|
return 20;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fclose(crtFile);
|
||||||
|
|
||||||
|
strcpy_s(crtPath, includePath);
|
||||||
|
strcat_s(crtPath, "/crt.c");
|
||||||
|
}
|
||||||
|
|
||||||
if (crtPath[0])
|
if (crtPath[0])
|
||||||
compiler->mCompilationUnits->AddUnit(loc, crtPath, nullptr);
|
compiler->mCompilationUnits->AddUnit(loc, crtPath, nullptr);
|
||||||
|
|
||||||
|
|
|
@ -25,8 +25,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_NEUTRAL
|
||||||
//
|
//
|
||||||
|
|
||||||
VS_VERSION_INFO VERSIONINFO
|
VS_VERSION_INFO VERSIONINFO
|
||||||
FILEVERSION 1,31,259,0
|
FILEVERSION 1,31,261,0
|
||||||
PRODUCTVERSION 1,31,259,0
|
PRODUCTVERSION 1,31,261,0
|
||||||
FILEFLAGSMASK 0x3fL
|
FILEFLAGSMASK 0x3fL
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
FILEFLAGS 0x1L
|
FILEFLAGS 0x1L
|
||||||
|
@ -43,12 +43,12 @@ BEGIN
|
||||||
BEGIN
|
BEGIN
|
||||||
VALUE "CompanyName", "oscar64"
|
VALUE "CompanyName", "oscar64"
|
||||||
VALUE "FileDescription", "oscar64 compiler"
|
VALUE "FileDescription", "oscar64 compiler"
|
||||||
VALUE "FileVersion", "1.31.259.0"
|
VALUE "FileVersion", "1.31.261.0"
|
||||||
VALUE "InternalName", "oscar64.exe"
|
VALUE "InternalName", "oscar64.exe"
|
||||||
VALUE "LegalCopyright", "Copyright (C) 2021"
|
VALUE "LegalCopyright", "Copyright (C) 2021"
|
||||||
VALUE "OriginalFilename", "oscar64.exe"
|
VALUE "OriginalFilename", "oscar64.exe"
|
||||||
VALUE "ProductName", "oscar64"
|
VALUE "ProductName", "oscar64"
|
||||||
VALUE "ProductVersion", "1.31.259.0"
|
VALUE "ProductVersion", "1.31.261.0"
|
||||||
END
|
END
|
||||||
END
|
END
|
||||||
BLOCK "VarFileInfo"
|
BLOCK "VarFileInfo"
|
||||||
|
|
|
@ -34,6 +34,12 @@
|
||||||
}
|
}
|
||||||
"Entry"
|
"Entry"
|
||||||
{
|
{
|
||||||
|
"MsmKey" = "8:_03D7013B0D39A89CEA9D267005ADCE39"
|
||||||
|
"OwnerKey" = "8:_FB2E467BC172457785F4279BB0BFE8B6"
|
||||||
|
"MsmSig" = "8:_UNDEFINED"
|
||||||
|
}
|
||||||
|
"Entry"
|
||||||
|
{
|
||||||
"MsmKey" = "8:_04ABABC55200450383686DD782DD1548"
|
"MsmKey" = "8:_04ABABC55200450383686DD782DD1548"
|
||||||
"OwnerKey" = "8:_UNDEFINED"
|
"OwnerKey" = "8:_UNDEFINED"
|
||||||
"MsmSig" = "8:_UNDEFINED"
|
"MsmSig" = "8:_UNDEFINED"
|
||||||
|
@ -394,6 +400,12 @@
|
||||||
}
|
}
|
||||||
"Entry"
|
"Entry"
|
||||||
{
|
{
|
||||||
|
"MsmKey" = "8:_4B482689C546CDFC92F367BA507E7ADE"
|
||||||
|
"OwnerKey" = "8:_FB2E467BC172457785F4279BB0BFE8B6"
|
||||||
|
"MsmSig" = "8:_UNDEFINED"
|
||||||
|
}
|
||||||
|
"Entry"
|
||||||
|
{
|
||||||
"MsmKey" = "8:_4B8FC526E6CC47FC8321D0191BFDBEDC"
|
"MsmKey" = "8:_4B8FC526E6CC47FC8321D0191BFDBEDC"
|
||||||
"OwnerKey" = "8:_UNDEFINED"
|
"OwnerKey" = "8:_UNDEFINED"
|
||||||
"MsmSig" = "8:_UNDEFINED"
|
"MsmSig" = "8:_UNDEFINED"
|
||||||
|
@ -412,6 +424,12 @@
|
||||||
}
|
}
|
||||||
"Entry"
|
"Entry"
|
||||||
{
|
{
|
||||||
|
"MsmKey" = "8:_4E94486A43C1D1C032A05ED1E6F1FCEF"
|
||||||
|
"OwnerKey" = "8:_FB2E467BC172457785F4279BB0BFE8B6"
|
||||||
|
"MsmSig" = "8:_UNDEFINED"
|
||||||
|
}
|
||||||
|
"Entry"
|
||||||
|
{
|
||||||
"MsmKey" = "8:_4E9503F4F8F343739E4685C2066B3AD0"
|
"MsmKey" = "8:_4E9503F4F8F343739E4685C2066B3AD0"
|
||||||
"OwnerKey" = "8:_UNDEFINED"
|
"OwnerKey" = "8:_UNDEFINED"
|
||||||
"MsmSig" = "8:_UNDEFINED"
|
"MsmSig" = "8:_UNDEFINED"
|
||||||
|
@ -508,6 +526,12 @@
|
||||||
}
|
}
|
||||||
"Entry"
|
"Entry"
|
||||||
{
|
{
|
||||||
|
"MsmKey" = "8:_65687B00DD49EEBBFFECE831614822A9"
|
||||||
|
"OwnerKey" = "8:_FB2E467BC172457785F4279BB0BFE8B6"
|
||||||
|
"MsmSig" = "8:_UNDEFINED"
|
||||||
|
}
|
||||||
|
"Entry"
|
||||||
|
{
|
||||||
"MsmKey" = "8:_67C8F824E02B4211B315AB32AB7ABBB1"
|
"MsmKey" = "8:_67C8F824E02B4211B315AB32AB7ABBB1"
|
||||||
"OwnerKey" = "8:_UNDEFINED"
|
"OwnerKey" = "8:_UNDEFINED"
|
||||||
"MsmSig" = "8:_UNDEFINED"
|
"MsmSig" = "8:_UNDEFINED"
|
||||||
|
@ -736,14 +760,14 @@
|
||||||
}
|
}
|
||||||
"Entry"
|
"Entry"
|
||||||
{
|
{
|
||||||
"MsmKey" = "8:_98B942589E984AAD381F87F18DDB79D3"
|
"MsmKey" = "8:_9B2E1BB3CD154CEFB214378A64B0B00C"
|
||||||
"OwnerKey" = "8:_FB2E467BC172457785F4279BB0BFE8B6"
|
"OwnerKey" = "8:_UNDEFINED"
|
||||||
"MsmSig" = "8:_UNDEFINED"
|
"MsmSig" = "8:_UNDEFINED"
|
||||||
}
|
}
|
||||||
"Entry"
|
"Entry"
|
||||||
{
|
{
|
||||||
"MsmKey" = "8:_9B2E1BB3CD154CEFB214378A64B0B00C"
|
"MsmKey" = "8:_9CA4DFBA483A862FBF3DAEDE506D7DBD"
|
||||||
"OwnerKey" = "8:_UNDEFINED"
|
"OwnerKey" = "8:_FB2E467BC172457785F4279BB0BFE8B6"
|
||||||
"MsmSig" = "8:_UNDEFINED"
|
"MsmSig" = "8:_UNDEFINED"
|
||||||
}
|
}
|
||||||
"Entry"
|
"Entry"
|
||||||
|
@ -772,14 +796,14 @@
|
||||||
}
|
}
|
||||||
"Entry"
|
"Entry"
|
||||||
{
|
{
|
||||||
"MsmKey" = "8:_A14BC161099E420286E6A1595596D0F0"
|
"MsmKey" = "8:_A1455504C259EDA9662CE90C07369CC5"
|
||||||
"OwnerKey" = "8:_UNDEFINED"
|
"OwnerKey" = "8:_FB2E467BC172457785F4279BB0BFE8B6"
|
||||||
"MsmSig" = "8:_UNDEFINED"
|
"MsmSig" = "8:_UNDEFINED"
|
||||||
}
|
}
|
||||||
"Entry"
|
"Entry"
|
||||||
{
|
{
|
||||||
"MsmKey" = "8:_A16BC2645A14DC0435B7119153B32DE8"
|
"MsmKey" = "8:_A14BC161099E420286E6A1595596D0F0"
|
||||||
"OwnerKey" = "8:_FB2E467BC172457785F4279BB0BFE8B6"
|
"OwnerKey" = "8:_UNDEFINED"
|
||||||
"MsmSig" = "8:_UNDEFINED"
|
"MsmSig" = "8:_UNDEFINED"
|
||||||
}
|
}
|
||||||
"Entry"
|
"Entry"
|
||||||
|
@ -802,6 +826,12 @@
|
||||||
}
|
}
|
||||||
"Entry"
|
"Entry"
|
||||||
{
|
{
|
||||||
|
"MsmKey" = "8:_A2F68033370E18CD792ECD1F91357C1B"
|
||||||
|
"OwnerKey" = "8:_FB2E467BC172457785F4279BB0BFE8B6"
|
||||||
|
"MsmSig" = "8:_UNDEFINED"
|
||||||
|
}
|
||||||
|
"Entry"
|
||||||
|
{
|
||||||
"MsmKey" = "8:_A32310DEFD4E41118CD7D36A8614C0D4"
|
"MsmKey" = "8:_A32310DEFD4E41118CD7D36A8614C0D4"
|
||||||
"OwnerKey" = "8:_UNDEFINED"
|
"OwnerKey" = "8:_UNDEFINED"
|
||||||
"MsmSig" = "8:_UNDEFINED"
|
"MsmSig" = "8:_UNDEFINED"
|
||||||
|
@ -856,6 +886,12 @@
|
||||||
}
|
}
|
||||||
"Entry"
|
"Entry"
|
||||||
{
|
{
|
||||||
|
"MsmKey" = "8:_AD3AED76152E705799261747B7FD2015"
|
||||||
|
"OwnerKey" = "8:_FB2E467BC172457785F4279BB0BFE8B6"
|
||||||
|
"MsmSig" = "8:_UNDEFINED"
|
||||||
|
}
|
||||||
|
"Entry"
|
||||||
|
{
|
||||||
"MsmKey" = "8:_AE023AEA6C444140B19CD627DDC2CB87"
|
"MsmKey" = "8:_AE023AEA6C444140B19CD627DDC2CB87"
|
||||||
"OwnerKey" = "8:_UNDEFINED"
|
"OwnerKey" = "8:_UNDEFINED"
|
||||||
"MsmSig" = "8:_UNDEFINED"
|
"MsmSig" = "8:_UNDEFINED"
|
||||||
|
@ -904,12 +940,6 @@
|
||||||
}
|
}
|
||||||
"Entry"
|
"Entry"
|
||||||
{
|
{
|
||||||
"MsmKey" = "8:_B61CD152136A6E3CE5FF69D29E7A3F7B"
|
|
||||||
"OwnerKey" = "8:_FB2E467BC172457785F4279BB0BFE8B6"
|
|
||||||
"MsmSig" = "8:_UNDEFINED"
|
|
||||||
}
|
|
||||||
"Entry"
|
|
||||||
{
|
|
||||||
"MsmKey" = "8:_B85448D515F0487FB6845119AE346F1D"
|
"MsmKey" = "8:_B85448D515F0487FB6845119AE346F1D"
|
||||||
"OwnerKey" = "8:_UNDEFINED"
|
"OwnerKey" = "8:_UNDEFINED"
|
||||||
"MsmSig" = "8:_UNDEFINED"
|
"MsmSig" = "8:_UNDEFINED"
|
||||||
|
@ -952,6 +982,12 @@
|
||||||
}
|
}
|
||||||
"Entry"
|
"Entry"
|
||||||
{
|
{
|
||||||
|
"MsmKey" = "8:_C0E88FBB7B883ED27FFB3C60DBE114B8"
|
||||||
|
"OwnerKey" = "8:_FB2E467BC172457785F4279BB0BFE8B6"
|
||||||
|
"MsmSig" = "8:_UNDEFINED"
|
||||||
|
}
|
||||||
|
"Entry"
|
||||||
|
{
|
||||||
"MsmKey" = "8:_C239EFB1C3A646809AD2740ABDE747B0"
|
"MsmKey" = "8:_C239EFB1C3A646809AD2740ABDE747B0"
|
||||||
"OwnerKey" = "8:_UNDEFINED"
|
"OwnerKey" = "8:_UNDEFINED"
|
||||||
"MsmSig" = "8:_UNDEFINED"
|
"MsmSig" = "8:_UNDEFINED"
|
||||||
|
@ -1048,6 +1084,18 @@
|
||||||
}
|
}
|
||||||
"Entry"
|
"Entry"
|
||||||
{
|
{
|
||||||
|
"MsmKey" = "8:_D04F8D80984DFA3EA342FE8FA1B7CC91"
|
||||||
|
"OwnerKey" = "8:_FB2E467BC172457785F4279BB0BFE8B6"
|
||||||
|
"MsmSig" = "8:_UNDEFINED"
|
||||||
|
}
|
||||||
|
"Entry"
|
||||||
|
{
|
||||||
|
"MsmKey" = "8:_D057B4CD935875ECE7F0A91620660D07"
|
||||||
|
"OwnerKey" = "8:_FB2E467BC172457785F4279BB0BFE8B6"
|
||||||
|
"MsmSig" = "8:_UNDEFINED"
|
||||||
|
}
|
||||||
|
"Entry"
|
||||||
|
{
|
||||||
"MsmKey" = "8:_D0E45B48D76B4407B0BDE4378C1DB2C7"
|
"MsmKey" = "8:_D0E45B48D76B4407B0BDE4378C1DB2C7"
|
||||||
"OwnerKey" = "8:_UNDEFINED"
|
"OwnerKey" = "8:_UNDEFINED"
|
||||||
"MsmSig" = "8:_UNDEFINED"
|
"MsmSig" = "8:_UNDEFINED"
|
||||||
|
@ -1469,6 +1517,26 @@
|
||||||
"IsDependency" = "11:FALSE"
|
"IsDependency" = "11:FALSE"
|
||||||
"IsolateTo" = "8:"
|
"IsolateTo" = "8:"
|
||||||
}
|
}
|
||||||
|
"{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_03D7013B0D39A89CEA9D267005ADCE39"
|
||||||
|
{
|
||||||
|
"SourcePath" = "8:VCRUNTIME140.dll"
|
||||||
|
"TargetName" = "8:VCRUNTIME140.dll"
|
||||||
|
"Tag" = "8:"
|
||||||
|
"Folder" = "8:_607E75AF0E2A4CB9908C4C39DF8FE6E4"
|
||||||
|
"Condition" = "8:"
|
||||||
|
"Transitive" = "11:FALSE"
|
||||||
|
"Vital" = "11:TRUE"
|
||||||
|
"ReadOnly" = "11:FALSE"
|
||||||
|
"Hidden" = "11:FALSE"
|
||||||
|
"System" = "11:FALSE"
|
||||||
|
"Permanent" = "11:FALSE"
|
||||||
|
"SharedLegacy" = "11:FALSE"
|
||||||
|
"PackageAs" = "3:1"
|
||||||
|
"Register" = "3:1"
|
||||||
|
"Exclude" = "11:FALSE"
|
||||||
|
"IsDependency" = "11:TRUE"
|
||||||
|
"IsolateTo" = "8:"
|
||||||
|
}
|
||||||
"{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_04ABABC55200450383686DD782DD1548"
|
"{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_04ABABC55200450383686DD782DD1548"
|
||||||
{
|
{
|
||||||
"SourcePath" = "8:..\\samples\\games\\lander.c"
|
"SourcePath" = "8:..\\samples\\games\\lander.c"
|
||||||
|
@ -2669,6 +2737,26 @@
|
||||||
"IsDependency" = "11:FALSE"
|
"IsDependency" = "11:FALSE"
|
||||||
"IsolateTo" = "8:"
|
"IsolateTo" = "8:"
|
||||||
}
|
}
|
||||||
|
"{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_4B482689C546CDFC92F367BA507E7ADE"
|
||||||
|
{
|
||||||
|
"SourcePath" = "8:api-ms-win-crt-runtime-l1-1-0.dll"
|
||||||
|
"TargetName" = "8:api-ms-win-crt-runtime-l1-1-0.dll"
|
||||||
|
"Tag" = "8:"
|
||||||
|
"Folder" = "8:_607E75AF0E2A4CB9908C4C39DF8FE6E4"
|
||||||
|
"Condition" = "8:"
|
||||||
|
"Transitive" = "11:FALSE"
|
||||||
|
"Vital" = "11:TRUE"
|
||||||
|
"ReadOnly" = "11:FALSE"
|
||||||
|
"Hidden" = "11:FALSE"
|
||||||
|
"System" = "11:FALSE"
|
||||||
|
"Permanent" = "11:FALSE"
|
||||||
|
"SharedLegacy" = "11:FALSE"
|
||||||
|
"PackageAs" = "3:1"
|
||||||
|
"Register" = "3:1"
|
||||||
|
"Exclude" = "11:FALSE"
|
||||||
|
"IsDependency" = "11:TRUE"
|
||||||
|
"IsolateTo" = "8:"
|
||||||
|
}
|
||||||
"{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_4B8FC526E6CC47FC8321D0191BFDBEDC"
|
"{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_4B8FC526E6CC47FC8321D0191BFDBEDC"
|
||||||
{
|
{
|
||||||
"SourcePath" = "8:..\\samples\\resources\\scifiglyph.bin"
|
"SourcePath" = "8:..\\samples\\resources\\scifiglyph.bin"
|
||||||
|
@ -2729,6 +2817,26 @@
|
||||||
"IsDependency" = "11:FALSE"
|
"IsDependency" = "11:FALSE"
|
||||||
"IsolateTo" = "8:"
|
"IsolateTo" = "8:"
|
||||||
}
|
}
|
||||||
|
"{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_4E94486A43C1D1C032A05ED1E6F1FCEF"
|
||||||
|
{
|
||||||
|
"SourcePath" = "8:api-ms-win-crt-locale-l1-1-0.dll"
|
||||||
|
"TargetName" = "8:api-ms-win-crt-locale-l1-1-0.dll"
|
||||||
|
"Tag" = "8:"
|
||||||
|
"Folder" = "8:_607E75AF0E2A4CB9908C4C39DF8FE6E4"
|
||||||
|
"Condition" = "8:"
|
||||||
|
"Transitive" = "11:FALSE"
|
||||||
|
"Vital" = "11:TRUE"
|
||||||
|
"ReadOnly" = "11:FALSE"
|
||||||
|
"Hidden" = "11:FALSE"
|
||||||
|
"System" = "11:FALSE"
|
||||||
|
"Permanent" = "11:FALSE"
|
||||||
|
"SharedLegacy" = "11:FALSE"
|
||||||
|
"PackageAs" = "3:1"
|
||||||
|
"Register" = "3:1"
|
||||||
|
"Exclude" = "11:FALSE"
|
||||||
|
"IsDependency" = "11:TRUE"
|
||||||
|
"IsolateTo" = "8:"
|
||||||
|
}
|
||||||
"{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_4E9503F4F8F343739E4685C2066B3AD0"
|
"{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_4E9503F4F8F343739E4685C2066B3AD0"
|
||||||
{
|
{
|
||||||
"SourcePath" = "8:..\\include\\plus4\\ted.c"
|
"SourcePath" = "8:..\\include\\plus4\\ted.c"
|
||||||
|
@ -3049,6 +3157,26 @@
|
||||||
"IsDependency" = "11:FALSE"
|
"IsDependency" = "11:FALSE"
|
||||||
"IsolateTo" = "8:"
|
"IsolateTo" = "8:"
|
||||||
}
|
}
|
||||||
|
"{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_65687B00DD49EEBBFFECE831614822A9"
|
||||||
|
{
|
||||||
|
"SourcePath" = "8:api-ms-win-crt-stdio-l1-1-0.dll"
|
||||||
|
"TargetName" = "8:api-ms-win-crt-stdio-l1-1-0.dll"
|
||||||
|
"Tag" = "8:"
|
||||||
|
"Folder" = "8:_607E75AF0E2A4CB9908C4C39DF8FE6E4"
|
||||||
|
"Condition" = "8:"
|
||||||
|
"Transitive" = "11:FALSE"
|
||||||
|
"Vital" = "11:TRUE"
|
||||||
|
"ReadOnly" = "11:FALSE"
|
||||||
|
"Hidden" = "11:FALSE"
|
||||||
|
"System" = "11:FALSE"
|
||||||
|
"Permanent" = "11:FALSE"
|
||||||
|
"SharedLegacy" = "11:FALSE"
|
||||||
|
"PackageAs" = "3:1"
|
||||||
|
"Register" = "3:1"
|
||||||
|
"Exclude" = "11:FALSE"
|
||||||
|
"IsDependency" = "11:TRUE"
|
||||||
|
"IsolateTo" = "8:"
|
||||||
|
}
|
||||||
"{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_67C8F824E02B4211B315AB32AB7ABBB1"
|
"{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_67C8F824E02B4211B315AB32AB7ABBB1"
|
||||||
{
|
{
|
||||||
"SourcePath" = "8:..\\samples\\games\\breakout.c"
|
"SourcePath" = "8:..\\samples\\games\\breakout.c"
|
||||||
|
@ -3809,26 +3937,6 @@
|
||||||
"IsDependency" = "11:FALSE"
|
"IsDependency" = "11:FALSE"
|
||||||
"IsolateTo" = "8:"
|
"IsolateTo" = "8:"
|
||||||
}
|
}
|
||||||
"{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_98B942589E984AAD381F87F18DDB79D3"
|
|
||||||
{
|
|
||||||
"SourcePath" = "8:ucrtbased.dll"
|
|
||||||
"TargetName" = "8:ucrtbased.dll"
|
|
||||||
"Tag" = "8:"
|
|
||||||
"Folder" = "8:_607E75AF0E2A4CB9908C4C39DF8FE6E4"
|
|
||||||
"Condition" = "8:"
|
|
||||||
"Transitive" = "11:FALSE"
|
|
||||||
"Vital" = "11:TRUE"
|
|
||||||
"ReadOnly" = "11:FALSE"
|
|
||||||
"Hidden" = "11:FALSE"
|
|
||||||
"System" = "11:FALSE"
|
|
||||||
"Permanent" = "11:FALSE"
|
|
||||||
"SharedLegacy" = "11:FALSE"
|
|
||||||
"PackageAs" = "3:1"
|
|
||||||
"Register" = "3:1"
|
|
||||||
"Exclude" = "11:FALSE"
|
|
||||||
"IsDependency" = "11:TRUE"
|
|
||||||
"IsolateTo" = "8:"
|
|
||||||
}
|
|
||||||
"{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_9B2E1BB3CD154CEFB214378A64B0B00C"
|
"{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_9B2E1BB3CD154CEFB214378A64B0B00C"
|
||||||
{
|
{
|
||||||
"SourcePath" = "8:..\\include\\plus4\\ted.h"
|
"SourcePath" = "8:..\\include\\plus4\\ted.h"
|
||||||
|
@ -3849,6 +3957,26 @@
|
||||||
"IsDependency" = "11:FALSE"
|
"IsDependency" = "11:FALSE"
|
||||||
"IsolateTo" = "8:"
|
"IsolateTo" = "8:"
|
||||||
}
|
}
|
||||||
|
"{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_9CA4DFBA483A862FBF3DAEDE506D7DBD"
|
||||||
|
{
|
||||||
|
"SourcePath" = "8:VCRUNTIME140_1.dll"
|
||||||
|
"TargetName" = "8:VCRUNTIME140_1.dll"
|
||||||
|
"Tag" = "8:"
|
||||||
|
"Folder" = "8:_607E75AF0E2A4CB9908C4C39DF8FE6E4"
|
||||||
|
"Condition" = "8:"
|
||||||
|
"Transitive" = "11:FALSE"
|
||||||
|
"Vital" = "11:TRUE"
|
||||||
|
"ReadOnly" = "11:FALSE"
|
||||||
|
"Hidden" = "11:FALSE"
|
||||||
|
"System" = "11:FALSE"
|
||||||
|
"Permanent" = "11:FALSE"
|
||||||
|
"SharedLegacy" = "11:FALSE"
|
||||||
|
"PackageAs" = "3:1"
|
||||||
|
"Register" = "3:1"
|
||||||
|
"Exclude" = "11:FALSE"
|
||||||
|
"IsDependency" = "11:TRUE"
|
||||||
|
"IsolateTo" = "8:"
|
||||||
|
}
|
||||||
"{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_9D0D7A63D6C848CD85489D6E7C43AFAD"
|
"{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_9D0D7A63D6C848CD85489D6E7C43AFAD"
|
||||||
{
|
{
|
||||||
"SourcePath" = "8:..\\include\\stdio.h"
|
"SourcePath" = "8:..\\include\\stdio.h"
|
||||||
|
@ -3929,6 +4057,26 @@
|
||||||
"IsDependency" = "11:FALSE"
|
"IsDependency" = "11:FALSE"
|
||||||
"IsolateTo" = "8:"
|
"IsolateTo" = "8:"
|
||||||
}
|
}
|
||||||
|
"{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_A1455504C259EDA9662CE90C07369CC5"
|
||||||
|
{
|
||||||
|
"SourcePath" = "8:api-ms-win-crt-time-l1-1-0.dll"
|
||||||
|
"TargetName" = "8:api-ms-win-crt-time-l1-1-0.dll"
|
||||||
|
"Tag" = "8:"
|
||||||
|
"Folder" = "8:_607E75AF0E2A4CB9908C4C39DF8FE6E4"
|
||||||
|
"Condition" = "8:"
|
||||||
|
"Transitive" = "11:FALSE"
|
||||||
|
"Vital" = "11:TRUE"
|
||||||
|
"ReadOnly" = "11:FALSE"
|
||||||
|
"Hidden" = "11:FALSE"
|
||||||
|
"System" = "11:FALSE"
|
||||||
|
"Permanent" = "11:FALSE"
|
||||||
|
"SharedLegacy" = "11:FALSE"
|
||||||
|
"PackageAs" = "3:1"
|
||||||
|
"Register" = "3:1"
|
||||||
|
"Exclude" = "11:FALSE"
|
||||||
|
"IsDependency" = "11:TRUE"
|
||||||
|
"IsolateTo" = "8:"
|
||||||
|
}
|
||||||
"{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_A14BC161099E420286E6A1595596D0F0"
|
"{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_A14BC161099E420286E6A1595596D0F0"
|
||||||
{
|
{
|
||||||
"SourcePath" = "8:..\\include\\opp\\ofstream.h"
|
"SourcePath" = "8:..\\include\\opp\\ofstream.h"
|
||||||
|
@ -3949,26 +4097,6 @@
|
||||||
"IsDependency" = "11:FALSE"
|
"IsDependency" = "11:FALSE"
|
||||||
"IsolateTo" = "8:"
|
"IsolateTo" = "8:"
|
||||||
}
|
}
|
||||||
"{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_A16BC2645A14DC0435B7119153B32DE8"
|
|
||||||
{
|
|
||||||
"SourcePath" = "8:VCRUNTIME140D.dll"
|
|
||||||
"TargetName" = "8:VCRUNTIME140D.dll"
|
|
||||||
"Tag" = "8:"
|
|
||||||
"Folder" = "8:_607E75AF0E2A4CB9908C4C39DF8FE6E4"
|
|
||||||
"Condition" = "8:"
|
|
||||||
"Transitive" = "11:FALSE"
|
|
||||||
"Vital" = "11:TRUE"
|
|
||||||
"ReadOnly" = "11:FALSE"
|
|
||||||
"Hidden" = "11:FALSE"
|
|
||||||
"System" = "11:FALSE"
|
|
||||||
"Permanent" = "11:FALSE"
|
|
||||||
"SharedLegacy" = "11:FALSE"
|
|
||||||
"PackageAs" = "3:1"
|
|
||||||
"Register" = "3:1"
|
|
||||||
"Exclude" = "11:FALSE"
|
|
||||||
"IsDependency" = "11:TRUE"
|
|
||||||
"IsolateTo" = "8:"
|
|
||||||
}
|
|
||||||
"{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_A18504BA88CE40128ED44BD1854F0A33"
|
"{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_A18504BA88CE40128ED44BD1854F0A33"
|
||||||
{
|
{
|
||||||
"SourcePath" = "8:..\\samples\\memmap\\easyflashreloc.c"
|
"SourcePath" = "8:..\\samples\\memmap\\easyflashreloc.c"
|
||||||
|
@ -4029,6 +4157,26 @@
|
||||||
"IsDependency" = "11:FALSE"
|
"IsDependency" = "11:FALSE"
|
||||||
"IsolateTo" = "8:"
|
"IsolateTo" = "8:"
|
||||||
}
|
}
|
||||||
|
"{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_A2F68033370E18CD792ECD1F91357C1B"
|
||||||
|
{
|
||||||
|
"SourcePath" = "8:api-ms-win-crt-filesystem-l1-1-0.dll"
|
||||||
|
"TargetName" = "8:api-ms-win-crt-filesystem-l1-1-0.dll"
|
||||||
|
"Tag" = "8:"
|
||||||
|
"Folder" = "8:_607E75AF0E2A4CB9908C4C39DF8FE6E4"
|
||||||
|
"Condition" = "8:"
|
||||||
|
"Transitive" = "11:FALSE"
|
||||||
|
"Vital" = "11:TRUE"
|
||||||
|
"ReadOnly" = "11:FALSE"
|
||||||
|
"Hidden" = "11:FALSE"
|
||||||
|
"System" = "11:FALSE"
|
||||||
|
"Permanent" = "11:FALSE"
|
||||||
|
"SharedLegacy" = "11:FALSE"
|
||||||
|
"PackageAs" = "3:1"
|
||||||
|
"Register" = "3:1"
|
||||||
|
"Exclude" = "11:FALSE"
|
||||||
|
"IsDependency" = "11:TRUE"
|
||||||
|
"IsolateTo" = "8:"
|
||||||
|
}
|
||||||
"{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_A32310DEFD4E41118CD7D36A8614C0D4"
|
"{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_A32310DEFD4E41118CD7D36A8614C0D4"
|
||||||
{
|
{
|
||||||
"SourcePath" = "8:..\\include\\limits.h"
|
"SourcePath" = "8:..\\include\\limits.h"
|
||||||
|
@ -4209,6 +4357,26 @@
|
||||||
"IsDependency" = "11:FALSE"
|
"IsDependency" = "11:FALSE"
|
||||||
"IsolateTo" = "8:"
|
"IsolateTo" = "8:"
|
||||||
}
|
}
|
||||||
|
"{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_AD3AED76152E705799261747B7FD2015"
|
||||||
|
{
|
||||||
|
"SourcePath" = "8:api-ms-win-crt-math-l1-1-0.dll"
|
||||||
|
"TargetName" = "8:api-ms-win-crt-math-l1-1-0.dll"
|
||||||
|
"Tag" = "8:"
|
||||||
|
"Folder" = "8:_607E75AF0E2A4CB9908C4C39DF8FE6E4"
|
||||||
|
"Condition" = "8:"
|
||||||
|
"Transitive" = "11:FALSE"
|
||||||
|
"Vital" = "11:TRUE"
|
||||||
|
"ReadOnly" = "11:FALSE"
|
||||||
|
"Hidden" = "11:FALSE"
|
||||||
|
"System" = "11:FALSE"
|
||||||
|
"Permanent" = "11:FALSE"
|
||||||
|
"SharedLegacy" = "11:FALSE"
|
||||||
|
"PackageAs" = "3:1"
|
||||||
|
"Register" = "3:1"
|
||||||
|
"Exclude" = "11:FALSE"
|
||||||
|
"IsDependency" = "11:TRUE"
|
||||||
|
"IsolateTo" = "8:"
|
||||||
|
}
|
||||||
"{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_AE023AEA6C444140B19CD627DDC2CB87"
|
"{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_AE023AEA6C444140B19CD627DDC2CB87"
|
||||||
{
|
{
|
||||||
"SourcePath" = "8:..\\include\\cx16\\vera.h"
|
"SourcePath" = "8:..\\include\\cx16\\vera.h"
|
||||||
|
@ -4369,26 +4537,6 @@
|
||||||
"IsDependency" = "11:FALSE"
|
"IsDependency" = "11:FALSE"
|
||||||
"IsolateTo" = "8:"
|
"IsolateTo" = "8:"
|
||||||
}
|
}
|
||||||
"{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_B61CD152136A6E3CE5FF69D29E7A3F7B"
|
|
||||||
{
|
|
||||||
"SourcePath" = "8:VCRUNTIME140_1D.dll"
|
|
||||||
"TargetName" = "8:VCRUNTIME140_1D.dll"
|
|
||||||
"Tag" = "8:"
|
|
||||||
"Folder" = "8:_607E75AF0E2A4CB9908C4C39DF8FE6E4"
|
|
||||||
"Condition" = "8:"
|
|
||||||
"Transitive" = "11:FALSE"
|
|
||||||
"Vital" = "11:TRUE"
|
|
||||||
"ReadOnly" = "11:FALSE"
|
|
||||||
"Hidden" = "11:FALSE"
|
|
||||||
"System" = "11:FALSE"
|
|
||||||
"Permanent" = "11:FALSE"
|
|
||||||
"SharedLegacy" = "11:FALSE"
|
|
||||||
"PackageAs" = "3:1"
|
|
||||||
"Register" = "3:1"
|
|
||||||
"Exclude" = "11:FALSE"
|
|
||||||
"IsDependency" = "11:TRUE"
|
|
||||||
"IsolateTo" = "8:"
|
|
||||||
}
|
|
||||||
"{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_B85448D515F0487FB6845119AE346F1D"
|
"{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_B85448D515F0487FB6845119AE346F1D"
|
||||||
{
|
{
|
||||||
"SourcePath" = "8:..\\samples\\resources\\landersprites.bin"
|
"SourcePath" = "8:..\\samples\\resources\\landersprites.bin"
|
||||||
|
@ -4529,6 +4677,26 @@
|
||||||
"IsDependency" = "11:FALSE"
|
"IsDependency" = "11:FALSE"
|
||||||
"IsolateTo" = "8:"
|
"IsolateTo" = "8:"
|
||||||
}
|
}
|
||||||
|
"{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_C0E88FBB7B883ED27FFB3C60DBE114B8"
|
||||||
|
{
|
||||||
|
"SourcePath" = "8:api-ms-win-crt-string-l1-1-0.dll"
|
||||||
|
"TargetName" = "8:api-ms-win-crt-string-l1-1-0.dll"
|
||||||
|
"Tag" = "8:"
|
||||||
|
"Folder" = "8:_607E75AF0E2A4CB9908C4C39DF8FE6E4"
|
||||||
|
"Condition" = "8:"
|
||||||
|
"Transitive" = "11:FALSE"
|
||||||
|
"Vital" = "11:TRUE"
|
||||||
|
"ReadOnly" = "11:FALSE"
|
||||||
|
"Hidden" = "11:FALSE"
|
||||||
|
"System" = "11:FALSE"
|
||||||
|
"Permanent" = "11:FALSE"
|
||||||
|
"SharedLegacy" = "11:FALSE"
|
||||||
|
"PackageAs" = "3:1"
|
||||||
|
"Register" = "3:1"
|
||||||
|
"Exclude" = "11:FALSE"
|
||||||
|
"IsDependency" = "11:TRUE"
|
||||||
|
"IsolateTo" = "8:"
|
||||||
|
}
|
||||||
"{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_C239EFB1C3A646809AD2740ABDE747B0"
|
"{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_C239EFB1C3A646809AD2740ABDE747B0"
|
||||||
{
|
{
|
||||||
"SourcePath" = "8:..\\include\\c64\\types.h"
|
"SourcePath" = "8:..\\include\\c64\\types.h"
|
||||||
|
@ -4849,6 +5017,46 @@
|
||||||
"IsDependency" = "11:FALSE"
|
"IsDependency" = "11:FALSE"
|
||||||
"IsolateTo" = "8:"
|
"IsolateTo" = "8:"
|
||||||
}
|
}
|
||||||
|
"{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_D04F8D80984DFA3EA342FE8FA1B7CC91"
|
||||||
|
{
|
||||||
|
"SourcePath" = "8:api-ms-win-crt-heap-l1-1-0.dll"
|
||||||
|
"TargetName" = "8:api-ms-win-crt-heap-l1-1-0.dll"
|
||||||
|
"Tag" = "8:"
|
||||||
|
"Folder" = "8:_607E75AF0E2A4CB9908C4C39DF8FE6E4"
|
||||||
|
"Condition" = "8:"
|
||||||
|
"Transitive" = "11:FALSE"
|
||||||
|
"Vital" = "11:TRUE"
|
||||||
|
"ReadOnly" = "11:FALSE"
|
||||||
|
"Hidden" = "11:FALSE"
|
||||||
|
"System" = "11:FALSE"
|
||||||
|
"Permanent" = "11:FALSE"
|
||||||
|
"SharedLegacy" = "11:FALSE"
|
||||||
|
"PackageAs" = "3:1"
|
||||||
|
"Register" = "3:1"
|
||||||
|
"Exclude" = "11:FALSE"
|
||||||
|
"IsDependency" = "11:TRUE"
|
||||||
|
"IsolateTo" = "8:"
|
||||||
|
}
|
||||||
|
"{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_D057B4CD935875ECE7F0A91620660D07"
|
||||||
|
{
|
||||||
|
"SourcePath" = "8:api-ms-win-crt-convert-l1-1-0.dll"
|
||||||
|
"TargetName" = "8:api-ms-win-crt-convert-l1-1-0.dll"
|
||||||
|
"Tag" = "8:"
|
||||||
|
"Folder" = "8:_607E75AF0E2A4CB9908C4C39DF8FE6E4"
|
||||||
|
"Condition" = "8:"
|
||||||
|
"Transitive" = "11:FALSE"
|
||||||
|
"Vital" = "11:TRUE"
|
||||||
|
"ReadOnly" = "11:FALSE"
|
||||||
|
"Hidden" = "11:FALSE"
|
||||||
|
"System" = "11:FALSE"
|
||||||
|
"Permanent" = "11:FALSE"
|
||||||
|
"SharedLegacy" = "11:FALSE"
|
||||||
|
"PackageAs" = "3:1"
|
||||||
|
"Register" = "3:1"
|
||||||
|
"Exclude" = "11:FALSE"
|
||||||
|
"IsDependency" = "11:TRUE"
|
||||||
|
"IsolateTo" = "8:"
|
||||||
|
}
|
||||||
"{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_D0E45B48D76B4407B0BDE4378C1DB2C7"
|
"{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_D0E45B48D76B4407B0BDE4378C1DB2C7"
|
||||||
{
|
{
|
||||||
"SourcePath" = "8:..\\include\\stdlib.h"
|
"SourcePath" = "8:..\\include\\stdlib.h"
|
||||||
|
@ -6102,15 +6310,15 @@
|
||||||
{
|
{
|
||||||
"Name" = "8:Microsoft Visual Studio"
|
"Name" = "8:Microsoft Visual Studio"
|
||||||
"ProductName" = "8:oscar64"
|
"ProductName" = "8:oscar64"
|
||||||
"ProductCode" = "8:{26C4BC0B-097A-4E5B-B403-8E947803667A}"
|
"ProductCode" = "8:{1B9A0E10-DEA6-4276-AC91-17782FE44D94}"
|
||||||
"PackageCode" = "8:{0C803CC6-29F2-44B4-91D3-62724E5BC165}"
|
"PackageCode" = "8:{51BFE576-50D1-4F8F-AE7A-9FF07396F53D}"
|
||||||
"UpgradeCode" = "8:{9AB61EFF-ACAC-4079-9950-8D96615CD4EF}"
|
"UpgradeCode" = "8:{9AB61EFF-ACAC-4079-9950-8D96615CD4EF}"
|
||||||
"AspNetVersion" = "8:2.0.50727.0"
|
"AspNetVersion" = "8:2.0.50727.0"
|
||||||
"RestartWWWService" = "11:FALSE"
|
"RestartWWWService" = "11:FALSE"
|
||||||
"RemovePreviousVersions" = "11:TRUE"
|
"RemovePreviousVersions" = "11:TRUE"
|
||||||
"DetectNewerInstalledVersion" = "11:TRUE"
|
"DetectNewerInstalledVersion" = "11:TRUE"
|
||||||
"InstallAllUsers" = "11:FALSE"
|
"InstallAllUsers" = "11:FALSE"
|
||||||
"ProductVersion" = "8:1.31.259"
|
"ProductVersion" = "8:1.31.261"
|
||||||
"Manufacturer" = "8:oscar64"
|
"Manufacturer" = "8:oscar64"
|
||||||
"ARPHELPTELEPHONE" = "8:"
|
"ARPHELPTELEPHONE" = "8:"
|
||||||
"ARPHELPLINK" = "8:"
|
"ARPHELPLINK" = "8:"
|
||||||
|
@ -6624,7 +6832,7 @@
|
||||||
{
|
{
|
||||||
"{5259A561-127C-4D43-A0A1-72F10C7B3BF8}:_FB2E467BC172457785F4279BB0BFE8B6"
|
"{5259A561-127C-4D43-A0A1-72F10C7B3BF8}:_FB2E467BC172457785F4279BB0BFE8B6"
|
||||||
{
|
{
|
||||||
"SourcePath" = "8:..\\Debugx64\\oscar64.exe"
|
"SourcePath" = "8:..\\Releasex64\\oscar64.exe"
|
||||||
"TargetName" = "8:"
|
"TargetName" = "8:"
|
||||||
"Tag" = "8:"
|
"Tag" = "8:"
|
||||||
"Folder" = "8:_607E75AF0E2A4CB9908C4C39DF8FE6E4"
|
"Folder" = "8:_607E75AF0E2A4CB9908C4C39DF8FE6E4"
|
||||||
|
|
|
@ -29,7 +29,7 @@ const char MissileChars[] = {
|
||||||
#define Charset ((char *)0xd800)
|
#define Charset ((char *)0xd800)
|
||||||
|
|
||||||
// Joystick and crosshair control
|
// Joystick and crosshair control
|
||||||
int CrossX = 160, CrossY = 100;
|
volatile int CrossX = 160, CrossY = 100;
|
||||||
bool CrossP = false;
|
bool CrossP = false;
|
||||||
char CrossDelay = 0;
|
char CrossDelay = 0;
|
||||||
|
|
||||||
|
@ -553,20 +553,22 @@ __interrupt void joy_interrupt()
|
||||||
joy_poll(0);
|
joy_poll(0);
|
||||||
|
|
||||||
// Move crosshair coordinates
|
// Move crosshair coordinates
|
||||||
CrossX += 2 * joyx[0]; CrossY += 2 * joyy[0];
|
int cx = CrossX + 2 * joyx[0], cy = CrossY + 2 * joyy[0];
|
||||||
|
|
||||||
// Stop at edges of screen
|
// Stop at edges of screen
|
||||||
if (CrossX < 8)
|
if (cx < 8)
|
||||||
CrossX = 8;
|
cx = 8;
|
||||||
else if (CrossX > 312)
|
else if (cx > 312)
|
||||||
CrossX = 312;
|
cx = 312;
|
||||||
if (CrossY < 20)
|
if (cy < 20)
|
||||||
CrossY = 20;
|
cy = 20;
|
||||||
else if (CrossY > 172)
|
else if (cy > 172)
|
||||||
CrossY = 172;
|
cy = 172;
|
||||||
|
|
||||||
// Move crosshair sprite
|
// Move crosshair sprite
|
||||||
spr_move(0, CrossX + 14, CrossY + 40);
|
spr_move(0, cx + 14, cy + 40);
|
||||||
|
CrossX = cx;
|
||||||
|
CrossY = cy;
|
||||||
|
|
||||||
// Check button
|
// Check button
|
||||||
if (joyb[0])
|
if (joyb[0])
|
||||||
|
@ -697,15 +699,17 @@ void game_play(void)
|
||||||
// Check if fire request
|
// Check if fire request
|
||||||
if (CrossP)
|
if (CrossP)
|
||||||
{
|
{
|
||||||
|
int cx = CrossX, cy = CrossY;
|
||||||
|
|
||||||
// Find launch site
|
// Find launch site
|
||||||
int sx = 160;
|
int sx = 160;
|
||||||
if (CrossX < 120)
|
if (cx < 120)
|
||||||
sx = 24;
|
sx = 24;
|
||||||
else if (CrossX > 200)
|
else if (cx > 200)
|
||||||
sx = 296;
|
sx = 296;
|
||||||
|
|
||||||
// Fire missile
|
// Fire missile
|
||||||
missile_start(sx, 184, CrossX, CrossY);
|
missile_start(sx, 184, cx, cy);
|
||||||
|
|
||||||
// Reset request
|
// Reset request
|
||||||
CrossP = false;
|
CrossP = false;
|
||||||
|
|
|
@ -22,7 +22,7 @@ __interrupt void doscroll(void)
|
||||||
vic.color_border++;
|
vic.color_border++;
|
||||||
|
|
||||||
// Update raster IRQ for scroll line with new horizontal scroll offset
|
// Update raster IRQ for scroll line with new horizontal scroll offset
|
||||||
rirq_data(&scroll, 0, 7 - (x & 7));
|
rirq_data(&scroll, 1, 7 - (x & 7));
|
||||||
// Copy scrolled version of text when switching over char border
|
// Copy scrolled version of text when switching over char border
|
||||||
if ((x & 7) == 0)
|
if ((x & 7) == 0)
|
||||||
memcpy((char *)0x0400 + 40 * 24, Text + ((x >> 3) & 255), 40);
|
memcpy((char *)0x0400 + 40 * 24, Text + ((x >> 3) & 255), 40);
|
||||||
|
@ -37,11 +37,13 @@ int main(void)
|
||||||
rirq_init(true);
|
rirq_init(true);
|
||||||
|
|
||||||
// Build switch to scroll line IRQ
|
// Build switch to scroll line IRQ
|
||||||
rirq_build(&scroll, 1);
|
rirq_build(&scroll, 2);
|
||||||
|
// Delay for one line to get to right border
|
||||||
|
rirq_delay(&scroll, 11);
|
||||||
// Change control register two with this IRQ
|
// Change control register two with this IRQ
|
||||||
rirq_write(&scroll, 0, &vic.ctrl2, 0);
|
rirq_write(&scroll, 1, &vic.ctrl2, 0);
|
||||||
// Put it onto the scroll line
|
// Put it onto the scroll line
|
||||||
rirq_set(0, 50 + 24 * 8, &scroll);
|
rirq_set(0, 49 + 24 * 8, &scroll);
|
||||||
|
|
||||||
// Build the switch to normal IRQ
|
// Build the switch to normal IRQ
|
||||||
rirq_build(&restore, 2);
|
rirq_build(&restore, 2);
|
||||||
|
|
|
@ -20,11 +20,13 @@ int main(void)
|
||||||
rirq_init(true);
|
rirq_init(true);
|
||||||
|
|
||||||
// Build switch to scroll line IRQ
|
// Build switch to scroll line IRQ
|
||||||
rirq_build(&scroll, 1);
|
rirq_build(&scroll, 2);
|
||||||
|
// Delay for one line to get to right border
|
||||||
|
rirq_delay(&scroll, 11);
|
||||||
// Change control register two with this IRQ
|
// Change control register two with this IRQ
|
||||||
rirq_write(&scroll, 0, &vic.ctrl2, 0);
|
rirq_write(&scroll, 1, &vic.ctrl2, 0);
|
||||||
// Put it onto the scroll line
|
// Put it onto the scroll line
|
||||||
rirq_set(0, 50 + 24 * 8, &scroll);
|
rirq_set(0, 49 + 24 * 8, &scroll);
|
||||||
|
|
||||||
// Build the switch to normal IRQ
|
// Build the switch to normal IRQ
|
||||||
rirq_build(&bottom, 1);
|
rirq_build(&bottom, 1);
|
||||||
|
@ -46,7 +48,7 @@ int main(void)
|
||||||
// wait for raster reaching bottom of screen
|
// wait for raster reaching bottom of screen
|
||||||
rirq_wait();
|
rirq_wait();
|
||||||
// Update raster IRQ for scroll line with new horizontal scroll offset
|
// Update raster IRQ for scroll line with new horizontal scroll offset
|
||||||
rirq_data(&scroll, 0, 7 - (x & 7));
|
rirq_data(&scroll, 1, 7 - (x & 7));
|
||||||
// Copy scrolled version of text when switching over char border
|
// Copy scrolled version of text when switching over char border
|
||||||
if ((x & 7) == 0)
|
if ((x & 7) == 0)
|
||||||
memcpy((char *)0x0400 + 40 * 24, Text + ((x >> 3) & 255), 40);
|
memcpy((char *)0x0400 + 40 * 24, Text + ((x >> 3) & 255), 40);
|
||||||
|
|
|
@ -27,7 +27,7 @@ ScreenRow * const color = (ScreenRow *)0xd800;
|
||||||
// Move the screen one character to the left
|
// Move the screen one character to the left
|
||||||
void scrollLeft(void)
|
void scrollLeft(void)
|
||||||
{
|
{
|
||||||
// Loop horizontaly
|
// Loop horizontally
|
||||||
for(char x=0; x<39; x++)
|
for(char x=0; x<39; x++)
|
||||||
{
|
{
|
||||||
// Unroll vertical loop 16 times
|
// Unroll vertical loop 16 times
|
||||||
|
|
|
@ -64,6 +64,7 @@ const char * scrolltext[] = {
|
||||||
"",
|
"",
|
||||||
"",
|
"",
|
||||||
"",
|
"",
|
||||||
|
""
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -198,7 +199,7 @@ int main(void)
|
||||||
// Update interrupt position
|
// Update interrupt position
|
||||||
for(char i=0; i<5; i++)
|
for(char i=0; i<5; i++)
|
||||||
{
|
{
|
||||||
int ty = 48 * i + 46 + oy;
|
int ty = 48 * i + 45 + oy;
|
||||||
|
|
||||||
// No interrupts below screen bottom
|
// No interrupts below screen bottom
|
||||||
if (ty < 250)
|
if (ty < 250)
|
||||||
|
@ -246,7 +247,7 @@ int main(void)
|
||||||
case 42:
|
case 42:
|
||||||
readline(line, lpos);
|
readline(line, lpos);
|
||||||
lpos++;
|
lpos++;
|
||||||
if (lpos == 28)
|
if (lpos == 27)
|
||||||
lpos = 0;
|
lpos = 0;
|
||||||
break;
|
break;
|
||||||
case 45:
|
case 45:
|
||||||
|
|
Loading…
Reference in New Issue