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