[cfe-commits] r66432 - /cfe/trunk/lib/CodeGen/CGObjCMac.cpp
Daniel Dunbar
daniel at zuster.org
Mon Mar 9 13:09:19 PDT 2009
Author: ddunbar
Date: Mon Mar 9 15:09:19 2009
New Revision: 66432
URL: http://llvm.org/viewvc/llvm-project?rev=66432&view=rev
Log:
NeXT: Add CreateMetadataVar utility method to encapsulate creation of
Obj-C metadata variables (which generally should be handled the same,
although they aren't currently).
- No functionality change.
Modified:
cfe/trunk/lib/CodeGen/CGObjCMac.cpp
Modified: cfe/trunk/lib/CodeGen/CGObjCMac.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCMac.cpp?rev=66432&r1=66431&r2=66432&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGObjCMac.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjCMac.cpp Mon Mar 9 15:09:19 2009
@@ -430,6 +430,18 @@
uint64_t GetIvarBaseOffset(const llvm::StructLayout *Layout,
FieldDecl *Field);
+ /// CreateMetadataVar - Create a global variable with internal
+ /// linkage for use by the Objective-C runtime.
+ ///
+ /// This is a convenience wrapper which not only creates the
+ /// variable, but also sets the section and alignment and adds the
+ /// global to the UsedGlobals list.
+ llvm::GlobalVariable *CreateMetadataVar(const std::string &Name,
+ llvm::Constant *Init,
+ const char *Section,
+ bool SetAlignment,
+ bool IsUsed);
+
public:
CGObjCCommonMac(CodeGen::CodeGenModule &cgm) : CGM(cgm)
{ }
@@ -1836,6 +1848,28 @@
CGM.getTypes().getLLVMFieldNo(Field));
}
+llvm::GlobalVariable *
+CGObjCCommonMac::CreateMetadataVar(const std::string &Name,
+ llvm::Constant *Init,
+ const char *Section,
+ bool SetAlignment,
+ bool IsUsed) {
+ const llvm::Type *Ty = Init->getType();
+ llvm::GlobalVariable *GV =
+ new llvm::GlobalVariable(Ty, false,
+ llvm::GlobalValue::InternalLinkage,
+ Init,
+ Name,
+ &CGM.getModule());
+ if (Section)
+ GV->setSection(Section);
+ if (SetAlignment)
+ GV->setAlignment(CGM.getTargetData().getPreferredAlignment(Ty));
+ if (IsUsed)
+ UsedGlobals.push_back(GV);
+ return GV;
+}
+
llvm::Function *CGObjCMac::ModuleInitFunction() {
// Abuse this interface function as a place to finalize.
FinishModule();
More information about the cfe-commits
mailing list