WebAssemblyTargetTransformInfo.h 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. //==- WebAssemblyTargetTransformInfo.h - WebAssembly-specific TTI -*- C++ -*-=//
  2. //
  3. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  4. // See https://llvm.org/LICENSE.txt for license information.
  5. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  6. //
  7. //===----------------------------------------------------------------------===//
  8. ///
  9. /// \file
  10. /// This file a TargetTransformInfo::Concept conforming object specific
  11. /// to the WebAssembly target machine.
  12. ///
  13. /// It uses the target's detailed information to provide more precise answers to
  14. /// certain TTI queries, while letting the target independent and default TTI
  15. /// implementations handle the rest.
  16. ///
  17. //===----------------------------------------------------------------------===//
  18. #ifndef LLVM_LIB_TARGET_WEBASSEMBLY_WEBASSEMBLYTARGETTRANSFORMINFO_H
  19. #define LLVM_LIB_TARGET_WEBASSEMBLY_WEBASSEMBLYTARGETTRANSFORMINFO_H
  20. #include "WebAssemblyTargetMachine.h"
  21. #include "llvm/CodeGen/BasicTTIImpl.h"
  22. #include <algorithm>
  23. namespace llvm {
  24. class WebAssemblyTTIImpl final : public BasicTTIImplBase<WebAssemblyTTIImpl> {
  25. typedef BasicTTIImplBase<WebAssemblyTTIImpl> BaseT;
  26. typedef TargetTransformInfo TTI;
  27. friend BaseT;
  28. const WebAssemblySubtarget *ST;
  29. const WebAssemblyTargetLowering *TLI;
  30. const WebAssemblySubtarget *getST() const { return ST; }
  31. const WebAssemblyTargetLowering *getTLI() const { return TLI; }
  32. public:
  33. WebAssemblyTTIImpl(const WebAssemblyTargetMachine *TM, const Function &F)
  34. : BaseT(TM, F.getParent()->getDataLayout()), ST(TM->getSubtargetImpl(F)),
  35. TLI(ST->getTargetLowering()) {}
  36. /// \name Scalar TTI Implementations
  37. /// @{
  38. // TODO: Implement more Scalar TTI for WebAssembly
  39. TTI::PopcntSupportKind getPopcntSupport(unsigned TyWidth) const;
  40. void getUnrollingPreferences(Loop *L, ScalarEvolution &SE,
  41. TTI::UnrollingPreferences &UP,
  42. OptimizationRemarkEmitter *ORE) const;
  43. /// @}
  44. /// \name Vector TTI Implementations
  45. /// @{
  46. unsigned getNumberOfRegisters(unsigned ClassID) const;
  47. TypeSize getRegisterBitWidth(TargetTransformInfo::RegisterKind K) const;
  48. InstructionCost getArithmeticInstrCost(
  49. unsigned Opcode, Type *Ty, TTI::TargetCostKind CostKind,
  50. TTI::OperandValueInfo Op1Info = {TTI::OK_AnyValue, TTI::OP_None},
  51. TTI::OperandValueInfo Op2Info = {TTI::OK_AnyValue, TTI::OP_None},
  52. ArrayRef<const Value *> Args = ArrayRef<const Value *>(),
  53. const Instruction *CxtI = nullptr);
  54. using BaseT::getVectorInstrCost;
  55. InstructionCost getVectorInstrCost(unsigned Opcode, Type *Val,
  56. TTI::TargetCostKind CostKind,
  57. unsigned Index, Value *Op0, Value *Op1);
  58. /// @}
  59. bool areInlineCompatible(const Function *Caller,
  60. const Function *Callee) const;
  61. bool supportsTailCalls() const;
  62. };
  63. } // end namespace llvm
  64. #endif