//===-- Instruction.cpp - Implement the Instruction class -----------------===//
-//
+//
// The LLVM Compiler Infrastructure
//
// This file was developed by the LLVM research group and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
-//
+//
//===----------------------------------------------------------------------===//
//
// This file implements the Instruction class for the VMCore library.
#include "llvm/Support/LeakDetector.h"
using namespace llvm;
-void Instruction::init() {
+Instruction::Instruction(const Type *ty, unsigned it, Use *Ops, unsigned NumOps,
+ const std::string &Name, Instruction *InsertBefore)
+ : User(ty, Value::InstructionVal + it, Ops, NumOps, Name), Parent(0) {
// Make sure that we get added to a basicblock
LeakDetector::addGarbageObject(this);
-}
-
-Instruction::Instruction(const Type *ty, unsigned it, const std::string &Name,
- Instruction *InsertBefore)
- : User(ty, Value::InstructionVal + it, Name), Parent(0) {
- init();
// If requested, insert this instruction into a basic block...
if (InsertBefore) {
}
}
-Instruction::Instruction(const Type *ty, unsigned it, const std::string &Name,
- BasicBlock *InsertAtEnd)
- : User(ty, Value::InstructionVal + it, Name), Parent(0) {
- init();
+Instruction::Instruction(const Type *ty, unsigned it, Use *Ops, unsigned NumOps,
+ const std::string &Name, BasicBlock *InsertAtEnd)
+ : User(ty, Value::InstructionVal + it, Ops, NumOps, Name), Parent(0) {
+ // Make sure that we get added to a basicblock
+ LeakDetector::addGarbageObject(this);
// append this instruction into the basic block
assert(InsertAtEnd && "Basic block to append to may not be NULL!");
Parent = P;
}
-// Specialize setName to take care of symbol table majik
-void Instruction::setName(const std::string &name, SymbolTable *ST) {
- BasicBlock *P = 0; Function *PP = 0;
- assert((ST == 0 || !getParent() || !getParent()->getParent() ||
- ST == &getParent()->getParent()->getSymbolTable()) &&
- "Invalid symtab argument!");
- if ((P = getParent()) && (PP = P->getParent()) && hasName())
- PP->getSymbolTable().remove(this);
- Value::setName(name);
- if (PP && hasName()) PP->getSymbolTable().insert(this);
-}
-
void Instruction::removeFromParent() {
getParent()->getInstList().remove(this);
}
getParent()->getInstList().erase(this);
}
+/// moveBefore - Unlink this instruction from its current basic block and
+/// insert it into the basic block that MovePos lives in, right before
+/// MovePos.
+void Instruction::moveBefore(Instruction *MovePos) {
+ MovePos->getParent()->getInstList().splice(MovePos,getParent()->getInstList(),
+ this);
+}
+
+
const char *Instruction::getOpcodeName(unsigned OpCode) {
switch (OpCode) {
// Terminators
case Invoke: return "invoke";
case Unwind: return "unwind";
case Unreachable: return "unreachable";
-
+
// Standard binary operators...
case Add: return "add";
case Sub: return "sub";
case SetGT: return "setgt";
case SetEQ: return "seteq";
case SetNE: return "setne";
-
+
// Memory instructions...
case Malloc: return "malloc";
case Free: return "free";
case Load: return "load";
case Store: return "store";
case GetElementPtr: return "getelementptr";
-
+
// Other instructions...
case PHI: return "phi";
case Cast: return "cast";
case Call: return "call";
case Shl: return "shl";
case Shr: return "shr";
- case VANext: return "vanext";
- case VAArg: return "vaarg";
+ case VAArg: return "va_arg";
+ case ExtractElement: return "extractelement";
+ case InsertElement: return "insertelement";
default: return "<Invalid operator> ";
}
-
+
return 0;
}
return LI->isVolatile() == cast<LoadInst>(I)->isVolatile();
if (const StoreInst *SI = dyn_cast<StoreInst>(this))
return SI->isVolatile() == cast<StoreInst>(I)->isVolatile();
- if (const VANextInst *VAN = dyn_cast<VANextInst>(this))
- return VAN->getArgType() == cast<VANextInst>(I)->getArgType();
+ if (const CallInst *CI = dyn_cast<CallInst>(this))
+ return CI->isTailCall() == cast<CallInst>(I)->isTailCall();
return true;
}
switch (op) {
case Add:
case Mul:
- case And:
+ case And:
case Or:
case Xor:
case SetEQ: