Add verbose option -v to compiler
This commit is contained in:
parent
f91bf21999
commit
743510b54e
|
@ -47,6 +47,8 @@ void Compiler::AddDefine(const Ident* ident, const char* value)
|
||||||
|
|
||||||
bool Compiler::ParseSource(void)
|
bool Compiler::ParseSource(void)
|
||||||
{
|
{
|
||||||
|
mPreprocessor->mCompilerOptions = mCompilerOptions;
|
||||||
|
|
||||||
CompilationUnit* cunit;
|
CompilationUnit* cunit;
|
||||||
while (mErrors->mErrorCount == 0 && (cunit = mCompilationUnits->PendingUnit()))
|
while (mErrors->mErrorCount == 0 && (cunit = mCompilationUnits->PendingUnit()))
|
||||||
{
|
{
|
||||||
|
@ -364,31 +366,38 @@ bool Compiler::WriteOutputFile(const char* targetPath)
|
||||||
|
|
||||||
if (mCompilerOptions & COPT_TARGET_PRG)
|
if (mCompilerOptions & COPT_TARGET_PRG)
|
||||||
{
|
{
|
||||||
printf("Writing <%s>\n", prgPath);
|
if (mCompilerOptions & COPT_VERBOSE)
|
||||||
|
printf("Writing <%s>\n", prgPath);
|
||||||
mLinker->WritePrgFile(prgPath);
|
mLinker->WritePrgFile(prgPath);
|
||||||
}
|
}
|
||||||
else if (mCompilerOptions & COPT_TARGET_CRT16)
|
else if (mCompilerOptions & COPT_TARGET_CRT16)
|
||||||
{
|
{
|
||||||
printf("Writing <%s>\n", crtPath);
|
if (mCompilerOptions & COPT_VERBOSE)
|
||||||
|
printf("Writing <%s>\n", crtPath);
|
||||||
mLinker->WriteCrtFile(crtPath);
|
mLinker->WriteCrtFile(crtPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
printf("Writing <%s>\n", mapPath);
|
if (mCompilerOptions & COPT_VERBOSE)
|
||||||
|
printf("Writing <%s>\n", mapPath);
|
||||||
mLinker->WriteMapFile(mapPath);
|
mLinker->WriteMapFile(mapPath);
|
||||||
|
|
||||||
printf("Writing <%s>\n", asmPath);
|
if (mCompilerOptions & COPT_VERBOSE)
|
||||||
|
printf("Writing <%s>\n", asmPath);
|
||||||
mLinker->WriteAsmFile(asmPath);
|
mLinker->WriteAsmFile(asmPath);
|
||||||
|
|
||||||
printf("Writing <%s>\n", lblPath);
|
if (mCompilerOptions & COPT_VERBOSE)
|
||||||
|
printf("Writing <%s>\n", lblPath);
|
||||||
mLinker->WriteLblFile(lblPath);
|
mLinker->WriteLblFile(lblPath);
|
||||||
|
|
||||||
printf("Writing <%s>\n", intPath);
|
if (mCompilerOptions & COPT_VERBOSE)
|
||||||
|
printf("Writing <%s>\n", intPath);
|
||||||
mInterCodeModule->Disassemble(intPath);
|
mInterCodeModule->Disassemble(intPath);
|
||||||
|
|
||||||
if (!(mCompilerOptions & COPT_NATIVE))
|
if (!(mCompilerOptions & COPT_NATIVE))
|
||||||
{
|
{
|
||||||
printf("Writing <%s>\n", bcsPath);
|
if (mCompilerOptions & COPT_VERBOSE)
|
||||||
|
printf("Writing <%s>\n", bcsPath);
|
||||||
mByteCodeGenerator->WriteByteCodeStats(bcsPath);
|
mByteCodeGenerator->WriteByteCodeStats(bcsPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,8 @@ static const uint64 COPT_TARGET_CRT16 = 0x200000000ULL;
|
||||||
static const uint64 COPT_TARGET_CRT512 = 0x400000000ULL;
|
static const uint64 COPT_TARGET_CRT512 = 0x400000000ULL;
|
||||||
static const uint64 COPT_TARGET_COPY = 0x800000000ULL;
|
static const uint64 COPT_TARGET_COPY = 0x800000000ULL;
|
||||||
|
|
||||||
|
static const uint64 COPT_VERBOSE = 0x1000000000ULL;
|
||||||
|
|
||||||
static const uint64 COPT_NATIVE = 0x01000000;
|
static const uint64 COPT_NATIVE = 0x01000000;
|
||||||
|
|
||||||
static const uint64 COPT_DEFAULT = COPT_OPTIMIZE_BASIC | COPT_OPTIMIZE_INLINE;
|
static const uint64 COPT_DEFAULT = COPT_OPTIMIZE_BASIC | COPT_OPTIMIZE_INLINE;
|
||||||
|
|
|
@ -4932,6 +4932,18 @@ bool InterCodeBasicBlock::MergeCommonPathInstructions(void)
|
||||||
return changed;
|
return changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool InterCodeBasicBlock::IsTempModifiedOnPath(int temp, int at) const
|
||||||
|
{
|
||||||
|
while (at < mInstructions.Size())
|
||||||
|
{
|
||||||
|
if (mInstructions[at]->mDst.mTemp == temp)
|
||||||
|
return true;
|
||||||
|
at++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool InterCodeBasicBlock::PushSinglePathResultInstructions(void)
|
bool InterCodeBasicBlock::PushSinglePathResultInstructions(void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
@ -4960,7 +4972,7 @@ bool InterCodeBasicBlock::PushSinglePathResultInstructions(void)
|
||||||
if (ins->mDst.mTemp >= 0 && !providedTemps[ins->mDst.mTemp] && !requiredTemps[ins->mDst.mTemp])
|
if (ins->mDst.mTemp >= 0 && !providedTemps[ins->mDst.mTemp] && !requiredTemps[ins->mDst.mTemp])
|
||||||
{
|
{
|
||||||
int j = 0;
|
int j = 0;
|
||||||
while (j < ins->mNumOperands && !(ins->mSrc[j].mTemp >= 0 && providedTemps[ins->mSrc[j].mTemp]))
|
while (j < ins->mNumOperands && !(ins->mSrc[j].mTemp >= 0 && providedTemps[ins->mSrc[j].mTemp]) && !IsTempModifiedOnPath(ins->mSrc[j].mTemp, i + 1))
|
||||||
j++;
|
j++;
|
||||||
|
|
||||||
if (j == ins->mNumOperands && IsMoveable(ins->mCode) && (ins->mCode != IC_LOAD || !hadStore))
|
if (j == ins->mNumOperands && IsMoveable(ins->mCode) && (ins->mCode != IC_LOAD || !hadStore))
|
||||||
|
@ -6586,6 +6598,8 @@ void InterCodeProcedure::Close(void)
|
||||||
|
|
||||||
DisassembleDebug("Peephole optimized");
|
DisassembleDebug("Peephole optimized");
|
||||||
|
|
||||||
|
BuildDataFlowSets();
|
||||||
|
|
||||||
TempForwarding();
|
TempForwarding();
|
||||||
RemoveUnusedInstructions();
|
RemoveUnusedInstructions();
|
||||||
|
|
||||||
|
@ -6612,6 +6626,8 @@ void InterCodeProcedure::Close(void)
|
||||||
ResetVisited();
|
ResetVisited();
|
||||||
changed = mEntryBlock->PushSinglePathResultInstructions();
|
changed = mEntryBlock->PushSinglePathResultInstructions();
|
||||||
|
|
||||||
|
DisassembleDebug("Pushed single path result");
|
||||||
|
|
||||||
} while (changed);
|
} while (changed);
|
||||||
|
|
||||||
|
|
||||||
|
@ -7030,6 +7046,7 @@ void InterCodeProcedure::Disassemble(FILE* file)
|
||||||
|
|
||||||
void InterCodeProcedure::Disassemble(const char* name, bool dumpSets)
|
void InterCodeProcedure::Disassemble(const char* name, bool dumpSets)
|
||||||
{
|
{
|
||||||
|
#ifdef _WIN32
|
||||||
FILE* file;
|
FILE* file;
|
||||||
static bool initial = true;
|
static bool initial = true;
|
||||||
|
|
||||||
|
@ -7063,6 +7080,7 @@ void InterCodeProcedure::Disassemble(const char* name, bool dumpSets)
|
||||||
|
|
||||||
fclose(file);
|
fclose(file);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
InterCodeModule::InterCodeModule(void)
|
InterCodeModule::InterCodeModule(void)
|
||||||
|
|
|
@ -543,6 +543,8 @@ public:
|
||||||
void MarkRelevantStatics(void);
|
void MarkRelevantStatics(void);
|
||||||
void RemoveNonRelevantStatics(void);
|
void RemoveNonRelevantStatics(void);
|
||||||
|
|
||||||
|
bool IsTempModifiedOnPath(int temp, int at) const;
|
||||||
|
|
||||||
bool PushSinglePathResultInstructions(void);
|
bool PushSinglePathResultInstructions(void);
|
||||||
bool MergeCommonPathInstructions(void);
|
bool MergeCommonPathInstructions(void);
|
||||||
|
|
||||||
|
|
|
@ -210,7 +210,8 @@ bool Preprocessor::EmbedData(const char* reason, const char* name, bool local, i
|
||||||
|
|
||||||
if (ok)
|
if (ok)
|
||||||
{
|
{
|
||||||
printf("%s \"%s\"\n", reason, source->mFileName);
|
if (mCompilerOptions & COPT_VERBOSE)
|
||||||
|
printf("%s \"%s\"\n", reason, source->mFileName);
|
||||||
|
|
||||||
source->Limit(skip, limit);
|
source->Limit(skip, limit);
|
||||||
|
|
||||||
|
@ -271,7 +272,9 @@ bool Preprocessor::OpenSource(const char * reason, const char* name, bool local)
|
||||||
|
|
||||||
if (ok)
|
if (ok)
|
||||||
{
|
{
|
||||||
printf("%s \"%s\"\n", reason, source->mFileName);
|
if (mCompilerOptions & COPT_VERBOSE)
|
||||||
|
printf("%s \"%s\"\n", reason, source->mFileName);
|
||||||
|
|
||||||
source->mUp = mSource;
|
source->mUp = mSource;
|
||||||
mSource = source;
|
mSource = source;
|
||||||
mLocation.mFileName = mSource->mFileName;
|
mLocation.mFileName = mSource->mFileName;
|
||||||
|
@ -318,7 +321,7 @@ bool Preprocessor::DropSource(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
Preprocessor::Preprocessor(Errors* errors)
|
Preprocessor::Preprocessor(Errors* errors)
|
||||||
: mSource(nullptr), mSourceList(nullptr), mPaths(nullptr), mErrors(errors)
|
: mSource(nullptr), mSourceList(nullptr), mPaths(nullptr), mErrors(errors), mCompilerOptions(COPT_DEFAULT)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#include "Errors.h"
|
#include "Errors.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "MachineTypes.h"
|
#include "MachineTypes.h"
|
||||||
|
#include "CompilerTypes.h"
|
||||||
|
|
||||||
class SourceStack
|
class SourceStack
|
||||||
{
|
{
|
||||||
|
@ -64,6 +65,8 @@ public:
|
||||||
SourceFile* mSource, * mSourceList;
|
SourceFile* mSource, * mSourceList;
|
||||||
SourcePath* mPaths;
|
SourcePath* mPaths;
|
||||||
|
|
||||||
|
uint64 mCompilerOptions;
|
||||||
|
|
||||||
void AddPath(const char* path);
|
void AddPath(const char* path);
|
||||||
bool NextLine(void);
|
bool NextLine(void);
|
||||||
|
|
||||||
|
|
|
@ -67,15 +67,13 @@ int main(int argc, const char** argv)
|
||||||
char strProductName[100], strProductVersion[200];
|
char strProductName[100], strProductVersion[200];
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
if (GetProductAndVersion(strProductName, strProductVersion))
|
GetProductAndVersion(strProductName, strProductVersion);
|
||||||
{
|
|
||||||
printf("Starting %s %s\n", strProductName, strProductVersion);
|
|
||||||
}
|
|
||||||
|
|
||||||
DWORD length = ::GetModuleFileNameA(NULL, basePath, sizeof(basePath));
|
DWORD length = ::GetModuleFileNameA(NULL, basePath, sizeof(basePath));
|
||||||
|
|
||||||
#else
|
#else
|
||||||
printf("Starting oscar64 1.1.50\n");
|
strcpy(strProductName, "oscar64");
|
||||||
|
strcpy(strProductVersion, "1.1.50");
|
||||||
|
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
uint32_t length = sizeof(basePath);
|
uint32_t length = sizeof(basePath);
|
||||||
|
@ -177,6 +175,8 @@ int main(int argc, const char** argv)
|
||||||
else
|
else
|
||||||
compiler->AddDefine(Ident::Unique(def), "");
|
compiler->AddDefine(Ident::Unique(def), "");
|
||||||
}
|
}
|
||||||
|
else if (arg[1] == 'v')
|
||||||
|
compiler->mCompilerOptions |= COPT_VERBOSE;
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
@ -203,6 +203,11 @@ int main(int argc, const char** argv)
|
||||||
|
|
||||||
if (compiler->mErrors->mErrorCount == 0)
|
if (compiler->mErrors->mErrorCount == 0)
|
||||||
{
|
{
|
||||||
|
if (compiler->mCompilerOptions & COPT_VERBOSE)
|
||||||
|
{
|
||||||
|
printf("Starting %s %s\n", strProductName, strProductVersion);
|
||||||
|
}
|
||||||
|
|
||||||
// Add runtime module
|
// Add runtime module
|
||||||
|
|
||||||
compiler->mCompilationUnits->AddUnit(loc, crtPath, nullptr);
|
compiler->mCompilationUnits->AddUnit(loc, crtPath, nullptr);
|
||||||
|
@ -221,7 +226,7 @@ int main(int argc, const char** argv)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
printf("oscar64 {-i=includePath} [-o=output.prg] [-rt=runtime.c] [-e] [-n] [-dSYMBOL[=value]] {source.c}\n");
|
printf("oscar64 {-i=includePath} [-o=output.prg] [-rt=runtime.c] [-e] [-n] [-dSYMBOL[=value]] [-v] {source.c}\n");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
..\..\bin\oscar64 mbtext.c -n
|
..\..\bin\oscar64 mbtext.c -n
|
||||||
..\..\bin\oscar64 mbhires.c -n
|
..\..\bin\oscar64 mbhires.c -n
|
||||||
..\..\bin\oscar64 mbmulti.c -n
|
..\..\bin\oscar64 mbmulti.c -n
|
||||||
|
..\..\bin\oscar64 mbmulti3d.c -n
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <c64/vic.h>
|
#include <c64/vic.h>
|
||||||
#include <c64/memmap.h>
|
#include <c64/memmap.h>
|
||||||
|
#include <conio.h>
|
||||||
|
|
||||||
#define Screen ((char *)0xe000)
|
#define Screen ((char *)0xe000)
|
||||||
#define Color ((char *)0xc800)
|
#define Color ((char *)0xc800)
|
||||||
|
@ -41,5 +42,11 @@ int main(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mmap_set(MMAP_NO_BASIC);
|
||||||
|
|
||||||
|
getch();
|
||||||
|
|
||||||
|
vic_setmode(VICM_TEXT, (char *)0x0400, (char *)0x1000);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,151 @@
|
||||||
|
#include <string.h>
|
||||||
|
#include <c64/vic.h>
|
||||||
|
#include <c64/memmap.h>
|
||||||
|
#include <conio.h>
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
|
#define Screen ((char *)0xe000)
|
||||||
|
#define Color1 ((char *)0xc800)
|
||||||
|
#define Color2 ((char *)0xd800)
|
||||||
|
|
||||||
|
byte colors[2][17] =
|
||||||
|
{
|
||||||
|
{0x00,
|
||||||
|
0x44, 0x44, 0x55, 0x55, 0xdd, 0xdd, 0xff, 0xff,
|
||||||
|
0x88, 0x88, 0xaa, 0xaa, 0xee, 0xee, 0xff, 0xff,
|
||||||
|
},
|
||||||
|
{0x00,
|
||||||
|
0x00, 0x11, 0x11, 0x55, 0x55, 0x77, 0x77, 0xff,
|
||||||
|
0x00, 0x22, 0x22, 0xaa, 0xaa, 0xbb, 0xbb, 0xff,
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
void VLine(int x, int py, int ty, char c)
|
||||||
|
{
|
||||||
|
if (py < 0)
|
||||||
|
py = 0;
|
||||||
|
if (ty > 100)
|
||||||
|
ty = 100;
|
||||||
|
|
||||||
|
if (py < ty)
|
||||||
|
{
|
||||||
|
char mask = 0xc0 >> (2 * (x & 3));
|
||||||
|
char * dp = Screen + 320 * (py >> 2) + 2 * (py & 3) + 2 * (x & ~3);
|
||||||
|
|
||||||
|
|
||||||
|
char c0 = colors[0][c] & mask, c1 = colors[1][c] & mask;
|
||||||
|
mask = ~mask;
|
||||||
|
char h = ty - py;
|
||||||
|
while (h)
|
||||||
|
{
|
||||||
|
dp[0] = (dp[0] & mask) | c0;
|
||||||
|
dp[1] = (dp[1] & mask) | c1;
|
||||||
|
|
||||||
|
dp += 2;
|
||||||
|
if (!((int)dp & 7))
|
||||||
|
dp += 312;
|
||||||
|
|
||||||
|
h--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
float iter(float xz, float yz)
|
||||||
|
{
|
||||||
|
float x = 0.0, y = 0.0, r;
|
||||||
|
int i;
|
||||||
|
for(i=0; i<32; i++)
|
||||||
|
{
|
||||||
|
r = x * x + y * y;
|
||||||
|
if (r > 64.0) break;
|
||||||
|
|
||||||
|
float xt = x * x - y * y + xz;
|
||||||
|
y = 2 * x * y + yz;
|
||||||
|
x = xt;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (i == 32)
|
||||||
|
return 32;
|
||||||
|
else
|
||||||
|
return i - log(log(r)/log(64.0))/log(2.0)
|
||||||
|
}
|
||||||
|
|
||||||
|
int light(float hl, float hu, float h)
|
||||||
|
{
|
||||||
|
float dx = h - hl, dz = h - hu, dy = 0.1;
|
||||||
|
|
||||||
|
float dd = sqrt(dx * dx + dy * dy + dz * dz);
|
||||||
|
int ni = (int)floor((-2 * dx + dy + dz) / dd * 0.408 * 8);
|
||||||
|
if (ni < 0) ni = 0; else if (ni > 7) ni = 7;
|
||||||
|
|
||||||
|
return ni;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
mmap_trampoline();
|
||||||
|
|
||||||
|
mmap_set(MMAP_NO_ROM);
|
||||||
|
|
||||||
|
vic_setmode(VICM_HIRES_MC, Color1, Screen);
|
||||||
|
|
||||||
|
vic.color_back = 0x00;
|
||||||
|
vic.color_border = 0x00;
|
||||||
|
|
||||||
|
memset(Screen, 0, 8000);
|
||||||
|
memset(Color1, 0x26, 1000);
|
||||||
|
memset(Color2, 0x0f, 1000);
|
||||||
|
|
||||||
|
float hl[200];
|
||||||
|
|
||||||
|
float w = -0.7;
|
||||||
|
float co = cos(w), si = sin(w);
|
||||||
|
|
||||||
|
for(int x=-1; x<160; x+= 1)
|
||||||
|
{
|
||||||
|
int py = 20;
|
||||||
|
float hu = 0;
|
||||||
|
for(int y=1; y<200; y+= 1)
|
||||||
|
{
|
||||||
|
float fz = 2.0 / (float)y;
|
||||||
|
float fx = (float)(x - 80) * fz / 100.0;
|
||||||
|
|
||||||
|
float mz = fz * 100.0 - 3.0, mx = fx * 100.0;
|
||||||
|
|
||||||
|
float rx = mx * co - mz * si, rz = mx * si + mz * co;
|
||||||
|
float dp = iter(rx, rz);
|
||||||
|
float v = 2 * dp;
|
||||||
|
if (v < 1.0) v = 1.0;
|
||||||
|
|
||||||
|
float fy = 5.0 * pow(2.0, - v * 0.4);
|
||||||
|
|
||||||
|
int ni = light(hl[y], hu, fy);
|
||||||
|
|
||||||
|
hl[y] = fy;
|
||||||
|
hu = fy;
|
||||||
|
|
||||||
|
int ty = 20 + y / 2 + (int)(floor(fy / fz));
|
||||||
|
|
||||||
|
int c;
|
||||||
|
|
||||||
|
if (dp != 32)
|
||||||
|
c = 1 + ni + 8 * ((int)floor(dp) & 1);
|
||||||
|
else
|
||||||
|
c = 0;
|
||||||
|
|
||||||
|
if (x >= 0)
|
||||||
|
VLine(x, py, ty, c);
|
||||||
|
|
||||||
|
py = ty;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mmap_set(MMAP_NO_BASIC);
|
||||||
|
|
||||||
|
getch();
|
||||||
|
|
||||||
|
vic_setmode(VICM_TEXT, (char *)0x0400, (char *)0x1000);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
Reference in New Issue