blob: 1de69116cd58ccc2fe2c440242d0249bb24558c3 [file] [log] [blame]
Nate Begeman21e463b2005-10-16 05:39:50 +00001//===-- PPCInstrBuilder.h - Aides for building PPC insts --------*- C++ -*-===//
Misha Brukmanb5f662f2005-04-21 23:30:14 +00002//
Misha Brukman5dfe3a92004-06-21 16:55:25 +00003// The LLVM Compiler Infrastructure
4//
Chris Lattner4ee451d2007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Misha Brukmanb5f662f2005-04-21 23:30:14 +00007//
Misha Brukman5dfe3a92004-06-21 16:55:25 +00008//===----------------------------------------------------------------------===//
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:
Misha Brukmane62cd372004-07-07 20:01:36 +000015// (Operand), Dest Reg, Base Reg, and either Reg Index or Immediate
16// Displacement.
Misha Brukman5dfe3a92004-06-21 16:55:25 +000017//
18//===----------------------------------------------------------------------===//
19
Misha Brukmane62cd372004-07-07 20:01:36 +000020#ifndef POWERPC_INSTRBUILDER_H
21#define POWERPC_INSTRBUILDER_H
Misha Brukman5dfe3a92004-06-21 16:55:25 +000022
23#include "llvm/CodeGen/MachineInstrBuilder.h"
24
25namespace llvm {
26
27/// addFrameReference - This function is used to add a reference to the base of
28/// an abstract object on the stack frame of the current function. This
29/// reference has base register as the FrameIndex offset until it is resolved.
30/// This allows a constant offset to be specified as well...
31///
Misha Brukmane62cd372004-07-07 20:01:36 +000032inline const MachineInstrBuilder&
Misha Brukmanb5f662f2005-04-21 23:30:14 +000033addFrameReference(const MachineInstrBuilder &MIB, int FI, int Offset = 0,
Misha Brukmane62cd372004-07-07 20:01:36 +000034 bool mem = true) {
35 if (mem)
Chris Lattner63b3d712006-05-04 17:21:20 +000036 return MIB.addImm(Offset).addFrameIndex(FI);
Misha Brukmane62cd372004-07-07 20:01:36 +000037 else
Chris Lattner63b3d712006-05-04 17:21:20 +000038 return MIB.addFrameIndex(FI).addImm(Offset);
Misha Brukman5dfe3a92004-06-21 16:55:25 +000039}
40
Misha Brukman5dfe3a92004-06-21 16:55:25 +000041} // End llvm namespace
42
43#endif