blob: 704e17c49b0f6cfe140d8953c704754a902b61ea [file] [log] [blame]
Misha Brukman5dfe3a92004-06-21 16:55:25 +00001//===-- 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
24namespace 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///
31inline const MachineInstrBuilder &
32addFrameReference(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///
45inline const MachineInstrBuilder &
46addConstantPoolReference(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