diff --git a/lib/core/program.rb b/lib/core/program.rb index 23ebebc7d88fc36fbefd7a615592121333dbebea..98e20c507104333cef402b24e4a759288fb0e9b6 100644 --- a/lib/core/program.rb +++ b/lib/core/program.rb @@ -488,6 +488,15 @@ module PML end end + # all called functions + def callees + Enumerator.new do |ss| + callsites.each{|cs| + cs.callees.each {|c| ss << c} + } + end + end + # find all instructions that a callee may return to def identify_return_sites blocks.each { |b| diff --git a/lib/core/programinfo.rb b/lib/core/programinfo.rb index dbc65f6aa4a0520e0f31134a2463d631301ce391..52c8e4c12b0f3c2c6ba87ecefd1911fcbb2f18d1 100644 --- a/lib/core/programinfo.rb +++ b/lib/core/programinfo.rb @@ -325,13 +325,24 @@ module PML lhs = "+ " + lhs end terms = [] + mf_scope = pml.machine_functions.by_label(scope) while lhs != "" do m = /(?<sign>[+-])\s*((?<factor>[0-9]+)\s*)?(?<pp>[^+-]*)\s*(?<lhs>.*)/.match(lhs) - factor = (m[:factor] || "1").to_i - factor *= {"+"=>1, "-"=>-1}[m[:sign]] - terms.push ({"factor"=>factor, - "program-point"=> {"function"=>m[:pp]}}) + if m[:pp][0] == "/" + reg = Regexp.new m[:pp][1..-2] + functions = pml.machine_functions\ + .select {|mf| mf.label =~ reg && mf_scope.callees.member?(mf.label) }\ + .map {|mf| mf.label} + else + functions = [m[:pp]] + end + functions.each {|mf_label| + factor = (m[:factor] || "1").to_i + factor *= {"+"=>1, "-"=>-1}[m[:sign]] + terms.push ({"factor"=>factor, + "program-point"=> {"function"=>mf_label}}) + } lhs = m[:lhs] end