xref: /aosp_15_r20/external/llvm/lib/Target/SystemZ/SystemZInstrBuilder.h (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker //===-- SystemZInstrBuilder.h - Functions to aid building insts -*- C++ -*-===//
2*9880d681SAndroid Build Coastguard Worker //
3*9880d681SAndroid Build Coastguard Worker //                     The LLVM Compiler Infrastructure
4*9880d681SAndroid Build Coastguard Worker //
5*9880d681SAndroid Build Coastguard Worker // This file is distributed under the University of Illinois Open Source
6*9880d681SAndroid Build Coastguard Worker // License. See LICENSE.TXT for details.
7*9880d681SAndroid Build Coastguard Worker //
8*9880d681SAndroid Build Coastguard Worker //===----------------------------------------------------------------------===//
9*9880d681SAndroid Build Coastguard Worker //
10*9880d681SAndroid Build Coastguard Worker // This file exposes functions that may be used with BuildMI from the
11*9880d681SAndroid Build Coastguard Worker // MachineInstrBuilder.h file to handle SystemZ'isms in a clean way.
12*9880d681SAndroid Build Coastguard Worker //
13*9880d681SAndroid Build Coastguard Worker //===----------------------------------------------------------------------===//
14*9880d681SAndroid Build Coastguard Worker 
15*9880d681SAndroid Build Coastguard Worker #ifndef LLVM_LIB_TARGET_SYSTEMZ_SYSTEMZINSTRBUILDER_H
16*9880d681SAndroid Build Coastguard Worker #define LLVM_LIB_TARGET_SYSTEMZ_SYSTEMZINSTRBUILDER_H
17*9880d681SAndroid Build Coastguard Worker 
18*9880d681SAndroid Build Coastguard Worker #include "llvm/CodeGen/MachineFrameInfo.h"
19*9880d681SAndroid Build Coastguard Worker #include "llvm/CodeGen/MachineInstrBuilder.h"
20*9880d681SAndroid Build Coastguard Worker #include "llvm/CodeGen/MachineMemOperand.h"
21*9880d681SAndroid Build Coastguard Worker #include "llvm/CodeGen/PseudoSourceValue.h"
22*9880d681SAndroid Build Coastguard Worker 
23*9880d681SAndroid Build Coastguard Worker namespace llvm {
24*9880d681SAndroid Build Coastguard Worker 
25*9880d681SAndroid Build Coastguard Worker /// Add a BDX memory reference for frame object FI to MIB.
26*9880d681SAndroid Build Coastguard Worker static inline const MachineInstrBuilder &
addFrameReference(const MachineInstrBuilder & MIB,int FI)27*9880d681SAndroid Build Coastguard Worker addFrameReference(const MachineInstrBuilder &MIB, int FI) {
28*9880d681SAndroid Build Coastguard Worker   MachineInstr *MI = MIB;
29*9880d681SAndroid Build Coastguard Worker   MachineFunction &MF = *MI->getParent()->getParent();
30*9880d681SAndroid Build Coastguard Worker   MachineFrameInfo *MFFrame = MF.getFrameInfo();
31*9880d681SAndroid Build Coastguard Worker   const MCInstrDesc &MCID = MI->getDesc();
32*9880d681SAndroid Build Coastguard Worker   unsigned Flags = 0;
33*9880d681SAndroid Build Coastguard Worker   if (MCID.mayLoad())
34*9880d681SAndroid Build Coastguard Worker     Flags |= MachineMemOperand::MOLoad;
35*9880d681SAndroid Build Coastguard Worker   if (MCID.mayStore())
36*9880d681SAndroid Build Coastguard Worker     Flags |= MachineMemOperand::MOStore;
37*9880d681SAndroid Build Coastguard Worker   int64_t Offset = 0;
38*9880d681SAndroid Build Coastguard Worker   MachineMemOperand *MMO = MF.getMachineMemOperand(
39*9880d681SAndroid Build Coastguard Worker       MachinePointerInfo::getFixedStack(MF, FI, Offset), Flags,
40*9880d681SAndroid Build Coastguard Worker       MFFrame->getObjectSize(FI), MFFrame->getObjectAlignment(FI));
41*9880d681SAndroid Build Coastguard Worker   return MIB.addFrameIndex(FI).addImm(Offset).addReg(0).addMemOperand(MMO);
42*9880d681SAndroid Build Coastguard Worker }
43*9880d681SAndroid Build Coastguard Worker 
44*9880d681SAndroid Build Coastguard Worker } // end namespace llvm
45*9880d681SAndroid Build Coastguard Worker 
46*9880d681SAndroid Build Coastguard Worker #endif
47