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

Side by Side Diff: src/IceTargetLoweringARM32.cpp

Issue 1386593004: Subzero: Fix nondeterministic behavior in constant pool creation. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Update comment Created 5 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 | « src/IceTargetLoweringARM32.h ('k') | src/IceTargetLoweringX8632.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 //===- subzero/src/IceTargetLoweringARM32.cpp - ARM32 lowering ------------===// 1 //===- subzero/src/IceTargetLoweringARM32.cpp - ARM32 lowering ------------===//
2 // 2 //
3 // The Subzero Code Generator 3 // The Subzero Code Generator
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 /// \file 10 /// \file
(...skipping 3132 matching lines...) Expand 10 before | Expand all | Expand 10 after
3143 assert(isScalarFloatingType(Ty)); 3143 assert(isScalarFloatingType(Ty));
3144 // Load floats/doubles from literal pool. 3144 // Load floats/doubles from literal pool.
3145 // TODO(jvoung): Allow certain immediates to be encoded directly in an 3145 // TODO(jvoung): Allow certain immediates to be encoded directly in an
3146 // operand. See Table A7-18 of the ARM manual: "Floating-point modified 3146 // operand. See Table A7-18 of the ARM manual: "Floating-point modified
3147 // immediate constants". Or, for 32-bit floating point numbers, just 3147 // immediate constants". Or, for 32-bit floating point numbers, just
3148 // encode the raw bits into a movw/movt pair to GPR, and vmov to an SREG, 3148 // encode the raw bits into a movw/movt pair to GPR, and vmov to an SREG,
3149 // instead of using a movw/movt pair to get the const-pool address then 3149 // instead of using a movw/movt pair to get the const-pool address then
3150 // loading to SREG. 3150 // loading to SREG.
3151 std::string Buffer; 3151 std::string Buffer;
3152 llvm::raw_string_ostream StrBuf(Buffer); 3152 llvm::raw_string_ostream StrBuf(Buffer);
3153 llvm::cast<Constant>(From)->emitPoolLabel(StrBuf); 3153 llvm::cast<Constant>(From)->emitPoolLabel(StrBuf, Ctx);
3154 llvm::cast<Constant>(From)->setShouldBePooled(true); 3154 llvm::cast<Constant>(From)->setShouldBePooled(true);
3155 Constant *Offset = Ctx->getConstantSym(0, StrBuf.str(), true); 3155 Constant *Offset = Ctx->getConstantSym(0, StrBuf.str(), true);
3156 Variable *BaseReg = makeReg(getPointerType()); 3156 Variable *BaseReg = makeReg(getPointerType());
3157 _movw(BaseReg, Offset); 3157 _movw(BaseReg, Offset);
3158 _movt(BaseReg, Offset); 3158 _movt(BaseReg, Offset);
3159 From = formMemoryOperand(BaseReg, Ty); 3159 From = formMemoryOperand(BaseReg, Ty);
3160 return copyToReg(From, RegNum); 3160 return copyToReg(From, RegNum);
3161 } 3161 }
3162 } 3162 }
3163 3163
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
3351 static_assert(sizeof(double) == sizeof(uint64_t), 3351 static_assert(sizeof(double) == sizeof(uint64_t),
3352 "Double should be 8 bytes."); 3352 "Double should be 8 bytes.");
3353 return *reinterpret_cast<uint64_t *>(&Value); 3353 return *reinterpret_cast<uint64_t *>(&Value);
3354 } 3354 }
3355 }; 3355 };
3356 const char ConstantPoolEmitterTraits<double>::AsmTag[] = ".quad"; 3356 const char ConstantPoolEmitterTraits<double>::AsmTag[] = ".quad";
3357 const char ConstantPoolEmitterTraits<double>::TypeName[] = "f64"; 3357 const char ConstantPoolEmitterTraits<double>::TypeName[] = "f64";
3358 3358
3359 template <typename T> 3359 template <typename T>
3360 void emitConstant( 3360 void emitConstant(
3361 Ostream &Str, 3361 Ostream &Str, const GlobalContext *Ctx,
3362 const typename ConstantPoolEmitterTraits<T>::ConstantType *Const) { 3362 const typename ConstantPoolEmitterTraits<T>::ConstantType *Const) {
3363 using Traits = ConstantPoolEmitterTraits<T>; 3363 using Traits = ConstantPoolEmitterTraits<T>;
3364 Const->emitPoolLabel(Str); 3364 Const->emitPoolLabel(Str, Ctx);
3365 Str << ":\n\t" << Traits::AsmTag << "\t0x"; 3365 Str << ":\n\t" << Traits::AsmTag << "\t0x";
3366 T Value = Const->getValue(); 3366 T Value = Const->getValue();
3367 Str.write_hex(Traits::bitcastToUint64(Value)); 3367 Str.write_hex(Traits::bitcastToUint64(Value));
3368 Str << "\t@" << Traits::TypeName << " " << Value << "\n"; 3368 Str << "\t@" << Traits::TypeName << " " << Value << "\n";
3369 } 3369 }
3370 3370
3371 template <typename T> void emitConstantPool(GlobalContext *Ctx) { 3371 template <typename T> void emitConstantPool(GlobalContext *Ctx) {
3372 if (!BuildDefs::dump()) { 3372 if (!BuildDefs::dump()) {
3373 return; 3373 return;
3374 } 3374 }
(...skipping 12 matching lines...) Expand all
3387 if (Ctx->getFlags().shouldReorderPooledConstants()) { 3387 if (Ctx->getFlags().shouldReorderPooledConstants()) {
3388 // TODO(jpp): add constant pooling. 3388 // TODO(jpp): add constant pooling.
3389 UnimplementedError(Ctx->getFlags()); 3389 UnimplementedError(Ctx->getFlags());
3390 } 3390 }
3391 3391
3392 for (Constant *C : Pool) { 3392 for (Constant *C : Pool) {
3393 if (!C->getShouldBePooled()) { 3393 if (!C->getShouldBePooled()) {
3394 continue; 3394 continue;
3395 } 3395 }
3396 3396
3397 emitConstant<T>(Str, llvm::dyn_cast<typename Traits::ConstantType>(C)); 3397 emitConstant<T>(Str, Ctx, llvm::dyn_cast<typename Traits::ConstantType>(C));
3398 } 3398 }
3399 } 3399 }
3400 } // end of anonymous namespace 3400 } // end of anonymous namespace
3401 3401
3402 void TargetDataARM32::lowerConstants() { 3402 void TargetDataARM32::lowerConstants() {
3403 if (Ctx->getFlags().getDisableTranslation()) 3403 if (Ctx->getFlags().getDisableTranslation())
3404 return; 3404 return;
3405 switch (Ctx->getFlags().getOutFileType()) { 3405 switch (Ctx->getFlags().getOutFileType()) {
3406 case FT_Elf: 3406 case FT_Elf:
3407 UnimplementedError(Ctx->getFlags()); 3407 UnimplementedError(Ctx->getFlags());
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
3479 << ".eabi_attribute 68, 1 @ Tag_Virtualization_use\n"; 3479 << ".eabi_attribute 68, 1 @ Tag_Virtualization_use\n";
3480 if (CPUFeatures.hasFeature(TargetARM32Features::HWDivArm)) { 3480 if (CPUFeatures.hasFeature(TargetARM32Features::HWDivArm)) {
3481 Str << ".eabi_attribute 44, 2 @ Tag_DIV_use\n"; 3481 Str << ".eabi_attribute 44, 2 @ Tag_DIV_use\n";
3482 } 3482 }
3483 // Technically R9 is used for TLS with Sandboxing, and we reserve it. 3483 // Technically R9 is used for TLS with Sandboxing, and we reserve it.
3484 // However, for compatibility with current NaCl LLVM, don't claim that. 3484 // However, for compatibility with current NaCl LLVM, don't claim that.
3485 Str << ".eabi_attribute 14, 3 @ Tag_ABI_PCS_R9_use: Not used\n"; 3485 Str << ".eabi_attribute 14, 3 @ Tag_ABI_PCS_R9_use: Not used\n";
3486 } 3486 }
3487 3487
3488 } // end of namespace Ice 3488 } // end of namespace Ice
OLDNEW
« no previous file with comments | « src/IceTargetLoweringARM32.h ('k') | src/IceTargetLoweringX8632.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698