[llvm-commits] [llvm] r45445 - in /llvm/trunk/include/llvm/CodeGen: MachineInstr.h MachineOperand.h
Chris Lattner
sabre at nondot.org
Sat Dec 29 20:40:26 PST 2007
Author: lattner
Date: Sat Dec 29 22:40:25 2007
New Revision: 45445
URL: http://llvm.org/viewvc/llvm-project?rev=45445&view=rev
Log:
split machineoperand out into its own header file.
Added:
llvm/trunk/include/llvm/CodeGen/MachineOperand.h
Modified:
llvm/trunk/include/llvm/CodeGen/MachineInstr.h
Modified: llvm/trunk/include/llvm/CodeGen/MachineInstr.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineInstr.h?rev=45445&r1=45444&r2=45445&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/MachineInstr.h (original)
+++ llvm/trunk/include/llvm/CodeGen/MachineInstr.h Sat Dec 29 22:40:25 2007
@@ -16,349 +16,17 @@
#ifndef LLVM_CODEGEN_MACHINEINSTR_H
#define LLVM_CODEGEN_MACHINEINSTR_H
-#include "llvm/Support/DataTypes.h"
-#include <vector>
-#include <cassert>
-#include <iosfwd>
+#include "llvm/CodeGen/MachineOperand.h"
namespace llvm {
-class Value;
-class Function;
-class MachineBasicBlock;
class TargetInstrDescriptor;
class TargetMachine;
-class GlobalValue;
template <typename T> struct ilist_traits;
template <typename T> struct ilist;
//===----------------------------------------------------------------------===//
-// class MachineOperand
-//
-// Representation of each machine instruction operand.
-//
-struct MachineOperand {
- enum MachineOperandType {
- MO_Register, // Register operand.
- MO_Immediate, // Immediate Operand
- MO_MachineBasicBlock, // MachineBasicBlock reference
- MO_FrameIndex, // Abstract Stack Frame Index
- MO_ConstantPoolIndex, // Address of indexed Constant in Constant Pool
- MO_JumpTableIndex, // Address of indexed Jump Table for switch
- MO_ExternalSymbol, // Name of external global symbol
- MO_GlobalAddress // Address of a global value
- };
-
-private:
- union {
- GlobalValue *GV; // For MO_GlobalAddress.
- MachineBasicBlock *MBB; // For MO_MachineBasicBlock.
- const char *SymbolName; // For MO_ExternalSymbol.
- unsigned RegNo; // For MO_Register.
- int64_t immedVal; // For MO_Immediate and MO_*Index.
- } contents;
-
- MachineOperandType opType:8; // Discriminate the union.
- bool IsDef : 1; // True if this is a def, false if this is a use.
- bool IsImp : 1; // True if this is an implicit def or use.
-
- bool IsKill : 1; // True if this is a reg use and the reg is dead
- // immediately after the read.
- bool IsDead : 1; // True if this is a reg def and the reg is dead
- // immediately after the write. i.e. A register
- // that is defined but never used.
-
- /// auxInfo - auxiliary information used by the MachineOperand
- union {
- /// offset - Offset to address of global or external, only valid for
- /// MO_GlobalAddress, MO_ExternalSym and MO_ConstantPoolIndex
- int offset;
-
- /// subReg - SubRegister number, only valid for MO_Register. A value of 0
- /// indicates the MO_Register has no subReg.
- unsigned char subReg;
- } auxInfo;
-
- MachineOperand() {}
-
- void print(std::ostream &os) const;
- void print(std::ostream *os) const { if (os) print(*os); }
-
-public:
- MachineOperand(const MachineOperand &M) {
- *this = M;
- }
-
- ~MachineOperand() {}
-
- /// getType - Returns the MachineOperandType for this operand.
- ///
- MachineOperandType getType() const { return opType; }
-
- /// Accessors that tell you what kind of MachineOperand you're looking at.
- ///
- bool isRegister() const { return opType == MO_Register; }
- bool isImmediate() const { return opType == MO_Immediate; }
- bool isMachineBasicBlock() const { return opType == MO_MachineBasicBlock; }
- bool isFrameIndex() const { return opType == MO_FrameIndex; }
- bool isConstantPoolIndex() const { return opType == MO_ConstantPoolIndex; }
- bool isJumpTableIndex() const { return opType == MO_JumpTableIndex; }
- bool isGlobalAddress() const { return opType == MO_GlobalAddress; }
- bool isExternalSymbol() const { return opType == MO_ExternalSymbol; }
-
- int64_t getImm() const {
- assert(isImmediate() && "Wrong MachineOperand accessor");
- return contents.immedVal;
- }
-
- int64_t getImmedValue() const {
- assert(isImmediate() && "Wrong MachineOperand accessor");
- return contents.immedVal;
- }
- MachineBasicBlock *getMBB() const {
- assert(isMachineBasicBlock() && "Wrong MachineOperand accessor");
- return contents.MBB;
- }
- MachineBasicBlock *getMachineBasicBlock() const {
- assert(isMachineBasicBlock() && "Wrong MachineOperand accessor");
- return contents.MBB;
- }
- void setMachineBasicBlock(MachineBasicBlock *MBB) {
- assert(isMachineBasicBlock() && "Wrong MachineOperand accessor");
- contents.MBB = MBB;
- }
- int getFrameIndex() const {
- assert(isFrameIndex() && "Wrong MachineOperand accessor");
- return (int)contents.immedVal;
- }
- unsigned getConstantPoolIndex() const {
- assert(isConstantPoolIndex() && "Wrong MachineOperand accessor");
- return (unsigned)contents.immedVal;
- }
- unsigned getJumpTableIndex() const {
- assert(isJumpTableIndex() && "Wrong MachineOperand accessor");
- return (unsigned)contents.immedVal;
- }
- GlobalValue *getGlobal() const {
- assert(isGlobalAddress() && "Wrong MachineOperand accessor");
- return contents.GV;
- }
- int getOffset() const {
- assert((isGlobalAddress() || isExternalSymbol() || isConstantPoolIndex()) &&
- "Wrong MachineOperand accessor");
- return auxInfo.offset;
- }
- unsigned getSubReg() const {
- assert(isRegister() && "Wrong MachineOperand accessor");
- return (unsigned)auxInfo.subReg;
- }
- const char *getSymbolName() const {
- assert(isExternalSymbol() && "Wrong MachineOperand accessor");
- return contents.SymbolName;
- }
-
- bool isUse() const {
- assert(isRegister() && "Wrong MachineOperand accessor");
- return !IsDef;
- }
- bool isDef() const {
- assert(isRegister() && "Wrong MachineOperand accessor");
- return IsDef;
- }
- void setIsUse() {
- assert(isRegister() && "Wrong MachineOperand accessor");
- IsDef = false;
- }
- void setIsDef() {
- assert(isRegister() && "Wrong MachineOperand accessor");
- IsDef = true;
- }
-
- bool isImplicit() const {
- assert(isRegister() && "Wrong MachineOperand accessor");
- return IsImp;
- }
- void setImplicit() {
- assert(isRegister() && "Wrong MachineOperand accessor");
- IsImp = true;
- }
-
- bool isKill() const {
- assert(isRegister() && "Wrong MachineOperand accessor");
- return IsKill;
- }
- bool isDead() const {
- assert(isRegister() && "Wrong MachineOperand accessor");
- return IsDead;
- }
- void setIsKill() {
- assert(isRegister() && !IsDef && "Wrong MachineOperand accessor");
- IsKill = true;
- }
- void setIsDead() {
- assert(isRegister() && IsDef && "Wrong MachineOperand accessor");
- IsDead = true;
- }
- void unsetIsKill() {
- assert(isRegister() && !IsDef && "Wrong MachineOperand accessor");
- IsKill = false;
- }
- void unsetIsDead() {
- assert(isRegister() && IsDef && "Wrong MachineOperand accessor");
- IsDead = false;
- }
-
- /// getReg - Returns the register number.
- ///
- unsigned getReg() const {
- assert(isRegister() && "This is not a register operand!");
- return contents.RegNo;
- }
-
- /// MachineOperand mutators.
- ///
- void setReg(unsigned Reg) {
- assert(isRegister() && "This is not a register operand!");
- contents.RegNo = Reg;
- }
-
- void setImmedValue(int64_t immVal) {
- assert(isImmediate() && "Wrong MachineOperand mutator");
- contents.immedVal = immVal;
- }
- void setImm(int64_t immVal) {
- assert(isImmediate() && "Wrong MachineOperand mutator");
- contents.immedVal = immVal;
- }
-
- void setOffset(int Offset) {
- assert((isGlobalAddress() || isExternalSymbol() || isConstantPoolIndex() ||
- isJumpTableIndex()) &&
- "Wrong MachineOperand accessor");
- auxInfo.offset = Offset;
- }
- void setSubReg(unsigned subReg) {
- assert(isRegister() && "Wrong MachineOperand accessor");
- auxInfo.subReg = (unsigned char)subReg;
- }
- void setConstantPoolIndex(unsigned Idx) {
- assert(isConstantPoolIndex() && "Wrong MachineOperand accessor");
- contents.immedVal = Idx;
- }
- void setJumpTableIndex(unsigned Idx) {
- assert(isJumpTableIndex() && "Wrong MachineOperand accessor");
- contents.immedVal = Idx;
- }
-
- /// isIdenticalTo - Return true if this operand is identical to the specified
- /// operand. Note: This method ignores isKill and isDead properties.
- bool isIdenticalTo(const MachineOperand &Other) const;
-
- /// ChangeToImmediate - Replace this operand with a new immediate operand of
- /// the specified value. If an operand is known to be an immediate already,
- /// the setImmedValue method should be used.
- void ChangeToImmediate(int64_t ImmVal) {
- opType = MO_Immediate;
- contents.immedVal = ImmVal;
- }
-
- /// ChangeToRegister - Replace this operand with a new register operand of
- /// the specified value. If an operand is known to be an register already,
- /// the setReg method should be used.
- void ChangeToRegister(unsigned Reg, bool isDef, bool isImp = false,
- bool isKill = false, bool isDead = false) {
- opType = MO_Register;
- contents.RegNo = Reg;
- IsDef = isDef;
- IsImp = isImp;
- IsKill = isKill;
- IsDead = isDead;
- }
-
- static MachineOperand CreateImm(int64_t Val) {
- MachineOperand Op;
- Op.opType = MachineOperand::MO_Immediate;
- Op.contents.immedVal = Val;
- Op.auxInfo.offset = 0;
- return Op;
- }
- static MachineOperand CreateReg(unsigned Reg, bool isDef, bool isImp = false,
- bool isKill = false, bool isDead = false,
- unsigned SubReg = 0) {
- MachineOperand Op;
- Op.opType = MachineOperand::MO_Register;
- Op.IsDef = isDef;
- Op.IsImp = isImp;
- Op.IsKill = isKill;
- Op.IsDead = isDead;
- Op.contents.RegNo = Reg;
- Op.auxInfo.subReg = SubReg;
- return Op;
- }
- static MachineOperand CreateMBB(MachineBasicBlock *MBB) {
- MachineOperand Op;
- Op.opType = MachineOperand::MO_MachineBasicBlock;
- Op.contents.MBB = MBB;
- Op.auxInfo.offset = 0;
- return Op;
- }
- static MachineOperand CreateFI(unsigned Idx) {
- MachineOperand Op;
- Op.opType = MachineOperand::MO_FrameIndex;
- Op.contents.immedVal = Idx;
- Op.auxInfo.offset = 0;
- return Op;
- }
- static MachineOperand CreateCPI(unsigned Idx, int Offset) {
- MachineOperand Op;
- Op.opType = MachineOperand::MO_ConstantPoolIndex;
- Op.contents.immedVal = Idx;
- Op.auxInfo.offset = Offset;
- return Op;
- }
- static MachineOperand CreateJTI(unsigned Idx) {
- MachineOperand Op;
- Op.opType = MachineOperand::MO_JumpTableIndex;
- Op.contents.immedVal = Idx;
- Op.auxInfo.offset = 0;
- return Op;
- }
- static MachineOperand CreateGA(GlobalValue *GV, int Offset) {
- MachineOperand Op;
- Op.opType = MachineOperand::MO_GlobalAddress;
- Op.contents.GV = GV;
- Op.auxInfo.offset = Offset;
- return Op;
- }
- static MachineOperand CreateES(const char *SymName, int Offset = 0) {
- MachineOperand Op;
- Op.opType = MachineOperand::MO_ExternalSymbol;
- Op.contents.SymbolName = SymName;
- Op.auxInfo.offset = Offset;
- return Op;
- }
- const MachineOperand &operator=(const MachineOperand &MO) {
- contents = MO.contents;
- IsDef = MO.IsDef;
- IsImp = MO.IsImp;
- IsKill = MO.IsKill;
- IsDead = MO.IsDead;
- opType = MO.opType;
- auxInfo = MO.auxInfo;
- return *this;
- }
-
- friend std::ostream& operator<<(std::ostream& os, const MachineOperand& mop) {
- mop.print(os);
- return os;
- }
-
- friend class MachineInstr;
-};
-
-
-//===----------------------------------------------------------------------===//
/// MachineInstr - Representation of each machine instruction.
///
class MachineInstr {
@@ -531,7 +199,6 @@
// Debugging Support
std::ostream& operator<<(std::ostream &OS, const MachineInstr &MI);
-std::ostream& operator<<(std::ostream &OS, const MachineOperand &MO);
} // End llvm namespace
Added: llvm/trunk/include/llvm/CodeGen/MachineOperand.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineOperand.h?rev=45445&view=auto
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/MachineOperand.h (added)
+++ llvm/trunk/include/llvm/CodeGen/MachineOperand.h Sat Dec 29 22:40:25 2007
@@ -0,0 +1,353 @@
+//===-- llvm/CodeGen/MachineOperand.h - MachineOperand class ----*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file contains the declaration of the MachineOperand class.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_CODEGEN_MACHINEOPERAND_H
+#define LLVM_CODEGEN_MACHINEOPERAND_H
+
+#include "llvm/Support/DataTypes.h"
+#include <vector>
+#include <cassert>
+#include <iosfwd>
+
+namespace llvm {
+
+class MachineBasicBlock;
+class GlobalValue;
+
+/// MachineOperand class - Representation of each machine instruction operand.
+///
+class MachineOperand {
+public:
+ enum MachineOperandType {
+ MO_Register, // Register operand.
+ MO_Immediate, // Immediate Operand
+ MO_MachineBasicBlock, // MachineBasicBlock reference
+ MO_FrameIndex, // Abstract Stack Frame Index
+ MO_ConstantPoolIndex, // Address of indexed Constant in Constant Pool
+ MO_JumpTableIndex, // Address of indexed Jump Table for switch
+ MO_ExternalSymbol, // Name of external global symbol
+ MO_GlobalAddress // Address of a global value
+ };
+
+private:
+ union {
+ GlobalValue *GV; // For MO_GlobalAddress.
+ MachineBasicBlock *MBB; // For MO_MachineBasicBlock.
+ const char *SymbolName; // For MO_ExternalSymbol.
+ unsigned RegNo; // For MO_Register.
+ int64_t immedVal; // For MO_Immediate and MO_*Index.
+ } contents;
+
+ MachineOperandType opType:8; // Discriminate the union.
+ bool IsDef : 1; // True if this is a def, false if this is a use.
+ bool IsImp : 1; // True if this is an implicit def or use.
+
+ bool IsKill : 1; // True if this is a reg use and the reg is dead
+ // immediately after the read.
+ bool IsDead : 1; // True if this is a reg def and the reg is dead
+ // immediately after the write. i.e. A register
+ // that is defined but never used.
+
+ /// auxInfo - auxiliary information used by the MachineOperand
+ union {
+ /// offset - Offset to address of global or external, only valid for
+ /// MO_GlobalAddress, MO_ExternalSym and MO_ConstantPoolIndex
+ int offset;
+
+ /// subReg - SubRegister number, only valid for MO_Register. A value of 0
+ /// indicates the MO_Register has no subReg.
+ unsigned char subReg;
+ } auxInfo;
+
+ MachineOperand() {}
+
+ void print(std::ostream &os) const;
+ void print(std::ostream *os) const { if (os) print(*os); }
+
+public:
+ MachineOperand(const MachineOperand &M) {
+ *this = M;
+ }
+
+ ~MachineOperand() {}
+
+ /// getType - Returns the MachineOperandType for this operand.
+ ///
+ MachineOperandType getType() const { return opType; }
+
+ /// Accessors that tell you what kind of MachineOperand you're looking at.
+ ///
+ bool isRegister() const { return opType == MO_Register; }
+ bool isImmediate() const { return opType == MO_Immediate; }
+ bool isMachineBasicBlock() const { return opType == MO_MachineBasicBlock; }
+ bool isFrameIndex() const { return opType == MO_FrameIndex; }
+ bool isConstantPoolIndex() const { return opType == MO_ConstantPoolIndex; }
+ bool isJumpTableIndex() const { return opType == MO_JumpTableIndex; }
+ bool isGlobalAddress() const { return opType == MO_GlobalAddress; }
+ bool isExternalSymbol() const { return opType == MO_ExternalSymbol; }
+
+ int64_t getImm() const {
+ assert(isImmediate() && "Wrong MachineOperand accessor");
+ return contents.immedVal;
+ }
+
+ int64_t getImmedValue() const {
+ assert(isImmediate() && "Wrong MachineOperand accessor");
+ return contents.immedVal;
+ }
+ MachineBasicBlock *getMBB() const {
+ assert(isMachineBasicBlock() && "Wrong MachineOperand accessor");
+ return contents.MBB;
+ }
+ MachineBasicBlock *getMachineBasicBlock() const {
+ assert(isMachineBasicBlock() && "Wrong MachineOperand accessor");
+ return contents.MBB;
+ }
+ void setMachineBasicBlock(MachineBasicBlock *MBB) {
+ assert(isMachineBasicBlock() && "Wrong MachineOperand accessor");
+ contents.MBB = MBB;
+ }
+ int getFrameIndex() const {
+ assert(isFrameIndex() && "Wrong MachineOperand accessor");
+ return (int)contents.immedVal;
+ }
+ unsigned getConstantPoolIndex() const {
+ assert(isConstantPoolIndex() && "Wrong MachineOperand accessor");
+ return (unsigned)contents.immedVal;
+ }
+ unsigned getJumpTableIndex() const {
+ assert(isJumpTableIndex() && "Wrong MachineOperand accessor");
+ return (unsigned)contents.immedVal;
+ }
+ GlobalValue *getGlobal() const {
+ assert(isGlobalAddress() && "Wrong MachineOperand accessor");
+ return contents.GV;
+ }
+ int getOffset() const {
+ assert((isGlobalAddress() || isExternalSymbol() || isConstantPoolIndex()) &&
+ "Wrong MachineOperand accessor");
+ return auxInfo.offset;
+ }
+ unsigned getSubReg() const {
+ assert(isRegister() && "Wrong MachineOperand accessor");
+ return (unsigned)auxInfo.subReg;
+ }
+ const char *getSymbolName() const {
+ assert(isExternalSymbol() && "Wrong MachineOperand accessor");
+ return contents.SymbolName;
+ }
+
+ bool isUse() const {
+ assert(isRegister() && "Wrong MachineOperand accessor");
+ return !IsDef;
+ }
+ bool isDef() const {
+ assert(isRegister() && "Wrong MachineOperand accessor");
+ return IsDef;
+ }
+ void setIsUse() {
+ assert(isRegister() && "Wrong MachineOperand accessor");
+ IsDef = false;
+ }
+ void setIsDef() {
+ assert(isRegister() && "Wrong MachineOperand accessor");
+ IsDef = true;
+ }
+
+ bool isImplicit() const {
+ assert(isRegister() && "Wrong MachineOperand accessor");
+ return IsImp;
+ }
+ void setImplicit() {
+ assert(isRegister() && "Wrong MachineOperand accessor");
+ IsImp = true;
+ }
+
+ bool isKill() const {
+ assert(isRegister() && "Wrong MachineOperand accessor");
+ return IsKill;
+ }
+ bool isDead() const {
+ assert(isRegister() && "Wrong MachineOperand accessor");
+ return IsDead;
+ }
+ void setIsKill() {
+ assert(isRegister() && !IsDef && "Wrong MachineOperand accessor");
+ IsKill = true;
+ }
+ void setIsDead() {
+ assert(isRegister() && IsDef && "Wrong MachineOperand accessor");
+ IsDead = true;
+ }
+ void unsetIsKill() {
+ assert(isRegister() && !IsDef && "Wrong MachineOperand accessor");
+ IsKill = false;
+ }
+ void unsetIsDead() {
+ assert(isRegister() && IsDef && "Wrong MachineOperand accessor");
+ IsDead = false;
+ }
+
+ /// getReg - Returns the register number.
+ ///
+ unsigned getReg() const {
+ assert(isRegister() && "This is not a register operand!");
+ return contents.RegNo;
+ }
+
+ /// MachineOperand mutators.
+ ///
+ void setReg(unsigned Reg) {
+ assert(isRegister() && "This is not a register operand!");
+ contents.RegNo = Reg;
+ }
+
+ void setImmedValue(int64_t immVal) {
+ assert(isImmediate() && "Wrong MachineOperand mutator");
+ contents.immedVal = immVal;
+ }
+ void setImm(int64_t immVal) {
+ assert(isImmediate() && "Wrong MachineOperand mutator");
+ contents.immedVal = immVal;
+ }
+
+ void setOffset(int Offset) {
+ assert((isGlobalAddress() || isExternalSymbol() || isConstantPoolIndex() ||
+ isJumpTableIndex()) &&
+ "Wrong MachineOperand accessor");
+ auxInfo.offset = Offset;
+ }
+ void setSubReg(unsigned subReg) {
+ assert(isRegister() && "Wrong MachineOperand accessor");
+ auxInfo.subReg = (unsigned char)subReg;
+ }
+ void setConstantPoolIndex(unsigned Idx) {
+ assert(isConstantPoolIndex() && "Wrong MachineOperand accessor");
+ contents.immedVal = Idx;
+ }
+ void setJumpTableIndex(unsigned Idx) {
+ assert(isJumpTableIndex() && "Wrong MachineOperand accessor");
+ contents.immedVal = Idx;
+ }
+
+ /// isIdenticalTo - Return true if this operand is identical to the specified
+ /// operand. Note: This method ignores isKill and isDead properties.
+ bool isIdenticalTo(const MachineOperand &Other) const;
+
+ /// ChangeToImmediate - Replace this operand with a new immediate operand of
+ /// the specified value. If an operand is known to be an immediate already,
+ /// the setImmedValue method should be used.
+ void ChangeToImmediate(int64_t ImmVal) {
+ opType = MO_Immediate;
+ contents.immedVal = ImmVal;
+ }
+
+ /// ChangeToRegister - Replace this operand with a new register operand of
+ /// the specified value. If an operand is known to be an register already,
+ /// the setReg method should be used.
+ void ChangeToRegister(unsigned Reg, bool isDef, bool isImp = false,
+ bool isKill = false, bool isDead = false) {
+ opType = MO_Register;
+ contents.RegNo = Reg;
+ IsDef = isDef;
+ IsImp = isImp;
+ IsKill = isKill;
+ IsDead = isDead;
+ }
+
+ static MachineOperand CreateImm(int64_t Val) {
+ MachineOperand Op;
+ Op.opType = MachineOperand::MO_Immediate;
+ Op.contents.immedVal = Val;
+ Op.auxInfo.offset = 0;
+ return Op;
+ }
+ static MachineOperand CreateReg(unsigned Reg, bool isDef, bool isImp = false,
+ bool isKill = false, bool isDead = false,
+ unsigned SubReg = 0) {
+ MachineOperand Op;
+ Op.opType = MachineOperand::MO_Register;
+ Op.IsDef = isDef;
+ Op.IsImp = isImp;
+ Op.IsKill = isKill;
+ Op.IsDead = isDead;
+ Op.contents.RegNo = Reg;
+ Op.auxInfo.subReg = SubReg;
+ return Op;
+ }
+ static MachineOperand CreateMBB(MachineBasicBlock *MBB) {
+ MachineOperand Op;
+ Op.opType = MachineOperand::MO_MachineBasicBlock;
+ Op.contents.MBB = MBB;
+ Op.auxInfo.offset = 0;
+ return Op;
+ }
+ static MachineOperand CreateFI(unsigned Idx) {
+ MachineOperand Op;
+ Op.opType = MachineOperand::MO_FrameIndex;
+ Op.contents.immedVal = Idx;
+ Op.auxInfo.offset = 0;
+ return Op;
+ }
+ static MachineOperand CreateCPI(unsigned Idx, int Offset) {
+ MachineOperand Op;
+ Op.opType = MachineOperand::MO_ConstantPoolIndex;
+ Op.contents.immedVal = Idx;
+ Op.auxInfo.offset = Offset;
+ return Op;
+ }
+ static MachineOperand CreateJTI(unsigned Idx) {
+ MachineOperand Op;
+ Op.opType = MachineOperand::MO_JumpTableIndex;
+ Op.contents.immedVal = Idx;
+ Op.auxInfo.offset = 0;
+ return Op;
+ }
+ static MachineOperand CreateGA(GlobalValue *GV, int Offset) {
+ MachineOperand Op;
+ Op.opType = MachineOperand::MO_GlobalAddress;
+ Op.contents.GV = GV;
+ Op.auxInfo.offset = Offset;
+ return Op;
+ }
+ static MachineOperand CreateES(const char *SymName, int Offset = 0) {
+ MachineOperand Op;
+ Op.opType = MachineOperand::MO_ExternalSymbol;
+ Op.contents.SymbolName = SymName;
+ Op.auxInfo.offset = Offset;
+ return Op;
+ }
+ const MachineOperand &operator=(const MachineOperand &MO) {
+ contents = MO.contents;
+ IsDef = MO.IsDef;
+ IsImp = MO.IsImp;
+ IsKill = MO.IsKill;
+ IsDead = MO.IsDead;
+ opType = MO.opType;
+ auxInfo = MO.auxInfo;
+ return *this;
+ }
+
+ friend std::ostream& operator<<(std::ostream& os, const MachineOperand& mop) {
+ mop.print(os);
+ return os;
+ }
+
+ friend class MachineInstr;
+};
+
+std::ostream& operator<<(std::ostream &OS, const MachineOperand &MO);
+
+} // End llvm namespace
+
+#endif
More information about the llvm-commits
mailing list