Add source location support to FuncCursor and EncCursor.
A cursor now also remembers a current source location which will be assigned to all new instructions created with the cursor. The old layout::Cursor can't support source locations because it doesn't have a reference to the full ir::Function.
This commit is contained in:
@@ -358,6 +358,7 @@ def gen_xform_group(xgrp, fmt, type_sets):
|
||||
'cfg: &mut ::flowgraph::ControlFlowGraph) -> '
|
||||
'bool {{'.format(xgrp.name), '}'):
|
||||
fmt.line('use ir::{InstBuilder, CursorBase};')
|
||||
fmt.line('let srcloc = func.srclocs[inst];')
|
||||
|
||||
# Group the xforms by opcode so we can generate a big switch.
|
||||
# Preserve ordering.
|
||||
@@ -372,8 +373,9 @@ def gen_xform_group(xgrp, fmt, type_sets):
|
||||
with fmt.indented(
|
||||
'ir::Opcode::{} => {{'.format(camel_name), '}'):
|
||||
fmt.line(
|
||||
'let pos = &mut '
|
||||
'ir::Cursor::new(&mut func.layout)'
|
||||
'let pos = &mut ir::Cursor::new'
|
||||
'(&mut func.layout, &mut func.srclocs)'
|
||||
'.with_srcloc(srcloc)'
|
||||
'.at_inst(inst);')
|
||||
fmt.line('let dfg = &mut func.dfg;')
|
||||
for xform in xforms[camel_name]:
|
||||
|
||||
Reference in New Issue
Block a user