PPCLegalizerInfo.cpp 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. //===- PPCLegalizerInfo.h ----------------------------------------*- 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. /// \file
  9. /// This file implements the targeting of the Machinelegalizer class for PowerPC
  10. //===----------------------------------------------------------------------===//
  11. #include "PPCLegalizerInfo.h"
  12. #include "llvm/Support/Debug.h"
  13. #define DEBUG_TYPE "ppc-legalinfo"
  14. using namespace llvm;
  15. using namespace LegalizeActions;
  16. PPCLegalizerInfo::PPCLegalizerInfo(const PPCSubtarget &ST) {
  17. using namespace TargetOpcode;
  18. const LLT P0 = LLT::pointer(0, 64);
  19. const LLT S1 = LLT::scalar(1);
  20. const LLT S8 = LLT::scalar(8);
  21. const LLT S16 = LLT::scalar(16);
  22. const LLT S32 = LLT::scalar(32);
  23. const LLT S64 = LLT::scalar(64);
  24. getActionDefinitionsBuilder(G_IMPLICIT_DEF).legalFor({S64});
  25. getActionDefinitionsBuilder(G_CONSTANT)
  26. .legalFor({S32, S64})
  27. .clampScalar(0, S64, S64);
  28. getActionDefinitionsBuilder({G_ZEXT, G_SEXT, G_ANYEXT})
  29. .legalForCartesianProduct({S64}, {S1, S8, S16, S32})
  30. .clampScalar(0, S64, S64);
  31. getActionDefinitionsBuilder({G_AND, G_OR, G_XOR})
  32. .legalFor({S64})
  33. .clampScalar(0, S64, S64);
  34. getActionDefinitionsBuilder({G_ADD, G_SUB})
  35. .legalFor({S64})
  36. .clampScalar(0, S64, S64);
  37. getActionDefinitionsBuilder({G_FADD, G_FSUB, G_FMUL, G_FDIV})
  38. .legalFor({S32, S64});
  39. getActionDefinitionsBuilder(G_FCMP).legalForCartesianProduct({S1},
  40. {S32, S64});
  41. getActionDefinitionsBuilder({G_FPTOSI, G_FPTOUI})
  42. .legalForCartesianProduct({S64}, {S32, S64});
  43. getActionDefinitionsBuilder({G_SITOFP, G_UITOFP})
  44. .legalForCartesianProduct({S32, S64}, {S64});
  45. getActionDefinitionsBuilder({G_LOAD, G_STORE})
  46. .legalForTypesWithMemDesc({{S64, P0, S64, 8}, {S32, P0, S32, 4}});
  47. getLegacyLegalizerInfo().computeTables();
  48. }