LoongArchSubtarget.cpp 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. //===-- LoongArchSubtarget.cpp - LoongArch Subtarget Information -*- 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. // This file implements the LoongArch specific subclass of TargetSubtargetInfo.
  10. //
  11. //===----------------------------------------------------------------------===//
  12. #include "LoongArchSubtarget.h"
  13. #include "LoongArchFrameLowering.h"
  14. using namespace llvm;
  15. #define DEBUG_TYPE "loongarch-subtarget"
  16. #define GET_SUBTARGETINFO_TARGET_DESC
  17. #define GET_SUBTARGETINFO_CTOR
  18. #include "LoongArchGenSubtargetInfo.inc"
  19. void LoongArchSubtarget::anchor() {}
  20. LoongArchSubtarget &LoongArchSubtarget::initializeSubtargetDependencies(
  21. const Triple &TT, StringRef CPU, StringRef TuneCPU, StringRef FS,
  22. StringRef ABIName) {
  23. bool Is64Bit = TT.isArch64Bit();
  24. if (CPU.empty() || CPU == "generic")
  25. CPU = Is64Bit ? "generic-la64" : "generic-la32";
  26. if (TuneCPU.empty())
  27. TuneCPU = CPU;
  28. ParseSubtargetFeatures(CPU, TuneCPU, FS);
  29. if (Is64Bit) {
  30. GRLenVT = MVT::i64;
  31. GRLen = 64;
  32. }
  33. if (HasLA32 == HasLA64)
  34. report_fatal_error("Please use one feature of 32bit and 64bit.");
  35. if (Is64Bit && HasLA32)
  36. report_fatal_error("Feature 32bit should be used for loongarch32 target.");
  37. if (!Is64Bit && HasLA64)
  38. report_fatal_error("Feature 64bit should be used for loongarch64 target.");
  39. // TODO: ILP32{S,F} LP64{S,F}
  40. TargetABI = Is64Bit ? LoongArchABI::ABI_LP64D : LoongArchABI::ABI_ILP32D;
  41. return *this;
  42. }
  43. LoongArchSubtarget::LoongArchSubtarget(const Triple &TT, StringRef CPU,
  44. StringRef TuneCPU, StringRef FS,
  45. StringRef ABIName,
  46. const TargetMachine &TM)
  47. : LoongArchGenSubtargetInfo(TT, CPU, TuneCPU, FS),
  48. FrameLowering(
  49. initializeSubtargetDependencies(TT, CPU, TuneCPU, FS, ABIName)),
  50. InstrInfo(*this), RegInfo(getHwMode()), TLInfo(TM, *this) {}