Skip to content

Commit

Permalink
Merge pull request #149 from physical-computation/issue-143
Browse files Browse the repository at this point in the history
Compiler warnings and embedded target tweaks
  • Loading branch information
phillipstanleymarbell authored Dec 2, 2019
2 parents 88ec086 + 4bd15e7 commit f802835
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 43 deletions.
2 changes: 1 addition & 1 deletion sim/fdr.c
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,7 @@ m_readstabs(Engine *E, State *S, char *filename)
/* */
if ((strlen(line) > 0) && (line[strlen(line)-1] != '\n'))
{
#ifndef SF_EMBEDDED
#if (SF_EMBEDDED == 0)
fscanf(fp, "%*s\n");
#endif
}
Expand Down
8 changes: 4 additions & 4 deletions sim/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ updaterandsched(Engine *E)
void
scheduler(Engine *E)
{
#ifndef SF_EMBEDDED
#if (SF_EMBEDDED == 0)
int jmpval;
#endif

Expand All @@ -509,7 +509,7 @@ scheduler(Engine *E)
/* */
marchinit();

#ifndef SF_EMBEDDED
#if (SF_EMBEDDED == 0)
if (!(jmpval = setjmp(E->jmpbuf)))
{
/* Returning from initial call */
Expand Down Expand Up @@ -832,7 +832,7 @@ savemem(Engine *E, State *S, ulong start_addr, ulong end_addr, char *filename)
void
sfatal(Engine *E, State *S, char *msg)
{
#ifndef SF_EMBEDDED
#if (SF_EMBEDDED == 0)
int do_jmp = E->on;
#endif

Expand All @@ -859,7 +859,7 @@ sfatal(Engine *E, State *S, char *msg)
/* Don't longjmp when, e.g., loading a file into mem, in */
/* which case we'd have entered sfatal w/ E->on false. */
/* */
#ifndef SF_EMBEDDED
#if (SF_EMBEDDED == 0)
if (do_jmp)
{
longjmp(E->jmpbuf, S->NODE_ID);
Expand Down
25 changes: 6 additions & 19 deletions sim/memory-hierarchy.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
*/


//Read from memory 2 bytes
void
big_endian_read_2(uchar * source, ushort * target)
{
Expand Down Expand Up @@ -66,7 +65,6 @@ read_2(State * S, uchar * source, ushort * target)
}
}

//Read from memory 4 bytes
void
big_endian_read_4(uchar * source, ulong * target)
{
Expand Down Expand Up @@ -97,7 +95,6 @@ read_4(State * S, uchar * source, ulong * target)
}


//Write to memory 2 bytes
void
big_endian_write_2(ushort source, uchar * target)
{
Expand Down Expand Up @@ -130,7 +127,6 @@ write_2(State *S, ushort source, uchar * target)
}


//Write to memory 4 bytes
void
big_endian_write_4(ulong source, uchar * target)
{
Expand Down Expand Up @@ -237,7 +233,7 @@ superHwritebyte(Engine *E, State *S, ulong vaddr, ulong xdata)
{
int inram, latency = 0;
int i, j, id;
ulong offset, destbase, destoffset;
ulong offset, destoffset;
TransAddr trans;
ulong paddr;
uchar data = xdata & 0xFF;
Expand Down Expand Up @@ -295,7 +291,6 @@ superHwritebyte(Engine *E, State *S, ulong vaddr, ulong xdata)

if (i != -1)
{
//fprintf(stderr, "!");
X->regions[i]->nwrites++;

id = X->regions[i]->map_id;
Expand Down Expand Up @@ -351,7 +346,6 @@ superHwritebyte(Engine *E, State *S, ulong vaddr, ulong xdata)


D = E->sp[id];
destbase = D->MEMBASE;
offset = vaddr - S->MEMBASE;
destoffset = offset + X->regions[i]->map_offset;

Expand Down Expand Up @@ -523,7 +517,7 @@ superHwriteword(Engine *E, State *S, ulong vaddr, ulong xdata)
{
int inram, latency = 0;
int i, id, j;
ulong offset, destoffset = 0, destbase;
ulong offset, destoffset = 0;
TransAddr trans;
ulong paddr;
ushort data = xdata & 0xFFFF;
Expand Down Expand Up @@ -581,7 +575,6 @@ superHwriteword(Engine *E, State *S, ulong vaddr, ulong xdata)

if (i != -1)
{
//fprintf(stderr, "!");
X->regions[i]->nwrites++;

id = X->regions[i]->map_id;
Expand Down Expand Up @@ -647,7 +640,6 @@ superHwriteword(Engine *E, State *S, ulong vaddr, ulong xdata)
}

D = E->sp[id];
destbase = D->MEMBASE;
offset = vaddr - S->MEMBASE;
destoffset = offset + X->regions[i]->map_offset;

Expand Down Expand Up @@ -833,7 +825,7 @@ superHwritelong(Engine *E, State *S, ulong vaddr, ulong data)
{
int inram, latency = 0;
int i, id, j;
ulong offset, destoffset = 0, destbase;
ulong offset, destoffset = 0;
TransAddr trans;
ulong paddr;
State *D;
Expand Down Expand Up @@ -890,7 +882,6 @@ superHwritelong(Engine *E, State *S, ulong vaddr, ulong data)

if (i != -1)
{
//fprintf(stderr, "!");
X->regions[i]->nwrites++;

id = X->regions[i]->map_id;
Expand Down Expand Up @@ -956,7 +947,6 @@ superHwritelong(Engine *E, State *S, ulong vaddr, ulong data)
}

D = E->sp[id];
destbase = D->MEMBASE;
offset = vaddr - S->MEMBASE;
destoffset = offset + X->regions[i]->map_offset;

Expand Down Expand Up @@ -1152,7 +1142,7 @@ superHreadbyte(Engine *E, State *S, ulong vaddr)
{
int inram, latency = 0;
int i, id, j;
ulong offset, destoffset = 0, destbase;
ulong offset, destoffset = 0;
TransAddr trans;
ulong paddr;
uchar data = 0;
Expand Down Expand Up @@ -1231,7 +1221,6 @@ superHreadbyte(Engine *E, State *S, ulong vaddr)
}

D = E->sp[id];
destbase = D->MEMBASE;
offset = vaddr - S->MEMBASE;
destoffset = offset + X->regions[i]->map_offset;

Expand Down Expand Up @@ -1423,7 +1412,7 @@ superHreadword(Engine *E, State *S, ulong vaddr)
{
int inram, latency = 0;
int i, id, j;
ulong offset, destoffset = 0, destbase;
ulong offset, destoffset = 0;
TransAddr trans;
ulong paddr;
ushort data = 0;
Expand Down Expand Up @@ -1502,7 +1491,6 @@ superHreadword(Engine *E, State *S, ulong vaddr)
}

D = E->sp[id];
destbase = D->MEMBASE;
offset = vaddr - S->MEMBASE;
destoffset = offset + X->regions[i]->map_offset;

Expand Down Expand Up @@ -1716,7 +1704,7 @@ superHreadlong(Engine *E, State *S, ulong vaddr)
{
int inram, latency = 0;
int i, id, j;
ulong offset, destoffset = 0, destbase;
ulong offset, destoffset = 0;
TransAddr trans;
ulong paddr;
ulong data = 0;
Expand Down Expand Up @@ -1796,7 +1784,6 @@ mprint(E,NULL,siminfo,"map_offset: " UHLONGFMT "\n",X->regions[i]->map_offset);
}

D = E->sp[id];
destbase = D->MEMBASE;
offset = vaddr - S->MEMBASE;
destoffset = offset + X->regions[i]->map_offset;

Expand Down
26 changes: 13 additions & 13 deletions sim/op-riscv.c
Original file line number Diff line number Diff line change
Expand Up @@ -1337,7 +1337,7 @@ rv32f_fmin_s(Engine *E, State *S, uint8_t rs1, uint8_t rs2, uint8_t rd)

merror(E, "We currently do not support unfmin.s. Sorry!");

uncertain_inst_mv(S->riscv->uncertain, rd, nan(""));
//uncertain_inst_mv(S->riscv->uncertain, rd, nan(""));
S->riscv->uncertain->last_op.valid = 0;
}

Expand Down Expand Up @@ -1372,7 +1372,7 @@ rv32f_fmax_s(Engine *E, State *S, uint8_t rs1, uint8_t rs2, uint8_t rd)

merror(E, "We currently do not support unfmax.s. Sorry!");

uncertain_inst_mv(S->riscv->uncertain, rd, nan(""));
//uncertain_inst_mv(S->riscv->uncertain, rd, nan(""));
S->riscv->uncertain->last_op.valid = 0;
}

Expand All @@ -1390,9 +1390,9 @@ rv32f_fcvt_w_s(Engine *E, State *S, uint8_t rs1, uint8_t rs2, uint8_t rd)
src1.bit_value = is_nan_boxed(freg_read_riscv(E, S, rs1));

/*
*Rounding modes - Reference
*https://www.gnu.org/software/libc/manual/html_node/Rounding-Functions.html
*/
* Rounding modes - Reference
* https://www.gnu.org/software/libc/manual/html_node/Rounding-Functions.html
*/
switch (rm) //TODO check rm value for rounding
{
case 0b000: //Round to nearest (ties to Even)
Expand Down Expand Up @@ -1478,9 +1478,9 @@ rv32f_fcvt_wu_s(Engine *E, State *S, uint8_t rs1, uint8_t rs2, uint8_t rd)
uint8_t rm = ((instr_r *)&S->riscv->P.EX.instr)->funct3;

/*
*Rounding modes - Reference
*https://www.gnu.org/software/libc/manual/html_node/Rounding-Functions.html
*/
* Rounding modes - Reference
* https://www.gnu.org/software/libc/manual/html_node/Rounding-Functions.html
*/
switch (rm) //TODO check rm value for rounding
{
case 0b000: //Round to nearest (ties to Even)
Expand Down Expand Up @@ -1994,7 +1994,7 @@ rv32d_fdiv_d(Engine *E, State *S, uint8_t rs1, uint8_t rs2, uint8_t rd)
void
rv32d_fsqrt_d(Engine *E, State *S, uint8_t rs1, uint8_t rs2, uint8_t rd)
{
//rs2 is unused
//TODO: rs2 is unused

uint8_t rm = ((instr_r *)&S->riscv->P.EX.instr)->funct3;
rv32d_rep src1, result;
Expand Down Expand Up @@ -2118,7 +2118,7 @@ rv32d_fcvt_s_d(Engine *E, State *S, uint8_t rs1, uint8_t rs2, uint8_t rd)
{
//uint8_t rm = ((instr_r *)&S->riscv->P.EX.instr)->funct3; //TODO check why there is a rm field?

//rs2 unused
//TODO: rs2 unused

rv32f_rep result;
rv32d_rep src1;
Expand All @@ -2142,7 +2142,7 @@ rv32d_fcvt_d_s(Engine *E, State *S, uint8_t rs1, uint8_t rs2, uint8_t rd)
{
//uint8_t rm = ((instr_r *)&S->riscv->P.EX.instr)->funct3; //TODO check why there is a rm field?

//rs2 unused
//TODO: rs2 unused

rv32d_rep result;
rv32f_rep src1;
Expand Down Expand Up @@ -2272,7 +2272,7 @@ rv32d_fclass_d(Engine *E, State *S, uint8_t rs1, uint8_t rs2, uint8_t rd)
void
rv32d_fcvt_w_d(Engine *E, State *S, uint8_t rs1, uint8_t rs2, uint8_t rd)
{
//rs2 unused
//TODO: rs2 unused

rv32d_rep src1;

Expand Down Expand Up @@ -2445,7 +2445,7 @@ void
rv32d_fcvt_d_w(Engine *E, State *S, uint8_t rs1, uint8_t rs2, uint8_t rd)
{
//uint8_t rm = ((instr_r *)&S->riscv->P.EX.instr)->funct3; //TODO check why there is a rm field?
//rs2 unused
//TODO: rs2 unused

rv32d_rep result;
int32_t src1 = (int32_t)reg_read_riscv(E, S, rs1);
Expand Down
12 changes: 6 additions & 6 deletions sim/syscalls.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#ifndef SF_EMBEDDED
#if (SF_EMBEDDED == 0)
# include <sys/times.h>
#endif
#include <time.h>
Expand Down Expand Up @@ -67,7 +67,7 @@ sim_syscall(Engine *E, State *S, ulong type, ulong arg1, ulong arg2, ulong arg3)
{
case SYS_exit:
{
#ifndef SF_EMBEDDED
#if (SF_EMBEDDED == 0)
struct tms t;
#endif
/*
Expand All @@ -79,7 +79,7 @@ sim_syscall(Engine *E, State *S, ulong type, ulong arg1, ulong arg2, ulong arg3)
mprint(E, S, nodeinfo, "SYSCALL: SYS_exit\n");
}

#ifndef SF_EMBEDDED
#if (SF_EMBEDDED == 0)
times(&t);
#endif
S->ufinish = musercputimeusecs();
Expand Down Expand Up @@ -566,7 +566,7 @@ ulong
sys_chmod(State *S, const char *path, short mode)
{
/* For now, just pass it on */
#ifndef SF_EMBEDDED
#if (SF_EMBEDDED == 0)
return chmod((char *)&S->MEM[(ulong)path - S->MEMBASE], mode);
#else
return 0;
Expand All @@ -577,7 +577,7 @@ ulong
sys_chown(State *S, const char *path, short owner, short group)
{
/* For now, just pass it on */
#ifndef SF_EMBEDDED
#if (SF_EMBEDDED == 0)
return chown((char *)&S->MEM[(ulong)path - S->MEMBASE], owner, group);
#else
return 0;
Expand Down Expand Up @@ -614,7 +614,7 @@ ulong
sys_utime(State *S, const char *path, const struct utimbuf *times)
{
/* For now, just pass it on */
#ifndef SF_EMBEDDED
#if (SF_EMBEDDED == 0)
return utime((char *)&S->MEM[(ulong)path - S->MEMBASE],\
(const struct utimbuf *)&S->MEM[(ulong)times - S->MEMBASE]);
#else
Expand Down

0 comments on commit f802835

Please sign in to comment.