[llvm-commits] CVS: llvm/lib/VMCore/BasicBlock.cpp Function.cpp Instruction.cpp
Christopher Lattner
lattner at cs.uiuc.edu
Fri Sep 6 16:34:01 PDT 2002
Changes in directory llvm/lib/VMCore:
BasicBlock.cpp updated: 1.23 -> 1.24
Function.cpp updated: 1.29 -> 1.30
Instruction.cpp updated: 1.16 -> 1.17
---
Log message:
Move code out of header files into .cpp files to make future changes easier
---
Diffs of the changes:
Index: llvm/lib/VMCore/BasicBlock.cpp
diff -u llvm/lib/VMCore/BasicBlock.cpp:1.23 llvm/lib/VMCore/BasicBlock.cpp:1.24
--- llvm/lib/VMCore/BasicBlock.cpp:1.23 Thu Jul 25 10:38:43 2002
+++ llvm/lib/VMCore/BasicBlock.cpp Fri Sep 6 16:33:15 2002
@@ -48,6 +48,9 @@
template SymbolTableListTraits<Instruction, BasicBlock, Function>;
+// BasicBlock ctor - If the function parameter is specified, the basic block is
+// automatically inserted at the end of the function.
+//
BasicBlock::BasicBlock(const std::string &name, Function *Parent)
: Value(Type::LabelTy, Value::BasicBlockVal, name) {
// Initialize the instlist...
@@ -60,6 +63,10 @@
BasicBlock::~BasicBlock() {
dropAllReferences();
InstList.clear();
+}
+
+void BasicBlock::setParent(Function *parent) {
+ InstList.setParent(parent);
}
// Specialize setName to take care of symbol table majik
Index: llvm/lib/VMCore/Function.cpp
diff -u llvm/lib/VMCore/Function.cpp:1.29 llvm/lib/VMCore/Function.cpp:1.30
--- llvm/lib/VMCore/Function.cpp:1.29 Fri Sep 6 15:46:32 2002
+++ llvm/lib/VMCore/Function.cpp Fri Sep 6 16:33:15 2002
@@ -10,6 +10,10 @@
#include "llvm/iOther.h"
#include "SymbolTableListTraitsImpl.h"
+BasicBlock *ilist_traits<BasicBlock>::createNode() {
+ return new BasicBlock();
+}
+
iplist<BasicBlock> &ilist_traits<BasicBlock>::getList(Function *F) {
return F->getBasicBlockList();
}
@@ -31,6 +35,14 @@
// Argument Implementation
//===----------------------------------------------------------------------===//
+Argument::Argument(const Type *Ty, const std::string &Name = "", Function *Par)
+ : Value(Ty, Value::ArgumentVal, Name) {
+ Parent = 0;
+ if (Par)
+ Par->getArgumentList().push_back(this);
+}
+
+
// Specialize setName to take care of symbol table majik
void Argument::setName(const std::string &name, SymbolTable *ST) {
Function *P;
@@ -41,11 +53,15 @@
if (P && hasName()) P->getSymbolTable()->insert(this);
}
+void Argument::setParent(Function *parent) {
+ Parent = parent;
+}
+
+
//===----------------------------------------------------------------------===//
// Function Implementation
//===----------------------------------------------------------------------===//
-
Function::Function(const FunctionType *Ty, bool isInternal,
const std::string &name, Module *ParentModule)
: GlobalValue(PointerType::get(Ty), Value::FunctionVal, isInternal, name) {
@@ -136,10 +152,17 @@
GlobalVariable::GlobalVariable(const Type *Ty, bool constant, bool isIntern,
Constant *Initializer,
- const std::string &Name)
+ const std::string &Name, Module *ParentModule)
: GlobalValue(PointerType::get(Ty), Value::GlobalVariableVal, isIntern, Name),
isConstantGlobal(constant) {
if (Initializer) Operands.push_back(Use((Value*)Initializer, this));
+
+ if (ParentModule)
+ ParentModule->getGlobalList().push_back(this);
+}
+
+void GlobalVariable::setParent(Module *parent) {
+ Parent = parent;
}
// Specialize setName to take care of symbol table majik
Index: llvm/lib/VMCore/Instruction.cpp
diff -u llvm/lib/VMCore/Instruction.cpp:1.16 llvm/lib/VMCore/Instruction.cpp:1.17
--- llvm/lib/VMCore/Instruction.cpp:1.16 Wed Aug 14 13:18:02 2002
+++ llvm/lib/VMCore/Instruction.cpp Fri Sep 6 16:33:15 2002
@@ -14,6 +14,10 @@
iType = it;
}
+void Instruction::setParent(BasicBlock *P) {
+ 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;
More information about the llvm-commits
mailing list