[llvm-commits] CVS: llvm/lib/VMCore/AsmWriter.cpp Function.cpp Module.cpp
Chris Lattner
lattner at cs.uiuc.edu
Wed Apr 16 15:29:06 PDT 2003
Changes in directory llvm/lib/VMCore:
AsmWriter.cpp updated: 1.82 -> 1.83
Function.cpp updated: 1.36 -> 1.37
Module.cpp updated: 1.33 -> 1.34
---
Log message:
Add new linkage types to support a real frontend
---
Diffs of the changes:
Index: llvm/lib/VMCore/AsmWriter.cpp
diff -u llvm/lib/VMCore/AsmWriter.cpp:1.82 llvm/lib/VMCore/AsmWriter.cpp:1.83
--- llvm/lib/VMCore/AsmWriter.cpp:1.82 Wed Apr 16 15:20:02 2003
+++ llvm/lib/VMCore/AsmWriter.cpp Wed Apr 16 15:28:45 2003
@@ -535,8 +535,15 @@
void AssemblyWriter::printGlobal(const GlobalVariable *GV) {
if (GV->hasName()) Out << "%" << GV->getName() << " = ";
- if (GV->hasInternalLinkage()) Out << "internal ";
- if (!GV->hasInitializer()) Out << "external ";
+ if (!GV->hasInitializer())
+ Out << "external ";
+ else
+ switch (GV->getLinkage()) {
+ case GlobalValue::InternalLinkage: Out << "internal "; break;
+ case GlobalValue::LinkOnceLinkage: Out << "linkonce "; break;
+ case GlobalValue::AppendingLinkage: Out << "appending "; break;
+ case GlobalValue::ExternalLinkage: break;
+ }
Out << (GV->isConstant() ? "constant " : "global ");
printType(GV->getType()->getElementType());
@@ -594,8 +601,18 @@
//
void AssemblyWriter::printFunction(const Function *F) {
// Print out the return type and name...
- Out << "\n" << (F->isExternal() ? "declare " : "")
- << (F->hasInternalLinkage() ? "internal " : "");
+ Out << "\n";
+
+ if (F->isExternal())
+ Out << "declare ";
+ else
+ switch (F->getLinkage()) {
+ case GlobalValue::InternalLinkage: Out << "internal "; break;
+ case GlobalValue::LinkOnceLinkage: Out << "linkonce "; break;
+ case GlobalValue::AppendingLinkage: Out << "appending "; break;
+ case GlobalValue::ExternalLinkage: break;
+ }
+
printType(F->getReturnType()) << " %" << F->getName() << "(";
Table.incorporateFunction(F);
Index: llvm/lib/VMCore/Function.cpp
diff -u llvm/lib/VMCore/Function.cpp:1.36 llvm/lib/VMCore/Function.cpp:1.37
--- llvm/lib/VMCore/Function.cpp:1.36 Wed Nov 20 12:33:41 2002
+++ llvm/lib/VMCore/Function.cpp Wed Apr 16 15:28:45 2003
@@ -77,9 +77,9 @@
// Function Implementation
//===----------------------------------------------------------------------===//
-Function::Function(const FunctionType *Ty, bool isInternal,
+Function::Function(const FunctionType *Ty, LinkageTypes Linkage,
const std::string &name, Module *ParentModule)
- : GlobalValue(PointerType::get(Ty), Value::FunctionVal, isInternal, name) {
+ : GlobalValue(PointerType::get(Ty), Value::FunctionVal, Linkage, name) {
BasicBlocks.setItemParent(this);
BasicBlocks.setParent(this);
ArgumentList.setItemParent(this);
@@ -154,10 +154,10 @@
// GlobalVariable Implementation
//===----------------------------------------------------------------------===//
-GlobalVariable::GlobalVariable(const Type *Ty, bool constant, bool isIntern,
+GlobalVariable::GlobalVariable(const Type *Ty, bool constant, LinkageTypes Link,
Constant *Initializer,
const std::string &Name, Module *ParentModule)
- : GlobalValue(PointerType::get(Ty), Value::GlobalVariableVal, isIntern, Name),
+ : GlobalValue(PointerType::get(Ty), Value::GlobalVariableVal, Link, Name),
isConstantGlobal(constant) {
if (Initializer) Operands.push_back(Use((Value*)Initializer, this));
Index: llvm/lib/VMCore/Module.cpp
diff -u llvm/lib/VMCore/Module.cpp:1.33 llvm/lib/VMCore/Module.cpp:1.34
--- llvm/lib/VMCore/Module.cpp:1.33 Wed Nov 20 12:33:41 2002
+++ llvm/lib/VMCore/Module.cpp Wed Apr 16 15:28:45 2003
@@ -17,13 +17,14 @@
Function *ilist_traits<Function>::createNode() {
FunctionType *FTy =
FunctionType::get(Type::VoidTy, std::vector<const Type*>(), false);
- Function *Ret = new Function(FTy, false);
+ Function *Ret = new Function(FTy, GlobalValue::ExternalLinkage);
// This should not be garbage monitored.
LeakDetector::removeGarbageObject(Ret);
return Ret;
}
GlobalVariable *ilist_traits<GlobalVariable>::createNode() {
- GlobalVariable *Ret = new GlobalVariable(Type::IntTy, false, false);
+ GlobalVariable *Ret = new GlobalVariable(Type::IntTy, false,
+ GlobalValue::ExternalLinkage);
// This should not be garbage monitored.
LeakDetector::removeGarbageObject(Ret);
return Ret;
@@ -87,7 +88,7 @@
if (Value *V = SymTab.lookup(PointerType::get(Ty), Name)) {
return cast<Function>(V); // Yup, got it
} else { // Nope, add one
- Function *New = new Function(Ty, false, Name);
+ Function *New = new Function(Ty, GlobalVariable::ExternalLinkage, Name);
FunctionList.push_back(New);
return New; // Return the new prototype...
}
More information about the llvm-commits
mailing list