Move inlineCost and inlineCost3 to a visitor class
Merge pull request #3110 from yebblies/inlinecost

[refactor] Move inlineCost and inlineCost3 to a visitor class
Refactor opId, opId_r, and isCommutative into free functions