Updated source file headers to llvm coding standard.
[oota-llvm.git] / lib / Target / CellSPU / SPUInstrBuilder.h
1 //==-- SPUInstrBuilder.h - Aides for building Cell SPU insts -----*- C++ -*-==//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file was developed by a team from the Computer Systems Research
6 // Department at The Aerospace Corporation and is distributed under the
7 // University of Illinois Open Source License. See LICENSE.TXT for details.
8 //
9 //===----------------------------------------------------------------------===//
10 //
11 // This file exposes functions that may be used with BuildMI from the
12 // MachineInstrBuilder.h file to simplify generating frame and constant pool
13 // references.
14 //
15 // For reference, the order of operands for memory references is:
16 // (Operand), Dest Reg, Base Reg, and either Reg Index or Immediate
17 // Displacement.
18 //
19 //===----------------------------------------------------------------------===//
20
21 #ifndef SPU_INSTRBUILDER_H
22 #define SPU_INSTRBUILDER_H
23
24 #include "llvm/CodeGen/MachineInstrBuilder.h"
25
26 namespace llvm {
27
28 /// addFrameReference - This function is used to add a reference to the base of
29 /// an abstract object on the stack frame of the current function.  This
30 /// reference has base register as the FrameIndex offset until it is resolved.
31 /// This allows a constant offset to be specified as well...
32 ///
33 inline const MachineInstrBuilder&
34 addFrameReference(const MachineInstrBuilder &MIB, int FI, int Offset = 0,
35                   bool mem = true) {
36   if (mem)
37     return MIB.addImm(Offset).addFrameIndex(FI);
38   else
39     return MIB.addFrameIndex(FI).addImm(Offset);
40 }
41
42 /// addConstantPoolReference - This function is used to add a reference to the
43 /// base of a constant value spilled to the per-function constant pool.  The
44 /// reference has base register ConstantPoolIndex offset which is retained until
45 /// either machine code emission or assembly output.  This allows an optional
46 /// offset to be added as well.
47 ///
48 inline const MachineInstrBuilder&
49 addConstantPoolReference(const MachineInstrBuilder &MIB, unsigned CPI,
50                          int Offset = 0) {
51   return MIB.addImm(Offset).addConstantPoolIndex(CPI);
52 }
53
54 } // End llvm namespace
55
56 #endif