1*0b57cec5SDimitry Andric //===-- PPCInstrBuilder.h - Aides for building PPC insts --------*- C++ -*-===// 2*0b57cec5SDimitry Andric // 3*0b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4*0b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 5*0b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6*0b57cec5SDimitry Andric // 7*0b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 8*0b57cec5SDimitry Andric // 9*0b57cec5SDimitry Andric // This file exposes functions that may be used with BuildMI from the 10*0b57cec5SDimitry Andric // MachineInstrBuilder.h file to simplify generating frame and constant pool 11*0b57cec5SDimitry Andric // references. 12*0b57cec5SDimitry Andric // 13*0b57cec5SDimitry Andric // For reference, the order of operands for memory references is: 14*0b57cec5SDimitry Andric // (Operand), Dest Reg, Base Reg, and either Reg Index or Immediate 15*0b57cec5SDimitry Andric // Displacement. 16*0b57cec5SDimitry Andric // 17*0b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 18*0b57cec5SDimitry Andric 19*0b57cec5SDimitry Andric #ifndef LLVM_LIB_TARGET_POWERPC_PPCINSTRBUILDER_H 20*0b57cec5SDimitry Andric #define LLVM_LIB_TARGET_POWERPC_PPCINSTRBUILDER_H 21*0b57cec5SDimitry Andric 22*0b57cec5SDimitry Andric #include "llvm/CodeGen/MachineInstrBuilder.h" 23*0b57cec5SDimitry Andric 24*0b57cec5SDimitry Andric namespace llvm { 25*0b57cec5SDimitry Andric 26*0b57cec5SDimitry Andric /// addFrameReference - This function is used to add a reference to the base of 27*0b57cec5SDimitry Andric /// an abstract object on the stack frame of the current function. This 28*0b57cec5SDimitry Andric /// reference has base register as the FrameIndex offset until it is resolved. 29*0b57cec5SDimitry Andric /// This allows a constant offset to be specified as well... 30*0b57cec5SDimitry Andric /// 31*0b57cec5SDimitry Andric static inline const MachineInstrBuilder& 32*0b57cec5SDimitry Andric addFrameReference(const MachineInstrBuilder &MIB, int FI, int Offset = 0, 33*0b57cec5SDimitry Andric bool mem = true) { 34*0b57cec5SDimitry Andric if (mem) 35*0b57cec5SDimitry Andric return MIB.addImm(Offset).addFrameIndex(FI); 36*0b57cec5SDimitry Andric else 37*0b57cec5SDimitry Andric return MIB.addFrameIndex(FI).addImm(Offset); 38*0b57cec5SDimitry Andric } 39*0b57cec5SDimitry Andric 40*0b57cec5SDimitry Andric } // End llvm namespace 41*0b57cec5SDimitry Andric 42*0b57cec5SDimitry Andric #endif 43