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

Side by Side Diff: src/IceTargetLoweringARM32.cpp

Issue 1766233002: Subzero: Fix symbol name mangling. Make flags global. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Code review changes Created 4 years, 9 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 889 matching lines...) Expand 10 before | Expand all | Expand 10 after
900 Variable *T = makeReg(IceType_i32); 900 Variable *T = makeReg(IceType_i32);
901 Context.insert<InstFakeDef>(T); 901 Context.insert<InstFakeDef>(T);
902 Context.insert<InstFakeDef>(GotPtr, T); 902 Context.insert<InstFakeDef>(GotPtr, T);
903 } 903 }
904 904
905 IceString TargetARM32::createGotoffRelocation(const ConstantRelocatable *CR) { 905 IceString TargetARM32::createGotoffRelocation(const ConstantRelocatable *CR) {
906 const IceString &CRName = CR->getName(); 906 const IceString &CRName = CR->getName();
907 const IceString CRGotoffName = 907 const IceString CRGotoffName =
908 "GOTOFF$" + Func->getFunctionName() + "$" + CRName; 908 "GOTOFF$" + Func->getFunctionName() + "$" + CRName;
909 if (KnownGotoffs.count(CRGotoffName) == 0) { 909 if (KnownGotoffs.count(CRGotoffName) == 0) {
910 auto *Global = VariableDeclaration::create(Ctx); 910 constexpr bool SuppressMangling = true;
911 auto *Global = VariableDeclaration::create(Ctx, SuppressMangling);
911 Global->setIsConstant(true); 912 Global->setIsConstant(true);
912 Global->setName(CRName); 913 Global->setName(CRName);
913 Global->setSuppressMangling();
914 914
915 auto *Gotoff = VariableDeclaration::create(Ctx); 915 auto *Gotoff = VariableDeclaration::create(Ctx, SuppressMangling);
916 constexpr auto GotFixup = R_ARM_GOTOFF32; 916 constexpr auto GotFixup = R_ARM_GOTOFF32;
917 Gotoff->setIsConstant(true); 917 Gotoff->setIsConstant(true);
918 Gotoff->setName(CRGotoffName);
919 Gotoff->setSuppressMangling();
920 Gotoff->addInitializer(VariableDeclaration::RelocInitializer::create( 918 Gotoff->addInitializer(VariableDeclaration::RelocInitializer::create(
921 Global, {RelocOffset::create(Ctx, 0)}, GotFixup)); 919 Global, {RelocOffset::create(Ctx, 0)}, GotFixup));
920 Gotoff->setName(CRGotoffName);
922 Func->addGlobal(Gotoff); 921 Func->addGlobal(Gotoff);
923 KnownGotoffs.emplace(CRGotoffName); 922 KnownGotoffs.emplace(CRGotoffName);
924 } 923 }
925 return CRGotoffName; 924 return CRGotoffName;
926 } 925 }
927 926
928 void TargetARM32::materializeGotAddr(CfgNode *Node) { 927 void TargetARM32::materializeGotAddr(CfgNode *Node) {
929 if (SandboxingType != ST_Nonsfi) { 928 if (SandboxingType != ST_Nonsfi) {
930 return; 929 return;
931 } 930 }
(...skipping 24 matching lines...) Expand all
956 assert(DefGotPtr->getSrcSize() == 1); 955 assert(DefGotPtr->getSrcSize() == 1);
957 auto *T = llvm::cast<Variable>(DefGotPtr->getSrc(0)); 956 auto *T = llvm::cast<Variable>(DefGotPtr->getSrc(0));
958 loadNamedConstantRelocatablePIC(GlobalOffsetTable, T, 957 loadNamedConstantRelocatablePIC(GlobalOffsetTable, T,
959 [this, T](Variable *PC) { _add(T, PC, T); }); 958 [this, T](Variable *PC) { _add(T, PC, T); });
960 _mov(GotPtr, T); 959 _mov(GotPtr, T);
961 DefGotPtr->setDeleted(); 960 DefGotPtr->setDeleted();
962 } 961 }
963 962
964 void TargetARM32::loadNamedConstantRelocatablePIC( 963 void TargetARM32::loadNamedConstantRelocatablePIC(
965 const IceString &Name, Variable *Register, 964 const IceString &Name, Variable *Register,
966 std::function<void(Variable *PC)> Finish, bool SuppressMangling) { 965 std::function<void(Variable *PC)> Finish) {
967 assert(SandboxingType == ST_Nonsfi); 966 assert(SandboxingType == ST_Nonsfi);
968 // We makeReg() here instead of getPhysicalRegister() because the latter ends 967 // We makeReg() here instead of getPhysicalRegister() because the latter ends
969 // up creating multi-blocks temporaries that liveness fails to validate. 968 // up creating multi-blocks temporaries that liveness fails to validate.
970 auto *PC = makeReg(IceType_i32, RegARM32::Reg_pc); 969 auto *PC = makeReg(IceType_i32, RegARM32::Reg_pc);
971 970
972 auto *AddPcReloc = RelocOffset::create(Ctx); 971 auto *AddPcReloc = RelocOffset::create(Ctx);
973 AddPcReloc->setSubtract(true); 972 AddPcReloc->setSubtract(true);
974 auto *AddPcLabel = InstARM32Label::create(Func, this); 973 auto *AddPcLabel = InstARM32Label::create(Func, this);
975 AddPcLabel->setRelocOffset(AddPcReloc); 974 AddPcLabel->setRelocOffset(AddPcReloc);
976 975
977 const IceString EmitText = Name;
978
979 auto *MovwReloc = RelocOffset::create(Ctx); 976 auto *MovwReloc = RelocOffset::create(Ctx);
980 auto *MovwLabel = InstARM32Label::create(Func, this); 977 auto *MovwLabel = InstARM32Label::create(Func, this);
981 MovwLabel->setRelocOffset(MovwReloc); 978 MovwLabel->setRelocOffset(MovwReloc);
982 979
983 auto *MovtReloc = RelocOffset::create(Ctx); 980 auto *MovtReloc = RelocOffset::create(Ctx);
984 auto *MovtLabel = InstARM32Label::create(Func, this); 981 auto *MovtLabel = InstARM32Label::create(Func, this);
985 MovtLabel->setRelocOffset(MovtReloc); 982 MovtLabel->setRelocOffset(MovtReloc);
986 983
987 // The EmitString for these constant relocatables have hardcoded offsets 984 // The EmitString for these constant relocatables have hardcoded offsets
988 // attached to them. This could be dangerous if, e.g., we ever implemented 985 // attached to them. This could be dangerous if, e.g., we ever implemented
989 // instruction scheduling but llvm-mc currently does not support 986 // instruction scheduling but llvm-mc currently does not support
990 // 987 //
991 // movw reg, #:lower16:(Symbol - Label - Number) 988 // movw reg, #:lower16:(Symbol - Label - Number)
992 // movt reg, #:upper16:(Symbol - Label - Number) 989 // movt reg, #:upper16:(Symbol - Label - Number)
993 // 990 //
994 // relocations. 991 // relocations.
995 static constexpr RelocOffsetT PcOffset = -8; 992 static constexpr RelocOffsetT PcOffset = -8;
996 auto *CRLower = Ctx->getConstantSym(PcOffset, {MovwReloc, AddPcReloc}, Name, 993 auto *CRLower = Ctx->getConstantSym(PcOffset, {MovwReloc, AddPcReloc}, Name,
997 EmitText + " -16", SuppressMangling); 994 Name + " -16");
998 auto *CRUpper = Ctx->getConstantSym(PcOffset, {MovtReloc, AddPcReloc}, Name, 995 auto *CRUpper = Ctx->getConstantSym(PcOffset, {MovtReloc, AddPcReloc}, Name,
999 EmitText + " -12", SuppressMangling); 996 Name + " -12");
1000 997
1001 Context.insert(MovwLabel); 998 Context.insert(MovwLabel);
1002 _movw(Register, CRLower); 999 _movw(Register, CRLower);
1003 Context.insert(MovtLabel); 1000 Context.insert(MovtLabel);
1004 _movt(Register, CRUpper); 1001 _movt(Register, CRUpper);
1005 // PC = fake-def to keep liveness consistent. 1002 // PC = fake-def to keep liveness consistent.
1006 Context.insert<InstFakeDef>(PC); 1003 Context.insert<InstFakeDef>(PC);
1007 Context.insert(AddPcLabel); 1004 Context.insert(AddPcLabel);
1008 Finish(PC); 1005 Finish(PC);
1009 } 1006 }
(...skipping 4957 matching lines...) Expand 10 before | Expand all | Expand 10 after
5967 // because ARM does not have a veor instruction with S registers. 5964 // because ARM does not have a veor instruction with S registers.
5968 Variable *T = makeReg(IceType_f64, RegNum); 5965 Variable *T = makeReg(IceType_f64, RegNum);
5969 Context.insert<InstFakeDef>(T); 5966 Context.insert<InstFakeDef>(T);
5970 _veor(T, T, T); 5967 _veor(T, T, T);
5971 return T; 5968 return T;
5972 } 5969 }
5973 5970
5974 // Load floats/doubles from literal pool. 5971 // Load floats/doubles from literal pool.
5975 std::string Buffer; 5972 std::string Buffer;
5976 llvm::raw_string_ostream StrBuf(Buffer); 5973 llvm::raw_string_ostream StrBuf(Buffer);
5977 llvm::cast<Constant>(From)->emitPoolLabel(StrBuf, Ctx); 5974 llvm::cast<Constant>(From)->emitPoolLabel(StrBuf);
5978 llvm::cast<Constant>(From)->setShouldBePooled(true); 5975 llvm::cast<Constant>(From)->setShouldBePooled(true);
5979 Constant *Offset = Ctx->getConstantSym(0, StrBuf.str(), true); 5976 Constant *Offset = Ctx->getConstantSym(0, StrBuf.str());
5980 Variable *BaseReg = nullptr; 5977 Variable *BaseReg = nullptr;
5981 if (SandboxingType == ST_Nonsfi) { 5978 if (SandboxingType == ST_Nonsfi) {
5982 // vldr does not support the [base, index] addressing mode, so we need 5979 // vldr does not support the [base, index] addressing mode, so we need
5983 // to legalize Offset to a register. Otherwise, we could simply 5980 // to legalize Offset to a register. Otherwise, we could simply
5984 // vldr dest, [got, reg(Offset)] 5981 // vldr dest, [got, reg(Offset)]
5985 BaseReg = legalizeToReg(Offset); 5982 BaseReg = legalizeToReg(Offset);
5986 } else { 5983 } else {
5987 BaseReg = makeReg(getPointerType()); 5984 BaseReg = makeReg(getPointerType());
5988 _movw(BaseReg, Offset); 5985 _movw(BaseReg, Offset);
5989 _movt(BaseReg, Offset); 5986 _movt(BaseReg, Offset);
(...skipping 761 matching lines...) Expand 10 before | Expand all | Expand 10 after
6751 static_assert(sizeof(double) == sizeof(uint64_t), 6748 static_assert(sizeof(double) == sizeof(uint64_t),
6752 "Double should be 8 bytes."); 6749 "Double should be 8 bytes.");
6753 return Utils::bitCopy<uint64_t>(Value); 6750 return Utils::bitCopy<uint64_t>(Value);
6754 } 6751 }
6755 }; 6752 };
6756 const char ConstantPoolEmitterTraits<double>::AsmTag[] = ".quad"; 6753 const char ConstantPoolEmitterTraits<double>::AsmTag[] = ".quad";
6757 const char ConstantPoolEmitterTraits<double>::TypeName[] = "f64"; 6754 const char ConstantPoolEmitterTraits<double>::TypeName[] = "f64";
6758 6755
6759 template <typename T> 6756 template <typename T>
6760 void emitConstant( 6757 void emitConstant(
6761 Ostream &Str, const GlobalContext *Ctx, 6758 Ostream &Str,
6762 const typename ConstantPoolEmitterTraits<T>::ConstantType *Const) { 6759 const typename ConstantPoolEmitterTraits<T>::ConstantType *Const) {
6763 using Traits = ConstantPoolEmitterTraits<T>; 6760 using Traits = ConstantPoolEmitterTraits<T>;
6764 Const->emitPoolLabel(Str, Ctx); 6761 Const->emitPoolLabel(Str);
6765 Str << ":\n\t" << Traits::AsmTag << "\t0x"; 6762 Str << ":\n\t" << Traits::AsmTag << "\t0x";
6766 T Value = Const->getValue(); 6763 T Value = Const->getValue();
6767 Str.write_hex(Traits::bitcastToUint64(Value)); 6764 Str.write_hex(Traits::bitcastToUint64(Value));
6768 Str << "\t/* " << Traits::TypeName << " " << Value << " */\n"; 6765 Str << "\t/* " << Traits::TypeName << " " << Value << " */\n";
6769 } 6766 }
6770 6767
6771 template <typename T> void emitConstantPool(GlobalContext *Ctx) { 6768 template <typename T> void emitConstantPool(GlobalContext *Ctx) {
6772 if (!BuildDefs::dump()) { 6769 if (!BuildDefs::dump()) {
6773 return; 6770 return;
6774 } 6771 }
(...skipping 12 matching lines...) Expand all
6787 if (Ctx->getFlags().shouldReorderPooledConstants()) { 6784 if (Ctx->getFlags().shouldReorderPooledConstants()) {
6788 // TODO(jpp): add constant pooling. 6785 // TODO(jpp): add constant pooling.
6789 UnimplementedError(Ctx->getFlags()); 6786 UnimplementedError(Ctx->getFlags());
6790 } 6787 }
6791 6788
6792 for (Constant *C : Pool) { 6789 for (Constant *C : Pool) {
6793 if (!C->getShouldBePooled()) { 6790 if (!C->getShouldBePooled()) {
6794 continue; 6791 continue;
6795 } 6792 }
6796 6793
6797 emitConstant<T>(Str, Ctx, llvm::dyn_cast<typename Traits::ConstantType>(C)); 6794 emitConstant<T>(Str, llvm::dyn_cast<typename Traits::ConstantType>(C));
6798 } 6795 }
6799 } 6796 }
6800 } // end of anonymous namespace 6797 } // end of anonymous namespace
6801 6798
6802 void TargetDataARM32::lowerConstants() { 6799 void TargetDataARM32::lowerConstants() {
6803 if (Ctx->getFlags().getDisableTranslation()) 6800 if (Ctx->getFlags().getDisableTranslation())
6804 return; 6801 return;
6805 switch (Ctx->getFlags().getOutFileType()) { 6802 switch (Ctx->getFlags().getOutFileType()) {
6806 case FT_Elf: { 6803 case FT_Elf: {
6807 ELFObjectWriter *Writer = Ctx->getObjectWriter(); 6804 ELFObjectWriter *Writer = Ctx->getObjectWriter();
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
6885 // However, for compatibility with current NaCl LLVM, don't claim that. 6882 // However, for compatibility with current NaCl LLVM, don't claim that.
6886 Str << ".eabi_attribute 14, 3 @ Tag_ABI_PCS_R9_use: Not used\n"; 6883 Str << ".eabi_attribute 14, 3 @ Tag_ABI_PCS_R9_use: Not used\n";
6887 } 6884 }
6888 6885
6889 SmallBitVector TargetARM32::TypeToRegisterSet[RegARM32::RCARM32_NUM]; 6886 SmallBitVector TargetARM32::TypeToRegisterSet[RegARM32::RCARM32_NUM];
6890 SmallBitVector TargetARM32::TypeToRegisterSetUnfiltered[RegARM32::RCARM32_NUM]; 6887 SmallBitVector TargetARM32::TypeToRegisterSetUnfiltered[RegARM32::RCARM32_NUM];
6891 SmallBitVector TargetARM32::RegisterAliases[RegARM32::Reg_NUM]; 6888 SmallBitVector TargetARM32::RegisterAliases[RegARM32::Reg_NUM];
6892 6889
6893 } // end of namespace ARM32 6890 } // end of namespace ARM32
6894 } // end of namespace Ice 6891 } // 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