mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-04 18:24:38 +00:00
remove all of the various setName implementations, consolidating them into
Value::setName, which is no longer virtual. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@20464 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -39,9 +39,6 @@ public:
|
|||||||
///
|
///
|
||||||
Argument(const Type *Ty, const std::string &Name = "", Function *F = 0);
|
Argument(const Type *Ty, const std::string &Name = "", Function *F = 0);
|
||||||
|
|
||||||
/// setName - Specialize setName to handle symbol table majik.
|
|
||||||
virtual void setName(const std::string &name);
|
|
||||||
|
|
||||||
inline const Function *getParent() const { return Parent; }
|
inline const Function *getParent() const { return Parent; }
|
||||||
inline Function *getParent() { return Parent; }
|
inline Function *getParent() { return Parent; }
|
||||||
|
|
||||||
|
@ -76,9 +76,6 @@ public:
|
|||||||
BasicBlock *InsertBefore = 0);
|
BasicBlock *InsertBefore = 0);
|
||||||
~BasicBlock();
|
~BasicBlock();
|
||||||
|
|
||||||
// Specialize setName to take care of symbol table majik
|
|
||||||
virtual void setName(const std::string &name);
|
|
||||||
|
|
||||||
/// getParent - Return the enclosing method, or null if none
|
/// getParent - Return the enclosing method, or null if none
|
||||||
///
|
///
|
||||||
const Function *getParent() const { return InstList.getParent(); }
|
const Function *getParent() const { return InstList.getParent(); }
|
||||||
|
@ -26,9 +26,6 @@ protected:
|
|||||||
|
|
||||||
void destroyConstantImpl();
|
void destroyConstantImpl();
|
||||||
public:
|
public:
|
||||||
// setName - Specialize setName to handle symbol table majik.
|
|
||||||
virtual void setName(const std::string &name);
|
|
||||||
|
|
||||||
/// Static constructor to get a '0' constant of arbitrary type...
|
/// Static constructor to get a '0' constant of arbitrary type...
|
||||||
///
|
///
|
||||||
static Constant *getNullValue(const Type *Ty);
|
static Constant *getNullValue(const Type *Ty);
|
||||||
|
@ -85,9 +85,6 @@ public:
|
|||||||
const std::string &N = "", Module *M = 0);
|
const std::string &N = "", Module *M = 0);
|
||||||
~Function();
|
~Function();
|
||||||
|
|
||||||
// Specialize setName to handle symbol table majik.
|
|
||||||
virtual void setName(const std::string &name);
|
|
||||||
|
|
||||||
const Type *getReturnType() const; // Return the type of the ret val
|
const Type *getReturnType() const; // Return the type of the ret val
|
||||||
const FunctionType *getFunctionType() const; // Return the FunctionType for me
|
const FunctionType *getFunctionType() const; // Return the FunctionType for me
|
||||||
|
|
||||||
|
@ -51,9 +51,6 @@ public:
|
|||||||
Constant *Initializer = 0, const std::string &Name = "",
|
Constant *Initializer = 0, const std::string &Name = "",
|
||||||
Module *Parent = 0);
|
Module *Parent = 0);
|
||||||
|
|
||||||
// Specialize setName to handle symbol table majik.
|
|
||||||
virtual void setName(const std::string &name);
|
|
||||||
|
|
||||||
/// isExternal - Is this global variable lacking an initializer? If so, the
|
/// isExternal - Is this global variable lacking an initializer? If so, the
|
||||||
/// global variable is defined in some other translation unit, and is thus
|
/// global variable is defined in some other translation unit, and is thus
|
||||||
/// externally defined here.
|
/// externally defined here.
|
||||||
|
@ -54,9 +54,6 @@ public:
|
|||||||
assert(Parent == 0 && "Instruction still linked in the program!");
|
assert(Parent == 0 && "Instruction still linked in the program!");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Specialize setName to handle symbol table majik.
|
|
||||||
virtual void setName(const std::string &name);
|
|
||||||
|
|
||||||
/// mayWriteToMemory - Return true if this instruction may modify memory.
|
/// mayWriteToMemory - Return true if this instruction may modify memory.
|
||||||
///
|
///
|
||||||
virtual bool mayWriteToMemory() const { return false; }
|
virtual bool mayWriteToMemory() const { return false; }
|
||||||
|
@ -75,9 +75,7 @@ public:
|
|||||||
inline bool hasName() const { return !Name.empty(); }
|
inline bool hasName() const { return !Name.empty(); }
|
||||||
inline const std::string &getName() const { return Name; }
|
inline const std::string &getName() const { return Name; }
|
||||||
|
|
||||||
virtual void setName(const std::string &name) {
|
void setName(const std::string &name);
|
||||||
Name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// replaceAllUsesWith - Go through the uses list for this definition and make
|
/// replaceAllUsesWith - Go through the uses list for this definition and make
|
||||||
/// each use point to "V" instead of "this". After this completes, 'this's
|
/// each use point to "V" instead of "this". After this completes, 'this's
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
#include "llvm/Instructions.h"
|
#include "llvm/Instructions.h"
|
||||||
#include "llvm/Type.h"
|
#include "llvm/Type.h"
|
||||||
#include "llvm/Support/CFG.h"
|
#include "llvm/Support/CFG.h"
|
||||||
#include "llvm/SymbolTable.h"
|
|
||||||
#include "llvm/Support/LeakDetector.h"
|
#include "llvm/Support/LeakDetector.h"
|
||||||
#include "SymbolTableListTraitsImpl.h"
|
#include "SymbolTableListTraitsImpl.h"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
@ -95,14 +94,6 @@ void BasicBlock::setParent(Function *parent) {
|
|||||||
LeakDetector::removeGarbageObject(this);
|
LeakDetector::removeGarbageObject(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Specialize setName to take care of symbol table majik
|
|
||||||
void BasicBlock::setName(const std::string &name) {
|
|
||||||
Function *P;
|
|
||||||
if ((P = getParent()) && hasName()) P->getSymbolTable().remove(this);
|
|
||||||
Value::setName(name);
|
|
||||||
if (P && hasName()) P->getSymbolTable().insert(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
void BasicBlock::removeFromParent() {
|
void BasicBlock::removeFromParent() {
|
||||||
getParent()->getBasicBlockList().remove(this);
|
getParent()->getBasicBlockList().remove(this);
|
||||||
}
|
}
|
||||||
|
@ -31,10 +31,6 @@ ConstantBool *ConstantBool::False = new ConstantBool(false);
|
|||||||
// Constant Class
|
// Constant Class
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
void Constant::setName(const std::string &Name) {
|
|
||||||
// Constants can't take names.
|
|
||||||
}
|
|
||||||
|
|
||||||
void Constant::destroyConstantImpl() {
|
void Constant::destroyConstantImpl() {
|
||||||
// When a Constant is destroyed, there may be lingering
|
// When a Constant is destroyed, there may be lingering
|
||||||
// references to the constant by other constants in the constant pool. These
|
// references to the constant by other constants in the constant pool. These
|
||||||
|
@ -62,15 +62,6 @@ Argument::Argument(const Type *Ty, const std::string &Name, Function *Par)
|
|||||||
Par->getArgumentList().push_back(this);
|
Par->getArgumentList().push_back(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Specialize setName to take care of symbol table majik
|
|
||||||
void Argument::setName(const std::string &name) {
|
|
||||||
Function *P;
|
|
||||||
if ((P = getParent()) && hasName()) P->getSymbolTable().remove(this);
|
|
||||||
Value::setName(name);
|
|
||||||
if (P && hasName()) P->getSymbolTable().insert(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Argument::setParent(Function *parent) {
|
void Argument::setParent(Function *parent) {
|
||||||
if (getParent())
|
if (getParent())
|
||||||
LeakDetector::addGarbageObject(this);
|
LeakDetector::addGarbageObject(this);
|
||||||
@ -118,14 +109,6 @@ Function::~Function() {
|
|||||||
delete SymTab;
|
delete SymTab;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Specialize setName to take care of symbol table majik
|
|
||||||
void Function::setName(const std::string &name) {
|
|
||||||
Module *P;
|
|
||||||
if ((P = getParent()) && hasName()) P->getSymbolTable().remove(this);
|
|
||||||
Value::setName(name);
|
|
||||||
if (P && hasName()) P->getSymbolTable().insert(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Function::setParent(Module *parent) {
|
void Function::setParent(Module *parent) {
|
||||||
if (getParent())
|
if (getParent())
|
||||||
LeakDetector::addGarbageObject(this);
|
LeakDetector::addGarbageObject(this);
|
||||||
|
@ -99,14 +99,6 @@ void GlobalVariable::setParent(Module *parent) {
|
|||||||
LeakDetector::removeGarbageObject(this);
|
LeakDetector::removeGarbageObject(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Specialize setName to take care of symbol table majik
|
|
||||||
void GlobalVariable::setName(const std::string &name) {
|
|
||||||
Module *P;
|
|
||||||
if ((P = getParent()) && hasName()) P->getSymbolTable().remove(this);
|
|
||||||
Value::setName(name);
|
|
||||||
if (P && hasName()) P->getSymbolTable().insert(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GlobalVariable::removeFromParent() {
|
void GlobalVariable::removeFromParent() {
|
||||||
getParent()->getGlobalList().remove(this);
|
getParent()->getGlobalList().remove(this);
|
||||||
}
|
}
|
||||||
|
@ -57,15 +57,6 @@ void Instruction::setParent(BasicBlock *P) {
|
|||||||
Parent = P;
|
Parent = P;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Specialize setName to take care of symbol table majik
|
|
||||||
void Instruction::setName(const std::string &name) {
|
|
||||||
BasicBlock *P = 0; Function *PP = 0;
|
|
||||||
if ((P = getParent()) && (PP = P->getParent()) && hasName())
|
|
||||||
PP->getSymbolTable().remove(this);
|
|
||||||
Value::setName(name);
|
|
||||||
if (PP && hasName()) PP->getSymbolTable().insert(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Instruction::removeFromParent() {
|
void Instruction::removeFromParent() {
|
||||||
getParent()->getInstList().remove(this);
|
getParent()->getInstList().remove(this);
|
||||||
}
|
}
|
||||||
|
@ -11,11 +11,11 @@
|
|||||||
//
|
//
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
#include "llvm/InstrTypes.h"
|
|
||||||
#include "llvm/SymbolTable.h"
|
|
||||||
#include "llvm/DerivedTypes.h"
|
|
||||||
#include "llvm/Constant.h"
|
#include "llvm/Constant.h"
|
||||||
#include "llvm/GlobalValue.h"
|
#include "llvm/DerivedTypes.h"
|
||||||
|
#include "llvm/InstrTypes.h"
|
||||||
|
#include "llvm/Module.h"
|
||||||
|
#include "llvm/SymbolTable.h"
|
||||||
#include "llvm/Support/LeakDetector.h"
|
#include "llvm/Support/LeakDetector.h"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
@ -93,6 +93,31 @@ unsigned Value::getNumUses() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Value::setName(const std::string &name) {
|
||||||
|
if (Name == name) return; // Name is already set.
|
||||||
|
|
||||||
|
SymbolTable *ST = 0;
|
||||||
|
|
||||||
|
if (Instruction *I = dyn_cast<Instruction>(this)) {
|
||||||
|
if (BasicBlock *P = I->getParent())
|
||||||
|
if (Function *PP = P->getParent())
|
||||||
|
ST = &PP->getSymbolTable();
|
||||||
|
} else if (BasicBlock *BB = dyn_cast<BasicBlock>(this)) {
|
||||||
|
if (Function *P = BB->getParent()) ST = &P->getSymbolTable();
|
||||||
|
} else if (GlobalValue *GV = dyn_cast<GlobalValue>(this)) {
|
||||||
|
if (Module *P = GV->getParent()) ST = &P->getSymbolTable();
|
||||||
|
} else if (Argument *A = dyn_cast<Argument>(this)) {
|
||||||
|
if (Function *P = A->getParent()) ST = &P->getSymbolTable();
|
||||||
|
} else {
|
||||||
|
assert(isa<Constant>(this) && "Unknown value type!");
|
||||||
|
return; // no name is setable for this.
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ST && hasName()) ST->remove(this);
|
||||||
|
Name = name;
|
||||||
|
if (ST && hasName()) ST->insert(this);
|
||||||
|
}
|
||||||
|
|
||||||
// uncheckedReplaceAllUsesWith - This is exactly the same as replaceAllUsesWith,
|
// uncheckedReplaceAllUsesWith - This is exactly the same as replaceAllUsesWith,
|
||||||
// except that it doesn't have all of the asserts. The asserts fail because we
|
// except that it doesn't have all of the asserts. The asserts fail because we
|
||||||
// are half-way done resolving types, which causes some types to exist as two
|
// are half-way done resolving types, which causes some types to exist as two
|
||||||
|
Reference in New Issue
Block a user