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

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
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 769 matching lines...) Expand 10 before | Expand all | Expand 10 after
847 // TODO(jpp): This could live in the Parser, if we provided a Target-specific 850 // TODO(jpp): This could live in the Parser, if we provided a Target-specific
848 // method that the Parser could call. 851 // method that the Parser could call.
849 void findMaxStackOutArgsSize(); 852 void findMaxStackOutArgsSize();
850 853
851 /// Returns true if the given Offset can be represented in a Load/Store Mem 854 /// Returns true if the given Offset can be represented in a Load/Store Mem
852 /// Operand. 855 /// Operand.
853 bool isLegalMemOffset(Type Ty, int32_t Offset) const; 856 bool isLegalMemOffset(Type Ty, int32_t Offset) const;
854 857
855 void postLowerLegalization(); 858 void postLowerLegalization();
856 859
860 /// Manages the GotPtr variable, which is used for Nonsfi sandboxing.
861 /// @{
862 void createGotPtr();
863 void insertGotPtrInitPlaceholder();
864 VariableDeclaration *createGotRelocation(RelocOffset *AddPcReloc);
865 void materializeGotAddr(CfgNode *Node);
866 Variable *GotPtr = nullptr;
867 // TODO(jpp): use CfgLocalAllocator.
868 /// @}
869
870 /// Manages the Gotoff relocations created during the function lowering. A
871 /// single Gotoff relocation is created for each global variable used by the
872 /// function being lowered.
873 /// @{
874 // TODO(jpp): if the same global G is used in different functions, then this
875 // method will emit one G(gotoff) relocation per function.
876 IceString createGotoffRelocation(const ConstantRelocatable *CR);
877 std::unordered_set<IceString> KnownGotoffs;
878 /// @}
879
880 /// Loads the constant relocatable Name to Register. Then invoke Finish to
881 /// finish the relocatable lowering. Finish **must** use PC in its first
882 /// emitted instruction, or the relocatable in Register will contain the wrong
883 /// value.
884 //
885 // Lowered sequence:
886 //
887 // Movw:
888 // movw Register, #:lower16:Name - (End - Movw) - 8 .
889 // Movt:
890 // movt Register, #:upper16:Name - (End - Movt) - 8 .
891 // PC = fake-def
892 // End:
893 // Finish(PC)
894 //
895 // The -8 in movw/movt above is to account for the PC value that the first
896 // instruction emitted by Finish(PC) will read.
897 void loadNamedConstantRelocatablePIC(const IceString &Name,
898 Variable *Register,
899 std::function<void(Variable *PC)> Finish,
900 bool SuppressMangling = true);
901
857 /// Sandboxer defines methods for ensuring that "dangerous" operations are 902 /// Sandboxer defines methods for ensuring that "dangerous" operations are
858 /// masked during sandboxed code emission. For regular, non-sandboxed code 903 /// masked during sandboxed code emission. For regular, non-sandboxed code
859 /// emission, its methods are simple pass-through methods. 904 /// emission, its methods are simple pass-through methods.
860 /// 905 ///
861 /// The Sandboxer also emits BundleLock/BundleUnlock pseudo-instructions 906 /// The Sandboxer also emits BundleLock/BundleUnlock pseudo-instructions
862 /// in the constructor/destructor during sandboxed code emission. Therefore, 907 /// in the constructor/destructor during sandboxed code emission. Therefore,
863 /// it is a bad idea to create an object of this type and "keep it around." 908 /// it is a bad idea to create an object of this type and "keep it around."
864 /// The recommended usage is: 909 /// The recommended usage is:
865 /// 910 ///
866 /// AutoSandboxing(this).<<operation>>(...); 911 /// AutoSandboxing(this).<<operation>>(...);
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
1238 private: 1283 private:
1239 ~TargetHeaderARM32() = default; 1284 ~TargetHeaderARM32() = default;
1240 1285
1241 TargetARM32Features CPUFeatures; 1286 TargetARM32Features CPUFeatures;
1242 }; 1287 };
1243 1288
1244 } // end of namespace ARM32 1289 } // end of namespace ARM32
1245 } // end of namespace Ice 1290 } // end of namespace Ice
1246 1291
1247 #endif // SUBZERO_SRC_ICETARGETLOWERINGARM32_H 1292 #endif // SUBZERO_SRC_ICETARGETLOWERINGARM32_H
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698