mirror of
https://github.com/vortexgpgpu/vortex.git
synced 2025-04-24 05:47:35 -04:00
Fixed byte, string directives.
git-svn-id: http://www.cdkersey.com/harp/harptool@118 0246edb2-e076-4747-b392-db732a341fa2
This commit is contained in:
parent
ea03ccb47d
commit
4956625a86
6 changed files with 69 additions and 70 deletions
3
src/BUGS
3
src/BUGS
|
@ -1,3 +0,0 @@
|
|||
_ The assembly writer for the disassembler uses the old assembly format.
|
||||
_ The BYTE directive was not updated when the word directive was; inconsistent
|
||||
behavior.
|
13
src/WISHLIST
13
src/WISHLIST
|
@ -1,15 +1,14 @@
|
|||
- Anonymous chunks whose names are not saved by the object writer.
|
||||
- 32-bit coding for larger-pointered architecture versions.
|
||||
- 32-bit instruction encoding for larger-pointered architecture versions.
|
||||
- HOFDump mode for HARPTool/HOFTool
|
||||
- Make operation information tables into functions of Instruction, if possible.
|
||||
- Make operation information tables into member functions of Instruction, if
|
||||
possible.
|
||||
- Anonymous assigned values in the assembler.
|
||||
- References (pointers) as .word directive contents in the assembler.
|
||||
- .byte directive for assembler.
|
||||
- Make assembler writer capable of writing binary data without making size of
|
||||
output a multiple of word size. Useful in pre-assembled code.
|
||||
- Instruction validation before encoding.
|
||||
- Make readError in obj.cpp throw something instead of printing the whine and
|
||||
- Make readError in obj.cpp throw something instead of printing a message and
|
||||
exiting.
|
||||
- Limit checking for byte/word encoders (e.g. 255 pRegs, 256 regs for byte)
|
||||
- Eliminate the tmp_buf nonsense from the chunk encoder.
|
||||
- Loosen arch restrictions imposed for interoperability.
|
||||
- Loosen arch restrictions imposed for interoperability (the number of lanes is
|
||||
typically unimportant)
|
||||
|
|
90
src/obj.cpp
90
src/obj.cpp
|
@ -213,34 +213,48 @@ Obj *AsmReader::read(std::istream &input) {
|
|||
dc->contents.resize(dc->size);
|
||||
for (size_t i = oldSize; i < dc->size; ++i) dc->contents[i] = 0;
|
||||
} break;
|
||||
case ST_BYTE1: dc->size += yylval.u;
|
||||
state = ST_INIT;
|
||||
break;
|
||||
case ST_BYTE2: if (outstate == OS_DATACHUNK) {
|
||||
dc->size++;
|
||||
dc->contents.resize(dc->size);
|
||||
*(dc->contents.end() - 1) = yylval.u;
|
||||
} else {
|
||||
asmReaderError(yyline, "Byte not in data chunk"
|
||||
"(internal error)");
|
||||
}
|
||||
state = ST_INIT;
|
||||
break;
|
||||
case ST_ALIGN: next_chunk_align = yylval.u;
|
||||
if (outstate != OS_NOCHUNK) {
|
||||
outstate = OS_NOCHUNK;
|
||||
entry = false;
|
||||
global = false;
|
||||
}
|
||||
state = ST_INIT;
|
||||
break;
|
||||
case ST_BYTE1:
|
||||
if (outstate != OS_DATACHUNK) {
|
||||
// TODO: more of this pasted code
|
||||
outstate = OS_DATACHUNK;
|
||||
dc = new DataChunk(next_chunk_name, next_chunk_align?
|
||||
next_chunk_align:wordSize,
|
||||
flagsToWord(permR, permW, permX));
|
||||
next_chunk_align = 0;
|
||||
o->chunks.push_back(dc);
|
||||
if (entry) o->entry = o->chunks.size() - 1;
|
||||
if (global) dc->setGlobal();
|
||||
}
|
||||
dc->size++;
|
||||
dc->contents.resize(dc->size);
|
||||
*(dc->contents.end() - 1) = yylval.u;
|
||||
state = ST_INIT;
|
||||
break;
|
||||
case ST_ALIGN:
|
||||
next_chunk_align = yylval.u;
|
||||
if (outstate != OS_NOCHUNK) {
|
||||
outstate = OS_NOCHUNK;
|
||||
entry = false;
|
||||
global = false;
|
||||
}
|
||||
state = ST_INIT;
|
||||
break;
|
||||
default: asmReaderError(yyline, "Unexpected literal argument");
|
||||
}
|
||||
break;
|
||||
case ASM_T_DIR_ARG_STRING:
|
||||
if (state == ST_STRING2 ||
|
||||
(state == ST_STRING1 && outstate == OS_DATACHUNK))
|
||||
{
|
||||
if (state == ST_STRING1) {
|
||||
if (outstate != OS_DATACHUNK) {
|
||||
// TODO: pasted code (see above)
|
||||
outstate = OS_DATACHUNK;
|
||||
dc = new DataChunk(next_chunk_name,
|
||||
next_chunk_align?next_chunk_align:wordSize,
|
||||
flagsToWord(permR, permW, permX));
|
||||
next_chunk_align = 0;
|
||||
o->chunks.push_back(dc);
|
||||
if (entry) o->entry = o->chunks.size() - 1;
|
||||
if (global) dc->setGlobal();
|
||||
}
|
||||
const char *s = yylval.s.c_str();
|
||||
do {
|
||||
if (*s == '\\') {
|
||||
|
@ -262,26 +276,6 @@ Obj *AsmReader::read(std::istream &input) {
|
|||
case ASM_T_DIR_ARG_SYM:
|
||||
switch (state) {
|
||||
case ST_DEF1: string_arg = yylval.s; state = ST_DEF2; break;
|
||||
case ST_BYTE1: {
|
||||
state = ST_BYTE2;
|
||||
outstate = OS_DATACHUNK;
|
||||
dc = new DataChunk(yylval.s, next_chunk_align,
|
||||
flagsToWord(permR, permW, permX));
|
||||
next_chunk_align = 0;
|
||||
o->chunks.push_back(dc);
|
||||
if (entry) o->entry = o->chunks.size() - 1;
|
||||
if (global) dc->setGlobal();
|
||||
} break;
|
||||
case ST_STRING1: {
|
||||
state = ST_STRING2;
|
||||
outstate = OS_DATACHUNK;
|
||||
dc = new DataChunk(yylval.s, next_chunk_align,
|
||||
flagsToWord(permR, permW, permX));
|
||||
next_chunk_align = 0;
|
||||
o->chunks.push_back(dc);
|
||||
if (entry) o->entry = o->chunks.size() - 1;
|
||||
if (global) dc->setGlobal();
|
||||
} break;
|
||||
default: asmReaderError(yyline, "");
|
||||
};
|
||||
break;
|
||||
|
@ -392,8 +386,6 @@ Obj *AsmReader::read(std::istream &input) {
|
|||
}
|
||||
|
||||
void AsmWriter::write(std::ostream &output, const Obj &obj) {
|
||||
unsigned anonWordNum(0);
|
||||
|
||||
Word prevFlags(0);
|
||||
|
||||
for (size_t j = 0; j < obj.chunks.size(); j++) {
|
||||
|
@ -439,10 +431,10 @@ void AsmWriter::write(std::ostream &output, const Obj &obj) {
|
|||
}
|
||||
|
||||
if (i == tmpWordSize && c->name != "") {
|
||||
output << ".word " << c->name << " 0x" << hex << w << '\n';
|
||||
output << c->name << ':' << endl;
|
||||
output << " .word " << " 0x" << hex << w << endl;
|
||||
} else {
|
||||
output << ".word __anonWord" << anonWordNum++ << " 0x"
|
||||
<< hex << w << '\n';
|
||||
output << " .word " << " 0x" << hex << w << endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,12 +1,15 @@
|
|||
HARPLD = ../harptool -L
|
||||
HARPAS = ../harptool -A
|
||||
HARPEM = ../harptool -E
|
||||
4BARCH = 4b16/16/2
|
||||
HARPLD = ../harptool -L
|
||||
HARPAS = ../harptool -A
|
||||
HARPEM = ../harptool -E
|
||||
HARPDIS = ../harptool -D
|
||||
4BARCH = 4b16/16/2
|
||||
|
||||
all: simple.bin sieve.bin 2thread.bin simple.4b.bin sieve.4b.bin 2thread.4b.bin
|
||||
|
||||
run: simple.out sieve.out 2thread.out simple.4b.out sieve.4b.out 2thread.4b.out
|
||||
|
||||
disas: simple.d sieve.d 2thread.d simple.4b.d sieve.4b.d 2thread.4b.d
|
||||
|
||||
%.4b.out : %.4b.bin
|
||||
$(HARPEM) -a $(4BARCH) -c $< > $@
|
||||
|
||||
|
@ -43,5 +46,11 @@ sieve.4b.bin : boot.4b.HOF lib.4b.HOF sieve.4b.HOF
|
|||
%.HOF : %.s
|
||||
$(HARPAS) -o $@ $<
|
||||
|
||||
%.4b.d : %.4b.HOF
|
||||
$(HARPDIS) -o $@ --arch $(4BARCH) $<
|
||||
|
||||
%.d : %.HOF
|
||||
$(HARPDIS) -o $@ $<
|
||||
|
||||
clean:
|
||||
rm -f *.HOF *.bin *.out *~
|
||||
rm -f *.HOF *.bin *.out *.d *~
|
||||
|
|
|
@ -78,10 +78,10 @@ loop4: ld %r1, %r0, array;
|
|||
trap; /* All traps currently cause a halt. */
|
||||
|
||||
.perm rw /* TODO: How should I write section permissions? */
|
||||
.string hello "\"Harp!\" is how a harp seal says hello!\n"
|
||||
.string wrstr "Doing write\n"
|
||||
.string wrfin "Done write\n"
|
||||
.string xstr "Exiting loop\n"
|
||||
hello: .string "\"Harp!\" is how a harp seal says hello!\n"
|
||||
wrstr: .string "Doing write\n"
|
||||
wrfin: .string "Did write\n"
|
||||
xstr: .string "Exiting loop\n"
|
||||
|
||||
.global
|
||||
array: .space 0x1000 /* SIZE words of space. */
|
||||
|
|
|
@ -18,5 +18,7 @@ entry: ldi %r7, hello
|
|||
trap; /* All traps currently cause a halt. */
|
||||
|
||||
.perm rw /* TODO: How should I write section permissions? */
|
||||
/* TODO: String literals! */
|
||||
.string hello "\"Harp!\" is how a harp seal says hello!\n"
|
||||
|
||||
hello:
|
||||
.byte 0x22
|
||||
.string "Harp!\" is how a harp seal says hello!\n"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue