Index: lib/Basic/Targets.cpp =================================================================== --- lib/Basic/Targets.cpp (revision 101173) +++ lib/Basic/Targets.cpp (working copy) @@ -378,9 +378,11 @@ static const Builtin::Info BuiltinInfo[]; static const char * const GCCRegNames[]; static const TargetInfo::GCCRegAlias GCCRegAliases[]; + std::string ABI; + unsigned boolSize; public: - PPCTargetInfo(const std::string& triple) : TargetInfo(triple) {} + PPCTargetInfo(const std::string& triple) : TargetInfo(triple), boolSize(8) {} virtual void getTargetBuiltins(const Builtin::Info *&Records, unsigned &NumRecords) const { @@ -391,16 +393,19 @@ virtual void getTargetDefines(const LangOptions &Opts, MacroBuilder &Builder) const; + virtual const char *getABI() const { return ABI.c_str(); } + virtual bool setABI(const std::string &Name) { + if (Name == "darwin") + boolSize = 32; + else + boolSize = 8; + + ABI = Name; + return true; + } + virtual const char *getVAListDeclaration() const { return "typedef char* __builtin_va_list;"; - // This is the right definition for ABI/V4: System V.4/eabi. - /*return "typedef struct __va_list_tag {" - " unsigned char gpr;" - " unsigned char fpr;" - " unsigned short reserved;" - " void* overflow_arg_area;" - " void* reg_save_area;" - "} __builtin_va_list[1];";*/ } virtual void getGCCRegNames(const char * const *&Names, unsigned &NumNames) const; @@ -421,6 +426,12 @@ virtual const char *getClobbers() const { return ""; } + virtual unsigned getBoolWidth() { + return boolSize; + } + virtual unsigned getBoolAlign() { + return boolSize; + } }; const Builtin::Info PPCTargetInfo::BuiltinInfo[] = { @@ -580,7 +591,26 @@ if (getTriple().getOS() == llvm::Triple::FreeBSD) this->SizeType = TargetInfo::UnsignedInt; + + if (getTriple().getOS() == llvm::Triple::Darwin) + setABI("darwin"); + else + setABI("sysv"); } + + virtual const char *getVAListDeclaration() const { + if (strcmp(getABI(),"sysv") == 0 || strcmp(getABI(),"eabi") == 0) { + return "typedef struct __va_list_tag {" + " unsigned char gpr;" + " unsigned char fpr;" + " unsigned short reserved;" + " void* overflow_arg_area;" + " void* reg_save_area;" + "} __builtin_va_list[1];"; + } else { + return "typedef char* __builtin_va_list;"; + } + } }; } // end anonymous namespace. @@ -594,6 +624,11 @@ Int64Type = SignedLong; DescriptionString = "E-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-" "i64:64:64-f32:32:32-f64:64:64-v128:128:128-n32:64"; + + if (getTriple().getOS() == llvm::Triple::Darwin) + setABI("darwin"); + else + setABI("aix"); } }; } // end anonymous namespace. @@ -2310,7 +2345,7 @@ case llvm::Triple::ppc: if (os == llvm::Triple::Darwin) - return new DarwinTargetInfo(T); + return new DarwinTargetInfo(T); else if (os == llvm::Triple::FreeBSD) return new FreeBSDTargetInfo(T); return new PPC32TargetInfo(T);