2007-12-30 04:40:25 +00:00
|
|
|
//===-- 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 <cassert>
|
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
|
2008-02-14 07:39:30 +00:00
|
|
|
class ConstantFP;
|
2007-12-30 04:40:25 +00:00
|
|
|
class MachineBasicBlock;
|
|
|
|
class GlobalValue;
|
2009-07-01 19:08:07 +00:00
|
|
|
class MDNode;
|
2007-12-30 21:56:09 +00:00
|
|
|
class MachineInstr;
|
|
|
|
class TargetMachine;
|
2008-01-01 01:12:31 +00:00
|
|
|
class MachineRegisterInfo;
|
2008-08-21 00:14:44 +00:00
|
|
|
class raw_ostream;
|
2007-12-30 06:11:04 +00:00
|
|
|
|
2007-12-30 04:40:25 +00:00
|
|
|
/// MachineOperand class - Representation of each machine instruction operand.
|
|
|
|
///
|
|
|
|
class MachineOperand {
|
|
|
|
public:
|
|
|
|
enum MachineOperandType {
|
2009-06-21 01:52:00 +00:00
|
|
|
MO_Register, ///< Register operand.
|
|
|
|
MO_Immediate, ///< Immediate operand
|
|
|
|
MO_FPImmediate, ///< Floating-point 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
|
2009-07-01 19:08:07 +00:00
|
|
|
MO_GlobalAddress, ///< Address of a global value
|
|
|
|
MO_Metadata ///< Metadata info
|
2007-12-30 04:40:25 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
private:
|
2007-12-30 22:24:06 +00:00
|
|
|
/// OpKind - Specify what kind of operand this is. This discriminates the
|
|
|
|
/// union.
|
2009-06-24 17:54:48 +00:00
|
|
|
unsigned char OpKind; // MachineOperandType
|
|
|
|
|
|
|
|
/// SubReg - Subregister number, only valid for MO_Register. A value of 0
|
|
|
|
/// indicates the MO_Register has no subReg.
|
|
|
|
unsigned char SubReg;
|
|
|
|
|
|
|
|
/// TargetFlags - This is a set of target-specific operand flags.
|
|
|
|
unsigned char TargetFlags;
|
2007-12-30 06:11:04 +00:00
|
|
|
|
2007-12-30 22:24:06 +00:00
|
|
|
/// IsDef/IsImp/IsKill/IsDead flags - These are only valid for MO_Register
|
|
|
|
/// operands.
|
|
|
|
|
|
|
|
/// IsDef - True if this is a def, false if this is a use of the register.
|
|
|
|
///
|
|
|
|
bool IsDef : 1;
|
|
|
|
|
|
|
|
/// IsImp - True if this is an implicit def or use, false if it is explicit.
|
|
|
|
///
|
|
|
|
bool IsImp : 1;
|
2007-12-30 04:40:25 +00:00
|
|
|
|
2007-12-30 22:24:06 +00:00
|
|
|
/// IsKill - True if this instruction is the last use of the register on this
|
|
|
|
/// path through the function. This is only valid on uses of registers.
|
|
|
|
bool IsKill : 1;
|
|
|
|
|
|
|
|
/// IsDead - True if this register is never used by a subsequent instruction.
|
|
|
|
/// This is only valid on definitions of registers.
|
|
|
|
bool IsDead : 1;
|
2007-12-30 21:31:53 +00:00
|
|
|
|
2009-06-30 08:49:04 +00:00
|
|
|
/// IsUndef - True if this is a register def / use of "undef", i.e. register
|
|
|
|
/// defined by an IMPLICIT_DEF. This is only valid on registers.
|
|
|
|
bool IsUndef : 1;
|
|
|
|
|
2008-09-21 23:30:17 +00:00
|
|
|
/// IsEarlyClobber - True if this MO_Register 'def' operand is written to
|
|
|
|
/// by the MachineInstr before all input registers are read. This is used to
|
|
|
|
/// model the GCC inline asm '&' constraint modifier.
|
2008-09-12 17:49:03 +00:00
|
|
|
bool IsEarlyClobber : 1;
|
|
|
|
|
2007-12-30 22:24:06 +00:00
|
|
|
/// ParentMI - This is the instruction that this operand is embedded into.
|
|
|
|
/// This is valid for all operand types, when the operand is in an instr.
|
|
|
|
MachineInstr *ParentMI;
|
2007-12-30 04:40:25 +00:00
|
|
|
|
2007-12-30 22:24:06 +00:00
|
|
|
/// Contents union - This contains the payload for the various operand types.
|
|
|
|
union {
|
|
|
|
MachineBasicBlock *MBB; // For MO_MachineBasicBlock.
|
2008-09-12 18:08:03 +00:00
|
|
|
const ConstantFP *CFP; // For MO_FPImmediate.
|
2007-12-30 22:24:06 +00:00
|
|
|
int64_t ImmVal; // For MO_Immediate.
|
2008-01-01 01:12:31 +00:00
|
|
|
|
|
|
|
struct { // For MO_Register.
|
|
|
|
unsigned RegNo;
|
|
|
|
MachineOperand **Prev; // Access list for register.
|
|
|
|
MachineOperand *Next;
|
|
|
|
} Reg;
|
2007-12-30 22:24:06 +00:00
|
|
|
|
|
|
|
/// OffsetedInfo - This struct contains the offset and an object identifier.
|
|
|
|
/// this represent the object as with an optional offset from it.
|
|
|
|
struct {
|
|
|
|
union {
|
|
|
|
int Index; // For MO_*Index - The index itself.
|
|
|
|
const char *SymbolName; // For MO_ExternalSymbol.
|
|
|
|
GlobalValue *GV; // For MO_GlobalAddress.
|
2009-07-02 17:39:40 +00:00
|
|
|
MDNode *Node; // For MO_Metadata.
|
2007-12-30 22:24:06 +00:00
|
|
|
} Val;
|
2009-09-03 06:00:00 +00:00
|
|
|
int64_t Offset; // An offset from the object.
|
2007-12-30 22:24:06 +00:00
|
|
|
} OffsetedInfo;
|
|
|
|
} Contents;
|
2007-12-30 04:40:25 +00:00
|
|
|
|
2009-06-24 17:54:48 +00:00
|
|
|
explicit MachineOperand(MachineOperandType K) : OpKind(K), ParentMI(0) {
|
|
|
|
TargetFlags = 0;
|
|
|
|
}
|
2007-12-30 04:40:25 +00:00
|
|
|
public:
|
|
|
|
/// getType - Returns the MachineOperandType for this operand.
|
|
|
|
///
|
2009-06-24 17:54:48 +00:00
|
|
|
MachineOperandType getType() const { return (MachineOperandType)OpKind; }
|
|
|
|
|
|
|
|
unsigned char getTargetFlags() const { return TargetFlags; }
|
|
|
|
void setTargetFlags(unsigned char F) { TargetFlags = F; }
|
|
|
|
void addTargetFlag(unsigned char F) { TargetFlags |= F; }
|
|
|
|
|
2007-12-30 04:40:25 +00:00
|
|
|
|
2007-12-30 21:31:53 +00:00
|
|
|
/// getParent - Return the instruction that this operand belongs to.
|
|
|
|
///
|
|
|
|
MachineInstr *getParent() { return ParentMI; }
|
|
|
|
const MachineInstr *getParent() const { return ParentMI; }
|
|
|
|
|
2008-08-21 00:14:44 +00:00
|
|
|
void print(raw_ostream &os, const TargetMachine *TM = 0) const;
|
2007-12-30 21:56:09 +00:00
|
|
|
|
2008-10-03 15:45:36 +00:00
|
|
|
//===--------------------------------------------------------------------===//
|
|
|
|
// Accessors that tell you what kind of MachineOperand you're looking at.
|
|
|
|
//===--------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
/// isReg - Tests if this is a MO_Register operand.
|
|
|
|
bool isReg() const { return OpKind == MO_Register; }
|
|
|
|
/// isImm - Tests if this is a MO_Immediate operand.
|
|
|
|
bool isImm() const { return OpKind == MO_Immediate; }
|
|
|
|
/// isFPImm - Tests if this is a MO_FPImmediate operand.
|
|
|
|
bool isFPImm() const { return OpKind == MO_FPImmediate; }
|
|
|
|
/// isMBB - Tests if this is a MO_MachineBasicBlock operand.
|
|
|
|
bool isMBB() const { return OpKind == MO_MachineBasicBlock; }
|
|
|
|
/// isFI - Tests if this is a MO_FrameIndex operand.
|
|
|
|
bool isFI() const { return OpKind == MO_FrameIndex; }
|
|
|
|
/// isCPI - Tests if this is a MO_ConstantPoolIndex operand.
|
|
|
|
bool isCPI() const { return OpKind == MO_ConstantPoolIndex; }
|
|
|
|
/// isJTI - Tests if this is a MO_JumpTableIndex operand.
|
|
|
|
bool isJTI() const { return OpKind == MO_JumpTableIndex; }
|
|
|
|
/// isGlobal - Tests if this is a MO_GlobalAddress operand.
|
|
|
|
bool isGlobal() const { return OpKind == MO_GlobalAddress; }
|
|
|
|
/// isSymbol - Tests if this is a MO_ExternalSymbol operand.
|
|
|
|
bool isSymbol() const { return OpKind == MO_ExternalSymbol; }
|
2009-07-06 23:46:02 +00:00
|
|
|
/// isMetadata - Tests if this is a MO_Metadata operand.
|
|
|
|
bool isMetadata() const { return OpKind == MO_Metadata; }
|
2007-12-30 04:40:25 +00:00
|
|
|
|
2007-12-30 21:56:09 +00:00
|
|
|
//===--------------------------------------------------------------------===//
|
|
|
|
// Accessors for Register Operands
|
|
|
|
//===--------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
/// getReg - Returns the register number.
|
|
|
|
unsigned getReg() const {
|
2008-10-03 15:45:36 +00:00
|
|
|
assert(isReg() && "This is not a register operand!");
|
2008-01-01 01:12:31 +00:00
|
|
|
return Contents.Reg.RegNo;
|
2007-12-30 21:56:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
unsigned getSubReg() const {
|
2008-10-03 15:45:36 +00:00
|
|
|
assert(isReg() && "Wrong MachineOperand accessor");
|
2007-12-30 21:56:09 +00:00
|
|
|
return (unsigned)SubReg;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isUse() const {
|
2008-10-03 15:45:36 +00:00
|
|
|
assert(isReg() && "Wrong MachineOperand accessor");
|
2007-12-30 21:56:09 +00:00
|
|
|
return !IsDef;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isDef() const {
|
2008-10-03 15:45:36 +00:00
|
|
|
assert(isReg() && "Wrong MachineOperand accessor");
|
2007-12-30 21:56:09 +00:00
|
|
|
return IsDef;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isImplicit() const {
|
2008-10-03 15:45:36 +00:00
|
|
|
assert(isReg() && "Wrong MachineOperand accessor");
|
2007-12-30 21:56:09 +00:00
|
|
|
return IsImp;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isDead() const {
|
2008-10-03 15:45:36 +00:00
|
|
|
assert(isReg() && "Wrong MachineOperand accessor");
|
2007-12-30 21:56:09 +00:00
|
|
|
return IsDead;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isKill() const {
|
2008-10-03 15:45:36 +00:00
|
|
|
assert(isReg() && "Wrong MachineOperand accessor");
|
2007-12-30 21:56:09 +00:00
|
|
|
return IsKill;
|
|
|
|
}
|
2008-01-01 02:55:32 +00:00
|
|
|
|
2009-06-30 08:49:04 +00:00
|
|
|
bool isUndef() const {
|
|
|
|
assert(isReg() && "Wrong MachineOperand accessor");
|
|
|
|
return IsUndef;
|
|
|
|
}
|
|
|
|
|
2008-09-12 17:49:03 +00:00
|
|
|
bool isEarlyClobber() const {
|
2008-10-03 15:45:36 +00:00
|
|
|
assert(isReg() && "Wrong MachineOperand accessor");
|
2008-09-12 17:49:03 +00:00
|
|
|
return IsEarlyClobber;
|
|
|
|
}
|
|
|
|
|
2008-01-01 02:55:32 +00:00
|
|
|
/// getNextOperandForReg - Return the next MachineOperand in the function that
|
|
|
|
/// uses or defines this register.
|
|
|
|
MachineOperand *getNextOperandForReg() const {
|
2008-10-03 15:45:36 +00:00
|
|
|
assert(isReg() && "This is not a register operand!");
|
2008-01-01 02:55:32 +00:00
|
|
|
return Contents.Reg.Next;
|
|
|
|
}
|
2007-12-30 21:56:09 +00:00
|
|
|
|
|
|
|
//===--------------------------------------------------------------------===//
|
|
|
|
// Mutators for Register Operands
|
|
|
|
//===--------------------------------------------------------------------===//
|
|
|
|
|
2008-01-01 01:12:31 +00:00
|
|
|
/// Change the register this operand corresponds to.
|
|
|
|
///
|
|
|
|
void setReg(unsigned Reg);
|
|
|
|
|
2007-12-30 21:56:09 +00:00
|
|
|
void setSubReg(unsigned subReg) {
|
2008-10-03 15:45:36 +00:00
|
|
|
assert(isReg() && "Wrong MachineOperand accessor");
|
2007-12-30 21:56:09 +00:00
|
|
|
SubReg = (unsigned char)subReg;
|
|
|
|
}
|
|
|
|
|
|
|
|
void setIsUse(bool Val = true) {
|
2008-10-03 15:45:36 +00:00
|
|
|
assert(isReg() && "Wrong MachineOperand accessor");
|
2007-12-30 21:56:09 +00:00
|
|
|
IsDef = !Val;
|
|
|
|
}
|
|
|
|
|
|
|
|
void setIsDef(bool Val = true) {
|
2008-10-03 15:45:36 +00:00
|
|
|
assert(isReg() && "Wrong MachineOperand accessor");
|
2007-12-30 21:56:09 +00:00
|
|
|
IsDef = Val;
|
|
|
|
}
|
|
|
|
|
|
|
|
void setImplicit(bool Val = true) {
|
2008-10-03 15:45:36 +00:00
|
|
|
assert(isReg() && "Wrong MachineOperand accessor");
|
2007-12-30 21:56:09 +00:00
|
|
|
IsImp = Val;
|
|
|
|
}
|
|
|
|
|
|
|
|
void setIsKill(bool Val = true) {
|
2008-10-03 15:45:36 +00:00
|
|
|
assert(isReg() && !IsDef && "Wrong MachineOperand accessor");
|
2007-12-30 21:56:09 +00:00
|
|
|
IsKill = Val;
|
|
|
|
}
|
|
|
|
|
|
|
|
void setIsDead(bool Val = true) {
|
2008-10-03 15:45:36 +00:00
|
|
|
assert(isReg() && IsDef && "Wrong MachineOperand accessor");
|
2007-12-30 21:56:09 +00:00
|
|
|
IsDead = Val;
|
|
|
|
}
|
|
|
|
|
2009-06-30 08:49:04 +00:00
|
|
|
void setIsUndef(bool Val = true) {
|
|
|
|
assert(isReg() && "Wrong MachineOperand accessor");
|
|
|
|
IsUndef = Val;
|
|
|
|
}
|
|
|
|
|
2008-09-12 17:49:03 +00:00
|
|
|
void setIsEarlyClobber(bool Val = true) {
|
2008-10-03 15:45:36 +00:00
|
|
|
assert(isReg() && IsDef && "Wrong MachineOperand accessor");
|
2008-09-12 17:49:03 +00:00
|
|
|
IsEarlyClobber = Val;
|
|
|
|
}
|
2007-12-30 21:56:09 +00:00
|
|
|
|
|
|
|
//===--------------------------------------------------------------------===//
|
|
|
|
// Accessors for various operand types.
|
|
|
|
//===--------------------------------------------------------------------===//
|
|
|
|
|
2007-12-30 04:40:25 +00:00
|
|
|
int64_t getImm() const {
|
2008-10-03 15:45:36 +00:00
|
|
|
assert(isImm() && "Wrong MachineOperand accessor");
|
2007-12-30 22:24:06 +00:00
|
|
|
return Contents.ImmVal;
|
2007-12-30 04:40:25 +00:00
|
|
|
}
|
|
|
|
|
2008-09-12 18:08:03 +00:00
|
|
|
const ConstantFP *getFPImm() const {
|
2008-10-03 15:45:36 +00:00
|
|
|
assert(isFPImm() && "Wrong MachineOperand accessor");
|
2008-02-14 07:39:30 +00:00
|
|
|
return Contents.CFP;
|
|
|
|
}
|
|
|
|
|
2007-12-30 04:40:25 +00:00
|
|
|
MachineBasicBlock *getMBB() const {
|
2008-10-03 15:45:36 +00:00
|
|
|
assert(isMBB() && "Wrong MachineOperand accessor");
|
2007-12-30 22:24:06 +00:00
|
|
|
return Contents.MBB;
|
2007-12-30 04:40:25 +00:00
|
|
|
}
|
2007-12-30 22:24:06 +00:00
|
|
|
|
|
|
|
int getIndex() const {
|
2008-10-03 15:45:36 +00:00
|
|
|
assert((isFI() || isCPI() || isJTI()) &&
|
2007-12-30 22:24:06 +00:00
|
|
|
"Wrong MachineOperand accessor");
|
|
|
|
return Contents.OffsetedInfo.Val.Index;
|
2007-12-30 04:40:25 +00:00
|
|
|
}
|
2007-12-30 22:24:06 +00:00
|
|
|
|
2007-12-30 04:40:25 +00:00
|
|
|
GlobalValue *getGlobal() const {
|
2008-10-03 15:45:36 +00:00
|
|
|
assert(isGlobal() && "Wrong MachineOperand accessor");
|
2007-12-30 22:24:06 +00:00
|
|
|
return Contents.OffsetedInfo.Val.GV;
|
2007-12-30 04:40:25 +00:00
|
|
|
}
|
2007-12-30 23:10:15 +00:00
|
|
|
|
2009-07-01 21:26:41 +00:00
|
|
|
MDNode *getMDNode() const {
|
|
|
|
return Contents.OffsetedInfo.Val.Node;
|
|
|
|
}
|
|
|
|
|
2009-09-03 06:00:00 +00:00
|
|
|
/// getOffset - Return the offset from the symbol in this operand. This always
|
|
|
|
/// returns 0 for ExternalSymbol operands.
|
Teach DAGCombine to fold constant offsets into GlobalAddress nodes,
and add a TargetLowering hook for it to use to determine when this
is legal (i.e. not in PIC mode, etc.)
This allows instruction selection to emit folded constant offsets
in more cases, such as the included testcase, eliminating the need
for explicit arithmetic instructions.
This eliminates the need for the C++ code in X86ISelDAGToDAG.cpp
that attempted to achieve the same effect, but wasn't as effective.
Also, fix handling of offsets in GlobalAddressSDNodes in several
places, including changing GlobalAddressSDNode's offset from
int to int64_t.
The Mips, Alpha, Sparc, and CellSPU targets appear to be
unaware of GlobalAddress offsets currently, so set the hook to
false on those targets.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@57748 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-18 02:06:02 +00:00
|
|
|
int64_t getOffset() const {
|
2008-10-03 15:45:36 +00:00
|
|
|
assert((isGlobal() || isSymbol() || isCPI()) &&
|
2007-12-30 21:56:09 +00:00
|
|
|
"Wrong MachineOperand accessor");
|
2007-12-30 22:24:06 +00:00
|
|
|
return Contents.OffsetedInfo.Offset;
|
2007-12-30 04:40:25 +00:00
|
|
|
}
|
2007-12-30 23:10:15 +00:00
|
|
|
|
2007-12-30 04:40:25 +00:00
|
|
|
const char *getSymbolName() const {
|
2008-10-03 15:45:36 +00:00
|
|
|
assert(isSymbol() && "Wrong MachineOperand accessor");
|
2007-12-30 22:24:06 +00:00
|
|
|
return Contents.OffsetedInfo.Val.SymbolName;
|
2007-12-30 04:40:25 +00:00
|
|
|
}
|
2007-12-30 21:56:09 +00:00
|
|
|
|
|
|
|
//===--------------------------------------------------------------------===//
|
|
|
|
// Mutators for various operand types.
|
|
|
|
//===--------------------------------------------------------------------===//
|
|
|
|
|
2007-12-30 04:40:25 +00:00
|
|
|
void setImm(int64_t immVal) {
|
2008-10-03 15:45:36 +00:00
|
|
|
assert(isImm() && "Wrong MachineOperand mutator");
|
2007-12-30 22:24:06 +00:00
|
|
|
Contents.ImmVal = immVal;
|
2007-12-30 04:40:25 +00:00
|
|
|
}
|
|
|
|
|
Teach DAGCombine to fold constant offsets into GlobalAddress nodes,
and add a TargetLowering hook for it to use to determine when this
is legal (i.e. not in PIC mode, etc.)
This allows instruction selection to emit folded constant offsets
in more cases, such as the included testcase, eliminating the need
for explicit arithmetic instructions.
This eliminates the need for the C++ code in X86ISelDAGToDAG.cpp
that attempted to achieve the same effect, but wasn't as effective.
Also, fix handling of offsets in GlobalAddressSDNodes in several
places, including changing GlobalAddressSDNode's offset from
int to int64_t.
The Mips, Alpha, Sparc, and CellSPU targets appear to be
unaware of GlobalAddress offsets currently, so set the hook to
false on those targets.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@57748 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-18 02:06:02 +00:00
|
|
|
void setOffset(int64_t Offset) {
|
2009-07-06 23:46:02 +00:00
|
|
|
assert((isGlobal() || isSymbol() || isCPI() || isMetadata()) &&
|
2007-12-30 04:40:25 +00:00
|
|
|
"Wrong MachineOperand accessor");
|
2007-12-30 22:24:06 +00:00
|
|
|
Contents.OffsetedInfo.Offset = Offset;
|
2007-12-30 04:40:25 +00:00
|
|
|
}
|
2007-12-30 21:56:09 +00:00
|
|
|
|
2007-12-30 22:24:06 +00:00
|
|
|
void setIndex(int Idx) {
|
2008-10-03 15:45:36 +00:00
|
|
|
assert((isFI() || isCPI() || isJTI()) &&
|
2007-12-30 22:24:06 +00:00
|
|
|
"Wrong MachineOperand accessor");
|
|
|
|
Contents.OffsetedInfo.Val.Index = Idx;
|
2007-12-30 04:40:25 +00:00
|
|
|
}
|
2007-12-30 21:56:09 +00:00
|
|
|
|
2007-12-30 23:10:15 +00:00
|
|
|
void setMBB(MachineBasicBlock *MBB) {
|
2008-10-03 15:45:36 +00:00
|
|
|
assert(isMBB() && "Wrong MachineOperand accessor");
|
2007-12-30 22:24:06 +00:00
|
|
|
Contents.MBB = MBB;
|
2007-12-30 04:40:25 +00:00
|
|
|
}
|
|
|
|
|
2007-12-30 21:56:09 +00:00
|
|
|
//===--------------------------------------------------------------------===//
|
|
|
|
// Other methods.
|
|
|
|
//===--------------------------------------------------------------------===//
|
|
|
|
|
2007-12-30 04:40:25 +00:00
|
|
|
/// 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,
|
2007-12-30 21:31:53 +00:00
|
|
|
/// the setImm method should be used.
|
2008-01-01 01:12:31 +00:00
|
|
|
void ChangeToImmediate(int64_t ImmVal);
|
|
|
|
|
2007-12-30 04:40:25 +00:00
|
|
|
/// 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,
|
2009-06-30 08:49:04 +00:00
|
|
|
bool isKill = false, bool isDead = false,
|
|
|
|
bool isUndef = false);
|
2007-12-30 04:40:25 +00:00
|
|
|
|
2007-12-30 21:56:09 +00:00
|
|
|
//===--------------------------------------------------------------------===//
|
|
|
|
// Construction methods.
|
|
|
|
//===--------------------------------------------------------------------===//
|
|
|
|
|
2007-12-30 04:40:25 +00:00
|
|
|
static MachineOperand CreateImm(int64_t Val) {
|
2007-12-30 22:24:06 +00:00
|
|
|
MachineOperand Op(MachineOperand::MO_Immediate);
|
|
|
|
Op.setImm(Val);
|
2007-12-30 04:40:25 +00:00
|
|
|
return Op;
|
|
|
|
}
|
2007-12-30 21:56:09 +00:00
|
|
|
|
2008-09-12 18:08:03 +00:00
|
|
|
static MachineOperand CreateFPImm(const ConstantFP *CFP) {
|
2008-02-14 07:39:30 +00:00
|
|
|
MachineOperand Op(MachineOperand::MO_FPImmediate);
|
|
|
|
Op.Contents.CFP = CFP;
|
|
|
|
return Op;
|
|
|
|
}
|
|
|
|
|
2007-12-30 04:40:25 +00:00
|
|
|
static MachineOperand CreateReg(unsigned Reg, bool isDef, bool isImp = false,
|
|
|
|
bool isKill = false, bool isDead = false,
|
2009-06-30 08:49:04 +00:00
|
|
|
bool isUndef = false,
|
|
|
|
bool isEarlyClobber = false,
|
|
|
|
unsigned SubReg = 0) {
|
2007-12-30 22:24:06 +00:00
|
|
|
MachineOperand Op(MachineOperand::MO_Register);
|
2007-12-30 04:40:25 +00:00
|
|
|
Op.IsDef = isDef;
|
|
|
|
Op.IsImp = isImp;
|
|
|
|
Op.IsKill = isKill;
|
|
|
|
Op.IsDead = isDead;
|
2009-06-30 08:49:04 +00:00
|
|
|
Op.IsUndef = isUndef;
|
2008-09-12 17:49:03 +00:00
|
|
|
Op.IsEarlyClobber = isEarlyClobber;
|
2008-01-01 01:12:31 +00:00
|
|
|
Op.Contents.Reg.RegNo = Reg;
|
|
|
|
Op.Contents.Reg.Prev = 0;
|
|
|
|
Op.Contents.Reg.Next = 0;
|
2007-12-30 21:31:53 +00:00
|
|
|
Op.SubReg = SubReg;
|
2007-12-30 04:40:25 +00:00
|
|
|
return Op;
|
|
|
|
}
|
2009-06-25 01:16:22 +00:00
|
|
|
static MachineOperand CreateMBB(MachineBasicBlock *MBB,
|
|
|
|
unsigned char TargetFlags = 0) {
|
2007-12-30 22:24:06 +00:00
|
|
|
MachineOperand Op(MachineOperand::MO_MachineBasicBlock);
|
2007-12-30 23:10:15 +00:00
|
|
|
Op.setMBB(MBB);
|
2009-06-25 01:16:22 +00:00
|
|
|
Op.setTargetFlags(TargetFlags);
|
2007-12-30 04:40:25 +00:00
|
|
|
return Op;
|
|
|
|
}
|
|
|
|
static MachineOperand CreateFI(unsigned Idx) {
|
2007-12-30 22:24:06 +00:00
|
|
|
MachineOperand Op(MachineOperand::MO_FrameIndex);
|
|
|
|
Op.setIndex(Idx);
|
2007-12-30 04:40:25 +00:00
|
|
|
return Op;
|
|
|
|
}
|
2009-06-25 01:16:22 +00:00
|
|
|
static MachineOperand CreateCPI(unsigned Idx, int Offset,
|
|
|
|
unsigned char TargetFlags = 0) {
|
2007-12-30 22:24:06 +00:00
|
|
|
MachineOperand Op(MachineOperand::MO_ConstantPoolIndex);
|
|
|
|
Op.setIndex(Idx);
|
|
|
|
Op.setOffset(Offset);
|
2009-06-25 01:16:22 +00:00
|
|
|
Op.setTargetFlags(TargetFlags);
|
2007-12-30 04:40:25 +00:00
|
|
|
return Op;
|
|
|
|
}
|
2009-06-25 01:16:22 +00:00
|
|
|
static MachineOperand CreateJTI(unsigned Idx,
|
|
|
|
unsigned char TargetFlags = 0) {
|
2007-12-30 22:24:06 +00:00
|
|
|
MachineOperand Op(MachineOperand::MO_JumpTableIndex);
|
|
|
|
Op.setIndex(Idx);
|
2009-06-25 01:16:22 +00:00
|
|
|
Op.setTargetFlags(TargetFlags);
|
2007-12-30 04:40:25 +00:00
|
|
|
return Op;
|
|
|
|
}
|
2009-06-25 01:16:22 +00:00
|
|
|
static MachineOperand CreateGA(GlobalValue *GV, int64_t Offset,
|
|
|
|
unsigned char TargetFlags = 0) {
|
2007-12-30 22:24:06 +00:00
|
|
|
MachineOperand Op(MachineOperand::MO_GlobalAddress);
|
|
|
|
Op.Contents.OffsetedInfo.Val.GV = GV;
|
|
|
|
Op.setOffset(Offset);
|
2009-06-25 01:16:22 +00:00
|
|
|
Op.setTargetFlags(TargetFlags);
|
2009-07-01 19:08:07 +00:00
|
|
|
return Op;
|
|
|
|
}
|
|
|
|
static MachineOperand CreateMDNode(MDNode *N, int64_t Offset,
|
2009-07-02 17:39:40 +00:00
|
|
|
unsigned char TargetFlags = 0) {
|
2009-07-01 19:08:07 +00:00
|
|
|
MachineOperand Op(MachineOperand::MO_Metadata);
|
|
|
|
Op.Contents.OffsetedInfo.Val.Node = N;
|
|
|
|
Op.setOffset(Offset);
|
|
|
|
Op.setTargetFlags(TargetFlags);
|
2007-12-30 04:40:25 +00:00
|
|
|
return Op;
|
|
|
|
}
|
2009-09-01 22:06:46 +00:00
|
|
|
static MachineOperand CreateES(const char *SymName,
|
2009-06-25 01:16:22 +00:00
|
|
|
unsigned char TargetFlags = 0) {
|
2007-12-30 22:24:06 +00:00
|
|
|
MachineOperand Op(MachineOperand::MO_ExternalSymbol);
|
|
|
|
Op.Contents.OffsetedInfo.Val.SymbolName = SymName;
|
2009-09-01 22:06:46 +00:00
|
|
|
Op.setOffset(0); // Offset is always 0.
|
2009-06-25 01:16:22 +00:00
|
|
|
Op.setTargetFlags(TargetFlags);
|
2007-12-30 04:40:25 +00:00
|
|
|
return Op;
|
|
|
|
}
|
|
|
|
|
|
|
|
friend class MachineInstr;
|
2008-01-01 01:12:31 +00:00
|
|
|
friend class MachineRegisterInfo;
|
|
|
|
private:
|
|
|
|
//===--------------------------------------------------------------------===//
|
|
|
|
// Methods for handling register use/def lists.
|
|
|
|
//===--------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
/// isOnRegUseList - Return true if this operand is on a register use/def list
|
|
|
|
/// or false if not. This can only be called for register operands that are
|
|
|
|
/// part of a machine instruction.
|
|
|
|
bool isOnRegUseList() const {
|
2008-10-03 15:45:36 +00:00
|
|
|
assert(isReg() && "Can only add reg operand to use lists");
|
2008-01-01 01:12:31 +00:00
|
|
|
return Contents.Reg.Prev != 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// AddRegOperandToRegInfo - Add this register operand to the specified
|
|
|
|
/// MachineRegisterInfo. If it is null, then the next/prev fields should be
|
|
|
|
/// explicitly nulled out.
|
|
|
|
void AddRegOperandToRegInfo(MachineRegisterInfo *RegInfo);
|
|
|
|
|
2009-04-15 01:17:37 +00:00
|
|
|
/// RemoveRegOperandFromRegInfo - Remove this register operand from the
|
|
|
|
/// MachineRegisterInfo it is linked with.
|
|
|
|
void RemoveRegOperandFromRegInfo();
|
2007-12-30 04:40:25 +00:00
|
|
|
};
|
|
|
|
|
2008-08-21 00:14:44 +00:00
|
|
|
inline raw_ostream &operator<<(raw_ostream &OS, const MachineOperand& MO) {
|
|
|
|
MO.print(OS, 0);
|
|
|
|
return OS;
|
|
|
|
}
|
|
|
|
|
2007-12-30 04:40:25 +00:00
|
|
|
} // End llvm namespace
|
|
|
|
|
|
|
|
#endif
|