2007-12-30 05:40:25 +01: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
|
|
|
|
|
2010-11-29 19:16:10 +01:00
|
|
|
#include "llvm/Support/DataTypes.h"
|
2007-12-30 05:40:25 +01:00
|
|
|
#include <cassert>
|
|
|
|
|
|
|
|
namespace llvm {
|
2010-09-15 18:08:15 +02:00
|
|
|
|
2009-10-30 01:20:08 +01:00
|
|
|
class BlockAddress;
|
2010-03-03 02:37:50 +01:00
|
|
|
class ConstantFP;
|
2011-06-24 22:46:11 +02:00
|
|
|
class ConstantInt;
|
2007-12-30 05:40:25 +01:00
|
|
|
class GlobalValue;
|
2010-03-03 02:37:50 +01:00
|
|
|
class MachineBasicBlock;
|
2007-12-30 22:56:09 +01:00
|
|
|
class MachineInstr;
|
2008-01-01 02:12:31 +01:00
|
|
|
class MachineRegisterInfo;
|
2010-01-12 03:01:53 +01:00
|
|
|
class MDNode;
|
2010-03-03 02:37:50 +01:00
|
|
|
class TargetMachine;
|
2010-05-28 20:18:53 +02:00
|
|
|
class TargetRegisterInfo;
|
2008-08-21 02:14:44 +02:00
|
|
|
class raw_ostream;
|
2010-03-13 09:14:18 +01:00
|
|
|
class MCSymbol;
|
2010-09-15 18:08:15 +02:00
|
|
|
|
2007-12-30 05:40:25 +01:00
|
|
|
/// MachineOperand class - Representation of each machine instruction operand.
|
|
|
|
///
|
|
|
|
class MachineOperand {
|
|
|
|
public:
|
|
|
|
enum MachineOperandType {
|
2009-06-21 03:52:00 +02:00
|
|
|
MO_Register, ///< Register operand.
|
|
|
|
MO_Immediate, ///< Immediate operand
|
2011-06-24 22:46:11 +02:00
|
|
|
MO_CImmediate, ///< Immediate >64bit operand
|
2009-06-21 03:52:00 +02:00
|
|
|
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 21:08:07 +02:00
|
|
|
MO_GlobalAddress, ///< Address of a global value
|
2010-01-12 03:01:53 +01:00
|
|
|
MO_BlockAddress, ///< Address of a basic block
|
2012-01-16 20:22:00 +01:00
|
|
|
MO_RegisterMask, ///< Mask of preserved registers.
|
2010-03-13 09:14:18 +01:00
|
|
|
MO_Metadata, ///< Metadata reference (for debug info)
|
|
|
|
MO_MCSymbol ///< MCSymbol reference (for debug/eh info)
|
2007-12-30 05:40:25 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
private:
|
2007-12-30 23:24:06 +01:00
|
|
|
/// OpKind - Specify what kind of operand this is. This discriminates the
|
|
|
|
/// union.
|
2009-06-24 19:54:48 +02:00
|
|
|
unsigned char OpKind; // MachineOperandType
|
2010-09-15 18:08:15 +02:00
|
|
|
|
2009-06-24 19:54:48 +02:00
|
|
|
/// SubReg - Subregister number, only valid for MO_Register. A value of 0
|
|
|
|
/// indicates the MO_Register has no subReg.
|
|
|
|
unsigned char SubReg;
|
2010-09-15 18:08:15 +02:00
|
|
|
|
2009-06-24 19:54:48 +02:00
|
|
|
/// TargetFlags - This is a set of target-specific operand flags.
|
|
|
|
unsigned char TargetFlags;
|
2010-09-15 18:08:15 +02:00
|
|
|
|
2007-12-30 23:24:06 +01:00
|
|
|
/// IsDef/IsImp/IsKill/IsDead flags - These are only valid for MO_Register
|
|
|
|
/// operands.
|
2010-09-15 18:08:15 +02:00
|
|
|
|
2007-12-30 23:24:06 +01:00
|
|
|
/// IsDef - True if this is a def, false if this is a use of the register.
|
|
|
|
///
|
|
|
|
bool IsDef : 1;
|
2010-09-15 18:08:15 +02:00
|
|
|
|
2007-12-30 23:24:06 +01:00
|
|
|
/// IsImp - True if this is an implicit def or use, false if it is explicit.
|
|
|
|
///
|
|
|
|
bool IsImp : 1;
|
2007-12-30 05:40:25 +01:00
|
|
|
|
2007-12-30 23:24:06 +01: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 22:31:53 +01:00
|
|
|
|
2011-10-04 23:49:33 +02:00
|
|
|
/// IsUndef - True if this register operand reads an "undef" value, i.e. the
|
|
|
|
/// read value doesn't matter. This flag can be set on both use and def
|
|
|
|
/// operands. On a sub-register def operand, it refers to the part of the
|
|
|
|
/// register that isn't written. On a full-register def operand, it is a
|
|
|
|
/// noop. See readsReg().
|
|
|
|
///
|
|
|
|
/// This is only valid on registers.
|
|
|
|
///
|
|
|
|
/// Note that an instruction may have multiple <undef> operands referring to
|
|
|
|
/// the same register. In that case, the instruction may depend on those
|
|
|
|
/// operands reading the same dont-care value. For example:
|
|
|
|
///
|
|
|
|
/// %vreg1<def> = XOR %vreg2<undef>, %vreg2<undef>
|
|
|
|
///
|
|
|
|
/// Any register can be used for %vreg2, and its value doesn't matter, but
|
|
|
|
/// the two operands must be the same register.
|
|
|
|
///
|
2009-06-30 10:49:04 +02:00
|
|
|
bool IsUndef : 1;
|
|
|
|
|
2011-12-07 01:22:07 +01:00
|
|
|
/// IsInternalRead - True if this operand reads a value that was defined
|
|
|
|
/// inside the same instruction or bundle. This flag can be set on both use
|
|
|
|
/// and def operands. On a sub-register def operand, it refers to the part
|
|
|
|
/// of the register that isn't written. On a full-register def operand, it
|
|
|
|
/// is a noop.
|
|
|
|
///
|
|
|
|
/// When this flag is set, the instruction bundle must contain at least one
|
|
|
|
/// other def of the register. If multiple instructions in the bundle define
|
|
|
|
/// the register, the meaning is target-defined.
|
|
|
|
bool IsInternalRead : 1;
|
|
|
|
|
2008-09-22 01:30:17 +02: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 19:49:03 +02:00
|
|
|
bool IsEarlyClobber : 1;
|
|
|
|
|
2010-02-06 03:28:32 +01:00
|
|
|
/// IsDebug - True if this MO_Register 'use' operand is in a debug pseudo,
|
|
|
|
/// not a real instruction. Such uses should be ignored during codegen.
|
|
|
|
bool IsDebug : 1;
|
|
|
|
|
2011-05-27 00:54:27 +02:00
|
|
|
/// SmallContents - This really should be part of the Contents union, but
|
|
|
|
/// lives out here so we can get a better packed struct.
|
2010-10-19 22:56:32 +02:00
|
|
|
/// MO_Register: Register number.
|
|
|
|
/// OffsetedInfo: Low bits of offset.
|
|
|
|
union {
|
|
|
|
unsigned RegNo; // For MO_Register.
|
|
|
|
unsigned OffsetLo; // Matches Contents.OffsetedInfo.OffsetHi.
|
|
|
|
} SmallContents;
|
|
|
|
|
2010-09-15 18:08:15 +02:00
|
|
|
/// ParentMI - This is the instruction that this operand is embedded into.
|
2007-12-30 23:24:06 +01:00
|
|
|
/// This is valid for all operand types, when the operand is in an instr.
|
|
|
|
MachineInstr *ParentMI;
|
2007-12-30 05:40:25 +01:00
|
|
|
|
2007-12-30 23:24:06 +01:00
|
|
|
/// Contents union - This contains the payload for the various operand types.
|
|
|
|
union {
|
|
|
|
MachineBasicBlock *MBB; // For MO_MachineBasicBlock.
|
2008-09-12 20:08:03 +02:00
|
|
|
const ConstantFP *CFP; // For MO_FPImmediate.
|
2011-06-24 22:46:11 +02:00
|
|
|
const ConstantInt *CI; // For MO_CImmediate. Integers > 64bit.
|
2007-12-30 23:24:06 +01:00
|
|
|
int64_t ImmVal; // For MO_Immediate.
|
2012-01-16 20:22:00 +01:00
|
|
|
const uint32_t *RegMask; // For MO_RegisterMask.
|
2010-02-26 20:39:56 +01:00
|
|
|
const MDNode *MD; // For MO_Metadata.
|
2010-03-13 09:14:18 +01:00
|
|
|
MCSymbol *Sym; // For MO_MCSymbol
|
2008-01-01 02:12:31 +01:00
|
|
|
|
|
|
|
struct { // For MO_Register.
|
2010-10-19 22:56:32 +02:00
|
|
|
// Register number is in SmallContents.RegNo.
|
2008-01-01 02:12:31 +01:00
|
|
|
MachineOperand **Prev; // Access list for register.
|
|
|
|
MachineOperand *Next;
|
|
|
|
} Reg;
|
2010-09-15 18:08:15 +02:00
|
|
|
|
2007-12-30 23:24:06 +01: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.
|
2010-04-15 03:51:59 +02:00
|
|
|
const GlobalValue *GV; // For MO_GlobalAddress.
|
|
|
|
const BlockAddress *BA; // For MO_BlockAddress.
|
2007-12-30 23:24:06 +01:00
|
|
|
} Val;
|
2010-10-19 22:56:32 +02:00
|
|
|
// Low bits of offset are in SmallContents.OffsetLo.
|
|
|
|
int OffsetHi; // An offset from the object, high 32 bits.
|
2007-12-30 23:24:06 +01:00
|
|
|
} OffsetedInfo;
|
|
|
|
} Contents;
|
2010-09-15 18:08:15 +02:00
|
|
|
|
2009-06-24 19:54:48 +02:00
|
|
|
explicit MachineOperand(MachineOperandType K) : OpKind(K), ParentMI(0) {
|
|
|
|
TargetFlags = 0;
|
|
|
|
}
|
2007-12-30 05:40:25 +01:00
|
|
|
public:
|
|
|
|
/// getType - Returns the MachineOperandType for this operand.
|
|
|
|
///
|
2009-06-24 19:54:48 +02:00
|
|
|
MachineOperandType getType() const { return (MachineOperandType)OpKind; }
|
2010-09-15 18:08:15 +02:00
|
|
|
|
2009-06-24 19:54:48 +02:00
|
|
|
unsigned char getTargetFlags() const { return TargetFlags; }
|
|
|
|
void setTargetFlags(unsigned char F) { TargetFlags = F; }
|
|
|
|
void addTargetFlag(unsigned char F) { TargetFlags |= F; }
|
2010-09-15 18:08:15 +02:00
|
|
|
|
2007-12-30 05:40:25 +01:00
|
|
|
|
2007-12-30 22:31:53 +01:00
|
|
|
/// getParent - Return the instruction that this operand belongs to.
|
|
|
|
///
|
|
|
|
MachineInstr *getParent() { return ParentMI; }
|
|
|
|
const MachineInstr *getParent() const { return ParentMI; }
|
2010-09-15 18:08:15 +02:00
|
|
|
|
2011-01-09 06:33:21 +01:00
|
|
|
/// clearParent - Reset the parent pointer.
|
|
|
|
///
|
|
|
|
/// The MachineOperand copy constructor also copies ParentMI, expecting the
|
|
|
|
/// original to be deleted. If a MachineOperand is ever stored outside a
|
|
|
|
/// MachineInstr, the parent pointer must be cleared.
|
|
|
|
///
|
|
|
|
/// Never call clearParent() on an operand in a MachineInstr.
|
|
|
|
///
|
|
|
|
void clearParent() { ParentMI = 0; }
|
|
|
|
|
2008-08-21 02:14:44 +02:00
|
|
|
void print(raw_ostream &os, const TargetMachine *TM = 0) const;
|
2007-12-30 22:56:09 +01:00
|
|
|
|
2008-10-03 17:45:36 +02: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; }
|
2011-06-24 22:46:11 +02:00
|
|
|
/// isCImm - Test if t his is a MO_CImmediate operand.
|
|
|
|
bool isCImm() const { return OpKind == MO_CImmediate; }
|
2008-10-03 17:45:36 +02:00
|
|
|
/// 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-10-30 01:20:08 +01:00
|
|
|
/// isBlockAddress - Tests if this is a MO_BlockAddress operand.
|
|
|
|
bool isBlockAddress() const { return OpKind == MO_BlockAddress; }
|
2012-01-16 20:22:00 +01:00
|
|
|
/// isRegMask - Tests if this is a MO_RegisterMask operand.
|
|
|
|
bool isRegMask() const { return OpKind == MO_RegisterMask; }
|
2010-01-12 03:01:53 +01:00
|
|
|
/// isMetadata - Tests if this is a MO_Metadata operand.
|
|
|
|
bool isMetadata() const { return OpKind == MO_Metadata; }
|
2010-03-13 09:14:18 +01:00
|
|
|
bool isMCSymbol() const { return OpKind == MO_MCSymbol; }
|
2007-12-30 05:40:25 +01:00
|
|
|
|
2012-01-16 20:22:00 +01:00
|
|
|
|
2007-12-30 22:56:09 +01:00
|
|
|
//===--------------------------------------------------------------------===//
|
|
|
|
// Accessors for Register Operands
|
|
|
|
//===--------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
/// getReg - Returns the register number.
|
|
|
|
unsigned getReg() const {
|
2008-10-03 17:45:36 +02:00
|
|
|
assert(isReg() && "This is not a register operand!");
|
2010-10-19 22:56:32 +02:00
|
|
|
return SmallContents.RegNo;
|
2007-12-30 22:56:09 +01:00
|
|
|
}
|
2010-09-15 18:08:15 +02:00
|
|
|
|
2007-12-30 22:56:09 +01:00
|
|
|
unsigned getSubReg() const {
|
2008-10-03 17:45:36 +02:00
|
|
|
assert(isReg() && "Wrong MachineOperand accessor");
|
2007-12-30 22:56:09 +01:00
|
|
|
return (unsigned)SubReg;
|
|
|
|
}
|
2010-09-15 18:08:15 +02:00
|
|
|
|
|
|
|
bool isUse() const {
|
2008-10-03 17:45:36 +02:00
|
|
|
assert(isReg() && "Wrong MachineOperand accessor");
|
2007-12-30 22:56:09 +01:00
|
|
|
return !IsDef;
|
|
|
|
}
|
2010-09-15 18:08:15 +02:00
|
|
|
|
2007-12-30 22:56:09 +01:00
|
|
|
bool isDef() const {
|
2008-10-03 17:45:36 +02:00
|
|
|
assert(isReg() && "Wrong MachineOperand accessor");
|
2007-12-30 22:56:09 +01:00
|
|
|
return IsDef;
|
|
|
|
}
|
2010-09-15 18:08:15 +02:00
|
|
|
|
|
|
|
bool isImplicit() const {
|
2008-10-03 17:45:36 +02:00
|
|
|
assert(isReg() && "Wrong MachineOperand accessor");
|
2007-12-30 22:56:09 +01:00
|
|
|
return IsImp;
|
|
|
|
}
|
2010-09-15 18:08:15 +02:00
|
|
|
|
2007-12-30 22:56:09 +01:00
|
|
|
bool isDead() const {
|
2008-10-03 17:45:36 +02:00
|
|
|
assert(isReg() && "Wrong MachineOperand accessor");
|
2007-12-30 22:56:09 +01:00
|
|
|
return IsDead;
|
|
|
|
}
|
2010-09-15 18:08:15 +02:00
|
|
|
|
2007-12-30 22:56:09 +01:00
|
|
|
bool isKill() const {
|
2008-10-03 17:45:36 +02:00
|
|
|
assert(isReg() && "Wrong MachineOperand accessor");
|
2007-12-30 22:56:09 +01:00
|
|
|
return IsKill;
|
|
|
|
}
|
2010-09-15 18:08:15 +02:00
|
|
|
|
2009-06-30 10:49:04 +02:00
|
|
|
bool isUndef() const {
|
|
|
|
assert(isReg() && "Wrong MachineOperand accessor");
|
|
|
|
return IsUndef;
|
|
|
|
}
|
2010-09-15 18:08:15 +02:00
|
|
|
|
2011-12-07 01:22:07 +01:00
|
|
|
bool isInternalRead() const {
|
|
|
|
assert(isReg() && "Wrong MachineOperand accessor");
|
|
|
|
return IsInternalRead;
|
|
|
|
}
|
|
|
|
|
2008-09-12 19:49:03 +02:00
|
|
|
bool isEarlyClobber() const {
|
2008-10-03 17:45:36 +02:00
|
|
|
assert(isReg() && "Wrong MachineOperand accessor");
|
2008-09-12 19:49:03 +02:00
|
|
|
return IsEarlyClobber;
|
|
|
|
}
|
|
|
|
|
2010-02-06 03:28:32 +01:00
|
|
|
bool isDebug() const {
|
|
|
|
assert(isReg() && "Wrong MachineOperand accessor");
|
|
|
|
return IsDebug;
|
|
|
|
}
|
|
|
|
|
2011-10-04 23:49:33 +02:00
|
|
|
/// readsReg - Returns true if this operand reads the previous value of its
|
|
|
|
/// register. A use operand with the <undef> flag set doesn't read its
|
|
|
|
/// register. A sub-register def implicitly reads the other parts of the
|
|
|
|
/// register being redefined unless the <undef> flag is set.
|
2011-12-07 01:22:07 +01:00
|
|
|
///
|
|
|
|
/// This refers to reading the register value from before the current
|
|
|
|
/// instruction or bundle. Internal bundle reads are not included.
|
2011-10-04 23:49:33 +02:00
|
|
|
bool readsReg() const {
|
|
|
|
assert(isReg() && "Wrong MachineOperand accessor");
|
2011-12-07 01:22:07 +01:00
|
|
|
return !isUndef() && !isInternalRead() && (isUse() || getSubReg());
|
2011-10-04 23:49:33 +02:00
|
|
|
}
|
|
|
|
|
2008-01-01 03:55:32 +01:00
|
|
|
/// getNextOperandForReg - Return the next MachineOperand in the function that
|
|
|
|
/// uses or defines this register.
|
|
|
|
MachineOperand *getNextOperandForReg() const {
|
2008-10-03 17:45:36 +02:00
|
|
|
assert(isReg() && "This is not a register operand!");
|
2008-01-01 03:55:32 +01:00
|
|
|
return Contents.Reg.Next;
|
|
|
|
}
|
2007-12-30 22:56:09 +01:00
|
|
|
|
|
|
|
//===--------------------------------------------------------------------===//
|
|
|
|
// Mutators for Register Operands
|
|
|
|
//===--------------------------------------------------------------------===//
|
2010-09-15 18:08:15 +02:00
|
|
|
|
2008-01-01 02:12:31 +01:00
|
|
|
/// Change the register this operand corresponds to.
|
|
|
|
///
|
|
|
|
void setReg(unsigned Reg);
|
2010-09-15 18:08:15 +02:00
|
|
|
|
2007-12-30 22:56:09 +01:00
|
|
|
void setSubReg(unsigned subReg) {
|
2008-10-03 17:45:36 +02:00
|
|
|
assert(isReg() && "Wrong MachineOperand accessor");
|
2007-12-30 22:56:09 +01:00
|
|
|
SubReg = (unsigned char)subReg;
|
|
|
|
}
|
2010-05-28 20:18:53 +02:00
|
|
|
|
|
|
|
/// substVirtReg - Substitute the current register with the virtual
|
|
|
|
/// subregister Reg:SubReg. Take any existing SubReg index into account,
|
|
|
|
/// using TargetRegisterInfo to compose the subreg indices if necessary.
|
|
|
|
/// Reg must be a virtual register, SubIdx can be 0.
|
|
|
|
///
|
|
|
|
void substVirtReg(unsigned Reg, unsigned SubIdx, const TargetRegisterInfo&);
|
|
|
|
|
|
|
|
/// substPhysReg - Substitute the current register with the physical register
|
|
|
|
/// Reg, taking any existing SubReg into account. For instance,
|
|
|
|
/// substPhysReg(%EAX) will change %reg1024:sub_8bit to %AL.
|
|
|
|
///
|
|
|
|
void substPhysReg(unsigned Reg, const TargetRegisterInfo&);
|
|
|
|
|
2007-12-30 22:56:09 +01:00
|
|
|
void setIsUse(bool Val = true) {
|
2008-10-03 17:45:36 +02:00
|
|
|
assert(isReg() && "Wrong MachineOperand accessor");
|
2010-02-09 01:42:08 +01:00
|
|
|
assert((Val || !isDebug()) && "Marking a debug operation as def");
|
2007-12-30 22:56:09 +01:00
|
|
|
IsDef = !Val;
|
|
|
|
}
|
2010-09-15 18:08:15 +02:00
|
|
|
|
2007-12-30 22:56:09 +01:00
|
|
|
void setIsDef(bool Val = true) {
|
2008-10-03 17:45:36 +02:00
|
|
|
assert(isReg() && "Wrong MachineOperand accessor");
|
2010-02-09 01:42:08 +01:00
|
|
|
assert((!Val || !isDebug()) && "Marking a debug operation as def");
|
2007-12-30 22:56:09 +01:00
|
|
|
IsDef = Val;
|
|
|
|
}
|
|
|
|
|
2010-09-15 18:08:15 +02:00
|
|
|
void setImplicit(bool Val = true) {
|
2008-10-03 17:45:36 +02:00
|
|
|
assert(isReg() && "Wrong MachineOperand accessor");
|
2007-12-30 22:56:09 +01:00
|
|
|
IsImp = Val;
|
|
|
|
}
|
|
|
|
|
|
|
|
void setIsKill(bool Val = true) {
|
2008-10-03 17:45:36 +02:00
|
|
|
assert(isReg() && !IsDef && "Wrong MachineOperand accessor");
|
2010-02-09 01:42:08 +01:00
|
|
|
assert((!Val || !isDebug()) && "Marking a debug operation as kill");
|
2007-12-30 22:56:09 +01:00
|
|
|
IsKill = Val;
|
|
|
|
}
|
2010-09-15 18:08:15 +02:00
|
|
|
|
2007-12-30 22:56:09 +01:00
|
|
|
void setIsDead(bool Val = true) {
|
2008-10-03 17:45:36 +02:00
|
|
|
assert(isReg() && IsDef && "Wrong MachineOperand accessor");
|
2007-12-30 22:56:09 +01:00
|
|
|
IsDead = Val;
|
|
|
|
}
|
|
|
|
|
2009-06-30 10:49:04 +02:00
|
|
|
void setIsUndef(bool Val = true) {
|
|
|
|
assert(isReg() && "Wrong MachineOperand accessor");
|
|
|
|
IsUndef = Val;
|
|
|
|
}
|
2010-09-15 18:08:15 +02:00
|
|
|
|
2011-12-07 01:22:07 +01:00
|
|
|
void setIsInternalRead(bool Val = true) {
|
|
|
|
assert(isReg() && "Wrong MachineOperand accessor");
|
|
|
|
IsInternalRead = Val;
|
|
|
|
}
|
|
|
|
|
2008-09-12 19:49:03 +02:00
|
|
|
void setIsEarlyClobber(bool Val = true) {
|
2008-10-03 17:45:36 +02:00
|
|
|
assert(isReg() && IsDef && "Wrong MachineOperand accessor");
|
2008-09-12 19:49:03 +02:00
|
|
|
IsEarlyClobber = Val;
|
|
|
|
}
|
2007-12-30 22:56:09 +01:00
|
|
|
|
2010-03-25 02:38:16 +01:00
|
|
|
void setIsDebug(bool Val = true) {
|
|
|
|
assert(isReg() && IsDef && "Wrong MachineOperand accessor");
|
|
|
|
IsDebug = Val;
|
|
|
|
}
|
|
|
|
|
2007-12-30 22:56:09 +01:00
|
|
|
//===--------------------------------------------------------------------===//
|
|
|
|
// Accessors for various operand types.
|
|
|
|
//===--------------------------------------------------------------------===//
|
2010-09-15 18:08:15 +02:00
|
|
|
|
2007-12-30 05:40:25 +01:00
|
|
|
int64_t getImm() const {
|
2008-10-03 17:45:36 +02:00
|
|
|
assert(isImm() && "Wrong MachineOperand accessor");
|
2007-12-30 23:24:06 +01:00
|
|
|
return Contents.ImmVal;
|
2007-12-30 05:40:25 +01:00
|
|
|
}
|
2010-09-15 18:08:15 +02:00
|
|
|
|
2011-06-24 22:46:11 +02:00
|
|
|
const ConstantInt *getCImm() const {
|
|
|
|
assert(isCImm() && "Wrong MachineOperand accessor");
|
|
|
|
return Contents.CI;
|
|
|
|
}
|
|
|
|
|
2008-09-12 20:08:03 +02:00
|
|
|
const ConstantFP *getFPImm() const {
|
2008-10-03 17:45:36 +02:00
|
|
|
assert(isFPImm() && "Wrong MachineOperand accessor");
|
2008-02-14 08:39:30 +01:00
|
|
|
return Contents.CFP;
|
|
|
|
}
|
2010-09-15 18:08:15 +02:00
|
|
|
|
2007-12-30 05:40:25 +01:00
|
|
|
MachineBasicBlock *getMBB() const {
|
2008-10-03 17:45:36 +02:00
|
|
|
assert(isMBB() && "Wrong MachineOperand accessor");
|
2007-12-30 23:24:06 +01:00
|
|
|
return Contents.MBB;
|
2007-12-30 05:40:25 +01:00
|
|
|
}
|
2007-12-30 23:24:06 +01:00
|
|
|
|
|
|
|
int getIndex() const {
|
2008-10-03 17:45:36 +02:00
|
|
|
assert((isFI() || isCPI() || isJTI()) &&
|
2007-12-30 23:24:06 +01:00
|
|
|
"Wrong MachineOperand accessor");
|
|
|
|
return Contents.OffsetedInfo.Val.Index;
|
2007-12-30 05:40:25 +01:00
|
|
|
}
|
2010-09-15 18:08:15 +02:00
|
|
|
|
2010-04-15 03:51:59 +02:00
|
|
|
const GlobalValue *getGlobal() const {
|
2008-10-03 17:45:36 +02:00
|
|
|
assert(isGlobal() && "Wrong MachineOperand accessor");
|
2007-12-30 23:24:06 +01:00
|
|
|
return Contents.OffsetedInfo.Val.GV;
|
2007-12-30 05:40:25 +01:00
|
|
|
}
|
2009-10-30 01:20:08 +01:00
|
|
|
|
2010-04-15 03:51:59 +02:00
|
|
|
const BlockAddress *getBlockAddress() const {
|
2009-10-30 01:20:08 +01:00
|
|
|
assert(isBlockAddress() && "Wrong MachineOperand accessor");
|
|
|
|
return Contents.OffsetedInfo.Val.BA;
|
|
|
|
}
|
2010-03-13 09:14:18 +01:00
|
|
|
|
|
|
|
MCSymbol *getMCSymbol() const {
|
|
|
|
assert(isMCSymbol() && "Wrong MachineOperand accessor");
|
|
|
|
return Contents.Sym;
|
|
|
|
}
|
2010-09-15 18:08:15 +02:00
|
|
|
|
2009-09-03 08:00:00 +02: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.
llvm-svn: 57748
2008-10-18 04:06:02 +02:00
|
|
|
int64_t getOffset() const {
|
2009-10-30 01:20:08 +01:00
|
|
|
assert((isGlobal() || isSymbol() || isCPI() || isBlockAddress()) &&
|
2007-12-30 22:56:09 +01:00
|
|
|
"Wrong MachineOperand accessor");
|
2010-10-19 22:56:32 +02:00
|
|
|
return (int64_t(Contents.OffsetedInfo.OffsetHi) << 32) |
|
|
|
|
SmallContents.OffsetLo;
|
2007-12-30 05:40:25 +01:00
|
|
|
}
|
2010-09-15 18:08:15 +02:00
|
|
|
|
2007-12-30 05:40:25 +01:00
|
|
|
const char *getSymbolName() const {
|
2008-10-03 17:45:36 +02:00
|
|
|
assert(isSymbol() && "Wrong MachineOperand accessor");
|
2007-12-30 23:24:06 +01:00
|
|
|
return Contents.OffsetedInfo.Val.SymbolName;
|
2007-12-30 05:40:25 +01:00
|
|
|
}
|
2010-01-12 03:01:53 +01:00
|
|
|
|
2012-02-10 20:23:53 +01:00
|
|
|
/// clobbersPhysReg - Returns true if this RegMask clobbers PhysReg.
|
|
|
|
/// It is sometimes necessary to detach the register mask pointer from its
|
|
|
|
/// machine operand. This static method can be used for such detached bit
|
2012-02-10 20:27:34 +01:00
|
|
|
/// mask pointers.
|
2012-02-10 20:23:53 +01:00
|
|
|
static bool clobbersPhysReg(const uint32_t *RegMask, unsigned PhysReg) {
|
2012-01-16 20:22:00 +01:00
|
|
|
// See TargetRegisterInfo.h.
|
|
|
|
assert(PhysReg < (1u << 30) && "Not a physical register");
|
2012-02-10 20:23:53 +01:00
|
|
|
return !(RegMask[PhysReg / 32] & (1u << PhysReg % 32));
|
|
|
|
}
|
|
|
|
|
|
|
|
/// clobbersPhysReg - Returns true if this RegMask operand clobbers PhysReg.
|
|
|
|
bool clobbersPhysReg(unsigned PhysReg) const {
|
|
|
|
return clobbersPhysReg(getRegMask(), PhysReg);
|
2012-01-16 20:22:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/// getRegMask - Returns a bit mask of registers preserved by this RegMask
|
2012-02-03 00:52:57 +01:00
|
|
|
/// operand.
|
2012-01-16 20:22:00 +01:00
|
|
|
const uint32_t *getRegMask() const {
|
|
|
|
assert(isRegMask() && "Wrong MachineOperand accessor");
|
|
|
|
return Contents.RegMask;
|
|
|
|
}
|
|
|
|
|
2010-01-13 01:00:24 +01:00
|
|
|
const MDNode *getMetadata() const {
|
2010-01-12 03:01:53 +01:00
|
|
|
assert(isMetadata() && "Wrong MachineOperand accessor");
|
|
|
|
return Contents.MD;
|
|
|
|
}
|
2010-09-15 18:08:15 +02:00
|
|
|
|
2007-12-30 22:56:09 +01:00
|
|
|
//===--------------------------------------------------------------------===//
|
|
|
|
// Mutators for various operand types.
|
|
|
|
//===--------------------------------------------------------------------===//
|
2010-09-15 18:08:15 +02:00
|
|
|
|
2007-12-30 05:40:25 +01:00
|
|
|
void setImm(int64_t immVal) {
|
2008-10-03 17:45:36 +02:00
|
|
|
assert(isImm() && "Wrong MachineOperand mutator");
|
2007-12-30 23:24:06 +01:00
|
|
|
Contents.ImmVal = immVal;
|
2007-12-30 05:40:25 +01: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.
llvm-svn: 57748
2008-10-18 04:06:02 +02:00
|
|
|
void setOffset(int64_t Offset) {
|
2009-10-30 01:39:25 +01:00
|
|
|
assert((isGlobal() || isSymbol() || isCPI() || isBlockAddress()) &&
|
2007-12-30 05:40:25 +01:00
|
|
|
"Wrong MachineOperand accessor");
|
2010-10-19 22:56:32 +02:00
|
|
|
SmallContents.OffsetLo = unsigned(Offset);
|
|
|
|
Contents.OffsetedInfo.OffsetHi = int(Offset >> 32);
|
2007-12-30 05:40:25 +01:00
|
|
|
}
|
2010-09-15 18:08:15 +02:00
|
|
|
|
2007-12-30 23:24:06 +01:00
|
|
|
void setIndex(int Idx) {
|
2008-10-03 17:45:36 +02:00
|
|
|
assert((isFI() || isCPI() || isJTI()) &&
|
2007-12-30 23:24:06 +01:00
|
|
|
"Wrong MachineOperand accessor");
|
|
|
|
Contents.OffsetedInfo.Val.Index = Idx;
|
2007-12-30 05:40:25 +01:00
|
|
|
}
|
2010-09-15 18:08:15 +02:00
|
|
|
|
2007-12-31 00:10:15 +01:00
|
|
|
void setMBB(MachineBasicBlock *MBB) {
|
2008-10-03 17:45:36 +02:00
|
|
|
assert(isMBB() && "Wrong MachineOperand accessor");
|
2007-12-30 23:24:06 +01:00
|
|
|
Contents.MBB = MBB;
|
2007-12-30 05:40:25 +01:00
|
|
|
}
|
2010-09-15 18:08:15 +02:00
|
|
|
|
2007-12-30 22:56:09 +01:00
|
|
|
//===--------------------------------------------------------------------===//
|
|
|
|
// Other methods.
|
|
|
|
//===--------------------------------------------------------------------===//
|
2010-09-15 18:08:15 +02:00
|
|
|
|
2007-12-30 05:40:25 +01: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;
|
2010-09-15 18:08:15 +02:00
|
|
|
|
2007-12-30 05:40:25 +01:00
|
|
|
/// 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 22:31:53 +01:00
|
|
|
/// the setImm method should be used.
|
2008-01-01 02:12:31 +01:00
|
|
|
void ChangeToImmediate(int64_t ImmVal);
|
2010-09-15 18:08:15 +02:00
|
|
|
|
2007-12-30 05:40:25 +01: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 10:49:04 +02:00
|
|
|
bool isKill = false, bool isDead = false,
|
2010-02-10 01:41:49 +01:00
|
|
|
bool isUndef = false, bool isDebug = false);
|
2010-09-15 18:08:15 +02:00
|
|
|
|
2007-12-30 22:56:09 +01:00
|
|
|
//===--------------------------------------------------------------------===//
|
|
|
|
// Construction methods.
|
|
|
|
//===--------------------------------------------------------------------===//
|
2010-09-15 18:08:15 +02:00
|
|
|
|
2007-12-30 05:40:25 +01:00
|
|
|
static MachineOperand CreateImm(int64_t Val) {
|
2007-12-30 23:24:06 +01:00
|
|
|
MachineOperand Op(MachineOperand::MO_Immediate);
|
|
|
|
Op.setImm(Val);
|
2007-12-30 05:40:25 +01:00
|
|
|
return Op;
|
|
|
|
}
|
2010-09-15 18:08:15 +02:00
|
|
|
|
2011-06-24 22:46:11 +02:00
|
|
|
static MachineOperand CreateCImm(const ConstantInt *CI) {
|
|
|
|
MachineOperand Op(MachineOperand::MO_CImmediate);
|
|
|
|
Op.Contents.CI = CI;
|
|
|
|
return Op;
|
|
|
|
}
|
|
|
|
|
2008-09-12 20:08:03 +02:00
|
|
|
static MachineOperand CreateFPImm(const ConstantFP *CFP) {
|
2008-02-14 08:39:30 +01:00
|
|
|
MachineOperand Op(MachineOperand::MO_FPImmediate);
|
|
|
|
Op.Contents.CFP = CFP;
|
|
|
|
return Op;
|
|
|
|
}
|
2010-09-15 18:08:15 +02:00
|
|
|
|
2007-12-30 05:40:25 +01:00
|
|
|
static MachineOperand CreateReg(unsigned Reg, bool isDef, bool isImp = false,
|
|
|
|
bool isKill = false, bool isDead = false,
|
2009-06-30 10:49:04 +02:00
|
|
|
bool isUndef = false,
|
|
|
|
bool isEarlyClobber = false,
|
2010-02-06 03:28:32 +01:00
|
|
|
unsigned SubReg = 0,
|
|
|
|
bool isDebug = false) {
|
2007-12-30 23:24:06 +01:00
|
|
|
MachineOperand Op(MachineOperand::MO_Register);
|
2007-12-30 05:40:25 +01:00
|
|
|
Op.IsDef = isDef;
|
|
|
|
Op.IsImp = isImp;
|
|
|
|
Op.IsKill = isKill;
|
|
|
|
Op.IsDead = isDead;
|
2009-06-30 10:49:04 +02:00
|
|
|
Op.IsUndef = isUndef;
|
2011-12-07 01:22:07 +01:00
|
|
|
Op.IsInternalRead = false;
|
2008-09-12 19:49:03 +02:00
|
|
|
Op.IsEarlyClobber = isEarlyClobber;
|
2010-02-06 03:28:32 +01:00
|
|
|
Op.IsDebug = isDebug;
|
2010-10-19 22:56:32 +02:00
|
|
|
Op.SmallContents.RegNo = Reg;
|
2008-01-01 02:12:31 +01:00
|
|
|
Op.Contents.Reg.Prev = 0;
|
|
|
|
Op.Contents.Reg.Next = 0;
|
2007-12-30 22:31:53 +01:00
|
|
|
Op.SubReg = SubReg;
|
2007-12-30 05:40:25 +01:00
|
|
|
return Op;
|
|
|
|
}
|
2009-06-25 03:16:22 +02:00
|
|
|
static MachineOperand CreateMBB(MachineBasicBlock *MBB,
|
|
|
|
unsigned char TargetFlags = 0) {
|
2007-12-30 23:24:06 +01:00
|
|
|
MachineOperand Op(MachineOperand::MO_MachineBasicBlock);
|
2007-12-31 00:10:15 +01:00
|
|
|
Op.setMBB(MBB);
|
2009-06-25 03:16:22 +02:00
|
|
|
Op.setTargetFlags(TargetFlags);
|
2007-12-30 05:40:25 +01:00
|
|
|
return Op;
|
|
|
|
}
|
2011-05-17 20:29:21 +02:00
|
|
|
static MachineOperand CreateFI(int Idx) {
|
2007-12-30 23:24:06 +01:00
|
|
|
MachineOperand Op(MachineOperand::MO_FrameIndex);
|
|
|
|
Op.setIndex(Idx);
|
2007-12-30 05:40:25 +01:00
|
|
|
return Op;
|
|
|
|
}
|
2009-06-25 03:16:22 +02:00
|
|
|
static MachineOperand CreateCPI(unsigned Idx, int Offset,
|
|
|
|
unsigned char TargetFlags = 0) {
|
2007-12-30 23:24:06 +01:00
|
|
|
MachineOperand Op(MachineOperand::MO_ConstantPoolIndex);
|
|
|
|
Op.setIndex(Idx);
|
|
|
|
Op.setOffset(Offset);
|
2009-06-25 03:16:22 +02:00
|
|
|
Op.setTargetFlags(TargetFlags);
|
2007-12-30 05:40:25 +01:00
|
|
|
return Op;
|
|
|
|
}
|
2009-06-25 03:16:22 +02:00
|
|
|
static MachineOperand CreateJTI(unsigned Idx,
|
|
|
|
unsigned char TargetFlags = 0) {
|
2007-12-30 23:24:06 +01:00
|
|
|
MachineOperand Op(MachineOperand::MO_JumpTableIndex);
|
|
|
|
Op.setIndex(Idx);
|
2009-06-25 03:16:22 +02:00
|
|
|
Op.setTargetFlags(TargetFlags);
|
2007-12-30 05:40:25 +01:00
|
|
|
return Op;
|
|
|
|
}
|
2010-04-15 03:51:59 +02:00
|
|
|
static MachineOperand CreateGA(const GlobalValue *GV, int64_t Offset,
|
2009-06-25 03:16:22 +02:00
|
|
|
unsigned char TargetFlags = 0) {
|
2007-12-30 23:24:06 +01:00
|
|
|
MachineOperand Op(MachineOperand::MO_GlobalAddress);
|
|
|
|
Op.Contents.OffsetedInfo.Val.GV = GV;
|
|
|
|
Op.setOffset(Offset);
|
2009-06-25 03:16:22 +02:00
|
|
|
Op.setTargetFlags(TargetFlags);
|
2009-07-01 21:08:07 +02:00
|
|
|
return Op;
|
|
|
|
}
|
2009-09-02 00:06:46 +02:00
|
|
|
static MachineOperand CreateES(const char *SymName,
|
2009-06-25 03:16:22 +02:00
|
|
|
unsigned char TargetFlags = 0) {
|
2007-12-30 23:24:06 +01:00
|
|
|
MachineOperand Op(MachineOperand::MO_ExternalSymbol);
|
|
|
|
Op.Contents.OffsetedInfo.Val.SymbolName = SymName;
|
2009-09-02 00:06:46 +02:00
|
|
|
Op.setOffset(0); // Offset is always 0.
|
2009-06-25 03:16:22 +02:00
|
|
|
Op.setTargetFlags(TargetFlags);
|
2007-12-30 05:40:25 +01:00
|
|
|
return Op;
|
|
|
|
}
|
2010-04-15 03:51:59 +02:00
|
|
|
static MachineOperand CreateBA(const BlockAddress *BA,
|
2009-11-21 00:18:13 +01:00
|
|
|
unsigned char TargetFlags = 0) {
|
2009-10-30 01:20:08 +01:00
|
|
|
MachineOperand Op(MachineOperand::MO_BlockAddress);
|
|
|
|
Op.Contents.OffsetedInfo.Val.BA = BA;
|
|
|
|
Op.setOffset(0); // Offset is always 0.
|
2009-11-21 00:18:13 +01:00
|
|
|
Op.setTargetFlags(TargetFlags);
|
2009-10-30 01:20:08 +01:00
|
|
|
return Op;
|
|
|
|
}
|
2012-01-16 20:22:00 +01:00
|
|
|
/// CreateRegMask - Creates a register mask operand referencing Mask. The
|
|
|
|
/// operand does not take ownership of the memory referenced by Mask, it must
|
|
|
|
/// remain valid for the lifetime of the operand.
|
|
|
|
///
|
|
|
|
/// A RegMask operand represents a set of non-clobbered physical registers on
|
|
|
|
/// an instruction that clobbers many registers, typically a call. The bit
|
|
|
|
/// mask has a bit set for each physreg that is preserved by this
|
|
|
|
/// instruction, as described in the documentation for
|
|
|
|
/// TargetRegisterInfo::getCallPreservedMask().
|
|
|
|
///
|
|
|
|
/// Any physreg with a 0 bit in the mask is clobbered by the instruction.
|
|
|
|
///
|
|
|
|
static MachineOperand CreateRegMask(const uint32_t *Mask) {
|
2012-02-03 00:52:57 +01:00
|
|
|
assert(Mask && "Missing register mask");
|
2012-01-16 20:22:00 +01:00
|
|
|
MachineOperand Op(MachineOperand::MO_RegisterMask);
|
|
|
|
Op.Contents.RegMask = Mask;
|
|
|
|
return Op;
|
|
|
|
}
|
2010-02-26 20:39:56 +01:00
|
|
|
static MachineOperand CreateMetadata(const MDNode *Meta) {
|
2010-01-12 03:01:53 +01:00
|
|
|
MachineOperand Op(MachineOperand::MO_Metadata);
|
|
|
|
Op.Contents.MD = Meta;
|
|
|
|
return Op;
|
|
|
|
}
|
2007-12-30 05:40:25 +01:00
|
|
|
|
2010-03-13 09:14:18 +01:00
|
|
|
static MachineOperand CreateMCSymbol(MCSymbol *Sym) {
|
|
|
|
MachineOperand Op(MachineOperand::MO_MCSymbol);
|
|
|
|
Op.Contents.Sym = Sym;
|
|
|
|
return Op;
|
|
|
|
}
|
2010-09-15 18:08:15 +02:00
|
|
|
|
2007-12-30 05:40:25 +01:00
|
|
|
friend class MachineInstr;
|
2008-01-01 02:12:31 +01: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 17:45:36 +02:00
|
|
|
assert(isReg() && "Can only add reg operand to use lists");
|
2008-01-01 02:12:31 +01:00
|
|
|
return Contents.Reg.Prev != 0;
|
|
|
|
}
|
2010-09-15 18:08:15 +02:00
|
|
|
|
2008-01-01 02:12:31 +01:00
|
|
|
/// 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 03:17:37 +02:00
|
|
|
/// RemoveRegOperandFromRegInfo - Remove this register operand from the
|
|
|
|
/// MachineRegisterInfo it is linked with.
|
|
|
|
void RemoveRegOperandFromRegInfo();
|
2007-12-30 05:40:25 +01:00
|
|
|
};
|
|
|
|
|
2008-08-21 02:14:44 +02:00
|
|
|
inline raw_ostream &operator<<(raw_ostream &OS, const MachineOperand& MO) {
|
|
|
|
MO.print(OS, 0);
|
|
|
|
return OS;
|
|
|
|
}
|
|
|
|
|
2007-12-30 05:40:25 +01:00
|
|
|
} // End llvm namespace
|
|
|
|
|
|
|
|
#endif
|