LoongArchISelDAGToDAG.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. //=- LoongArchISelDAGToDAG.h - A dag to dag inst selector for LoongArch ---===//
  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 defines an instruction selector for the LoongArch target.
  10. //
  11. //===----------------------------------------------------------------------===//
  12. #ifndef LLVM_LIB_TARGET_LOONGARCH_LOONGARCHISELDAGTODAG_H
  13. #define LLVM_LIB_TARGET_LOONGARCH_LOONGARCHISELDAGTODAG_H
  14. #include "LoongArch.h"
  15. #include "LoongArchTargetMachine.h"
  16. #include "llvm/CodeGen/SelectionDAGISel.h"
  17. // LoongArch-specific code to select LoongArch machine instructions for
  18. // SelectionDAG operations.
  19. namespace llvm {
  20. class LoongArchDAGToDAGISel : public SelectionDAGISel {
  21. const LoongArchSubtarget *Subtarget = nullptr;
  22. public:
  23. static char ID;
  24. LoongArchDAGToDAGISel() = delete;
  25. explicit LoongArchDAGToDAGISel(LoongArchTargetMachine &TM)
  26. : SelectionDAGISel(ID, TM) {}
  27. bool runOnMachineFunction(MachineFunction &MF) override {
  28. Subtarget = &MF.getSubtarget<LoongArchSubtarget>();
  29. return SelectionDAGISel::runOnMachineFunction(MF);
  30. }
  31. void Select(SDNode *Node) override;
  32. bool SelectInlineAsmMemoryOperand(const SDValue &Op, unsigned ConstraintID,
  33. std::vector<SDValue> &OutOps) override;
  34. bool SelectBaseAddr(SDValue Addr, SDValue &Base);
  35. bool selectNonFIBaseAddr(SDValue Addr, SDValue &Base);
  36. bool selectShiftMask(SDValue N, unsigned ShiftWidth, SDValue &ShAmt);
  37. bool selectShiftMaskGRLen(SDValue N, SDValue &ShAmt) {
  38. return selectShiftMask(N, Subtarget->getGRLen(), ShAmt);
  39. }
  40. bool selectShiftMask32(SDValue N, SDValue &ShAmt) {
  41. return selectShiftMask(N, 32, ShAmt);
  42. }
  43. bool selectSExti32(SDValue N, SDValue &Val);
  44. bool selectZExti32(SDValue N, SDValue &Val);
  45. // Include the pieces autogenerated from the target description.
  46. #include "LoongArchGenDAGISel.inc"
  47. };
  48. } // end namespace llvm
  49. #endif // LLVM_LIB_TARGET_LOONGARCH_LOONGARCHISELDAGTODAG_H