Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(120)

Side by Side Diff: lib/CodeGen/TargetInfo.cpp

Issue 10986071: Properly factor Native Client defines to support NaCl OS on ARM and x86 (Closed) Base URL: http://llvm.org/git/clang.git@master
Patch Set: Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « lib/Basic/Targets.cpp ('k') | test/CodeGen/arm-aapcs-vfp.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 //===---- TargetInfo.cpp - Encapsulate target details -----------*- C++ -*-===// 1 //===---- TargetInfo.cpp - Encapsulate target details -----------*- C++ -*-===//
2 // 2 //
3 // The LLVM Compiler Infrastructure 3 // The LLVM Compiler Infrastructure
4 // 4 //
5 // This file is distributed under the University of Illinois Open Source 5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details. 6 // License. See LICENSE.TXT for details.
7 // 7 //
8 //===----------------------------------------------------------------------===// 8 //===----------------------------------------------------------------------===//
9 // 9 //
10 // These classes wrap the information about a call or function 10 // These classes wrap the information about a call or function
(...skipping 1096 matching lines...) Expand 10 before | Expand all | Expand 10 after
1107 /// The 0.98 ABI revision clarified a lot of ambiguities, 1107 /// The 0.98 ABI revision clarified a lot of ambiguities,
1108 /// unfortunately in ways that were not always consistent with 1108 /// unfortunately in ways that were not always consistent with
1109 /// certain previous compilers. In particular, platforms which 1109 /// certain previous compilers. In particular, platforms which
1110 /// required strict binary compatibility with older versions of GCC 1110 /// required strict binary compatibility with older versions of GCC
1111 /// may need to exempt themselves. 1111 /// may need to exempt themselves.
1112 bool honorsRevision0_98() const { 1112 bool honorsRevision0_98() const {
1113 return !getContext().getTargetInfo().getTriple().isOSDarwin(); 1113 return !getContext().getTargetInfo().getTriple().isOSDarwin();
1114 } 1114 }
1115 1115
1116 bool HasAVX; 1116 bool HasAVX;
1117 // Some ABIs (e.g. X32 ABI and Native Client OS) use 32 bit pointers on
1118 // 64-bit hardware.
1119 bool Has64BitPointers;
1117 1120
1118 public: 1121 public:
1119 X86_64ABIInfo(CodeGen::CodeGenTypes &CGT, bool hasavx) : 1122 X86_64ABIInfo(CodeGen::CodeGenTypes &CGT, bool hasavx) :
1120 ABIInfo(CGT), HasAVX(hasavx) {} 1123 ABIInfo(CGT), HasAVX(hasavx),
1124 Has64BitPointers(CGT.getDataLayout().getPointerSize() == 8) {
1125 }
1121 1126
1122 bool isPassedUsingAVXType(QualType type) const { 1127 bool isPassedUsingAVXType(QualType type) const {
1123 unsigned neededInt, neededSSE; 1128 unsigned neededInt, neededSSE;
1124 // The freeIntRegs argument doesn't matter here. 1129 // The freeIntRegs argument doesn't matter here.
1125 ABIArgInfo info = classifyArgumentType(type, 0, neededInt, neededSSE); 1130 ABIArgInfo info = classifyArgumentType(type, 0, neededInt, neededSSE);
1126 if (info.isDirect()) { 1131 if (info.isDirect()) {
1127 llvm::Type *ty = info.getCoerceToType(); 1132 llvm::Type *ty = info.getCoerceToType();
1128 if (llvm::VectorType *vectorTy = dyn_cast_or_null<llvm::VectorType>(ty)) 1133 if (llvm::VectorType *vectorTy = dyn_cast_or_null<llvm::VectorType>(ty))
1129 return (vectorTy->getBitWidth() > 128); 1134 return (vectorTy->getBitWidth() > 128);
1130 } 1135 }
(...skipping 16 matching lines...) Expand all
1147 1152
1148 virtual void computeInfo(CGFunctionInfo &FI) const; 1153 virtual void computeInfo(CGFunctionInfo &FI) const;
1149 1154
1150 virtual llvm::Value *EmitVAArg(llvm::Value *VAListAddr, QualType Ty, 1155 virtual llvm::Value *EmitVAArg(llvm::Value *VAListAddr, QualType Ty,
1151 CodeGenFunction &CGF) const; 1156 CodeGenFunction &CGF) const;
1152 }; 1157 };
1153 1158
1154 class X86_64TargetCodeGenInfo : public TargetCodeGenInfo { 1159 class X86_64TargetCodeGenInfo : public TargetCodeGenInfo {
1155 public: 1160 public:
1156 X86_64TargetCodeGenInfo(CodeGen::CodeGenTypes &CGT, bool HasAVX) 1161 X86_64TargetCodeGenInfo(CodeGen::CodeGenTypes &CGT, bool HasAVX)
1157 : TargetCodeGenInfo(new X86_64ABIInfo(CGT, HasAVX)) {} 1162 : TargetCodeGenInfo(new X86_64ABIInfo(CGT, HasAVX)) {}
1158 1163
1159 const X86_64ABIInfo &getABIInfo() const { 1164 const X86_64ABIInfo &getABIInfo() const {
1160 return static_cast<const X86_64ABIInfo&>(TargetCodeGenInfo::getABIInfo()); 1165 return static_cast<const X86_64ABIInfo&>(TargetCodeGenInfo::getABIInfo());
1161 } 1166 }
1162 1167
1163 int getDwarfEHStackPointer(CodeGen::CodeGenModule &CGM) const { 1168 int getDwarfEHStackPointer(CodeGen::CodeGenModule &CGM) const {
1164 return 7; 1169 return 7;
1165 } 1170 }
1166 1171
1167 bool initDwarfEHRegSizeTable(CodeGen::CodeGenFunction &CGF, 1172 bool initDwarfEHRegSizeTable(CodeGen::CodeGenFunction &CGF,
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
1320 if (const BuiltinType *BT = Ty->getAs<BuiltinType>()) { 1325 if (const BuiltinType *BT = Ty->getAs<BuiltinType>()) {
1321 BuiltinType::Kind k = BT->getKind(); 1326 BuiltinType::Kind k = BT->getKind();
1322 1327
1323 if (k == BuiltinType::Void) { 1328 if (k == BuiltinType::Void) {
1324 Current = NoClass; 1329 Current = NoClass;
1325 } else if (k == BuiltinType::Int128 || k == BuiltinType::UInt128) { 1330 } else if (k == BuiltinType::Int128 || k == BuiltinType::UInt128) {
1326 Lo = Integer; 1331 Lo = Integer;
1327 Hi = Integer; 1332 Hi = Integer;
1328 } else if (k >= BuiltinType::Bool && k <= BuiltinType::LongLong) { 1333 } else if (k >= BuiltinType::Bool && k <= BuiltinType::LongLong) {
1329 Current = Integer; 1334 Current = Integer;
1330 } else if (k == BuiltinType::Float || k == BuiltinType::Double) { 1335 } else if ((k == BuiltinType::Float || k == BuiltinType::Double) ||
1336 (k == BuiltinType::LongDouble &&
1337 getContext().getTargetInfo().getTriple().getOS() ==
1338 llvm::Triple::NativeClient)) {
1331 Current = SSE; 1339 Current = SSE;
1332 } else if (k == BuiltinType::LongDouble) { 1340 } else if (k == BuiltinType::LongDouble) {
1333 Lo = X87; 1341 Lo = X87;
1334 Hi = X87Up; 1342 Hi = X87Up;
1335 } 1343 }
1336 // FIXME: _Decimal32 and _Decimal64 are SSE. 1344 // FIXME: _Decimal32 and _Decimal64 are SSE.
1337 // FIXME: _float128 and _Decimal128 are (SSE, SSEUp). 1345 // FIXME: _float128 and _Decimal128 are (SSE, SSEUp).
1338 return; 1346 return;
1339 } 1347 }
1340 1348
1341 if (const EnumType *ET = Ty->getAs<EnumType>()) { 1349 if (const EnumType *ET = Ty->getAs<EnumType>()) {
1342 // Classify the underlying integer type. 1350 // Classify the underlying integer type.
1343 classify(ET->getDecl()->getIntegerType(), OffsetBase, Lo, Hi); 1351 classify(ET->getDecl()->getIntegerType(), OffsetBase, Lo, Hi);
1344 return; 1352 return;
1345 } 1353 }
1346 1354
1347 if (Ty->hasPointerRepresentation()) { 1355 if (Ty->hasPointerRepresentation()) {
1348 Current = Integer; 1356 Current = Integer;
1349 return; 1357 return;
1350 } 1358 }
1351 1359
1352 if (Ty->isMemberPointerType()) { 1360 if (Ty->isMemberPointerType()) {
1353 if (Ty->isMemberFunctionPointerType()) 1361 if (Ty->isMemberFunctionPointerType() && Has64BitPointers)
1354 Lo = Hi = Integer; 1362 Lo = Hi = Integer;
1355 else 1363 else
1356 Current = Integer; 1364 Current = Integer;
1357 return; 1365 return;
1358 } 1366 }
1359 1367
1360 if (const VectorType *VT = Ty->getAs<VectorType>()) { 1368 if (const VectorType *VT = Ty->getAs<VectorType>()) {
1361 uint64_t Size = getContext().getTypeSize(VT); 1369 uint64_t Size = getContext().getTypeSize(VT);
1362 if (Size == 32) { 1370 if (Size == 32) {
1363 // gcc passes all <4 x char>, <2 x short>, <1 x int>, <1 x 1371 // gcc passes all <4 x char>, <2 x short>, <1 x int>, <1 x
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
1406 QualType ET = getContext().getCanonicalType(CT->getElementType()); 1414 QualType ET = getContext().getCanonicalType(CT->getElementType());
1407 1415
1408 uint64_t Size = getContext().getTypeSize(Ty); 1416 uint64_t Size = getContext().getTypeSize(Ty);
1409 if (ET->isIntegralOrEnumerationType()) { 1417 if (ET->isIntegralOrEnumerationType()) {
1410 if (Size <= 64) 1418 if (Size <= 64)
1411 Current = Integer; 1419 Current = Integer;
1412 else if (Size <= 128) 1420 else if (Size <= 128)
1413 Lo = Hi = Integer; 1421 Lo = Hi = Integer;
1414 } else if (ET == getContext().FloatTy) 1422 } else if (ET == getContext().FloatTy)
1415 Current = SSE; 1423 Current = SSE;
1416 else if (ET == getContext().DoubleTy) 1424 else if (ET == getContext().DoubleTy ||
1425 (ET == getContext().LongDoubleTy &&
1426 getContext().getTargetInfo().getTriple().getOS() ==
1427 llvm::Triple::NativeClient))
1417 Lo = Hi = SSE; 1428 Lo = Hi = SSE;
1418 else if (ET == getContext().LongDoubleTy) 1429 else if (ET == getContext().LongDoubleTy)
1419 Current = ComplexX87; 1430 Current = ComplexX87;
1420 1431
1421 // If this complex type crosses an eightbyte boundary then it 1432 // If this complex type crosses an eightbyte boundary then it
1422 // should be split. 1433 // should be split.
1423 uint64_t EB_Real = (OffsetBase) / 64; 1434 uint64_t EB_Real = (OffsetBase) / 64;
1424 uint64_t EB_Imag = (OffsetBase + getContext().getTypeSize(ET)) / 64; 1435 uint64_t EB_Imag = (OffsetBase + getContext().getTypeSize(ET)) / 64;
1425 if (Hi == NoClass && EB_Real != EB_Imag) 1436 if (Hi == NoClass && EB_Real != EB_Imag)
1426 Hi = Lo; 1437 Hi = Lo;
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after
1854 /// SourceTy is the source level type for the entire argument. SourceOffset is 1865 /// SourceTy is the source level type for the entire argument. SourceOffset is
1855 /// an offset into this that we're processing (which is always either 0 or 8). 1866 /// an offset into this that we're processing (which is always either 0 or 8).
1856 /// 1867 ///
1857 llvm::Type *X86_64ABIInfo:: 1868 llvm::Type *X86_64ABIInfo::
1858 GetINTEGERTypeAtOffset(llvm::Type *IRType, unsigned IROffset, 1869 GetINTEGERTypeAtOffset(llvm::Type *IRType, unsigned IROffset,
1859 QualType SourceTy, unsigned SourceOffset) const { 1870 QualType SourceTy, unsigned SourceOffset) const {
1860 // If we're dealing with an un-offset LLVM IR type, then it means that we're 1871 // If we're dealing with an un-offset LLVM IR type, then it means that we're
1861 // returning an 8-byte unit starting with it. See if we can safely use it. 1872 // returning an 8-byte unit starting with it. See if we can safely use it.
1862 if (IROffset == 0) { 1873 if (IROffset == 0) {
1863 // Pointers and int64's always fill the 8-byte unit. 1874 // Pointers and int64's always fill the 8-byte unit.
1864 if (isa<llvm::PointerType>(IRType) || IRType->isIntegerTy(64)) 1875 if ((isa<llvm::PointerType>(IRType) && Has64BitPointers) ||
1876 IRType->isIntegerTy(64))
1865 return IRType; 1877 return IRType;
1866 1878
1867 // If we have a 1/2/4-byte integer, we can use it only if the rest of the 1879 // If we have a 1/2/4-byte integer, we can use it only if the rest of the
1868 // goodness in the source type is just tail padding. This is allowed to 1880 // goodness in the source type is just tail padding. This is allowed to
1869 // kick in for struct {double,int} on the int, but not on 1881 // kick in for struct {double,int} on the int, but not on
1870 // struct{double,int,int} because we wouldn't return the second int. We 1882 // struct{double,int,int} because we wouldn't return the second int. We
1871 // have to do this analysis on the source type because we can't depend on 1883 // have to do this analysis on the source type because we can't depend on
1872 // unions being lowered a specific way etc. 1884 // unions being lowered a specific way etc.
1873 if (IRType->isIntegerTy(8) || IRType->isIntegerTy(16) || 1885 if (IRType->isIntegerTy(8) || IRType->isIntegerTy(16) ||
1874 IRType->isIntegerTy(32)) { 1886 IRType->isIntegerTy(32) ||
1875 unsigned BitWidth = cast<llvm::IntegerType>(IRType)->getBitWidth(); 1887 (isa<llvm::PointerType>(IRType) && !Has64BitPointers)) {
1888 unsigned BitWidth = isa<llvm::PointerType>(IRType) ? 32 :
1889 cast<llvm::IntegerType>(IRType)->getBitWidth();
1876 1890
1877 if (BitsContainNoUserData(SourceTy, SourceOffset*8+BitWidth, 1891 if (BitsContainNoUserData(SourceTy, SourceOffset*8+BitWidth,
1878 SourceOffset*8+64, getContext())) 1892 SourceOffset*8+64, getContext()))
1879 return IRType; 1893 return IRType;
1880 } 1894 }
1881 } 1895 }
1882 1896
1883 if (llvm::StructType *STy = dyn_cast<llvm::StructType>(IRType)) { 1897 if (llvm::StructType *STy = dyn_cast<llvm::StructType>(IRType)) {
1884 // If this is a struct, recurse into the field at the specified offset. 1898 // If this is a struct, recurse into the field at the specified offset.
1885 const llvm::StructLayout *SL = getDataLayout().getStructLayout(STy); 1899 const llvm::StructLayout *SL = getDataLayout().getStructLayout(STy);
(...skipping 2149 matching lines...) Expand 10 before | Expand all | Expand 10 after
4035 return *(TheTargetCodeGenInfo = new WinX86_64TargetCodeGenInfo(Types)); 4049 return *(TheTargetCodeGenInfo = new WinX86_64TargetCodeGenInfo(Types));
4036 default: 4050 default:
4037 return *(TheTargetCodeGenInfo = new X86_64TargetCodeGenInfo(Types, 4051 return *(TheTargetCodeGenInfo = new X86_64TargetCodeGenInfo(Types,
4038 HasAVX)); 4052 HasAVX));
4039 } 4053 }
4040 } 4054 }
4041 case llvm::Triple::hexagon: 4055 case llvm::Triple::hexagon:
4042 return *(TheTargetCodeGenInfo = new HexagonTargetCodeGenInfo(Types)); 4056 return *(TheTargetCodeGenInfo = new HexagonTargetCodeGenInfo(Types));
4043 } 4057 }
4044 } 4058 }
OLDNEW
« no previous file with comments | « lib/Basic/Targets.cpp ('k') | test/CodeGen/arm-aapcs-vfp.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698