fixed all C++ extra + pedantic errors

This commit is contained in:
Blaise Tine
2020-02-17 15:02:06 -05:00
parent 4184980188
commit 90c3813340
25 changed files with 141 additions and 98 deletions

View File

@@ -111,6 +111,6 @@ namespace Harp {
RegNum nRegs, nPRegs;
char encChar;
};
};
}
#endif

View File

@@ -56,6 +56,6 @@ namespace HarpTools {
bool &x;
};
};
}
#endif

View File

@@ -11,6 +11,6 @@ namespace HarpTools {
ASM_T_PREG, ASM_T_REG, ASM_T_REG_RA, ASM_T_REG_SP,
ASM_T_REG_FP, ASM_T_LIT, ASM_T_SYM, ASM_T_PEXP
};
};
}
#endif

View File

@@ -35,9 +35,9 @@ namespace Harp {
template <typename T> class Reg {
public:
Reg(): cpuId(0), regNum(0), val(0) {}
Reg(Word c, Word n): cpuId(c), regNum(n), val(0) {}
Reg(Word c, Word n, T v): cpuId(c), regNum(n), val(v) {}
Reg(): val(0), cpuId(0), regNum(0) {}
Reg(Word c, Word n): val(0), cpuId(c), regNum(n) {}
Reg(Word c, Word n, T v): val(v), cpuId(c), regNum(n) {}
Reg &operator=(T r) { if (regNum) {val = r; doWrite();} return *this; }
@@ -83,10 +83,10 @@ namespace Harp {
DomStackEntry(const std::vector<bool> &tmask):
tmask(tmask), fallThrough(true), uni(false) {}
bool fallThrough;
bool uni;
std::vector<bool> tmask;
std::vector<bool> tmask;
Word pc;
bool fallThrough;
bool uni;
};
struct vtype
@@ -193,13 +193,14 @@ namespace Harp {
std::vector<std::vector<Reg<char*>>> vreg; // 32 vector registers
bool interruptEnable, shadowInterruptEnable, supervisorMode,
shadowSupervisorMode, spawned;
bool interruptEnable, shadowInterruptEnable;
bool supervisorMode, shadowSupervisorMode;
bool spawned;
unsigned long steps, insts, loads, stores;
friend class Instruction;
};
};
}
#endif

View File

@@ -50,7 +50,10 @@ namespace Harp {
public:
WordDecoder(const ArchDef &);
virtual Instruction *decode(const std::vector<Byte> &v, Size &n, trace_inst_t * trace_inst);
virtual Instruction *decode(const std::vector<Byte> &v, Size &n) {printf("Not implemented\n");}
virtual Instruction *decode(const std::vector<Byte> &v, Size &n) {
printf("Not implemented\n");
return nullptr;
}
private:
Size n, o, r, p, i1, i2, i3;
@@ -72,6 +75,6 @@ namespace Harp {
};
};
}
#endif

View File

@@ -64,7 +64,7 @@ namespace Harp {
DEBUGMSG("Set to " << d);
}
Float(double d, Size n): sz(n), d(d) { DEBUGMSG("Float(double, size)"); }
Float(double d, Size n): d(d), sz(n) { DEBUGMSG("Float(double, size)"); }
operator Word_u() {
DEBUGMSG("Float -> Word_u: " << d);
@@ -120,4 +120,4 @@ namespace Harp {
double d;
Size sz;
};
};
}

View File

@@ -32,6 +32,6 @@ namespace HarpTools {
*disasmHelp = "HARP Disassembler command line arguments:\n"
" -a, --arch <arch string> Architecture string.\n"
" -o, --output <filename> Output filename.\n";
};
};
}
}
#endif

View File

@@ -164,7 +164,7 @@ namespace Harp {
};
};
}
#endif

View File

@@ -99,9 +99,10 @@ namespace Harp {
Byte *file;
Size blocks;
};
std::vector <Disk> disks;
Size wordSize, blockSize;
Core &core;
Size wordSize, blockSize;;
std::vector <Disk> disks;
};
class MemoryUnit {
@@ -136,7 +137,7 @@ namespace Harp {
private:
class ADecoder {
public:
ADecoder() : zeroChild(NULL), oneChild(NULL), range(0) {}
ADecoder() : zeroChild(NULL), oneChild(NULL), range(0), md(nullptr) {}
ADecoder(MemDevice &md, Size range) :
zeroChild(NULL), oneChild(NULL), range(range), md(&md) {}
Byte *getPtr(Addr a, Size sz, Size wordSize);
@@ -145,24 +146,24 @@ namespace Harp {
void map(Addr a, MemDevice &md, Size range, Size bit);
private:
MemDevice &doLookup(Addr a, Size &bit);
ADecoder *zeroChild, *oneChild;
MemDevice *md;
ADecoder *zeroChild, *oneChild;
Size range;
MemDevice *md;
};
ADecoder ad;
struct TLBEntry {
TLBEntry() {}
TLBEntry(Word pfn, Word flags): pfn(pfn), flags(flags) {}
Word flags;
Word pfn;
Word flags;
};
std::map<Addr, TLBEntry> tlb;
TLBEntry tlbLookup(Addr vAddr, Word flagMask);
Size pageSize, addrBytes;
ADecoder ad;
std::map<Addr, TLBEntry> tlb;
TLBEntry tlbLookup(Addr vAddr, Word flagMask);
bool disableVm;
};
@@ -402,7 +403,7 @@ namespace Harp {
char* content = new char[size];
int x = fread(content, 1, size, fp);
if (!x) { std::cout << "COULD NOT READ FILE\n"; exit(1);}
if (!x) { std::cout << "COULD NOT READ FILE\n"; std::abort();}
int offset = 0;
char* line = content;
@@ -455,7 +456,7 @@ namespace Harp {
};
}
#endif

View File

@@ -40,7 +40,7 @@ namespace Harp {
Ref(name, rel), addr(addr) { }
virtual void bind(Addr addr, Addr base = 0) {
std::cout << "Attempted to bind a SimpleRef.\n";
exit(1);
std::abort();
}
virtual Addr getAddr() const { return this->addr; }
Byte *getAddrPtr() { return (Byte*)&addr; }
@@ -86,7 +86,7 @@ namespace Harp {
// std::cout << "Attempt to bind a " << bits << "-bit "
// << (relative?"":"non-") << "relative symbol to an address"
// " it cannot reach.\n";
// exit(1);
// std::abort();
// }
// virtual Addr getAddr() const {
@@ -205,6 +205,6 @@ namespace Harp {
// private:
// const ArchDef &arch;
// };
};
}
#endif

View File

@@ -20,6 +20,6 @@ namespace Harp {
enum MemFlags {RD_USR = 1, WR_USR = 2, EX_USR = 4,
RD_SUP = 8, WR_SUP = 16, EX_SUP = 32};
};
}
#endif

View File

@@ -19,6 +19,6 @@ namespace Harp {
Word_u readWord(const std::vector<Byte> &b, Size &n, Size wordSize);
void writeByte(std::vector<Byte> &p, Size &n, Byte b);
void writeWord(std::vector<Byte> &p, Size &n, Size wordSize, Word w);
};
}
#endif