add targethandler hooks from Writer and cleanup

llvm-svn: 173904
9 files changed