TargetOpcodes.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. //===-- llvm/CodeGen/TargetOpcodes.h - Target Indep Opcodes -----*- 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 defines the target independent instruction opcodes.
  10. //
  11. //===----------------------------------------------------------------------===//
  12. #ifndef LLVM_CODEGEN_TARGETOPCODES_H
  13. #define LLVM_CODEGEN_TARGETOPCODES_H
  14. namespace llvm {
  15. /// Invariant opcodes: All instruction sets have these as their low opcodes.
  16. ///
  17. namespace TargetOpcode {
  18. enum {
  19. #define HANDLE_TARGET_OPCODE(OPC) OPC,
  20. #define HANDLE_TARGET_OPCODE_MARKER(IDENT, OPC) IDENT = OPC,
  21. #include "llvm/Support/TargetOpcodes.def"
  22. };
  23. } // end namespace TargetOpcode
  24. /// Check whether the given Opcode is a generic opcode that is not supposed
  25. /// to appear after ISel.
  26. inline bool isPreISelGenericOpcode(unsigned Opcode) {
  27. return Opcode >= TargetOpcode::PRE_ISEL_GENERIC_OPCODE_START &&
  28. Opcode <= TargetOpcode::PRE_ISEL_GENERIC_OPCODE_END;
  29. }
  30. /// Check whether the given Opcode is a target-specific opcode.
  31. inline bool isTargetSpecificOpcode(unsigned Opcode) {
  32. return Opcode > TargetOpcode::PRE_ISEL_GENERIC_OPCODE_END;
  33. }
  34. /// \returns true if \p Opcode is an optimization hint opcode which is not
  35. /// supposed to appear after ISel.
  36. inline bool isPreISelGenericOptimizationHint(unsigned Opcode) {
  37. return Opcode >= TargetOpcode::PRE_ISEL_GENERIC_OPTIMIZATION_HINT_START &&
  38. Opcode <= TargetOpcode::PRE_ISEL_GENERIC_OPTIMIZATION_HINT_END;
  39. }
  40. } // end namespace llvm
  41. #endif