Commit 6b137997 authored by Axel Simon's avatar Axel Simon

use proper name for ip_get

parent b3ad3805
......@@ -139,7 +139,7 @@ __obj __zx (__obj x) {
}
/* FIXME */
__obj __idxget (__obj s) {
__obj __get-ip (__obj s) {
__LOCAL(blob, __RECORD_SELECT(s,___blob));
__LOCAL0(y);
__INT_BEGIN(y);
......
......@@ -936,7 +936,7 @@ structure C1 = struct
| emitPrim s (SETSTATEprim, [e],_) = seq [str "s->mon_state = ", emitExp s e]
| emitPrim s (SEEKprim, [e],_) = seq [str "gdsl_seek(s, (size_t) (", emitExp s e, str "))"]
| emitPrim s (DIVprim, [e1, e2],_) = seq [str "(", emitExp s e1, str ")/(", emitExp s e2, str ")"]
| emitPrim s (IPGETprim, [],_) = str "gdsl_get_ip_offset(s)"
| emitPrim s (IPGETprim, [],_) = str "gdsl_get_ip(s)"
| emitPrim s (CONSUME8prim, [],_) = (addConsume s 8; str "consume(s, 1)")
| emitPrim s (CONSUME16prim, [],_) = (addConsume s 16; str "consume(s, 2)")
| emitPrim s (CONSUME32prim, [],_) = (addConsume s 32; str "consume(s, 4)")
......@@ -1350,7 +1350,7 @@ structure C1 = struct
C1Templates.expandRuntime path outputName [
C1Templates.mkHook ("init", str (prefix ^ "init")),
C1Templates.mkHook ("set_code", str (prefix ^ "set_code")),
C1Templates.mkHook ("get_ip_offset", str (prefix ^ "get_ip_offset")),
C1Templates.mkHook ("get_ip", str (prefix ^ "get_ip")),
C1Templates.mkHook ("seek", str (prefix ^ "seek")),
(*C1Templates.mkHook ("rseek", str (prefix ^ "rseek")),*)
C1Templates.mkHook ("err_tgt", str (prefix ^ "err_tgt")),
......
......@@ -331,7 +331,7 @@ void
}
size_t
@get_ip_offset@
@get_ip@
(state_t s) {
return s->ip_base + (s->ip - s->ip_start);
}
......@@ -472,14 +472,20 @@ int main (int argc, char** argv) {
#if defined(gdsl_decoder_config)
for (config = gdsl_decoder_config(s); gdsl_has_conf(s,config);
config = gdsl_conf_next(s,config))
if (strcmp(arg,gdsl_conf_short(s,config))==0)
if (strcmp(arg,gdsl_conf_short(s,config))==0) {
decode_options |= gdsl_conf_data(s,config);
break;
}
if (gdsl_has_conf(s,config)) continue;
#endif
#if defined(gdsl_rreil_config)
for (config = gdsl_rreil_config(s); gdsl_has_conf(s,config);
#if defined(gdsl_optimization_config)
for (config = gdsl_optimization_config(s); gdsl_has_conf(s,config);
config = gdsl_conf_next(s,config))
if (strcmp(arg,gdsl_conf_short(s,config))==0)
if (strcmp(arg,gdsl_conf_short(s,config))==0) {
optimization_options |= gdsl_conf_data(s,config);
break;
}
if (gdsl_has_conf(s,config)) continue;
#endif
if (strncmp(arg,"base=",5)==0) {
int res=readNum(arg+5,&base_address);
......@@ -495,18 +501,19 @@ int main (int argc, char** argv) {
continue;
}
fprintf(stderr,
"usage: %s [options] filename\nwhere\n"
"Command line argument `%s' not recognized. Usage:\n"
"\t%s [options] filename\nwhere\n"
" --trans translate to semantics\n"
" --base=addr print addresses relative to addr\n"
" --start=addr decode starting from addr\n", argv[0]);
" --start=addr decode starting from addr\n", argv[i], argv[0]);
#if defined(gdsl_decoder_config)
for (config = gdsl_decoder_config(s); gdsl_has_conf(s,config);
config = gdsl_conf_next(s,config))
fprintf(stderr," --%s\t\t%s\n",
gdsl_conf_short(s,config), gdsl_conf_long(s,config));
#endif
#if defined(gdsl_rreil_config)
for (config = gdsl_rreil_config(s); gdsl_has_conf(s,config);
#if defined(gdsl_optimization_config)
for (config = gdsl_optimization_config(s); gdsl_has_conf(s,config);
config = gdsl_conf_next(s,config))
fprintf(stderr," --%s\t\t%s\n",
gdsl_conf_short(s,config), gdsl_conf_long(s,config));
......@@ -545,18 +552,18 @@ int main (int argc, char** argv) {
alloc_no = 0;
alloc_max = 0;
while (gdsl_get_ip_offset(s)<buf_size) {
while (gdsl_get_ip(s)-base_address<buf_size) {
size_t size;
size_t address=0;
if (setjmp(*gdsl_err_tgt(s))==0) {
if (run_translate) {
#ifdef HAVE_TRANS
address = gdsl_get_ip_offset(s);
obj_t rreil = gdsl_decode_translate_block_optimized(s,
address = gdsl_get_ip(s);
opt_result_t block = gdsl_decode_translate_block_optimized(s,
decode_options,
gdsl_int_max(s),
optimization_options);
obj_t res = gdsl_rreil_pretty(s,rreil);
obj_t res = gdsl_rreil_pretty(s,block->rreil);
string_t str = gdsl_merge_rope(s,res);
if (print_addr) printf("0x%016lx:\n",address);
fputs(str,stdout);
......@@ -566,7 +573,7 @@ int main (int argc, char** argv) {
#endif
} else {
#ifdef HAVE_DECODE
address = gdsl_get_ip_offset(s);
address = gdsl_get_ip(s);
obj_t instr = gdsl_decode(s, decode_options);
obj_t res = gdsl_pretty(s,instr);
string_t str = gdsl_merge_rope(s,res);
......
......@@ -47,7 +47,7 @@ end = struct
val == = get "=="
val not = get "not"
val raisee = get "raise"
val idxget = get "idxget"
val get_ip = get "get-ip"
(* val rseek = get "rseek"*)
val seek = get "seek"
val index = get "index"
......@@ -271,14 +271,14 @@ end = struct
(raisee, [a], body)
end
(* val idxget s = %idxget(s) *)
val idxget =
(* val get_ip s = %get-ip(s) *)
val get_ip =
let
val s = fresh "s"
val primidxget = get "%idxget"
val body = PRI (primidxget, [s])
val primget_ip = get "%get-ip"
val body = PRI (primget_ip, [s])
in
(idxget, [s], body)
(get_ip, [s], body)
end
(* val rseek x s = %rseek(x, s)
......@@ -412,8 +412,7 @@ end = struct
==,
concat,
raisee,
idxget,
(*rseek,*)
get_ip,
seek,
index,
puts,
......
......@@ -98,7 +98,7 @@ structure Imp = struct
and the priority is the operator precedence, 0 if not infix *)
fun prim_info GETSTATEprim = { name = "__get_state", prio = 0 }
| prim_info SETSTATEprim = { name = "__set_state", prio = 0 }
| prim_info IPGETprim = { name = "idxget", prio = 0 }
| prim_info IPGETprim = { name = "get-ip", prio = 0 }
| prim_info SEEKprim = { name = "seek", prio = 0 }
(*| prim_info RSEEKprim = { name = "rseek", prio = 0 }*)
| prim_info DIVprim = { name = "/z", prio = 5 }
......
......@@ -129,7 +129,7 @@ structure Primitives = struct
flow = BD.meetVarImpliesVar (bvar stateC', bvar stateC)},
{name="raise", ty=MONAD (freshVar (),stateD, stateD'),
flow = noFlow},
{name="idxget", ty=MONAD (ZENO, stateN, stateN'),
{name="get-ip", ty=MONAD (ZENO, stateN, stateN'),
flow = BD.meetVarImpliesVar (bvar stateN', bvar stateN)},
{name="seek", ty=func (ZENO, MONAD (ZENO, stateO, stateO')),
flow = BD.meetVarImpliesVar (bvar stateO', bvar stateO)},
......@@ -231,8 +231,7 @@ structure Primitives = struct
{name="%consume32", ty=UNIT, flow = noFlow},
{name="%unconsume32", ty=UNIT, flow = noFlow},
{name="%slice", ty=UNIT, flow = noFlow},
{name="%idxget", ty=UNIT, flow = noFlow},
(*{name="%rseek", ty=UNIT, flow = noFlow},*)
{name="%get-ip", ty=UNIT, flow = noFlow},
{name="%seek", ty=UNIT, flow = noFlow},
{name="%invoke", ty=UNIT, flow = noFlow},
{name="%invoke_int", ty=UNIT, flow = noFlow},
......@@ -359,7 +358,7 @@ structure Primitives = struct
INVOKEexp (oo, f,[PRIexp (GETSTATEprim, o_, [])])
]))
| _ => raise ImpPrimTranslationBug))),
("idxget", (t 0, fn args => action (boxI (PRIexp (IPGETprim,i,args))))),
("get-ip", (t 0, fn args => action (boxI (PRIexp (IPGETprim,i,args))))),
("seek", (t 0, fn args => action (boxI (PRIexp (SEEKprim,ii,unboxI args))))),
(*("rseek", (t 0, fn args => action (boxI (PRIexp (RSEEKprim,ii,unboxI args))))),*)
("/z", (t 2, fn args => boxI (pr (DIVprim,iii,unboxI args)))),
......
......@@ -528,9 +528,9 @@ val / ['1001001 d d d d d 0100'] = binop XCH /Z rd5
val decode config = do
set-endianness LITTLE_ENDIAN 2;
update@{rd='',rr='',ck='',cs='',cb='',io='',dq='', config = config};
idx-before <- idxget;
idx-before <- get-ip;
insn <- /;
idx-after <- idxget;
idx-after <- get-ip;
return {length=(idx-after - idx-before), insn=insn}
end
......@@ -538,7 +538,7 @@ val isTiny s = zx (s.config and '1') > 0
val genTinyInstr = do
update@{rd='',rr='',ck='',cs='',cb='',io='',dq=''};
index <- idxget;
index <- get-ip;
seek (index - 4);
/tiny
end
......@@ -1083,9 +1083,9 @@ val rr4h-rr4l = do
end
val sizeof-next = do
index <- idxget;
index <- get-ip;
/;
new <- idxget;
new <- get-ip;
seek index;
return (IMM (IMMi (/z (new - index) 2)))
end
......
......@@ -65,9 +65,9 @@ val pause? s = (s.rt == '00000') and (s.rd == '00000') and (s.sa == '00101')
val decode config = do
set-endianness BIG_ENDIAN 4;
update@{rs='00000',rt='00000',rd='00000',fr='00000',fs='00000',ft='00000',fd='00000',immediate='0000000000000000',offset16='0000000000000000',offset9='000000000',sel='000',impl='0000000000000000',code10='0000000000',code19='0000000000000000000',code20='00000000000000000000',stype='00000',msb='00000',msbd='00000',lsb='00000',sa='00000',instr_index='00000000000000000000000000',cofun='0000000000000000000000000',cc='000',cond='0000',op='00000',hint='00000',fmt='00000'};
idx-before <- idxget;
idx-before <- get-ip;
insn <- /;
idx-after <- idxget;
idx-after <- get-ip;
return {length=(idx-after - idx-before), insn=insn}
end
......
......@@ -11,7 +11,7 @@ val decode-translate-block-headless config limit = do
update @{insns=INSNS_CONS {insn=insn, tl=insns}};
translate-block-single insn;
jmp <- query $foundJump;
idx <- idxget;
idx <- get-ip;
if jmp or (idx >= limit) then
query $stack
else
......@@ -87,8 +87,7 @@ type translate-result = {
val decode-translate-super-block config limit = let
val translate-block-at idx = do
current <- idxget;
#error <- rseek idx;
current <- get-ip;
error <- seek (current + idx);
result <- if error === 0 then do
stmts <- decode-translate-block config int-max;
......
......@@ -46,9 +46,9 @@ val main config = do
~tab
};
idx-before <- idxget;
idx-before <- get-ip;
instr <- p64;
idx-after <- idxget;
idx-after <- get-ip;
update @{tab=t};
return (@{length=(idx-after - idx-before), config=config} instr)
......@@ -1741,7 +1741,7 @@ val ymm15 = return (REG YMM15)
val st0 = return (REG ST0)
val imm-build cons b size = do
ip <- idxget;
ip <- get-ip;
return (cons {imm=b,address=(ip - size)})
end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment