2003-09-30 18:37:50 +00:00
|
|
|
//===-- llvm/CodeGen/MachineInstr.h - MachineInstr class --------*- C++ -*-===//
|
2005-04-21 20:39:54 +00:00
|
|
|
//
|
2003-10-20 20:19:47 +00:00
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2007-12-29 19:59:42 +00:00
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
2005-04-21 20:39:54 +00:00
|
|
|
//
|
2003-10-20 20:19:47 +00:00
|
|
|
//===----------------------------------------------------------------------===//
|
2002-02-03 07:11:59 +00:00
|
|
|
//
|
|
|
|
// This file contains the declaration of the MachineInstr class, which is the
|
2003-08-21 22:14:26 +00:00
|
|
|
// basic representation for all target dependent machine instructions used by
|
2002-02-03 07:11:59 +00:00
|
|
|
// the back end.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
2001-07-21 12:39:03 +00:00
|
|
|
|
|
|
|
#ifndef LLVM_CODEGEN_MACHINEINSTR_H
|
|
|
|
#define LLVM_CODEGEN_MACHINEINSTR_H
|
|
|
|
|
2008-07-28 21:51:04 +00:00
|
|
|
#include "llvm/ADT/ilist.h"
|
|
|
|
#include "llvm/ADT/ilist_node.h"
|
|
|
|
#include "llvm/ADT/STLExtras.h"
|
2007-12-30 04:40:25 +00:00
|
|
|
#include "llvm/CodeGen/MachineOperand.h"
|
2008-04-07 19:35:22 +00:00
|
|
|
#include "llvm/CodeGen/MachineMemOperand.h"
|
2008-08-14 23:25:30 +00:00
|
|
|
#include "llvm/Target/TargetInstrDesc.h"
|
2009-06-19 22:08:58 +00:00
|
|
|
#include "llvm/Support/DebugLoc.h"
|
2008-07-28 21:51:04 +00:00
|
|
|
#include <list>
|
2008-05-29 19:52:31 +00:00
|
|
|
#include <vector>
|
2003-06-11 14:01:36 +00:00
|
|
|
|
2003-11-11 22:41:34 +00:00
|
|
|
namespace llvm {
|
|
|
|
|
2008-01-07 07:27:27 +00:00
|
|
|
class TargetInstrDesc;
|
2008-03-13 00:44:09 +00:00
|
|
|
class TargetInstrInfo;
|
2008-02-10 18:45:23 +00:00
|
|
|
class TargetRegisterInfo;
|
2008-07-07 23:14:23 +00:00
|
|
|
class MachineFunction;
|
2004-02-12 02:27:10 +00:00
|
|
|
|
2003-06-03 15:42:53 +00:00
|
|
|
//===----------------------------------------------------------------------===//
|
2006-05-04 18:16:01 +00:00
|
|
|
/// MachineInstr - Representation of each machine instruction.
|
|
|
|
///
|
2008-07-28 21:51:04 +00:00
|
|
|
class MachineInstr : public ilist_node<MachineInstr> {
|
2008-01-07 07:27:27 +00:00
|
|
|
const TargetInstrDesc *TID; // Instruction descriptor.
|
2006-11-27 23:37:22 +00:00
|
|
|
unsigned short NumImplicitOps; // Number of implicit operands (which
|
2006-11-15 20:48:17 +00:00
|
|
|
// are determined at construction time).
|
|
|
|
|
2006-05-04 19:14:44 +00:00
|
|
|
std::vector<MachineOperand> Operands; // the operands
|
2008-07-28 21:51:04 +00:00
|
|
|
std::list<MachineMemOperand> MemOperands; // information on memory references
|
2007-12-31 04:56:33 +00:00
|
|
|
MachineBasicBlock *Parent; // Pointer to the owning basic block.
|
2009-01-27 23:20:29 +00:00
|
|
|
DebugLoc debugLoc; // Source line information.
|
2004-03-03 19:07:27 +00:00
|
|
|
|
2002-10-28 20:48:39 +00:00
|
|
|
// OperandComplete - Return true if it's illegal to add a new operand
|
|
|
|
bool OperandsComplete() const;
|
2002-10-29 19:41:18 +00:00
|
|
|
|
2008-07-07 23:14:23 +00:00
|
|
|
MachineInstr(const MachineInstr&); // DO NOT IMPLEMENT
|
2003-06-02 22:07:37 +00:00
|
|
|
void operator=(const MachineInstr&); // DO NOT IMPLEMENT
|
2004-02-12 02:27:10 +00:00
|
|
|
|
|
|
|
// Intrusive list support
|
2008-07-28 21:51:04 +00:00
|
|
|
friend struct ilist_traits<MachineInstr>;
|
|
|
|
friend struct ilist_traits<MachineBasicBlock>;
|
2007-12-31 04:56:33 +00:00
|
|
|
void setParent(MachineBasicBlock *P) { Parent = P; }
|
2008-07-07 23:14:23 +00:00
|
|
|
|
|
|
|
/// MachineInstr ctor - This constructor creates a copy of the given
|
|
|
|
/// MachineInstr in the given MachineFunction.
|
|
|
|
MachineInstr(MachineFunction &, const MachineInstr &);
|
|
|
|
|
2006-11-27 23:37:22 +00:00
|
|
|
/// MachineInstr ctor - This constructor creates a dummy MachineInstr with
|
2006-11-30 07:08:44 +00:00
|
|
|
/// TID NULL and no operands.
|
2006-11-27 23:37:22 +00:00
|
|
|
MachineInstr();
|
2002-09-20 00:47:49 +00:00
|
|
|
|
2009-01-27 23:20:29 +00:00
|
|
|
// The next two constructors have DebugLoc and non-DebugLoc versions;
|
|
|
|
// over time, the non-DebugLoc versions should be phased out and eventually
|
|
|
|
// removed.
|
|
|
|
|
2006-11-13 23:34:06 +00:00
|
|
|
/// MachineInstr ctor - This constructor create a MachineInstr and add the
|
2007-12-30 00:12:25 +00:00
|
|
|
/// implicit operands. It reserves space for number of operands specified by
|
2009-01-27 23:20:29 +00:00
|
|
|
/// TargetInstrDesc. The version with a DebugLoc should be preferred.
|
2008-01-07 07:27:27 +00:00
|
|
|
explicit MachineInstr(const TargetInstrDesc &TID, bool NoImp = false);
|
2006-11-13 23:34:06 +00:00
|
|
|
|
2002-10-29 23:18:23 +00:00
|
|
|
/// MachineInstr ctor - Work exactly the same as the ctor above, except that
|
|
|
|
/// the MachineInstr is created and added to the end of the specified basic
|
2009-01-27 23:20:29 +00:00
|
|
|
/// block. The version with a DebugLoc should be preferred.
|
2002-10-29 23:18:23 +00:00
|
|
|
///
|
2008-01-07 07:27:27 +00:00
|
|
|
MachineInstr(MachineBasicBlock *MBB, const TargetInstrDesc &TID);
|
2005-04-21 20:39:54 +00:00
|
|
|
|
2009-01-27 23:20:29 +00:00
|
|
|
/// MachineInstr ctor - This constructor create a MachineInstr and add the
|
|
|
|
/// implicit operands. It reserves space for number of operands specified by
|
|
|
|
/// TargetInstrDesc. An explicit DebugLoc is supplied.
|
|
|
|
explicit MachineInstr(const TargetInstrDesc &TID, const DebugLoc dl,
|
|
|
|
bool NoImp = false);
|
|
|
|
|
|
|
|
/// MachineInstr ctor - Work exactly the same as the ctor above, except that
|
|
|
|
/// the MachineInstr is created and added to the end of the specified basic
|
|
|
|
/// block.
|
|
|
|
///
|
|
|
|
MachineInstr(MachineBasicBlock *MBB, const DebugLoc dl,
|
|
|
|
const TargetInstrDesc &TID);
|
|
|
|
|
2004-02-16 07:17:43 +00:00
|
|
|
~MachineInstr();
|
|
|
|
|
2008-07-07 23:14:23 +00:00
|
|
|
// MachineInstrs are pool-allocated and owned by MachineFunction.
|
|
|
|
friend class MachineFunction;
|
|
|
|
|
|
|
|
public:
|
2007-12-31 04:56:33 +00:00
|
|
|
const MachineBasicBlock* getParent() const { return Parent; }
|
|
|
|
MachineBasicBlock* getParent() { return Parent; }
|
2009-01-27 23:20:29 +00:00
|
|
|
|
|
|
|
/// getDebugLoc - Returns the debug location id of this MachineInstr.
|
|
|
|
///
|
2009-06-19 23:59:57 +00:00
|
|
|
DebugLoc getDebugLoc() const { return debugLoc; }
|
2006-11-30 07:08:44 +00:00
|
|
|
|
2008-01-07 01:56:04 +00:00
|
|
|
/// getDesc - Returns the target instruction descriptor of this
|
2006-11-30 07:08:44 +00:00
|
|
|
/// MachineInstr.
|
2008-01-07 07:27:27 +00:00
|
|
|
const TargetInstrDesc &getDesc() const { return *TID; }
|
2004-02-12 18:49:07 +00:00
|
|
|
|
2004-03-03 19:07:27 +00:00
|
|
|
/// getOpcode - Returns the opcode of this MachineInstr.
|
2004-02-12 01:34:03 +00:00
|
|
|
///
|
2008-08-14 23:25:30 +00:00
|
|
|
int getOpcode() const { return TID->Opcode; }
|
2003-05-31 07:43:01 +00:00
|
|
|
|
2004-02-12 01:34:03 +00:00
|
|
|
/// Access to explicit operands of the instruction.
|
|
|
|
///
|
2008-05-05 18:30:58 +00:00
|
|
|
unsigned getNumOperands() const { return (unsigned)Operands.size(); }
|
2005-04-21 20:39:54 +00:00
|
|
|
|
2002-10-28 04:24:49 +00:00
|
|
|
const MachineOperand& getOperand(unsigned i) const {
|
2002-10-29 19:41:18 +00:00
|
|
|
assert(i < getNumOperands() && "getOperand() out of range!");
|
2006-05-04 19:14:44 +00:00
|
|
|
return Operands[i];
|
2002-10-28 04:24:49 +00:00
|
|
|
}
|
|
|
|
MachineOperand& getOperand(unsigned i) {
|
2002-10-29 19:41:18 +00:00
|
|
|
assert(i < getNumOperands() && "getOperand() out of range!");
|
2006-05-04 19:14:44 +00:00
|
|
|
return Operands[i];
|
2002-10-28 04:24:49 +00:00
|
|
|
}
|
2002-10-28 04:30:20 +00:00
|
|
|
|
2007-05-15 01:26:09 +00:00
|
|
|
/// getNumExplicitOperands - Returns the number of non-implicit operands.
|
|
|
|
///
|
|
|
|
unsigned getNumExplicitOperands() const;
|
2006-10-20 22:39:36 +00:00
|
|
|
|
2008-02-06 22:27:42 +00:00
|
|
|
/// Access to memory operands of the instruction
|
2008-07-28 21:51:04 +00:00
|
|
|
std::list<MachineMemOperand>::iterator memoperands_begin()
|
2008-07-07 23:14:23 +00:00
|
|
|
{ return MemOperands.begin(); }
|
2008-07-28 21:51:04 +00:00
|
|
|
std::list<MachineMemOperand>::iterator memoperands_end()
|
2008-07-07 23:14:23 +00:00
|
|
|
{ return MemOperands.end(); }
|
2008-07-28 21:51:04 +00:00
|
|
|
std::list<MachineMemOperand>::const_iterator memoperands_begin() const
|
2008-07-07 23:14:23 +00:00
|
|
|
{ return MemOperands.begin(); }
|
2008-07-28 21:51:04 +00:00
|
|
|
std::list<MachineMemOperand>::const_iterator memoperands_end() const
|
2008-07-07 23:14:23 +00:00
|
|
|
{ return MemOperands.end(); }
|
|
|
|
bool memoperands_empty() const { return MemOperands.empty(); }
|
2008-02-06 22:27:42 +00:00
|
|
|
|
2008-07-12 00:10:52 +00:00
|
|
|
/// hasOneMemOperand - Return true if this instruction has exactly one
|
|
|
|
/// MachineMemOperand.
|
|
|
|
bool hasOneMemOperand() const {
|
|
|
|
return !memoperands_empty() &&
|
|
|
|
next(memoperands_begin()) == memoperands_end();
|
|
|
|
}
|
|
|
|
|
2006-10-20 22:39:36 +00:00
|
|
|
/// isIdenticalTo - Return true if this instruction is identical to (same
|
|
|
|
/// opcode and same operands as) the specified instruction.
|
|
|
|
bool isIdenticalTo(const MachineInstr *Other) const {
|
|
|
|
if (Other->getOpcode() != getOpcode() ||
|
2006-10-20 22:44:45 +00:00
|
|
|
Other->getNumOperands() != getNumOperands())
|
2006-10-20 22:39:36 +00:00
|
|
|
return false;
|
|
|
|
for (unsigned i = 0, e = getNumOperands(); i != e; ++i)
|
|
|
|
if (!getOperand(i).isIdenticalTo(Other->getOperand(i)))
|
|
|
|
return false;
|
|
|
|
return true;
|
|
|
|
}
|
2002-10-29 19:41:18 +00:00
|
|
|
|
2006-04-17 21:35:08 +00:00
|
|
|
/// removeFromParent - This method unlinks 'this' from the containing basic
|
|
|
|
/// block, and returns it, but does not delete it.
|
|
|
|
MachineInstr *removeFromParent();
|
|
|
|
|
|
|
|
/// eraseFromParent - This method unlinks 'this' from the containing basic
|
|
|
|
/// block and deletes it.
|
2008-07-07 23:14:23 +00:00
|
|
|
void eraseFromParent();
|
2004-05-23 19:35:12 +00:00
|
|
|
|
2008-07-01 00:05:16 +00:00
|
|
|
/// isLabel - Returns true if the MachineInstr represents a label.
|
|
|
|
///
|
|
|
|
bool isLabel() const;
|
|
|
|
|
2008-01-31 09:59:15 +00:00
|
|
|
/// isDebugLabel - Returns true if the MachineInstr represents a debug label.
|
|
|
|
///
|
|
|
|
bool isDebugLabel() const;
|
|
|
|
|
2008-03-05 00:59:57 +00:00
|
|
|
/// readsRegister - Return true if the MachineInstr reads the specified
|
|
|
|
/// register. If TargetRegisterInfo is passed, then it also checks if there
|
|
|
|
/// is a read of a super-register.
|
|
|
|
bool readsRegister(unsigned Reg, const TargetRegisterInfo *TRI = NULL) const {
|
|
|
|
return findRegisterUseOperandIdx(Reg, false, TRI) != -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// killsRegister - Return true if the MachineInstr kills the specified
|
|
|
|
/// register. If TargetRegisterInfo is passed, then it also checks if there is
|
|
|
|
/// a kill of a super-register.
|
|
|
|
bool killsRegister(unsigned Reg, const TargetRegisterInfo *TRI = NULL) const {
|
|
|
|
return findRegisterUseOperandIdx(Reg, true, TRI) != -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// modifiesRegister - Return true if the MachineInstr modifies the
|
|
|
|
/// specified register. If TargetRegisterInfo is passed, then it also checks
|
|
|
|
/// if there is a def of a super-register.
|
|
|
|
bool modifiesRegister(unsigned Reg,
|
|
|
|
const TargetRegisterInfo *TRI = NULL) const {
|
|
|
|
return findRegisterDefOperandIdx(Reg, false, TRI) != -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// registerDefIsDead - Returns true if the register is dead in this machine
|
|
|
|
/// instruction. If TargetRegisterInfo is passed, then it also checks
|
|
|
|
/// if there is a dead def of a super-register.
|
|
|
|
bool registerDefIsDead(unsigned Reg,
|
|
|
|
const TargetRegisterInfo *TRI = NULL) const {
|
|
|
|
return findRegisterDefOperandIdx(Reg, true, TRI) != -1;
|
|
|
|
}
|
|
|
|
|
2007-04-26 19:00:32 +00:00
|
|
|
/// findRegisterUseOperandIdx() - Returns the operand index that is a use of
|
2007-03-26 22:37:45 +00:00
|
|
|
/// the specific register or -1 if it is not found. It further tightening
|
2007-02-23 01:04:26 +00:00
|
|
|
/// the search criteria to a use that kills the register if isKill is true.
|
2008-03-05 00:59:57 +00:00
|
|
|
int findRegisterUseOperandIdx(unsigned Reg, bool isKill = false,
|
|
|
|
const TargetRegisterInfo *TRI = NULL) const;
|
|
|
|
|
|
|
|
/// findRegisterUseOperand - Wrapper for findRegisterUseOperandIdx, it returns
|
|
|
|
/// a pointer to the MachineOperand rather than an index.
|
2008-03-29 01:04:05 +00:00
|
|
|
MachineOperand *findRegisterUseOperand(unsigned Reg, bool isKill = false,
|
2008-03-05 00:59:57 +00:00
|
|
|
const TargetRegisterInfo *TRI = NULL) {
|
|
|
|
int Idx = findRegisterUseOperandIdx(Reg, isKill, TRI);
|
|
|
|
return (Idx == -1) ? NULL : &getOperand(Idx);
|
|
|
|
}
|
2006-12-06 08:27:42 +00:00
|
|
|
|
2008-03-05 00:59:57 +00:00
|
|
|
/// findRegisterDefOperandIdx() - Returns the operand index that is a def of
|
2008-05-06 00:20:10 +00:00
|
|
|
/// the specified register or -1 if it is not found. If isDead is true, defs
|
|
|
|
/// that are not dead are skipped. If TargetRegisterInfo is non-null, then it
|
|
|
|
/// also checks if there is a def of a super-register.
|
2008-03-05 00:59:57 +00:00
|
|
|
int findRegisterDefOperandIdx(unsigned Reg, bool isDead = false,
|
|
|
|
const TargetRegisterInfo *TRI = NULL) const;
|
|
|
|
|
|
|
|
/// findRegisterDefOperand - Wrapper for findRegisterDefOperandIdx, it returns
|
|
|
|
/// a pointer to the MachineOperand rather than an index.
|
2009-01-20 17:30:40 +00:00
|
|
|
MachineOperand *findRegisterDefOperand(unsigned Reg, bool isDead = false,
|
2008-03-05 00:59:57 +00:00
|
|
|
const TargetRegisterInfo *TRI = NULL) {
|
|
|
|
int Idx = findRegisterDefOperandIdx(Reg, isDead, TRI);
|
|
|
|
return (Idx == -1) ? NULL : &getOperand(Idx);
|
|
|
|
}
|
2007-05-15 01:26:09 +00:00
|
|
|
|
2007-05-29 18:35:22 +00:00
|
|
|
/// findFirstPredOperandIdx() - Find the index of the first operand in the
|
|
|
|
/// operand list that is used to represent the predicate. It returns -1 if
|
|
|
|
/// none is found.
|
|
|
|
int findFirstPredOperandIdx() const;
|
2007-02-19 21:49:54 +00:00
|
|
|
|
2009-04-09 17:16:43 +00:00
|
|
|
/// isRegTiedToUseOperand - Given the index of a register def operand,
|
|
|
|
/// check if the register def is tied to a source operand, due to either
|
|
|
|
/// two-address elimination or inline assembly constraints. Returns the
|
|
|
|
/// first tied use operand index by reference is UseOpIdx is not null.
|
2009-04-29 20:57:16 +00:00
|
|
|
bool isRegTiedToUseOperand(unsigned DefOpIdx, unsigned *UseOpIdx = 0) const;
|
2007-10-12 08:50:34 +00:00
|
|
|
|
2009-03-19 20:30:06 +00:00
|
|
|
/// isRegTiedToDefOperand - Return true if the use operand of the specified
|
|
|
|
/// index is tied to an def operand. It also returns the def operand index by
|
|
|
|
/// reference if DefOpIdx is not null.
|
2009-04-29 20:57:16 +00:00
|
|
|
bool isRegTiedToDefOperand(unsigned UseOpIdx, unsigned *DefOpIdx = 0) const;
|
2009-03-19 20:30:06 +00:00
|
|
|
|
2006-11-15 20:48:17 +00:00
|
|
|
/// copyKillDeadInfo - Copies kill / dead operand properties from MI.
|
|
|
|
///
|
2006-12-06 08:27:42 +00:00
|
|
|
void copyKillDeadInfo(const MachineInstr *MI);
|
2006-11-15 20:48:17 +00:00
|
|
|
|
2007-05-15 01:26:09 +00:00
|
|
|
/// copyPredicates - Copies predicate operand(s) from MI.
|
|
|
|
void copyPredicates(const MachineInstr *MI);
|
|
|
|
|
2008-01-24 01:10:07 +00:00
|
|
|
/// addRegisterKilled - We have determined MI kills a register. Look for the
|
|
|
|
/// operand that uses it and mark it as IsKill. If AddIfNotFound is true,
|
|
|
|
/// add a implicit operand if it's not found. Returns true if the operand
|
|
|
|
/// exists / is added.
|
2008-02-10 18:45:23 +00:00
|
|
|
bool addRegisterKilled(unsigned IncomingReg,
|
|
|
|
const TargetRegisterInfo *RegInfo,
|
2008-01-24 01:10:07 +00:00
|
|
|
bool AddIfNotFound = false);
|
|
|
|
|
|
|
|
/// addRegisterDead - We have determined MI defined a register without a use.
|
|
|
|
/// Look for the operand that defines it and mark it as IsDead. If
|
|
|
|
/// AddIfNotFound is true, add a implicit operand if it's not found. Returns
|
|
|
|
/// true if the operand exists / is added.
|
2008-02-10 18:45:23 +00:00
|
|
|
bool addRegisterDead(unsigned IncomingReg, const TargetRegisterInfo *RegInfo,
|
2008-01-24 01:10:07 +00:00
|
|
|
bool AddIfNotFound = false);
|
|
|
|
|
2008-07-03 09:09:37 +00:00
|
|
|
/// isSafeToMove - Return true if it is safe to move this instruction. If
|
|
|
|
/// SawStore is set to true, it means that there is a store (or call) between
|
|
|
|
/// the instruction's location and its intended destination.
|
2008-11-18 19:04:29 +00:00
|
|
|
bool isSafeToMove(const TargetInstrInfo *TII, bool &SawStore) const;
|
2008-03-13 00:44:09 +00:00
|
|
|
|
2008-09-24 00:06:15 +00:00
|
|
|
/// isSafeToReMat - Return true if it's safe to rematerialize the specified
|
|
|
|
/// instruction which defined the specified register instead of copying it.
|
2008-11-18 19:04:29 +00:00
|
|
|
bool isSafeToReMat(const TargetInstrInfo *TII, unsigned DstReg) const;
|
2008-08-27 20:33:50 +00:00
|
|
|
|
2008-09-24 00:06:15 +00:00
|
|
|
/// hasVolatileMemoryRef - Return true if this instruction may have a
|
|
|
|
/// volatile memory reference, or if the information describing the
|
|
|
|
/// memory reference is not available. Return false if it is known to
|
|
|
|
/// have no volatile memory references.
|
|
|
|
bool hasVolatileMemoryRef() const;
|
|
|
|
|
2001-10-11 04:23:19 +00:00
|
|
|
//
|
|
|
|
// Debugging support
|
2002-10-30 00:46:48 +00:00
|
|
|
//
|
2006-12-17 05:15:13 +00:00
|
|
|
void print(std::ostream *OS, const TargetMachine *TM) const {
|
|
|
|
if (OS) print(*OS, TM);
|
2006-11-28 22:21:29 +00:00
|
|
|
}
|
2007-12-30 21:31:53 +00:00
|
|
|
void print(std::ostream &OS, const TargetMachine *TM = 0) const;
|
2006-12-17 05:15:13 +00:00
|
|
|
void print(std::ostream *OS) const { if (OS) print(*OS); }
|
2008-08-21 00:14:44 +00:00
|
|
|
void print(raw_ostream *OS, const TargetMachine *TM) const {
|
|
|
|
if (OS) print(*OS, TM);
|
|
|
|
}
|
|
|
|
void print(raw_ostream &OS, const TargetMachine *TM = 0) const;
|
|
|
|
void print(raw_ostream *OS) const { if (OS) print(*OS); }
|
2002-10-28 04:24:49 +00:00
|
|
|
void dump() const;
|
2002-02-05 06:02:59 +00:00
|
|
|
|
2002-10-28 20:48:39 +00:00
|
|
|
//===--------------------------------------------------------------------===//
|
2008-01-01 01:12:31 +00:00
|
|
|
// Accessors used to build up machine instructions.
|
2002-12-28 20:05:44 +00:00
|
|
|
|
2008-01-01 01:12:31 +00:00
|
|
|
/// addOperand - Add the specified operand to the instruction. If it is an
|
|
|
|
/// implicit operand, it is added to the end of the operand list. If it is
|
|
|
|
/// an explicit operand it is added at the end of the explicit operand list
|
|
|
|
/// (before the first implicit operand).
|
|
|
|
void addOperand(const MachineOperand &Op);
|
|
|
|
|
2008-01-11 18:10:50 +00:00
|
|
|
/// setDesc - Replace the instruction descriptor (thus opcode) of
|
2006-11-30 07:08:44 +00:00
|
|
|
/// the current instruction with a new one.
|
2003-01-13 00:18:17 +00:00
|
|
|
///
|
2008-01-11 18:10:50 +00:00
|
|
|
void setDesc(const TargetInstrDesc &tid) { TID = &tid; }
|
2003-01-13 00:18:17 +00:00
|
|
|
|
2009-01-27 23:20:29 +00:00
|
|
|
/// setDebugLoc - Replace current source information with new such.
|
2009-01-27 23:32:10 +00:00
|
|
|
/// Avoid using this, the constructor argument is preferable.
|
2009-01-27 23:20:29 +00:00
|
|
|
///
|
|
|
|
void setDebugLoc(const DebugLoc dl) { debugLoc = dl; }
|
|
|
|
|
2003-01-13 00:18:17 +00:00
|
|
|
/// RemoveOperand - Erase an operand from an instruction, leaving it with one
|
|
|
|
/// fewer operand than it started with.
|
|
|
|
///
|
2008-01-01 01:12:31 +00:00
|
|
|
void RemoveOperand(unsigned i);
|
|
|
|
|
2008-04-07 19:35:22 +00:00
|
|
|
/// addMemOperand - Add a MachineMemOperand to the machine instruction,
|
|
|
|
/// referencing arbitrary storage.
|
2008-07-07 23:14:23 +00:00
|
|
|
void addMemOperand(MachineFunction &MF,
|
|
|
|
const MachineMemOperand &MO);
|
|
|
|
|
|
|
|
/// clearMemOperands - Erase all of this MachineInstr's MachineMemOperands.
|
|
|
|
void clearMemOperands(MachineFunction &MF);
|
2008-02-06 22:27:42 +00:00
|
|
|
|
2006-05-04 19:14:44 +00:00
|
|
|
private:
|
2008-01-01 01:12:31 +00:00
|
|
|
/// getRegInfo - If this instruction is embedded into a MachineFunction,
|
|
|
|
/// return the MachineRegisterInfo object for the current function, otherwise
|
|
|
|
/// return null.
|
|
|
|
MachineRegisterInfo *getRegInfo();
|
2006-11-13 23:34:06 +00:00
|
|
|
|
|
|
|
/// addImplicitDefUseOperands - Add all implicit def and use operands to
|
|
|
|
/// this instruction.
|
2006-11-30 07:08:44 +00:00
|
|
|
void addImplicitDefUseOperands();
|
2008-01-01 01:12:31 +00:00
|
|
|
|
|
|
|
/// RemoveRegOperandsFromUseLists - Unlink all of the register operands in
|
|
|
|
/// this instruction from their respective use lists. This requires that the
|
|
|
|
/// operands already be on their use lists.
|
|
|
|
void RemoveRegOperandsFromUseLists();
|
|
|
|
|
|
|
|
/// AddRegOperandsToUseLists - Add all of the register operands in
|
|
|
|
/// this instruction from their respective use lists. This requires that the
|
|
|
|
/// operands not be on their use lists yet.
|
|
|
|
void AddRegOperandsToUseLists(MachineRegisterInfo &RegInfo);
|
2001-10-11 04:23:19 +00:00
|
|
|
};
|
2001-07-21 12:39:03 +00:00
|
|
|
|
2003-06-03 15:42:53 +00:00
|
|
|
//===----------------------------------------------------------------------===//
|
2001-10-10 20:50:20 +00:00
|
|
|
// Debugging Support
|
|
|
|
|
2007-12-30 21:31:53 +00:00
|
|
|
inline std::ostream& operator<<(std::ostream &OS, const MachineInstr &MI) {
|
|
|
|
MI.print(OS);
|
|
|
|
return OS;
|
|
|
|
}
|
2001-08-28 23:11:46 +00:00
|
|
|
|
2008-08-21 00:14:44 +00:00
|
|
|
inline raw_ostream& operator<<(raw_ostream &OS, const MachineInstr &MI) {
|
|
|
|
MI.print(OS);
|
|
|
|
return OS;
|
|
|
|
}
|
|
|
|
|
2003-11-11 22:41:34 +00:00
|
|
|
} // End llvm namespace
|
|
|
|
|
2001-07-21 12:39:03 +00:00
|
|
|
#endif
|