10b57cec5SDimitry Andric //===-- PPCInstrBuilder.h - Aides for building PPC insts --------*- C++ -*-===//
20b57cec5SDimitry Andric //
30b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
40b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
50b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
60b57cec5SDimitry Andric //
70b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
80b57cec5SDimitry Andric //
90b57cec5SDimitry Andric // This file exposes functions that may be used with BuildMI from the
100b57cec5SDimitry Andric // MachineInstrBuilder.h file to simplify generating frame and constant pool
110b57cec5SDimitry Andric // references.
120b57cec5SDimitry Andric //
130b57cec5SDimitry Andric // For reference, the order of operands for memory references is:
140b57cec5SDimitry Andric // (Operand), Dest Reg, Base Reg, and either Reg Index or Immediate
150b57cec5SDimitry Andric // Displacement.
160b57cec5SDimitry Andric //
170b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
180b57cec5SDimitry Andric 
190b57cec5SDimitry Andric #ifndef LLVM_LIB_TARGET_POWERPC_PPCINSTRBUILDER_H
200b57cec5SDimitry Andric #define LLVM_LIB_TARGET_POWERPC_PPCINSTRBUILDER_H
210b57cec5SDimitry Andric 
220b57cec5SDimitry Andric #include "llvm/CodeGen/MachineInstrBuilder.h"
230b57cec5SDimitry Andric 
240b57cec5SDimitry Andric namespace llvm {
250b57cec5SDimitry Andric 
260b57cec5SDimitry Andric /// addFrameReference - This function is used to add a reference to the base of
270b57cec5SDimitry Andric /// an abstract object on the stack frame of the current function.  This
280b57cec5SDimitry Andric /// reference has base register as the FrameIndex offset until it is resolved.
290b57cec5SDimitry Andric /// This allows a constant offset to be specified as well...
300b57cec5SDimitry Andric ///
310b57cec5SDimitry Andric static inline const MachineInstrBuilder&
320b57cec5SDimitry Andric addFrameReference(const MachineInstrBuilder &MIB, int FI, int Offset = 0,
330b57cec5SDimitry Andric                   bool mem = true) {
340b57cec5SDimitry Andric   if (mem)
350b57cec5SDimitry Andric     return MIB.addImm(Offset).addFrameIndex(FI);
360b57cec5SDimitry Andric   else
370b57cec5SDimitry Andric     return MIB.addFrameIndex(FI).addImm(Offset);
380b57cec5SDimitry Andric }
390b57cec5SDimitry Andric 
400b57cec5SDimitry Andric } // End llvm namespace
410b57cec5SDimitry Andric 
420b57cec5SDimitry Andric #endif
43