* Be consistent about MachineBB labels and references to them in instr stream
[oota-llvm.git] / lib / Target / PowerPC / PPCInstrBuilder.h
1 //===-- PowerPCInstrBuilder.h - Functions to aid building PPC insts -*- C++ -*-===//
2 // 
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file was developed by the LLVM research group and is distributed under
6 // the University of Illinois Open Source 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 simplify generating frame and constant pool
12 // references.
13 //
14 // For reference, the order of operands for memory references is:
15 // (Operand), Dest Reg, Base Reg, and either Reg Index or Immediate Displacement.
16 //
17 //===----------------------------------------------------------------------===//
18
19 #ifndef PPCINSTRBUILDER_H
20 #define PPCINSTRBUILDER_H
21
22 #include "llvm/CodeGen/MachineInstrBuilder.h"
23
24 namespace llvm {
25
26 /// addFrameReference - This function is used to add a reference to the base of
27 /// an abstract object on the stack frame of the current function.  This
28 /// reference has base register as the FrameIndex offset until it is resolved.
29 /// This allows a constant offset to be specified as well...
30 ///
31 inline const MachineInstrBuilder &
32 addFrameReference(const MachineInstrBuilder &MIB, int FI, int Offset = 0, bool mem = true) {
33         if (mem)
34                 return MIB.addSImm(Offset).addFrameIndex(FI);
35         else
36                 return MIB.addFrameIndex(FI).addSImm(Offset);
37 }
38
39 /// addConstantPoolReference - This function is used to add a reference to the
40 /// base of a constant value spilled to the per-function constant pool.  The
41 /// reference has base register ConstantPoolIndex offset which is retained until
42 /// either machine code emission or assembly output.  This allows an optional
43 /// offset to be added as well.
44 ///
45 inline const MachineInstrBuilder &
46 addConstantPoolReference(const MachineInstrBuilder &MIB, unsigned CPI,
47                          int Offset = 0) {
48   return MIB.addSImm(Offset).addConstantPoolIndex(CPI);
49 }
50
51 } // End llvm namespace
52
53 #endif