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

Side by Side Diff: src/IceTargetLoweringARM32.h

Issue 1665263003: Subzero. ARM32. Nonsfi. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Addresses comments. Created 4 years, 10 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/IceTargetLowering.cpp ('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
11 /// \brief Declares the TargetLoweringARM32 class, which implements the 11 /// \brief Declares the TargetLoweringARM32 class, which implements the
12 /// TargetLowering interface for the ARM 32-bit architecture. 12 /// TargetLowering interface for the ARM 32-bit architecture.
13 /// 13 ///
14 //===----------------------------------------------------------------------===// 14 //===----------------------------------------------------------------------===//
15 15
16 #ifndef SUBZERO_SRC_ICETARGETLOWERINGARM32_H 16 #ifndef SUBZERO_SRC_ICETARGETLOWERINGARM32_H
17 #define SUBZERO_SRC_ICETARGETLOWERINGARM32_H 17 #define SUBZERO_SRC_ICETARGETLOWERINGARM32_H
18 18
19 #include "IceAssemblerARM32.h" 19 #include "IceAssemblerARM32.h"
20 #include "IceDefs.h" 20 #include "IceDefs.h"
21 #include "IceInstARM32.h" 21 #include "IceInstARM32.h"
22 #include "IceRegistersARM32.h" 22 #include "IceRegistersARM32.h"
23 #include "IceTargetLowering.h" 23 #include "IceTargetLowering.h"
24 24
25 #include "llvm/ADT/SmallBitVector.h" 25 #include "llvm/ADT/SmallBitVector.h"
26 26
27 #include <unordered_set>
28
27 namespace Ice { 29 namespace Ice {
28 namespace ARM32 { 30 namespace ARM32 {
29 31
30 // Class encapsulating ARM cpu features / instruction set. 32 // Class encapsulating ARM cpu features / instruction set.
31 class TargetARM32Features { 33 class TargetARM32Features {
32 TargetARM32Features() = delete; 34 TargetARM32Features() = delete;
33 TargetARM32Features(const TargetARM32Features &) = delete; 35 TargetARM32Features(const TargetARM32Features &) = delete;
34 TargetARM32Features &operator=(const TargetARM32Features &) = delete; 36 TargetARM32Features &operator=(const TargetARM32Features &) = delete;
35 37
36 public: 38 public:
(...skipping 20 matching lines...) Expand all
57 TargetARM32 &operator=(const TargetARM32 &) = delete; 59 TargetARM32 &operator=(const TargetARM32 &) = delete;
58 60
59 public: 61 public:
60 static void staticInit(GlobalContext *Ctx); 62 static void staticInit(GlobalContext *Ctx);
61 // TODO(jvoung): return a unique_ptr. 63 // TODO(jvoung): return a unique_ptr.
62 static std::unique_ptr<::Ice::TargetLowering> create(Cfg *Func) { 64 static std::unique_ptr<::Ice::TargetLowering> create(Cfg *Func) {
63 return makeUnique<TargetARM32>(Func); 65 return makeUnique<TargetARM32>(Func);
64 } 66 }
65 67
66 std::unique_ptr<::Ice::Assembler> createAssembler() const override { 68 std::unique_ptr<::Ice::Assembler> createAssembler() const override {
67 return makeUnique<ARM32::AssemblerARM32>(); 69 const bool IsNonsfi = SandboxingType == ST_Nonsfi;
70 return makeUnique<ARM32::AssemblerARM32>(IsNonsfi);
68 } 71 }
69 72
70 void initNodeForLowering(CfgNode *Node) override { 73 void initNodeForLowering(CfgNode *Node) override {
71 Computations.forgetProducers(); 74 Computations.forgetProducers();
72 Computations.recordProducers(Node); 75 Computations.recordProducers(Node);
73 Computations.dump(Func); 76 Computations.dump(Func);
74 } 77 }
75 78
76 void translateOm1() override; 79 void translateOm1() override;
77 void translateO2() override; 80 void translateO2() override;
(...skipping 771 matching lines...) Expand 10 before | Expand all | Expand 10 after
849 // TODO(jpp): This could live in the Parser, if we provided a Target-specific 852 // TODO(jpp): This could live in the Parser, if we provided a Target-specific
850 // method that the Parser could call. 853 // method that the Parser could call.
851 void findMaxStackOutArgsSize(); 854 void findMaxStackOutArgsSize();
852 855
853 /// Returns true if the given Offset can be represented in a Load/Store Mem 856 /// Returns true if the given Offset can be represented in a Load/Store Mem
854 /// Operand. 857 /// Operand.
855 bool isLegalMemOffset(Type Ty, int32_t Offset) const; 858 bool isLegalMemOffset(Type Ty, int32_t Offset) const;
856 859
857 void postLowerLegalization(); 860 void postLowerLegalization();
858 861
862 /// Manages the GotPtr variable, which is used for Nonsfi sandboxing.
863 /// @{
864 void createGotPtr();
865 void insertGotPtrInitPlaceholder();
866 VariableDeclaration *createGotRelocation(RelocOffset *AddPcReloc);
867 void materializeGotAddr(CfgNode *Node);
868 Variable *GotPtr = nullptr;
869 // TODO(jpp): use CfgLocalAllocator.
870 /// @}
871
872 /// Manages the Gotoff relocations created during the function lowering. A
873 /// single Gotoff relocation is created for each global variable used by the
874 /// function being lowered.
875 /// @{
876 // TODO(jpp): if the same global G is used in different functions, then this
877 // method will emit one G(gotoff) relocation per function.
878 IceString createGotoffRelocation(const ConstantRelocatable *CR);
879 std::unordered_set<IceString> KnownGotoffs;
880 /// @}
881
882 /// Loads the constant relocatable Name to Register. Then invoke Finish to
883 /// finish the relocatable lowering. Finish **must** use PC in its first
884 /// emitted instruction, or the relocatable in Register will contain the wrong
885 /// value.
886 //
887 // Lowered sequence:
888 //
889 // Movw:
890 // movw Register, #:lower16:Name - (End - Movw) - 8 .
891 // Movt:
892 // movt Register, #:upper16:Name - (End - Movt) - 8 .
893 // PC = fake-def
894 // End:
895 // Finish(PC)
896 //
897 // The -8 in movw/movt above is to account for the PC value that the first
898 // instruction emitted by Finish(PC) will read.
899 void loadNamedConstantRelocatablePIC(const IceString &Name,
900 Variable *Register,
901 std::function<void(Variable *PC)> Finish,
902 bool SuppressMangling = true);
903
859 /// Sandboxer defines methods for ensuring that "dangerous" operations are 904 /// Sandboxer defines methods for ensuring that "dangerous" operations are
860 /// masked during sandboxed code emission. For regular, non-sandboxed code 905 /// masked during sandboxed code emission. For regular, non-sandboxed code
861 /// emission, its methods are simple pass-through methods. 906 /// emission, its methods are simple pass-through methods.
862 /// 907 ///
863 /// The Sandboxer also emits BundleLock/BundleUnlock pseudo-instructions 908 /// The Sandboxer also emits BundleLock/BundleUnlock pseudo-instructions
864 /// in the constructor/destructor during sandboxed code emission. Therefore, 909 /// in the constructor/destructor during sandboxed code emission. Therefore,
865 /// it is a bad idea to create an object of this type and "keep it around." 910 /// it is a bad idea to create an object of this type and "keep it around."
866 /// The recommended usage is: 911 /// The recommended usage is:
867 /// 912 ///
868 /// AutoSandboxing(this).<<operation>>(...); 913 /// AutoSandboxing(this).<<operation>>(...);
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
1240 private: 1285 private:
1241 ~TargetHeaderARM32() = default; 1286 ~TargetHeaderARM32() = default;
1242 1287
1243 TargetARM32Features CPUFeatures; 1288 TargetARM32Features CPUFeatures;
1244 }; 1289 };
1245 1290
1246 } // end of namespace ARM32 1291 } // end of namespace ARM32
1247 } // end of namespace Ice 1292 } // end of namespace Ice
1248 1293
1249 #endif // SUBZERO_SRC_ICETARGETLOWERINGARM32_H 1294 #endif // SUBZERO_SRC_ICETARGETLOWERINGARM32_H
OLDNEW
« no previous file with comments | « src/IceTargetLowering.cpp ('k') | src/IceTargetLoweringARM32.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698