Target.td 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. //===- Target.td - Define GlobalISel rules -----------------*- tablegen -*-===//
  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 interfaces used to support
  10. // SelectionDAG instruction selection patterns (specified in
  11. // TargetSelectionDAG.td) when generating GlobalISel instruction selectors.
  12. //
  13. // This is intended as a compatibility layer, to enable reuse of target
  14. // descriptions written for SelectionDAG without requiring explicit GlobalISel
  15. // support. It will eventually supersede SelectionDAG patterns.
  16. //
  17. //===----------------------------------------------------------------------===//
  18. // Definitions that inherit from LLT define types that will be used in the
  19. // GlobalISel matcher.
  20. class LLT;
  21. def s32 : LLT;
  22. def s64 : LLT;
  23. // Defines a matcher for complex operands. This is analogous to ComplexPattern
  24. // from SelectionDAG.
  25. //
  26. // Definitions that inherit from this may also inherit from
  27. // GIComplexPatternEquiv to enable the import of SelectionDAG patterns involving
  28. // those ComplexPatterns.
  29. class GIComplexOperandMatcher<LLT type, string matcherfn> {
  30. // The expected type of the root of the match.
  31. //
  32. // TODO: We should probably support, any-type, any-scalar, and multiple types
  33. // in the future.
  34. LLT Type = type;
  35. // The function that determines whether the operand matches. It should be of
  36. // the form:
  37. // ComplexRendererFn select(MachineOperand &Root) const;
  38. // where Root is the root of the match. The function should return nullptr
  39. // on match failure, or a ComplexRendererFn that renders the operand in case
  40. // of a successful match.
  41. string MatcherFn = matcherfn;
  42. }
  43. // Defines a custom renderer. This is analogous to SDNodeXForm from
  44. // SelectionDAG. Unlike SDNodeXForm, this matches a MachineInstr and
  45. // renders directly to the result instruction without an intermediate node.
  46. //
  47. // Definitions that inherit from this may also inherit from GISDNodeXFormEquiv
  48. // to enable the import of SelectionDAG patterns involving those SDNodeXForms.
  49. class GICustomOperandRenderer<string rendererfn> {
  50. // The function renders the operand(s) of the matched instruction to
  51. // the specified instruction. It should be of the form:
  52. // void render(MachineInstrBuilder &MIB, const MachineInstr &MI,
  53. // int OpIdx = -1)
  54. //
  55. // If OpIdx is specified (i.e. not invalid/negative), this
  56. // references the source operand MI.getOperand(OpIdx). Otherwise,
  57. // this is the value defined by MI. This is to support the case
  58. // where there is no corresponding instruction to match.
  59. string RendererFn = rendererfn;
  60. }