def code_gen_extract_sub_runs_old(sub_runs, vname, start_clean = True):
"""Write code that assigns bits to vname based on the sub runs. If
start_clean is false, we OR in our first stuff. Otherwise we do an
assignment for the very first bits extracted."""
# position is the position of the start of the bit run, treated as
# a string, so shifts must be adjusted for the width of the run.
eol = ';\n'
nl = '\n'
if start_clean:
first = True
else:
first = False
s = ''
for (bit,count,position_str, nonterminal_addr) in sub_runs:
print("PROCESSING SUBRUN (%s, %d, %s, %s)" % (
bit, count ,position_str, nonterminal_addr))
# control whether or not we do an assignment or and |= in to our
# dest var c.
if first:
bar = ''
first = False
else:
bar = '|'
# must shift last "c" by the amount we are or-ing in on this iteration
t += "%s=%s<<%s%s" % (vname, vname, str(count), eol)
s += t
print("ADDING SHIFT OF PREV STUFF: %s" % t)
sindex = str(position_str)
if nonterminal_addr != '':
sindex += nonterminal_addr
sindex += '+xed_decoded_inst_nonterminal_bitpos_start(xds)'
s += "%s %s=xed_decoded_inst_read_any_bits(xds,%s,%s)%s" % (
vname, bar, sindex, str(count), eol )
return s
评论列表
文章目录