xref: /freebsd/contrib/llvm-project/llvm/lib/Target/SystemZ/SystemZInstrBuilder.h (revision e25152834cdf3b353892835a4f3b157e066a8ed4)
10b57cec5SDimitry Andric //===-- SystemZInstrBuilder.h - Functions to aid building 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 handle SystemZ'isms in a clean way.
110b57cec5SDimitry Andric //
120b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
130b57cec5SDimitry Andric 
140b57cec5SDimitry Andric #ifndef LLVM_LIB_TARGET_SYSTEMZ_SYSTEMZINSTRBUILDER_H
150b57cec5SDimitry Andric #define LLVM_LIB_TARGET_SYSTEMZ_SYSTEMZINSTRBUILDER_H
160b57cec5SDimitry Andric 
170b57cec5SDimitry Andric #include "llvm/CodeGen/MachineFrameInfo.h"
180b57cec5SDimitry Andric #include "llvm/CodeGen/MachineInstrBuilder.h"
190b57cec5SDimitry Andric #include "llvm/CodeGen/MachineMemOperand.h"
200b57cec5SDimitry Andric 
210b57cec5SDimitry Andric namespace llvm {
220b57cec5SDimitry Andric 
230b57cec5SDimitry Andric /// Add a BDX memory reference for frame object FI to MIB.
240b57cec5SDimitry Andric static inline const MachineInstrBuilder &
addFrameReference(const MachineInstrBuilder & MIB,int FI)250b57cec5SDimitry Andric addFrameReference(const MachineInstrBuilder &MIB, int FI) {
260b57cec5SDimitry Andric   MachineInstr *MI = MIB;
270b57cec5SDimitry Andric   MachineFunction &MF = *MI->getParent()->getParent();
280b57cec5SDimitry Andric   MachineFrameInfo &MFFrame = MF.getFrameInfo();
290b57cec5SDimitry Andric   const MCInstrDesc &MCID = MI->getDesc();
300b57cec5SDimitry Andric   auto Flags = MachineMemOperand::MONone;
310b57cec5SDimitry Andric   if (MCID.mayLoad())
320b57cec5SDimitry Andric     Flags |= MachineMemOperand::MOLoad;
330b57cec5SDimitry Andric   if (MCID.mayStore())
340b57cec5SDimitry Andric     Flags |= MachineMemOperand::MOStore;
350b57cec5SDimitry Andric   int64_t Offset = 0;
360b57cec5SDimitry Andric   MachineMemOperand *MMO = MF.getMachineMemOperand(
370b57cec5SDimitry Andric       MachinePointerInfo::getFixedStack(MF, FI, Offset), Flags,
38*5ffd83dbSDimitry Andric       MFFrame.getObjectSize(FI), MFFrame.getObjectAlign(FI));
390b57cec5SDimitry Andric   return MIB.addFrameIndex(FI).addImm(Offset).addReg(0).addMemOperand(MMO);
400b57cec5SDimitry Andric }
410b57cec5SDimitry Andric 
420b57cec5SDimitry Andric } // end namespace llvm
430b57cec5SDimitry Andric 
440b57cec5SDimitry Andric #endif
45