Nate Begeman | 21e463b | 2005-10-16 05:39:50 +0000 | [diff] [blame] | 1 | //===-- PPCInstrBuilder.h - Aides for building PPC insts --------*- C++ -*-===// |
Misha Brukman | b5f662f | 2005-04-21 23:30:14 +0000 | [diff] [blame] | 2 | // |
Misha Brukman | 5dfe3a9 | 2004-06-21 16:55:25 +0000 | [diff] [blame] | 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. |
Misha Brukman | b5f662f | 2005-04-21 23:30:14 +0000 | [diff] [blame] | 7 | // |
Misha Brukman | 5dfe3a9 | 2004-06-21 16:55:25 +0000 | [diff] [blame] | 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: |
Misha Brukman | e62cd37 | 2004-07-07 20:01:36 +0000 | [diff] [blame] | 15 | // (Operand), Dest Reg, Base Reg, and either Reg Index or Immediate |
| 16 | // Displacement. |
Misha Brukman | 5dfe3a9 | 2004-06-21 16:55:25 +0000 | [diff] [blame] | 17 | // |
| 18 | //===----------------------------------------------------------------------===// |
| 19 | |
Misha Brukman | e62cd37 | 2004-07-07 20:01:36 +0000 | [diff] [blame] | 20 | #ifndef POWERPC_INSTRBUILDER_H |
| 21 | #define POWERPC_INSTRBUILDER_H |
Misha Brukman | 5dfe3a9 | 2004-06-21 16:55:25 +0000 | [diff] [blame] | 22 | |
| 23 | #include "llvm/CodeGen/MachineInstrBuilder.h" |
| 24 | |
| 25 | namespace 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 Brukman | e62cd37 | 2004-07-07 20:01:36 +0000 | [diff] [blame] | 32 | inline const MachineInstrBuilder& |
Misha Brukman | b5f662f | 2005-04-21 23:30:14 +0000 | [diff] [blame] | 33 | addFrameReference(const MachineInstrBuilder &MIB, int FI, int Offset = 0, |
Misha Brukman | e62cd37 | 2004-07-07 20:01:36 +0000 | [diff] [blame] | 34 | bool mem = true) { |
| 35 | if (mem) |
Chris Lattner | 63b3d71 | 2006-05-04 17:21:20 +0000 | [diff] [blame] | 36 | return MIB.addImm(Offset).addFrameIndex(FI); |
Misha Brukman | e62cd37 | 2004-07-07 20:01:36 +0000 | [diff] [blame] | 37 | else |
Chris Lattner | 63b3d71 | 2006-05-04 17:21:20 +0000 | [diff] [blame] | 38 | return MIB.addFrameIndex(FI).addImm(Offset); |
Misha Brukman | 5dfe3a9 | 2004-06-21 16:55:25 +0000 | [diff] [blame] | 39 | } |
| 40 | |
| 41 | /// addConstantPoolReference - This function is used to add a reference to the |
| 42 | /// base of a constant value spilled to the per-function constant pool. The |
| 43 | /// reference has base register ConstantPoolIndex offset which is retained until |
| 44 | /// either machine code emission or assembly output. This allows an optional |
| 45 | /// offset to be added as well. |
| 46 | /// |
Misha Brukman | e62cd37 | 2004-07-07 20:01:36 +0000 | [diff] [blame] | 47 | inline const MachineInstrBuilder& |
Misha Brukman | 5dfe3a9 | 2004-06-21 16:55:25 +0000 | [diff] [blame] | 48 | addConstantPoolReference(const MachineInstrBuilder &MIB, unsigned CPI, |
| 49 | int Offset = 0) { |
Chris Lattner | 63b3d71 | 2006-05-04 17:21:20 +0000 | [diff] [blame] | 50 | return MIB.addImm(Offset).addConstantPoolIndex(CPI); |
Misha Brukman | 5dfe3a9 | 2004-06-21 16:55:25 +0000 | [diff] [blame] | 51 | } |
| 52 | |
| 53 | } // End llvm namespace |
| 54 | |
| 55 | #endif |