Implement load.
This commit is contained in:
parent
f04d22c27e
commit
5f7a5bf26c
4
ll.py
4
ll.py
|
@ -110,6 +110,10 @@ def insn2s(insn):
|
||||||
if isinstance(insn, Alloca):
|
if isinstance(insn, Alloca):
|
||||||
return ('alloca {}'
|
return ('alloca {}'
|
||||||
.format(ty2s(insn.ty)))
|
.format(ty2s(insn.ty)))
|
||||||
|
if isinstance(insn, Load):
|
||||||
|
return ('load {}, {}* {}'
|
||||||
|
.format(ty2s(insn.ty), ty2s(insn.ty),
|
||||||
|
oper2s(insn.location)))
|
||||||
if isinstance(insn, Store):
|
if isinstance(insn, Store):
|
||||||
return ('store {} {}, {}* {}'
|
return ('store {} {}, {}* {}'
|
||||||
.format(ty2s(insn.ty),
|
.format(ty2s(insn.ty),
|
||||||
|
|
22
stepper.py
22
stepper.py
|
@ -62,7 +62,22 @@ def step(insns, terminator, blocks, stack_frames, ssa_env, global_env, heap,
|
||||||
|
|
||||||
res = ptr
|
res = ptr
|
||||||
elif isinstance(next_insn, ll.Load):
|
elif isinstance(next_insn, ll.Load):
|
||||||
TODO('Load')
|
ty = next_insn.ty
|
||||||
|
base_ty = ty2base_ty(ty, tdecs)
|
||||||
|
size = base_ty2size(base_ty)
|
||||||
|
location = next_insn.location
|
||||||
|
location_v = eval_oper(location, ssa_env, global_env)
|
||||||
|
|
||||||
|
# TODO
|
||||||
|
print('load heap[{}]'
|
||||||
|
.format(location_v))
|
||||||
|
|
||||||
|
if size != 1:
|
||||||
|
err(('This emulator cannot load objects larger than 1 cell.'
|
||||||
|
' Current size is {}')
|
||||||
|
.format(size))
|
||||||
|
|
||||||
|
res = heap[location_v]
|
||||||
elif isinstance(next_insn, ll.Store):
|
elif isinstance(next_insn, ll.Store):
|
||||||
ty = next_insn.ty
|
ty = next_insn.ty
|
||||||
base_ty = ty2base_ty(ty, tdecs)
|
base_ty = ty2base_ty(ty, tdecs)
|
||||||
|
@ -351,8 +366,11 @@ def gogo():
|
||||||
data = r'''
|
data = r'''
|
||||||
define i64 @tigermain (i64 %U_mainSL_8, i64 %U_mainDummy_9) {
|
define i64 @tigermain (i64 %U_mainSL_8, i64 %U_mainDummy_9) {
|
||||||
%a = alloca i64
|
%a = alloca i64
|
||||||
|
%a_alt = alloca i64
|
||||||
store i64 9, i64* %a
|
store i64 9, i64* %a
|
||||||
ret i64 77
|
%b = load i64, i64* %a
|
||||||
|
%b_alt = load i64, i64* %a_alt
|
||||||
|
ret i64 %b
|
||||||
}
|
}
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user