new hlt block terminator
It is handy to express when the end of a block cannot be reached. If a hlt terminator is executed, it traps the program. We don't go the llvm way and specify execution semantics as undefined behavior.
This commit is contained in:
parent
b5da3f3d64
commit
9126afa2da
9 changed files with 30 additions and 13 deletions
|
@ -582,6 +582,9 @@ amd64_emitfn(Fn *fn, FILE *f)
|
|||
emitins(*i, fn, f);
|
||||
lbl = 1;
|
||||
switch (b->jmp.type) {
|
||||
case Jhlt:
|
||||
fprintf(f, "\tud2\n");
|
||||
break;
|
||||
case Jret0:
|
||||
if (fn->dynalloc)
|
||||
fprintf(f,
|
||||
|
|
|
@ -465,7 +465,9 @@ seljmp(Blk *b, Fn *fn)
|
|||
Ins *fi;
|
||||
Tmp *t;
|
||||
|
||||
if (b->jmp.type == Jret0 || b->jmp.type == Jjmp)
|
||||
if (b->jmp.type == Jret0
|
||||
|| b->jmp.type == Jjmp
|
||||
|| b->jmp.type == Jhlt)
|
||||
return;
|
||||
assert(b->jmp.type == Jjnz);
|
||||
r = b->jmp.arg;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue