blob: 323f7e39adf7e766e66503aeceed42846f9e975f [file] [log] [blame]
Nate Begeman6cca84e2005-10-16 05:39:50 +00001//===-- PPCInstrBuilder.h - Aides for building PPC insts --------*- C++ -*-===//
Misha Brukmanb4402432005-04-21 23:30:14 +00002//
Chandler Carruth2946cd72019-01-19 08:50:56 +00003// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
Misha Brukmanb4402432005-04-21 23:30:14 +00006//
Misha Brukmane05203f2004-06-21 16:55:25 +00007//===----------------------------------------------------------------------===//
8//
9// This file exposes functions that may be used with BuildMI from the
10// MachineInstrBuilder.h file to simplify generating frame and constant pool
11// references.
12//
13// For reference, the order of operands for memory references is:
Misha Brukman6ff65512004-07-07 20:01:36 +000014// (Operand), Dest Reg, Base Reg, and either Reg Index or Immediate
15// Displacement.
Misha Brukmane05203f2004-06-21 16:55:25 +000016//
17//===----------------------------------------------------------------------===//
18
Benjamin Kramera7c40ef2014-08-13 16:26:38 +000019#ifndef LLVM_LIB_TARGET_POWERPC_PPCINSTRBUILDER_H
20#define LLVM_LIB_TARGET_POWERPC_PPCINSTRBUILDER_H
Misha Brukmane05203f2004-06-21 16:55:25 +000021
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///
Anton Korobeynikov12b4b7c2009-07-16 14:03:08 +000031static inline const MachineInstrBuilder&
Misha Brukmanb4402432005-04-21 23:30:14 +000032addFrameReference(const MachineInstrBuilder &MIB, int FI, int Offset = 0,
Misha Brukman6ff65512004-07-07 20:01:36 +000033 bool mem = true) {
34 if (mem)
Chris Lattnerfef7a2d2006-05-04 17:21:20 +000035 return MIB.addImm(Offset).addFrameIndex(FI);
Misha Brukman6ff65512004-07-07 20:01:36 +000036 else
Chris Lattnerfef7a2d2006-05-04 17:21:20 +000037 return MIB.addFrameIndex(FI).addImm(Offset);
Misha Brukmane05203f2004-06-21 16:55:25 +000038}
39
Alexander Kornienkof00654e2015-06-23 09:49:53 +000040} // End llvm namespace
Misha Brukmane05203f2004-06-21 16:55:25 +000041
42#endif