helper functions instead of duplicating it inline each time it is needed. This eliminates a few hundred or so copies of this code in each target. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@56759 91177308-0d34-0410-b5e6-96231b3b80d8