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

Side by Side Diff: src/IceTargetLoweringARM32.h

Issue 1499973002: Revert "Subzero. ARM32. Initial sandboxing code." (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Created 5 years 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 | « pydir/targets.py ('k') | src/IceTargetLoweringARM32.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.h - ARM32 lowering ----*- C++ -*-===// 1 //===- subzero/src/IceTargetLoweringARM32.h - ARM32 lowering ----*- C++ -*-===//
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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 int32_t RegNum = Variable::NoRegister); 155 int32_t RegNum = Variable::NoRegister);
156 Variable *legalizeToReg(Operand *From, int32_t RegNum = Variable::NoRegister); 156 Variable *legalizeToReg(Operand *From, int32_t RegNum = Variable::NoRegister);
157 157
158 OperandARM32ShAmtImm *shAmtImm(uint32_t ShAmtImm) const { 158 OperandARM32ShAmtImm *shAmtImm(uint32_t ShAmtImm) const {
159 assert(ShAmtImm < 32); 159 assert(ShAmtImm < 32);
160 return OperandARM32ShAmtImm::create( 160 return OperandARM32ShAmtImm::create(
161 Func, 161 Func,
162 llvm::cast<ConstantInteger32>(Ctx->getConstantInt32(ShAmtImm & 0x1F))); 162 llvm::cast<ConstantInteger32>(Ctx->getConstantInt32(ShAmtImm & 0x1F)));
163 } 163 }
164 164
165 OperandARM32FlexImm *indirectBranchBicMask() const {
166 constexpr uint32_t Imm8 = 0xFC; // 0xC000000F
167 constexpr uint32_t RotateAmt = 2;
168 return OperandARM32FlexImm::create(Func, IceType_i32, Imm8, RotateAmt);
169 }
170
171 OperandARM32FlexImm *memOpBicMask() const {
172 constexpr uint32_t Imm8 = 0x0C; // 0xC0000000
173 constexpr uint32_t RotateAmt = 2;
174 return OperandARM32FlexImm::create(Func, IceType_i32, Imm8, RotateAmt);
175 }
176
177 GlobalContext *getCtx() const { return Ctx; } 165 GlobalContext *getCtx() const { return Ctx; }
178 166
179 protected: 167 protected:
180 explicit TargetARM32(Cfg *Func); 168 explicit TargetARM32(Cfg *Func);
181 169
182 void postLower() override; 170 void postLower() override;
183 171
184 enum SafeBoolChain { 172 enum SafeBoolChain {
185 SBC_No, 173 SBC_No,
186 SBC_Yes, 174 SBC_Yes,
(...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after
827 // TODO(jpp): This could live in the Parser, if we provided a Target-specific 815 // TODO(jpp): This could live in the Parser, if we provided a Target-specific
828 // method that the Parser could call. 816 // method that the Parser could call.
829 void findMaxStackOutArgsSize(); 817 void findMaxStackOutArgsSize();
830 818
831 /// Returns true if the given Offset can be represented in a Load/Store Mem 819 /// Returns true if the given Offset can be represented in a Load/Store Mem
832 /// Operand. 820 /// Operand.
833 bool isLegalMemOffset(Type Ty, int32_t Offset) const; 821 bool isLegalMemOffset(Type Ty, int32_t Offset) const;
834 822
835 void postLowerLegalization(); 823 void postLowerLegalization();
836 824
837 class AutoSandboxer {
838 public:
839 explicit AutoSandboxer(
840 TargetARM32 *Target,
841 InstBundleLock::Option BundleOption = InstBundleLock::Opt_None)
842 : Target(Target) {
843 if (Target->NeedSandboxing) {
844 Target->_bundle_lock(BundleOption);
845 }
846 }
847
848 void add_sp(Operand *AddAmount) {
849 Variable *SP = Target->getPhysicalRegister(RegARM32::Reg_sp);
850 Target->_add(SP, SP, AddAmount);
851 if (Target->NeedSandboxing) {
852 Target->_bic(SP, SP, Target->memOpBicMask());
853 }
854 }
855
856 void align_sp(size_t Alignment) {
857 Variable *SP = Target->getPhysicalRegister(RegARM32::Reg_sp);
858 Target->alignRegisterPow2(SP, Alignment);
859 if (Target->NeedSandboxing) {
860 Target->_bic(SP, SP, Target->memOpBicMask());
861 }
862 }
863
864 InstARM32Call *bl(Variable *ReturnReg, Operand *CallTarget) {
865 if (Target->NeedSandboxing) {
866 if (auto *CallTargetR = llvm::dyn_cast<Variable>(CallTarget)) {
867 Target->_bic(CallTargetR, CallTargetR,
868 Target->indirectBranchBicMask());
869 }
870 }
871 auto *Call = InstARM32Call::create(Target->Func, ReturnReg, CallTarget);
872 Target->Context.insert(Call);
873 return Call;
874 }
875
876 void ldr(Variable *Dest, OperandARM32Mem *Mem, CondARM32::Cond Pred) {
877 if (Target->NeedSandboxing) {
878 assert(!Mem->isRegReg());
879 Variable *MemBase = Mem->getBase();
880 Target->_bic(MemBase, MemBase, Target->memOpBicMask(), Pred);
881 }
882 Target->_ldr(Dest, Mem, Pred);
883 }
884
885 void ldrex(Variable *Dest, OperandARM32Mem *Mem, CondARM32::Cond Pred) {
886 if (Target->NeedSandboxing) {
887 assert(!Mem->isRegReg());
888 Variable *MemBase = Mem->getBase();
889 Target->_bic(MemBase, MemBase, Target->memOpBicMask(), Pred);
890 }
891 Target->_ldrex(Dest, Mem, Pred);
892 }
893
894 void reset_sp(Variable *Src) {
895 Variable *SP = Target->getPhysicalRegister(RegARM32::Reg_sp);
896 Target->_mov_redefined(SP, Src);
897 if (Target->NeedSandboxing) {
898 Target->_bic(SP, SP, Target->memOpBicMask());
899 }
900 }
901
902 void ret(Variable *RetAddr, Variable *RetValue) {
903 if (Target->NeedSandboxing) {
904 Target->_bic(RetAddr, RetAddr, Target->indirectBranchBicMask());
905 }
906 Target->_ret(RetAddr, RetValue);
907 }
908
909 void str(Variable *Src, OperandARM32Mem *Mem, CondARM32::Cond Pred) {
910 if (Target->NeedSandboxing) {
911 assert(!Mem->isRegReg());
912 Variable *MemBase = Mem->getBase();
913 Target->_bic(MemBase, MemBase, Target->memOpBicMask(), Pred);
914 }
915 Target->_str(Src, Mem, Pred);
916 }
917
918 void strex(Variable *Dest, Variable *Src, OperandARM32Mem *Mem,
919 CondARM32::Cond Pred) {
920 if (Target->NeedSandboxing) {
921 assert(!Mem->isRegReg());
922 Variable *MemBase = Mem->getBase();
923 Target->_bic(MemBase, MemBase, Target->memOpBicMask(), Pred);
924 }
925 Target->_strex(Dest, Src, Mem, Pred);
926 }
927
928 void sub_sp(Operand *SubAmount) {
929 Variable *SP = Target->getPhysicalRegister(RegARM32::Reg_sp);
930 Target->_sub(SP, SP, SubAmount);
931 if (Target->NeedSandboxing) {
932 Target->_bic(SP, SP, Target->memOpBicMask());
933 }
934 }
935
936 ~AutoSandboxer() {
937 if (Target->NeedSandboxing) {
938 Target->_bundle_unlock();
939 }
940 }
941
942 private:
943 TargetARM32 *Target;
944 };
945
946 class PostLoweringLegalizer { 825 class PostLoweringLegalizer {
947 PostLoweringLegalizer() = delete; 826 PostLoweringLegalizer() = delete;
948 PostLoweringLegalizer(const PostLoweringLegalizer &) = delete; 827 PostLoweringLegalizer(const PostLoweringLegalizer &) = delete;
949 PostLoweringLegalizer &operator=(const PostLoweringLegalizer &) = delete; 828 PostLoweringLegalizer &operator=(const PostLoweringLegalizer &) = delete;
950 829
951 public: 830 public:
952 explicit PostLoweringLegalizer(TargetARM32 *Target) 831 explicit PostLoweringLegalizer(TargetARM32 *Target)
953 : Target(Target), StackOrFrameReg(Target->getPhysicalRegister( 832 : Target(Target), StackOrFrameReg(Target->getPhysicalRegister(
954 Target->getFrameOrStackReg())) {} 833 Target->getFrameOrStackReg())) {}
955 834
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
992 /// a new base register ip=Base+Offset is created, and the method returns a 871 /// a new base register ip=Base+Offset is created, and the method returns a
993 /// memory operand expressing [ip, #0]. 872 /// memory operand expressing [ip, #0].
994 OperandARM32Mem *createMemOperand(Type Ty, Variable *Base, int32_t Offset, 873 OperandARM32Mem *createMemOperand(Type Ty, Variable *Base, int32_t Offset,
995 bool AllowOffsets = true); 874 bool AllowOffsets = true);
996 TargetARM32 *const Target; 875 TargetARM32 *const Target;
997 Variable *const StackOrFrameReg; 876 Variable *const StackOrFrameReg;
998 Variable *TempBaseReg = nullptr; 877 Variable *TempBaseReg = nullptr;
999 int32_t TempBaseOffset = 0; 878 int32_t TempBaseOffset = 0;
1000 }; 879 };
1001 880
1002 const bool NeedSandboxing;
1003 TargetARM32Features CPUFeatures; 881 TargetARM32Features CPUFeatures;
1004 bool UsesFramePointer = false; 882 bool UsesFramePointer = false;
1005 bool NeedsStackAlignment = false; 883 bool NeedsStackAlignment = false;
1006 bool MaybeLeafFunc = true; 884 bool MaybeLeafFunc = true;
1007 size_t SpillAreaSizeBytes = 0; 885 size_t SpillAreaSizeBytes = 0;
1008 size_t FixedAllocaSizeBytes = 0; 886 size_t FixedAllocaSizeBytes = 0;
1009 size_t FixedAllocaAlignBytes = 0; 887 size_t FixedAllocaAlignBytes = 0;
1010 bool PrologEmitsFixedAllocas = false; 888 bool PrologEmitsFixedAllocas = false;
1011 uint32_t MaxOutArgsSizeBytes = 0; 889 uint32_t MaxOutArgsSizeBytes = 0;
1012 // TODO(jpp): std::array instead of array. 890 // TODO(jpp): std::array instead of array.
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
1198 1076
1199 private: 1077 private:
1200 ~TargetHeaderARM32() = default; 1078 ~TargetHeaderARM32() = default;
1201 1079
1202 TargetARM32Features CPUFeatures; 1080 TargetARM32Features CPUFeatures;
1203 }; 1081 };
1204 1082
1205 } // end of namespace Ice 1083 } // end of namespace Ice
1206 1084
1207 #endif // SUBZERO_SRC_ICETARGETLOWERINGARM32_H 1085 #endif // SUBZERO_SRC_ICETARGETLOWERINGARM32_H
OLDNEW
« no previous file with comments | « pydir/targets.py ('k') | src/IceTargetLoweringARM32.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698