Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TamerPlus fails to handle a user defined function #7

Open
wukefe opened this issue Jun 20, 2016 · 0 comments
Open

TamerPlus fails to handle a user defined function #7

wukefe opened this issue Jun 20, 2016 · 0 comments
Labels

Comments

@wukefe
Copy link

wukefe commented Jun 20, 2016

Originally, I have two MATLAB files: main.m and myIfElse.m.

function z = main(x)
  n = x + 1;
  z = zeros(1,n);
  for i = 1:n
    z(i) = myIfElse(i,1);
  end
end

function z = myIfElse(a, b)
  z = a - 1;
  if(a > b)
    z = b + 1;
  end
end

After I get the TameIR of the two files and save it for each file as follows (mainIR.m and myIfElseIR.m).

function [z] = mainIR(x)
  mc_t9 = 1;
  [n] = plus(x, mc_t9);
  mc_t10 = 1;
  [z] = zeros(mc_t10, n);
  mc_t12 = 1;
  for i = (mc_t12 : n);
    mc_t11 = 1;
    mc_t8 = myIfElse(i, mc_t11);
    z(i) = mc_t8;
  end
end

function [z] = myIfElseIR(a, b)
  mc_t13 = 1;
  [z] = minus(a, mc_t13);
  [mc_t15] = gt(a, b);
  if mc_t15
    mc_t14 = 1;
    [z] = plus(b, mc_t14);
  else
  end
end

I feed the TamerPlus with mainIR.m and myIfElseIR.m that it is expected to produce the 'same' code as the original code. But the user defined function myIfElseIR disappears in the main function mainIR. Maybe I should not use the program which contains temporary variables (e.g. mc_10).

% After Tamer plus
function [z] = mainIR(x)
  [n] = plus(x, mc_t9);
  [z] = zeros(mc_t10, n);
  for i = (mc_t12 : n);
    z(i) = mc_t8; %one line is missing
  end
end

function [z] = myIfElse(a, b)
  [z] = minus(a, 1);
  if gt(a, b)
    [z] = plus(b, 1);
  else 
  end
end

The Java code I used to invoke TamerPlus is listed below.

for(StaticFunction f : localAnalysis.getFunctionCollection().getAllFunctions()){
            PrintMessage.See(TransformationEngine.forAST(f.getAst())
                             .getTIRToMcSAFIRWithoutTemp()
                             .getTransformedTree()
                             .getPrettyPrinted());
}
@wukefe wukefe added the bug label Jun 20, 2016
@wukefe wukefe changed the title TamerPlus fails to handle a defined function TamerPlus fails to handle a user defined function Jun 20, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant