WebAssemblySubtarget.cpp 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. //===-- WebAssemblySubtarget.cpp - WebAssembly Subtarget Information ------===//
  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 implements the WebAssembly-specific subclass of
  11. /// TargetSubtarget.
  12. ///
  13. //===----------------------------------------------------------------------===//
  14. #include "WebAssemblySubtarget.h"
  15. #include "MCTargetDesc/WebAssemblyMCTargetDesc.h"
  16. #include "WebAssemblyInstrInfo.h"
  17. #include "llvm/MC/TargetRegistry.h"
  18. using namespace llvm;
  19. #define DEBUG_TYPE "wasm-subtarget"
  20. #define GET_SUBTARGETINFO_CTOR
  21. #define GET_SUBTARGETINFO_TARGET_DESC
  22. #include "WebAssemblyGenSubtargetInfo.inc"
  23. WebAssemblySubtarget &
  24. WebAssemblySubtarget::initializeSubtargetDependencies(StringRef CPU,
  25. StringRef FS) {
  26. // Determine default and user-specified characteristics
  27. LLVM_DEBUG(llvm::dbgs() << "initializeSubtargetDependencies\n");
  28. if (CPU.empty())
  29. CPU = "generic";
  30. ParseSubtargetFeatures(CPU, /*TuneCPU*/ CPU, FS);
  31. return *this;
  32. }
  33. WebAssemblySubtarget::WebAssemblySubtarget(const Triple &TT,
  34. const std::string &CPU,
  35. const std::string &FS,
  36. const TargetMachine &TM)
  37. : WebAssemblyGenSubtargetInfo(TT, CPU, /*TuneCPU*/ CPU, FS),
  38. TargetTriple(TT), InstrInfo(initializeSubtargetDependencies(CPU, FS)),
  39. TLInfo(TM, *this) {}
  40. bool WebAssemblySubtarget::enableAtomicExpand() const {
  41. // If atomics are disabled, atomic ops are lowered instead of expanded
  42. return hasAtomics();
  43. }
  44. bool WebAssemblySubtarget::enableMachineScheduler() const {
  45. // Disable the MachineScheduler for now. Even with ShouldTrackPressure set and
  46. // enableMachineSchedDefaultSched overridden, it appears to have an overall
  47. // negative effect for the kinds of register optimizations we're doing.
  48. return false;
  49. }
  50. bool WebAssemblySubtarget::useAA() const { return true; }