LLVM API Documentation

SystemZInstrBuilder.h
Go to the documentation of this file.
00001 //===-- SystemZInstrBuilder.h - Functions to aid building insts -*- C++ -*-===//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file is distributed under the University of Illinois Open Source
00006 // License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 //
00010 // This file exposes functions that may be used with BuildMI from the
00011 // MachineInstrBuilder.h file to handle SystemZ'isms in a clean way.
00012 //
00013 //===----------------------------------------------------------------------===//
00014 
00015 #ifndef LLVM_LIB_TARGET_SYSTEMZ_SYSTEMZINSTRBUILDER_H
00016 #define LLVM_LIB_TARGET_SYSTEMZ_SYSTEMZINSTRBUILDER_H
00017 
00018 #include "llvm/CodeGen/MachineFrameInfo.h"
00019 #include "llvm/CodeGen/MachineInstrBuilder.h"
00020 #include "llvm/CodeGen/MachineMemOperand.h"
00021 #include "llvm/CodeGen/PseudoSourceValue.h"
00022 
00023 namespace llvm {
00024 
00025 /// Add a BDX memory reference for frame object FI to MIB.
00026 static inline const MachineInstrBuilder &
00027 addFrameReference(const MachineInstrBuilder &MIB, int FI) {
00028   MachineInstr *MI = MIB;
00029   MachineFunction &MF = *MI->getParent()->getParent();
00030   MachineFrameInfo *MFFrame = MF.getFrameInfo();
00031   const MCInstrDesc &MCID = MI->getDesc();
00032   unsigned Flags = 0;
00033   if (MCID.mayLoad())
00034     Flags |= MachineMemOperand::MOLoad;
00035   if (MCID.mayStore())
00036     Flags |= MachineMemOperand::MOStore;
00037   int64_t Offset = 0;
00038   MachineMemOperand *MMO =
00039     MF.getMachineMemOperand(MachinePointerInfo(
00040                               PseudoSourceValue::getFixedStack(FI), Offset),
00041                             Flags, MFFrame->getObjectSize(FI),
00042                             MFFrame->getObjectAlignment(FI));
00043   return MIB.addFrameIndex(FI).addImm(Offset).addReg(0).addMemOperand(MMO);
00044 }
00045 
00046 } // end namespace llvm
00047 
00048 #endif