Scott Michel | 266bc8f | 2007-12-04 22:23:35 +0000 | [diff] [blame^] | 1 | //==-- SPUInstrBuilder.h - Aides for building Cell SPU insts -----*- C++ -*-==// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | //===----------------------------------------------------------------------===// |
| 6 | // |
| 7 | // This file exposes functions that may be used with BuildMI from the |
| 8 | // MachineInstrBuilder.h file to simplify generating frame and constant pool |
| 9 | // references. |
| 10 | // |
| 11 | // For reference, the order of operands for memory references is: |
| 12 | // (Operand), Dest Reg, Base Reg, and either Reg Index or Immediate |
| 13 | // Displacement. |
| 14 | // |
| 15 | //===----------------------------------------------------------------------===// |
| 16 | |
| 17 | #ifndef SPU_INSTRBUILDER_H |
| 18 | #define SPU_INSTRBUILDER_H |
| 19 | |
| 20 | #include "llvm/CodeGen/MachineInstrBuilder.h" |
| 21 | |
| 22 | namespace llvm { |
| 23 | |
| 24 | /// addFrameReference - This function is used to add a reference to the base of |
| 25 | /// an abstract object on the stack frame of the current function. This |
| 26 | /// reference has base register as the FrameIndex offset until it is resolved. |
| 27 | /// This allows a constant offset to be specified as well... |
| 28 | /// |
| 29 | inline const MachineInstrBuilder& |
| 30 | addFrameReference(const MachineInstrBuilder &MIB, int FI, int Offset = 0, |
| 31 | bool mem = true) { |
| 32 | if (mem) |
| 33 | return MIB.addImm(Offset).addFrameIndex(FI); |
| 34 | else |
| 35 | return MIB.addFrameIndex(FI).addImm(Offset); |
| 36 | } |
| 37 | |
| 38 | /// addConstantPoolReference - This function is used to add a reference to the |
| 39 | /// base of a constant value spilled to the per-function constant pool. The |
| 40 | /// reference has base register ConstantPoolIndex offset which is retained until |
| 41 | /// either machine code emission or assembly output. This allows an optional |
| 42 | /// offset to be added as well. |
| 43 | /// |
| 44 | inline const MachineInstrBuilder& |
| 45 | addConstantPoolReference(const MachineInstrBuilder &MIB, unsigned CPI, |
| 46 | int Offset = 0) { |
| 47 | return MIB.addImm(Offset).addConstantPoolIndex(CPI); |
| 48 | } |
| 49 | |
| 50 | } // End llvm namespace |
| 51 | |
| 52 | #endif |