LLVM API Documentation

PPCInstrBuilder.h

Go to the documentation of this file.
00001 //===-- PPCInstrBuilder.h - Aides for building PPC insts --------*- C++ -*-===//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file was developed by the LLVM research group and is distributed under
00006 // the University of Illinois Open Source 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 simplify generating frame and constant pool
00012 // references.
00013 //
00014 // For reference, the order of operands for memory references is:
00015 // (Operand), Dest Reg, Base Reg, and either Reg Index or Immediate
00016 // Displacement.
00017 //
00018 //===----------------------------------------------------------------------===//
00019 
00020 #ifndef POWERPC_INSTRBUILDER_H
00021 #define POWERPC_INSTRBUILDER_H
00022 
00023 #include "llvm/CodeGen/MachineInstrBuilder.h"
00024 
00025 namespace llvm {
00026 
00027 /// addFrameReference - This function is used to add a reference to the base of
00028 /// an abstract object on the stack frame of the current function.  This
00029 /// reference has base register as the FrameIndex offset until it is resolved.
00030 /// This allows a constant offset to be specified as well...
00031 ///
00032 inline const MachineInstrBuilder&
00033 addFrameReference(const MachineInstrBuilder &MIB, int FI, int Offset = 0,
00034                   bool mem = true) {
00035   if (mem)
00036     return MIB.addImm(Offset).addFrameIndex(FI);
00037   else
00038     return MIB.addFrameIndex(FI).addImm(Offset);
00039 }
00040 
00041 /// addConstantPoolReference - This function is used to add a reference to the
00042 /// base of a constant value spilled to the per-function constant pool.  The
00043 /// reference has base register ConstantPoolIndex offset which is retained until
00044 /// either machine code emission or assembly output.  This allows an optional
00045 /// offset to be added as well.
00046 ///
00047 inline const MachineInstrBuilder&
00048 addConstantPoolReference(const MachineInstrBuilder &MIB, unsigned CPI,
00049                          int Offset = 0) {
00050   return MIB.addImm(Offset).addConstantPoolIndex(CPI);
00051 }
00052 
00053 } // End llvm namespace
00054 
00055 #endif