PPCInstrBuilder.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. //===-- PPCInstrBuilder.h - Aides for building PPC insts --------*- 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 exposes functions that may be used with BuildMI from the
  10. // MachineInstrBuilder.h file to simplify generating frame and constant pool
  11. // references.
  12. //
  13. // For reference, the order of operands for memory references is:
  14. // (Operand), Dest Reg, Base Reg, and either Reg Index or Immediate
  15. // Displacement.
  16. //
  17. //===----------------------------------------------------------------------===//
  18. #ifndef LLVM_LIB_TARGET_POWERPC_PPCINSTRBUILDER_H
  19. #define LLVM_LIB_TARGET_POWERPC_PPCINSTRBUILDER_H
  20. #include "llvm/CodeGen/MachineInstrBuilder.h"
  21. namespace llvm {
  22. /// addFrameReference - This function is used to add a reference to the base of
  23. /// an abstract object on the stack frame of the current function. This
  24. /// reference has base register as the FrameIndex offset until it is resolved.
  25. /// This allows a constant offset to be specified as well...
  26. ///
  27. static inline const MachineInstrBuilder&
  28. addFrameReference(const MachineInstrBuilder &MIB, int FI, int Offset = 0,
  29. bool mem = true) {
  30. if (mem)
  31. return MIB.addImm(Offset).addFrameIndex(FI);
  32. else
  33. return MIB.addFrameIndex(FI).addImm(Offset);
  34. }
  35. } // End llvm namespace
  36. #endif