blob: 074e1739c7aee41900467c8851f6b0427d4df415 [file] [log] [blame]
Scott Michel266bc8f2007-12-04 22:23:35 +00001//==-- SPUInstrBuilder.h - Aides for building Cell SPU insts -----*- C++ -*-==//
2//
3// The LLVM Compiler Infrastructure
4//
Scott Michel2466c372007-12-05 01:40:25 +00005// 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//
Scott Michel266bc8f2007-12-04 22:23:35 +00009//===----------------------------------------------------------------------===//
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
26namespace 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///
33inline const MachineInstrBuilder&
34addFrameReference(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///
48inline const MachineInstrBuilder&
49addConstantPoolReference(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