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

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

Powered by Google App Engine
This is Rietveld 408576698