1 | //===-- SystemZInstrBuilder.h - Functions to aid building 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 handle SystemZ'isms in a clean way. |
11 | // |
12 | //===----------------------------------------------------------------------===// |
13 | |
14 | #ifndef LLVM_LIB_TARGET_SYSTEMZ_SYSTEMZINSTRBUILDER_H |
15 | #define LLVM_LIB_TARGET_SYSTEMZ_SYSTEMZINSTRBUILDER_H |
16 | |
17 | #include "llvm/CodeGen/MachineFrameInfo.h" |
18 | #include "llvm/CodeGen/MachineInstrBuilder.h" |
19 | #include "llvm/CodeGen/MachineMemOperand.h" |
20 | |
21 | namespace llvm { |
22 | |
23 | /// Add a BDX memory reference for frame object FI to MIB. |
24 | static inline const MachineInstrBuilder & |
25 | addFrameReference(const MachineInstrBuilder &MIB, int FI) { |
26 | MachineInstr *MI = MIB; |
27 | MachineFunction &MF = *MI->getParent()->getParent(); |
28 | MachineFrameInfo &MFFrame = MF.getFrameInfo(); |
29 | const MCInstrDesc &MCID = MI->getDesc(); |
30 | auto Flags = MachineMemOperand::MONone; |
31 | if (MCID.mayLoad()) |
32 | Flags |= MachineMemOperand::MOLoad; |
33 | if (MCID.mayStore()) |
34 | Flags |= MachineMemOperand::MOStore; |
35 | int64_t Offset = 0; |
36 | MachineMemOperand *MMO = MF.getMachineMemOperand( |
37 | PtrInfo: MachinePointerInfo::getFixedStack(MF, FI, Offset), F: Flags, |
38 | Size: MFFrame.getObjectSize(ObjectIdx: FI), BaseAlignment: MFFrame.getObjectAlign(ObjectIdx: FI)); |
39 | return MIB.addFrameIndex(Idx: FI).addImm(Val: Offset).addReg(RegNo: 0).addMemOperand(MMO); |
40 | } |
41 | |
42 | } // end namespace llvm |
43 | |
44 | #endif |
45 |