ARMLegalizerInfo.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. //===- ARMLegalizerInfo ------------------------------------------*- 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 declares the targeting of the Machinelegalizer class for ARM.
  10. /// \todo This should be generated by TableGen.
  11. //===----------------------------------------------------------------------===//
  12. #ifndef LLVM_LIB_TARGET_ARM_ARMMACHINELEGALIZER_H
  13. #define LLVM_LIB_TARGET_ARM_ARMMACHINELEGALIZER_H
  14. #include "llvm/ADT/IndexedMap.h"
  15. #include "llvm/CodeGen/GlobalISel/GISelChangeObserver.h"
  16. #include "llvm/CodeGen/GlobalISel/LegalizerInfo.h"
  17. #include "llvm/CodeGen/RuntimeLibcalls.h"
  18. #include "llvm/IR/Instructions.h"
  19. namespace llvm {
  20. class ARMSubtarget;
  21. /// This class provides the information for the target register banks.
  22. class ARMLegalizerInfo : public LegalizerInfo {
  23. public:
  24. ARMLegalizerInfo(const ARMSubtarget &ST);
  25. bool legalizeCustom(LegalizerHelper &Helper, MachineInstr &MI) const override;
  26. private:
  27. void setFCmpLibcallsGNU();
  28. void setFCmpLibcallsAEABI();
  29. struct FCmpLibcallInfo {
  30. // Which libcall this is.
  31. RTLIB::Libcall LibcallID;
  32. // The predicate to be used when comparing the value returned by the
  33. // function with a relevant constant (currently hard-coded to zero). This is
  34. // necessary because often the libcall will return e.g. a value greater than
  35. // 0 to represent 'true' and anything negative to represent 'false', or
  36. // maybe 0 to represent 'true' and non-zero for 'false'. If no comparison is
  37. // needed, this should be CmpInst::BAD_ICMP_PREDICATE.
  38. CmpInst::Predicate Predicate;
  39. };
  40. using FCmpLibcallsList = SmallVector<FCmpLibcallInfo, 2>;
  41. // Map from each FCmp predicate to the corresponding libcall infos. A FCmp
  42. // instruction may be lowered to one or two libcalls, which is why we need a
  43. // list. If two libcalls are needed, their results will be OR'ed.
  44. using FCmpLibcallsMapTy = IndexedMap<FCmpLibcallsList>;
  45. FCmpLibcallsMapTy FCmp32Libcalls;
  46. FCmpLibcallsMapTy FCmp64Libcalls;
  47. // Get the libcall(s) corresponding to \p Predicate for operands of \p Size
  48. // bits.
  49. FCmpLibcallsList getFCmpLibcalls(CmpInst::Predicate, unsigned Size) const;
  50. };
  51. } // End llvm namespace.
  52. #endif