aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/CGObjCMac.cpp
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2008-08-23 18:37:06 +0000
committerDaniel Dunbar <daniel@zuster.org>2008-08-23 18:37:06 +0000
commit3e9df9920db8de8ec93a424b0c1784f9bff301ea (patch)
tree704ed64383629d3ac44919148c0b0f03b3bc7248 /lib/CodeGen/CGObjCMac.cpp
parent5654ffda8f44cb11e3380823a99f6556961bdc16 (diff)
NeXT: Clean up constant CFString handling.
- Use CodeGenModule::GetAddrOfConstantCFString Some tweaks of CodeGenModule::GetAddrOfConstantCFString git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55243 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGObjCMac.cpp')
-rw-r--r--lib/CodeGen/CGObjCMac.cpp74
1 files changed, 2 insertions, 72 deletions
diff --git a/lib/CodeGen/CGObjCMac.cpp b/lib/CodeGen/CGObjCMac.cpp
index 7b5db81231..95f23c9c27 100644
--- a/lib/CodeGen/CGObjCMac.cpp
+++ b/lib/CodeGen/CGObjCMac.cpp
@@ -38,8 +38,6 @@ class ObjCTypesHelper {
private:
CodeGen::CodeGenModule &CGM;
- const llvm::StructType *CFStringType;
- llvm::Constant *CFConstantStringClassReference;
llvm::Function *MessageSendFn, *MessageSendStretFn;
llvm::Function *MessageSendSuperFn, *MessageSendSuperStretFn;
@@ -129,8 +127,6 @@ public:
ObjCTypesHelper(CodeGen::CodeGenModule &cgm);
~ObjCTypesHelper();
- llvm::Constant *getCFConstantStringClassReference();
- const llvm::StructType *getCFStringType();
llvm::Value *getMessageSendFn(bool IsSuper, const llvm::Type *ReturnTy);
};
@@ -388,40 +384,7 @@ llvm::Value *CGObjCMac::GetSelector(llvm::IRBuilder<> &Builder, Selector Sel) {
*/
llvm::Constant *CGObjCMac::GenerateConstantString(const std::string &String) {
- // FIXME: I have no idea what this constant is (it is a magic
- // constant in GCC as well). Most likely the encoding of the string
- // and at least one part of it relates to UTF-16. Is this just the
- // code for UTF-8? Where is this handled for us?
- // See: <rdr://2996215>
- unsigned flags = 0x07c8;
-
- // FIXME: Use some machinery to unique this. We can't reuse the CGM
- // one since we put them in a different section.
- llvm::Constant *StringC = llvm::ConstantArray::get(String);
- llvm::Constant *StringGV =
- new llvm::GlobalVariable(StringC->getType(), true,
- llvm::GlobalValue::InternalLinkage,
- StringC, ".str", &CGM.getModule());
- llvm::Constant *Values[4] = {
- ObjCTypes.getCFConstantStringClassReference(),
- llvm::ConstantInt::get(llvm::Type::Int32Ty, flags),
- getConstantGEP(StringGV, 0, 0), // Decay array -> ptr
- llvm::ConstantInt::get(ObjCTypes.LongTy, String.size())
- };
-
- llvm::Constant *CFStringC =
- llvm::ConstantStruct::get(ObjCTypes.getCFStringType(),
- std::vector<llvm::Constant*>(Values, Values+4));
-
- llvm::GlobalVariable *CFStringGV =
- new llvm::GlobalVariable(CFStringC->getType(), true,
- llvm::GlobalValue::InternalLinkage,
- CFStringC, "",
- &CGM.getModule());
-
- CFStringGV->setSection("__DATA, __cfstring");
-
- return CFStringGV;
+ return CGM.GetAddrOfConstantCFString(String);
}
/// Generates a message send where the super is the receiver. This is
@@ -1537,9 +1500,7 @@ void CGObjCMac::FinishModule() {
/* *** */
ObjCTypesHelper::ObjCTypesHelper(CodeGen::CodeGenModule &cgm)
- : CGM(cgm),
- CFStringType(0),
- CFConstantStringClassReference(0)
+ : CGM(cgm)
{
CodeGen::CodeGenTypes &Types = CGM.getTypes();
ASTContext &Ctx = CGM.getContext();
@@ -1770,37 +1731,6 @@ ObjCTypesHelper::ObjCTypesHelper(CodeGen::CodeGenModule &cgm)
ObjCTypesHelper::~ObjCTypesHelper() {
}
-const llvm::StructType *ObjCTypesHelper::getCFStringType() {
- if (!CFStringType) {
- CFStringType =
- llvm::StructType::get(llvm::PointerType::getUnqual(llvm::Type::Int32Ty),
- llvm::Type::Int32Ty,
- Int8PtrTy,
- LongTy,
- NULL);
-
- CGM.getModule().addTypeName("struct.__builtin_CFString", CFStringType);
- }
-
- return CFStringType;
-}
-
-llvm::Constant *ObjCTypesHelper::getCFConstantStringClassReference() {
- if (!CFConstantStringClassReference) {
- llvm::GlobalValue *GV =
- new llvm::GlobalVariable(llvm::ArrayType::get(llvm::Type::Int32Ty, 0),
- false,
- llvm::GlobalValue::ExternalLinkage,
- 0, "__CFConstantStringClassReference",
- &CGM.getModule());
-
- // Decay to pointer.
- CFConstantStringClassReference = getConstantGEP(GV, 0, 0);
- }
-
- return CFConstantStringClassReference;
-}
-
llvm::Value *ObjCTypesHelper::getMessageSendFn(bool IsSuper,
const llvm::Type *ReturnTy) {
llvm::Function *F;