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
|
|
|
|
|
2010-11-29 18:16:10 +00:00
|
|
|
#include "llvm/Support/DataTypes.h"
|
2007-12-30 04:40:25 +00:00
|
|
|
#include <cassert>
|
|
|
|
|
|
|
|
namespace llvm {
|
2010-09-15 16:08:15 +00:00
|
|
|
|
2009-10-30 00:20:08 +00:00
|
|
|
class BlockAddress;
|
2010-03-03 01:37:50 +00:00
|
|
|
class ConstantFP;
|
2011-06-24 20:46:11 +00:00
|
|
|
class ConstantInt;
|
2007-12-30 04:40:25 +00:00
|
|
|
class GlobalValue;
|
2010-03-03 01:37:50 +00:00
|
|
|
class MachineBasicBlock;
|
2007-12-30 21:56:09 +00:00
|
|
|
class MachineInstr;
|
2008-01-01 01:12:31 +00:00
|
|
|
class MachineRegisterInfo;
|
2010-01-12 02:01:53 +00:00
|
|
|
class MDNode;
|
2010-03-03 01:37:50 +00:00
|
|
|
class TargetMachine;
|
2010-05-28 18:18:53 +00:00
|
|
|
class TargetRegisterInfo;
|
2012-09-05 18:19:08 +00:00
|
|
|
class hash_code;
|
2008-08-21 00:14:44 +00:00
|
|
|
class raw_ostream;
|
2010-03-13 08:14:18 +00:00
|
|
|
class MCSymbol;
|
2010-09-15 16:08:15 +00:00
|
|
|
|
2007-12-30 04:40:25 +00:00
|
|
|
/// MachineOperand class - Representation of each machine instruction operand.
|
|
|
|
///
|
2013-01-05 05:00:09 +00:00
|
|
|
/// This class isn't a POD type because it has a private constructor, but its
|
|
|
|
/// destructor must be trivial. Functions like MachineInstr::addOperand(),
|
|
|
|
/// MachineRegisterInfo::moveOperands(), and MF::DeleteMachineInstr() depend on
|
|
|
|
/// not having to call the MachineOperand destructor.
|
|
|
|
///
|
2007-12-30 04:40:25 +00:00
|
|
|
class MachineOperand {
|
|
|
|
public:
|
|
|
|
enum MachineOperandType {
|
2009-06-21 01:52:00 +00:00
|
|
|
MO_Register, ///< Register operand.
|
|
|
|
MO_Immediate, ///< Immediate operand
|
2011-06-24 20:46:11 +00:00
|
|
|
MO_CImmediate, ///< Immediate >64bit operand
|
2009-06-21 01:52:00 +00: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
|
2012-08-07 18:56:39 +00:00
|
|
|
MO_TargetIndex, ///< Target-dependent index+offset operand.
|
2009-06-21 01:52:00 +00:00
|
|
|
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
|
2010-01-12 02:01:53 +00:00
|
|
|
MO_BlockAddress, ///< Address of a basic block
|
2012-01-16 19:22:00 +00:00
|
|
|
MO_RegisterMask, ///< Mask of preserved registers.
|
2010-03-13 08:14:18 +00:00
|
|
|
MO_Metadata, ///< Metadata reference (for debug info)
|
|
|
|
MO_MCSymbol ///< MCSymbol reference (for debug/eh 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
|
2010-09-15 16:08:15 +00:00
|
|
|
|
2013-01-07 23:21:44 +00:00
|
|
|
/// Subregister number for MO_Register. A value of 0 indicates the
|
|
|
|
/// MO_Register has no subReg.
|
|
|
|
///
|
|
|
|
/// For all other kinds of operands, this field holds target-specific flags.
|
|
|
|
unsigned SubReg_TargetFlags : 12;
|
2010-09-15 16:08:15 +00:00
|
|
|
|
2012-09-04 18:36:28 +00:00
|
|
|
/// TiedTo - Non-zero when this register operand is tied to another register
|
|
|
|
/// operand. The encoding of this field is described in the block comment
|
|
|
|
/// before MachineInstr::tieOperands().
|
|
|
|
unsigned char TiedTo : 4;
|
|
|
|
|
2007-12-30 22:24:06 +00:00
|
|
|
/// IsDef/IsImp/IsKill/IsDead flags - These are only valid for MO_Register
|
|
|
|
/// operands.
|
2010-09-15 16:08:15 +00:00
|
|
|
|
2007-12-30 22:24:06 +00:00
|
|
|
/// IsDef - True if this is a def, false if this is a use of the register.
|
|
|
|
///
|
|
|
|
bool IsDef : 1;
|
2010-09-15 16:08:15 +00:00
|
|
|
|
2007-12-30 22:24:06 +00:00
|
|
|
/// 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
|
|
|
|
2011-10-04 21:49:33 +00: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 08:49:04 +00:00
|
|
|
bool IsUndef : 1;
|
|
|
|
|
2011-12-07 00:22:07 +00: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-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;
|
|
|
|
|
2010-02-06 02:28:32 +00: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-26 22:54:27 +00: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 20:56:32 +00: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 16:08:15 +00:00
|
|
|
/// ParentMI - This is the instruction that this operand is embedded into.
|
2007-12-30 22:24:06 +00:00
|
|
|
/// 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.
|
2011-06-24 20:46:11 +00:00
|
|
|
const ConstantInt *CI; // For MO_CImmediate. Integers > 64bit.
|
2007-12-30 22:24:06 +00:00
|
|
|
int64_t ImmVal; // For MO_Immediate.
|
2012-01-16 19:22:00 +00:00
|
|
|
const uint32_t *RegMask; // For MO_RegisterMask.
|
2010-02-26 19:39:56 +00:00
|
|
|
const MDNode *MD; // For MO_Metadata.
|
2010-03-13 08:14:18 +00:00
|
|
|
MCSymbol *Sym; // For MO_MCSymbol
|
2008-01-01 01:12:31 +00:00
|
|
|
|
|
|
|
struct { // For MO_Register.
|
2010-10-19 20:56:32 +00:00
|
|
|
// Register number is in SmallContents.RegNo.
|
2012-08-10 00:21:30 +00:00
|
|
|
MachineOperand *Prev; // Access list for register. See MRI.
|
2008-01-01 01:12:31 +00:00
|
|
|
MachineOperand *Next;
|
|
|
|
} Reg;
|
2010-09-15 16:08:15 +00:00
|
|
|
|
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.
|
2010-04-15 01:51:59 +00:00
|
|
|
const GlobalValue *GV; // For MO_GlobalAddress.
|
|
|
|
const BlockAddress *BA; // For MO_BlockAddress.
|
2007-12-30 22:24:06 +00:00
|
|
|
} Val;
|
2010-10-19 20:56:32 +00:00
|
|
|
// Low bits of offset are in SmallContents.OffsetLo.
|
|
|
|
int OffsetHi; // An offset from the object, high 32 bits.
|
2007-12-30 22:24:06 +00:00
|
|
|
} OffsetedInfo;
|
|
|
|
} Contents;
|
2010-09-15 16:08:15 +00:00
|
|
|
|
2013-01-07 23:21:44 +00:00
|
|
|
explicit MachineOperand(MachineOperandType K)
|
|
|
|
: OpKind(K), SubReg_TargetFlags(0), ParentMI(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; }
|
2010-09-15 16:08:15 +00:00
|
|
|
|
2013-01-07 23:21:44 +00:00
|
|
|
unsigned getTargetFlags() const {
|
|
|
|
return isReg() ? 0 : SubReg_TargetFlags;
|
2012-08-28 18:05:48 +00:00
|
|
|
}
|
2013-01-07 23:21:44 +00:00
|
|
|
void setTargetFlags(unsigned F) {
|
2012-08-28 18:05:48 +00:00
|
|
|
assert(!isReg() && "Register operands can't have target flags");
|
2013-01-07 23:21:44 +00:00
|
|
|
SubReg_TargetFlags = F;
|
|
|
|
assert(SubReg_TargetFlags == F && "Target flags out of range");
|
2012-08-28 18:05:48 +00:00
|
|
|
}
|
2013-01-07 23:21:44 +00:00
|
|
|
void addTargetFlag(unsigned F) {
|
2012-08-28 18:05:48 +00:00
|
|
|
assert(!isReg() && "Register operands can't have target flags");
|
2013-01-07 23:21:44 +00:00
|
|
|
SubReg_TargetFlags |= F;
|
|
|
|
assert((SubReg_TargetFlags & F) && "Target flags out of range");
|
2012-08-28 18:05:48 +00:00
|
|
|
}
|
2010-09-15 16:08:15 +00:00
|
|
|
|
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; }
|
2010-09-15 16:08:15 +00:00
|
|
|
|
2011-01-09 05:33:21 +00: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 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; }
|
2011-06-24 20:46:11 +00:00
|
|
|
/// isCImm - Test if t his is a MO_CImmediate operand.
|
|
|
|
bool isCImm() const { return OpKind == MO_CImmediate; }
|
2008-10-03 15:45:36 +00: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; }
|
2012-08-07 18:56:39 +00:00
|
|
|
/// isTargetIndex - Tests if this is a MO_TargetIndex operand.
|
|
|
|
bool isTargetIndex() const { return OpKind == MO_TargetIndex; }
|
2008-10-03 15:45:36 +00:00
|
|
|
/// 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 00:20:08 +00:00
|
|
|
/// isBlockAddress - Tests if this is a MO_BlockAddress operand.
|
|
|
|
bool isBlockAddress() const { return OpKind == MO_BlockAddress; }
|
2012-01-16 19:22:00 +00:00
|
|
|
/// isRegMask - Tests if this is a MO_RegisterMask operand.
|
|
|
|
bool isRegMask() const { return OpKind == MO_RegisterMask; }
|
2010-01-12 02:01:53 +00:00
|
|
|
/// isMetadata - Tests if this is a MO_Metadata operand.
|
|
|
|
bool isMetadata() const { return OpKind == MO_Metadata; }
|
2010-03-13 08:14:18 +00:00
|
|
|
bool isMCSymbol() const { return OpKind == MO_MCSymbol; }
|
2007-12-30 04:40:25 +00:00
|
|
|
|
2012-01-16 19:22:00 +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!");
|
2010-10-19 20:56:32 +00:00
|
|
|
return SmallContents.RegNo;
|
2007-12-30 21:56:09 +00:00
|
|
|
}
|
2010-09-15 16:08:15 +00:00
|
|
|
|
2007-12-30 21:56:09 +00:00
|
|
|
unsigned getSubReg() const {
|
2008-10-03 15:45:36 +00:00
|
|
|
assert(isReg() && "Wrong MachineOperand accessor");
|
2013-01-07 23:21:44 +00:00
|
|
|
return SubReg_TargetFlags;
|
2007-12-30 21:56:09 +00:00
|
|
|
}
|
2010-09-15 16:08:15 +00:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
2010-09-15 16:08:15 +00:00
|
|
|
|
2007-12-30 21:56:09 +00:00
|
|
|
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;
|
|
|
|
}
|
2010-09-15 16:08:15 +00:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
2010-09-15 16:08:15 +00:00
|
|
|
|
2007-12-30 21:56:09 +00:00
|
|
|
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;
|
|
|
|
}
|
2010-09-15 16:08:15 +00:00
|
|
|
|
2007-12-30 21:56:09 +00:00
|
|
|
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;
|
|
|
|
}
|
2010-09-15 16:08:15 +00:00
|
|
|
|
2009-06-30 08:49:04 +00:00
|
|
|
bool isUndef() const {
|
|
|
|
assert(isReg() && "Wrong MachineOperand accessor");
|
|
|
|
return IsUndef;
|
|
|
|
}
|
2010-09-15 16:08:15 +00:00
|
|
|
|
2011-12-07 00:22:07 +00:00
|
|
|
bool isInternalRead() const {
|
|
|
|
assert(isReg() && "Wrong MachineOperand accessor");
|
|
|
|
return IsInternalRead;
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
Add a MachineOperand::isTied() flag.
While in SSA form, a MachineInstr can have pairs of tied defs and uses.
The tied operands are used to represent read-modify-write operands that
must be assigned the same physical register.
Previously, tied operand pairs were computed from fixed MCInstrDesc
fields, or by using black magic on inline assembly instructions.
The isTied flag makes it possible to add tied operands to any
instruction while getting rid of (some of) the inlineasm magic.
Tied operands on normal instructions are needed to represent predicated
individual instructions in SSA form. An extra <tied,imp-use> operand is
required to represent the output value when the instruction predicate is
false.
Adding a predicate to:
%vreg0<def> = ADD %vreg1, %vreg2
Will look like:
%vreg0<tied,def> = ADD %vreg1, %vreg2, pred:3, %vreg7<tied,imp-use>
The virtual register %vreg7 is the value given to %vreg0 when the
predicate is false. It will be assigned the same physreg as %vreg0.
This commit adds the isTied flag and sets it based on MCInstrDesc when
building an instruction. The flag is not used for anything yet.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@162774 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-28 18:34:41 +00:00
|
|
|
bool isTied() const {
|
|
|
|
assert(isReg() && "Wrong MachineOperand accessor");
|
2012-09-04 18:36:28 +00:00
|
|
|
return TiedTo;
|
Add a MachineOperand::isTied() flag.
While in SSA form, a MachineInstr can have pairs of tied defs and uses.
The tied operands are used to represent read-modify-write operands that
must be assigned the same physical register.
Previously, tied operand pairs were computed from fixed MCInstrDesc
fields, or by using black magic on inline assembly instructions.
The isTied flag makes it possible to add tied operands to any
instruction while getting rid of (some of) the inlineasm magic.
Tied operands on normal instructions are needed to represent predicated
individual instructions in SSA form. An extra <tied,imp-use> operand is
required to represent the output value when the instruction predicate is
false.
Adding a predicate to:
%vreg0<def> = ADD %vreg1, %vreg2
Will look like:
%vreg0<tied,def> = ADD %vreg1, %vreg2, pred:3, %vreg7<tied,imp-use>
The virtual register %vreg7 is the value given to %vreg0 when the
predicate is false. It will be assigned the same physreg as %vreg0.
This commit adds the isTied flag and sets it based on MCInstrDesc when
building an instruction. The flag is not used for anything yet.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@162774 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-28 18:34:41 +00:00
|
|
|
}
|
|
|
|
|
2010-02-06 02:28:32 +00:00
|
|
|
bool isDebug() const {
|
|
|
|
assert(isReg() && "Wrong MachineOperand accessor");
|
|
|
|
return IsDebug;
|
|
|
|
}
|
|
|
|
|
2011-10-04 21:49:33 +00: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 00:22:07 +00:00
|
|
|
///
|
|
|
|
/// This refers to reading the register value from before the current
|
|
|
|
/// instruction or bundle. Internal bundle reads are not included.
|
2011-10-04 21:49:33 +00:00
|
|
|
bool readsReg() const {
|
|
|
|
assert(isReg() && "Wrong MachineOperand accessor");
|
2011-12-07 00:22:07 +00:00
|
|
|
return !isUndef() && !isInternalRead() && (isUse() || getSubReg());
|
2011-10-04 21:49:33 +00:00
|
|
|
}
|
|
|
|
|
2007-12-30 21:56:09 +00:00
|
|
|
//===--------------------------------------------------------------------===//
|
|
|
|
// Mutators for Register Operands
|
|
|
|
//===--------------------------------------------------------------------===//
|
2010-09-15 16:08:15 +00:00
|
|
|
|
2008-01-01 01:12:31 +00:00
|
|
|
/// Change the register this operand corresponds to.
|
|
|
|
///
|
|
|
|
void setReg(unsigned Reg);
|
2010-09-15 16:08:15 +00:00
|
|
|
|
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");
|
2013-01-07 23:21:44 +00:00
|
|
|
SubReg_TargetFlags = subReg;
|
|
|
|
assert(SubReg_TargetFlags == subReg && "SubReg out of range");
|
2007-12-30 21:56:09 +00:00
|
|
|
}
|
2010-05-28 18:18:53 +00: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&);
|
|
|
|
|
2012-08-10 00:21:26 +00:00
|
|
|
void setIsUse(bool Val = true) { setIsDef(!Val); }
|
2010-09-15 16:08:15 +00:00
|
|
|
|
2012-08-10 00:21:26 +00:00
|
|
|
void setIsDef(bool Val = true);
|
2007-12-30 21:56:09 +00:00
|
|
|
|
2010-09-15 16:08:15 +00:00
|
|
|
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");
|
2010-02-09 00:42:08 +00:00
|
|
|
assert((!Val || !isDebug()) && "Marking a debug operation as kill");
|
2007-12-30 21:56:09 +00:00
|
|
|
IsKill = Val;
|
|
|
|
}
|
2010-09-15 16:08:15 +00:00
|
|
|
|
2007-12-30 21:56:09 +00:00
|
|
|
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;
|
|
|
|
}
|
2010-09-15 16:08:15 +00:00
|
|
|
|
2011-12-07 00:22:07 +00:00
|
|
|
void setIsInternalRead(bool Val = true) {
|
|
|
|
assert(isReg() && "Wrong MachineOperand accessor");
|
|
|
|
IsInternalRead = 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
|
|
|
|
2010-03-25 01:38:16 +00:00
|
|
|
void setIsDebug(bool Val = true) {
|
2013-06-16 20:34:09 +00:00
|
|
|
assert(isReg() && !IsDef && "Wrong MachineOperand accessor");
|
2010-03-25 01:38:16 +00:00
|
|
|
IsDebug = Val;
|
|
|
|
}
|
|
|
|
|
2007-12-30 21:56:09 +00:00
|
|
|
//===--------------------------------------------------------------------===//
|
|
|
|
// Accessors for various operand types.
|
|
|
|
//===--------------------------------------------------------------------===//
|
2010-09-15 16:08:15 +00:00
|
|
|
|
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
|
|
|
}
|
2010-09-15 16:08:15 +00:00
|
|
|
|
2011-06-24 20:46:11 +00:00
|
|
|
const ConstantInt *getCImm() const {
|
|
|
|
assert(isCImm() && "Wrong MachineOperand accessor");
|
|
|
|
return Contents.CI;
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
}
|
2010-09-15 16:08:15 +00:00
|
|
|
|
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 {
|
2012-08-07 18:56:39 +00:00
|
|
|
assert((isFI() || isCPI() || isTargetIndex() || 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
|
|
|
}
|
2010-09-15 16:08:15 +00:00
|
|
|
|
2010-04-15 01:51:59 +00:00
|
|
|
const 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
|
|
|
}
|
2009-10-30 00:20:08 +00:00
|
|
|
|
2010-04-15 01:51:59 +00:00
|
|
|
const BlockAddress *getBlockAddress() const {
|
2009-10-30 00:20:08 +00:00
|
|
|
assert(isBlockAddress() && "Wrong MachineOperand accessor");
|
|
|
|
return Contents.OffsetedInfo.Val.BA;
|
|
|
|
}
|
2010-03-13 08:14:18 +00:00
|
|
|
|
|
|
|
MCSymbol *getMCSymbol() const {
|
|
|
|
assert(isMCSymbol() && "Wrong MachineOperand accessor");
|
|
|
|
return Contents.Sym;
|
|
|
|
}
|
2010-09-15 16:08:15 +00:00
|
|
|
|
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 {
|
2012-08-07 18:56:39 +00:00
|
|
|
assert((isGlobal() || isSymbol() || isCPI() || isTargetIndex() ||
|
|
|
|
isBlockAddress()) && "Wrong MachineOperand accessor");
|
2012-08-24 23:29:28 +00:00
|
|
|
return int64_t(uint64_t(Contents.OffsetedInfo.OffsetHi) << 32) |
|
2010-10-19 20:56:32 +00:00
|
|
|
SmallContents.OffsetLo;
|
2007-12-30 04:40:25 +00:00
|
|
|
}
|
2010-09-15 16:08: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
|
|
|
}
|
2010-01-12 02:01:53 +00:00
|
|
|
|
2012-02-10 19:23:53 +00: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 19:27:34 +00:00
|
|
|
/// mask pointers.
|
2012-02-10 19:23:53 +00:00
|
|
|
static bool clobbersPhysReg(const uint32_t *RegMask, unsigned PhysReg) {
|
2012-01-16 19:22:00 +00:00
|
|
|
// See TargetRegisterInfo.h.
|
|
|
|
assert(PhysReg < (1u << 30) && "Not a physical register");
|
2012-02-10 19:23:53 +00: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 19:22:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// getRegMask - Returns a bit mask of registers preserved by this RegMask
|
2012-02-02 23:52:57 +00:00
|
|
|
/// operand.
|
2012-01-16 19:22:00 +00:00
|
|
|
const uint32_t *getRegMask() const {
|
|
|
|
assert(isRegMask() && "Wrong MachineOperand accessor");
|
|
|
|
return Contents.RegMask;
|
|
|
|
}
|
|
|
|
|
2010-01-13 00:00:24 +00:00
|
|
|
const MDNode *getMetadata() const {
|
2010-01-12 02:01:53 +00:00
|
|
|
assert(isMetadata() && "Wrong MachineOperand accessor");
|
|
|
|
return Contents.MD;
|
|
|
|
}
|
2010-09-15 16:08:15 +00:00
|
|
|
|
2007-12-30 21:56:09 +00:00
|
|
|
//===--------------------------------------------------------------------===//
|
|
|
|
// Mutators for various operand types.
|
|
|
|
//===--------------------------------------------------------------------===//
|
2010-09-15 16:08:15 +00:00
|
|
|
|
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) {
|
2012-08-07 18:56:39 +00:00
|
|
|
assert((isGlobal() || isSymbol() || isCPI() || isTargetIndex() ||
|
|
|
|
isBlockAddress()) && "Wrong MachineOperand accessor");
|
2010-10-19 20:56:32 +00:00
|
|
|
SmallContents.OffsetLo = unsigned(Offset);
|
|
|
|
Contents.OffsetedInfo.OffsetHi = int(Offset >> 32);
|
2007-12-30 04:40:25 +00:00
|
|
|
}
|
2010-09-15 16:08:15 +00:00
|
|
|
|
2007-12-30 22:24:06 +00:00
|
|
|
void setIndex(int Idx) {
|
2012-08-07 18:56:39 +00:00
|
|
|
assert((isFI() || isCPI() || isTargetIndex() || 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
|
|
|
}
|
2010-09-15 16:08:15 +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
|
|
|
}
|
2010-09-15 16:08:15 +00:00
|
|
|
|
2007-12-30 21:56:09 +00:00
|
|
|
//===--------------------------------------------------------------------===//
|
|
|
|
// Other methods.
|
|
|
|
//===--------------------------------------------------------------------===//
|
2010-09-15 16:08:15 +00:00
|
|
|
|
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;
|
2010-09-15 16:08:15 +00:00
|
|
|
|
2012-07-05 11:06:22 +00:00
|
|
|
/// \brief MachineOperand hash_value overload.
|
|
|
|
///
|
|
|
|
/// Note that this includes the same information in the hash that
|
|
|
|
/// isIdenticalTo uses for comparison. It is thus suited for use in hash
|
|
|
|
/// tables which use that function for equality comparisons only.
|
|
|
|
friend hash_code hash_value(const MachineOperand &MO);
|
|
|
|
|
2007-12-30 04:40:25 +00: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 21:31:53 +00:00
|
|
|
/// the setImm method should be used.
|
2008-01-01 01:12:31 +00:00
|
|
|
void ChangeToImmediate(int64_t ImmVal);
|
2010-09-15 16:08:15 +00:00
|
|
|
|
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,
|
2010-02-10 00:41:49 +00:00
|
|
|
bool isUndef = false, bool isDebug = false);
|
2010-09-15 16:08:15 +00:00
|
|
|
|
2007-12-30 21:56:09 +00:00
|
|
|
//===--------------------------------------------------------------------===//
|
|
|
|
// Construction methods.
|
|
|
|
//===--------------------------------------------------------------------===//
|
2010-09-15 16:08:15 +00:00
|
|
|
|
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;
|
|
|
|
}
|
2010-09-15 16:08:15 +00:00
|
|
|
|
2011-06-24 20:46:11 +00:00
|
|
|
static MachineOperand CreateCImm(const ConstantInt *CI) {
|
|
|
|
MachineOperand Op(MachineOperand::MO_CImmediate);
|
|
|
|
Op.Contents.CI = CI;
|
|
|
|
return Op;
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
}
|
2010-09-15 16:08:15 +00:00
|
|
|
|
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,
|
2010-02-06 02:28:32 +00:00
|
|
|
unsigned SubReg = 0,
|
2012-06-07 04:43:52 +00:00
|
|
|
bool isDebug = false,
|
|
|
|
bool isInternalRead = false) {
|
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;
|
2012-06-07 04:43:52 +00:00
|
|
|
Op.IsInternalRead = isInternalRead;
|
2008-09-12 17:49:03 +00:00
|
|
|
Op.IsEarlyClobber = isEarlyClobber;
|
2012-09-04 18:36:28 +00:00
|
|
|
Op.TiedTo = 0;
|
2010-02-06 02:28:32 +00:00
|
|
|
Op.IsDebug = isDebug;
|
2010-10-19 20:56:32 +00:00
|
|
|
Op.SmallContents.RegNo = Reg;
|
2008-01-01 01:12:31 +00:00
|
|
|
Op.Contents.Reg.Prev = 0;
|
|
|
|
Op.Contents.Reg.Next = 0;
|
2013-01-07 23:21:44 +00:00
|
|
|
Op.setSubReg(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;
|
|
|
|
}
|
2011-05-17 18:29:21 +00:00
|
|
|
static MachineOperand CreateFI(int 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;
|
|
|
|
}
|
2012-08-07 18:56:39 +00:00
|
|
|
static MachineOperand CreateTargetIndex(unsigned Idx, int64_t Offset,
|
|
|
|
unsigned char TargetFlags = 0) {
|
|
|
|
MachineOperand Op(MachineOperand::MO_TargetIndex);
|
|
|
|
Op.setIndex(Idx);
|
|
|
|
Op.setOffset(Offset);
|
|
|
|
Op.setTargetFlags(TargetFlags);
|
|
|
|
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;
|
|
|
|
}
|
2010-04-15 01:51:59 +00:00
|
|
|
static MachineOperand CreateGA(const GlobalValue *GV, int64_t Offset,
|
2009-06-25 01:16:22 +00:00
|
|
|
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;
|
|
|
|
}
|
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;
|
|
|
|
}
|
2012-09-12 21:43:09 +00:00
|
|
|
static MachineOperand CreateBA(const BlockAddress *BA, int64_t Offset,
|
2009-11-20 23:18:13 +00:00
|
|
|
unsigned char TargetFlags = 0) {
|
2009-10-30 00:20:08 +00:00
|
|
|
MachineOperand Op(MachineOperand::MO_BlockAddress);
|
|
|
|
Op.Contents.OffsetedInfo.Val.BA = BA;
|
2012-09-12 21:43:09 +00:00
|
|
|
Op.setOffset(Offset);
|
2009-11-20 23:18:13 +00:00
|
|
|
Op.setTargetFlags(TargetFlags);
|
2009-10-30 00:20:08 +00:00
|
|
|
return Op;
|
|
|
|
}
|
2012-01-16 19:22:00 +00: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-02 23:52:57 +00:00
|
|
|
assert(Mask && "Missing register mask");
|
2012-01-16 19:22:00 +00:00
|
|
|
MachineOperand Op(MachineOperand::MO_RegisterMask);
|
|
|
|
Op.Contents.RegMask = Mask;
|
|
|
|
return Op;
|
|
|
|
}
|
2010-02-26 19:39:56 +00:00
|
|
|
static MachineOperand CreateMetadata(const MDNode *Meta) {
|
2010-01-12 02:01:53 +00:00
|
|
|
MachineOperand Op(MachineOperand::MO_Metadata);
|
|
|
|
Op.Contents.MD = Meta;
|
|
|
|
return Op;
|
|
|
|
}
|
2007-12-30 04:40:25 +00:00
|
|
|
|
2010-03-13 08:14:18 +00:00
|
|
|
static MachineOperand CreateMCSymbol(MCSymbol *Sym) {
|
|
|
|
MachineOperand Op(MachineOperand::MO_MCSymbol);
|
|
|
|
Op.Contents.Sym = Sym;
|
|
|
|
return Op;
|
|
|
|
}
|
2010-09-15 16:08:15 +00:00
|
|
|
|
2007-12-30 04:40:25 +00:00
|
|
|
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;
|
|
|
|
}
|
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;
|
|
|
|
}
|
|
|
|
|
2012-10-31 00:46:18 +00:00
|
|
|
// See friend declaration above. This additional declaration is required in
|
|
|
|
// order to compile LLVM with IBM xlC compiler.
|
|
|
|
hash_code hash_value(const MachineOperand &MO);
|
2007-12-30 04:40:25 +00:00
|
|
|
} // End llvm namespace
|
|
|
|
|
|
|
|
#endif
|