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

Side by Side Diff: src/IceTargetLoweringX86Base.h

Issue 1506653002: Subzero: Add Non-SFI support for x86-32. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Refactor the link commands Created 4 years, 11 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/IceTargetLoweringX86Base.h - x86 lowering ----*- C++ -*-===// 1 //===- subzero/src/IceTargetLoweringX86Base.h - x86 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 TargetX86Base() = delete; 52 TargetX86Base() = delete;
53 TargetX86Base(const TargetX86Base &) = delete; 53 TargetX86Base(const TargetX86Base &) = delete;
54 TargetX86Base &operator=(const TargetX86Base &) = delete; 54 TargetX86Base &operator=(const TargetX86Base &) = delete;
55 55
56 public: 56 public:
57 using Traits = MachineTraits<Machine>; 57 using Traits = MachineTraits<Machine>;
58 using BoolFolding = ::Ice::X86Internal::BoolFolding<Traits>; 58 using BoolFolding = ::Ice::X86Internal::BoolFolding<Traits>;
59 59
60 ~TargetX86Base() override = default; 60 ~TargetX86Base() override = default;
61 61
62 static void staticInit(); 62 static void staticInit(const ClFlags &Flags);
63 static TargetX86Base *create(Cfg *Func) { return new TargetX86Base(Func); } 63 static TargetX86Base *create(Cfg *Func) { return new TargetX86Base(Func); }
64 64
65 static FixupKind getPcRelFixup() { return PcRelFixup; }
66 static FixupKind getAbsFixup() { return AbsFixup; }
67
65 void translateOm1() override; 68 void translateOm1() override;
66 void translateO2() override; 69 void translateO2() override;
67 void doLoadOpt(); 70 void doLoadOpt();
68 bool doBranchOpt(Inst *I, const CfgNode *NextNode) override; 71 bool doBranchOpt(Inst *I, const CfgNode *NextNode) override;
69 72
70 SizeT getNumRegisters() const override { 73 SizeT getNumRegisters() const override {
71 return Traits::RegisterSet::Reg_NUM; 74 return Traits::RegisterSet::Reg_NUM;
72 } 75 }
73 Variable *getPhysicalRegister(SizeT RegNum, Type Ty = IceType_void) override; 76 Variable *getPhysicalRegister(SizeT RegNum, Type Ty = IceType_void) override;
74 IceString getRegName(SizeT RegNum, Type Ty) const override; 77 IceString getRegName(SizeT RegNum, Type Ty) const override;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 } 122 }
120 123
121 bool shouldSplitToVariable64On32(Type Ty) const override { 124 bool shouldSplitToVariable64On32(Type Ty) const override {
122 return Traits::Is64Bit ? false : Ty == IceType_i64; 125 return Traits::Is64Bit ? false : Ty == IceType_i64;
123 } 126 }
124 127
125 SizeT getMinJumpTableSize() const override { return 4; } 128 SizeT getMinJumpTableSize() const override { return 4; }
126 129
127 void emitVariable(const Variable *Var) const override; 130 void emitVariable(const Variable *Var) const override;
128 131
129 const char *getConstantPrefix() const final { return "$"; }
130 void emit(const ConstantUndef *C) const final;
131 void emit(const ConstantInteger32 *C) const final; 132 void emit(const ConstantInteger32 *C) const final;
132 void emit(const ConstantInteger64 *C) const final; 133 void emit(const ConstantInteger64 *C) const final;
133 void emit(const ConstantFloat *C) const final; 134 void emit(const ConstantFloat *C) const final;
134 void emit(const ConstantDouble *C) const final; 135 void emit(const ConstantDouble *C) const final;
136 void emit(const ConstantUndef *C) const final;
137 void emit(const ConstantRelocatable *C) const final;
135 138
136 void initNodeForLowering(CfgNode *Node) override; 139 void initNodeForLowering(CfgNode *Node) override;
137 140
138 template <typename T = Traits> 141 template <typename T = Traits>
139 typename std::enable_if<!T::Is64Bit, Operand>::type * 142 typename std::enable_if<!T::Is64Bit, Operand>::type *
140 loOperand(Operand *Operand); 143 loOperand(Operand *Operand);
141 template <typename T = Traits> 144 template <typename T = Traits>
142 typename std::enable_if<T::Is64Bit, Operand>::type *loOperand(Operand *) { 145 typename std::enable_if<T::Is64Bit, Operand>::type *loOperand(Operand *) {
143 llvm::report_fatal_error( 146 llvm::report_fatal_error(
144 "Hey, yo! This is x86-64. Watcha doin'? (loOperand)"); 147 "Hey, yo! This is x86-64. Watcha doin'? (loOperand)");
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 /// that the Operand kind is one of those indicated by the LegalMask (a 262 /// that the Operand kind is one of those indicated by the LegalMask (a
260 /// bitmask of allowed kinds). If the input Operand is known to already meet 263 /// bitmask of allowed kinds). If the input Operand is known to already meet
261 /// the constraints, it may be simply returned as the result, without creating 264 /// the constraints, it may be simply returned as the result, without creating
262 /// any new instructions or operands. 265 /// any new instructions or operands.
263 enum OperandLegalization { 266 enum OperandLegalization {
264 Legal_None = 0, 267 Legal_None = 0,
265 Legal_Reg = 1 << 0, // physical register, not stack location 268 Legal_Reg = 1 << 0, // physical register, not stack location
266 Legal_Imm = 1 << 1, 269 Legal_Imm = 1 << 1,
267 Legal_Mem = 1 << 2, // includes [eax+4*ecx] as well as [esp+12] 270 Legal_Mem = 1 << 2, // includes [eax+4*ecx] as well as [esp+12]
268 Legal_Rematerializable = 1 << 3, 271 Legal_Rematerializable = 1 << 3,
269 Legal_All = ~Legal_Rematerializable 272 Legal_AddrAbs = 1 << 4, // ConstantRelocatable doesn't have to add GotVar
273 Legal_Default = ~(Legal_Rematerializable | Legal_AddrAbs)
274 // TODO(stichnot): Figure out whether this default works for x86-64.
270 }; 275 };
271 using LegalMask = uint32_t; 276 using LegalMask = uint32_t;
272 Operand *legalize(Operand *From, LegalMask Allowed = Legal_All, 277 Operand *legalize(Operand *From, LegalMask Allowed = Legal_Default,
273 int32_t RegNum = Variable::NoRegister); 278 int32_t RegNum = Variable::NoRegister);
274 Variable *legalizeToReg(Operand *From, int32_t RegNum = Variable::NoRegister); 279 Variable *legalizeToReg(Operand *From, int32_t RegNum = Variable::NoRegister);
275 /// Legalize the first source operand for use in the cmp instruction. 280 /// Legalize the first source operand for use in the cmp instruction.
276 Operand *legalizeSrc0ForCmp(Operand *Src0, Operand *Src1); 281 Operand *legalizeSrc0ForCmp(Operand *Src0, Operand *Src1);
277 /// Turn a pointer operand into a memory operand that can be used by a real 282 /// Turn a pointer operand into a memory operand that can be used by a real
278 /// load/store operation. Legalizes the operand as well. This is a nop if the 283 /// load/store operation. Legalizes the operand as well. This is a nop if the
279 /// operand is already a legal memory operand. 284 /// operand is already a legal memory operand.
280 typename Traits::X86OperandMem *formMemoryOperand(Operand *Ptr, Type Ty, 285 typename Traits::X86OperandMem *formMemoryOperand(Operand *Ptr, Type Ty,
281 bool DoLegalize = true); 286 bool DoLegalize = true);
282 287
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after
725 size_t FixedAllocaSizeBytes = 0; 730 size_t FixedAllocaSizeBytes = 0;
726 size_t FixedAllocaAlignBytes = 0; 731 size_t FixedAllocaAlignBytes = 0;
727 bool PrologEmitsFixedAllocas = false; 732 bool PrologEmitsFixedAllocas = false;
728 uint32_t MaxOutArgsSizeBytes = 0; 733 uint32_t MaxOutArgsSizeBytes = 0;
729 static std::array<llvm::SmallBitVector, RCX86_NUM> TypeToRegisterSet; 734 static std::array<llvm::SmallBitVector, RCX86_NUM> TypeToRegisterSet;
730 static std::array<llvm::SmallBitVector, Traits::RegisterSet::Reg_NUM> 735 static std::array<llvm::SmallBitVector, Traits::RegisterSet::Reg_NUM>
731 RegisterAliases; 736 RegisterAliases;
732 static llvm::SmallBitVector ScratchRegs; 737 static llvm::SmallBitVector ScratchRegs;
733 llvm::SmallBitVector RegsUsed; 738 llvm::SmallBitVector RegsUsed;
734 std::array<VarList, IceType_NUM> PhysicalRegisters; 739 std::array<VarList, IceType_NUM> PhysicalRegisters;
740 // GotVar is a Variable that holds the GlobalOffsetTable address for Non-SFI
741 // mode.
742 Variable *GotVar = nullptr;
735 743
736 /// Randomize a given immediate operand 744 /// Randomize a given immediate operand
737 Operand *randomizeOrPoolImmediate(Constant *Immediate, 745 Operand *randomizeOrPoolImmediate(Constant *Immediate,
738 int32_t RegNum = Variable::NoRegister); 746 int32_t RegNum = Variable::NoRegister);
739 typename Traits::X86OperandMem * 747 typename Traits::X86OperandMem *
740 randomizeOrPoolImmediate(typename Traits::X86OperandMem *MemOperand, 748 randomizeOrPoolImmediate(typename Traits::X86OperandMem *MemOperand,
741 int32_t RegNum = Variable::NoRegister); 749 int32_t RegNum = Variable::NoRegister);
742 bool RandomizationPoolingPaused = false; 750 bool RandomizationPoolingPaused = false;
743 751
744 private: 752 private:
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
791 void lowerSelectMove(Variable *Dest, typename Traits::Cond::BrCond Cond, 799 void lowerSelectMove(Variable *Dest, typename Traits::Cond::BrCond Cond,
792 Operand *SrcT, Operand *SrcF); 800 Operand *SrcT, Operand *SrcF);
793 void lowerSelectIntMove(Variable *Dest, typename Traits::Cond::BrCond Cond, 801 void lowerSelectIntMove(Variable *Dest, typename Traits::Cond::BrCond Cond,
794 Operand *SrcT, Operand *SrcF); 802 Operand *SrcT, Operand *SrcF);
795 /// Generic helper to move an arbitrary type from Src to Dest. 803 /// Generic helper to move an arbitrary type from Src to Dest.
796 void lowerMove(Variable *Dest, Operand *Src, bool IsRedefinition); 804 void lowerMove(Variable *Dest, Operand *Src, bool IsRedefinition);
797 805
798 /// Optimizations for idiom recognition. 806 /// Optimizations for idiom recognition.
799 bool lowerOptimizeFcmpSelect(const InstFcmp *Fcmp, const InstSelect *Select); 807 bool lowerOptimizeFcmpSelect(const InstFcmp *Fcmp, const InstSelect *Select);
800 808
809 /// Emit code that initializes the value of the GotVar near the start of the
810 /// function. (This code is emitted only in Non-SFI mode.)
811 void initGotVarIfNeeded();
812
801 /// Complains loudly if invoked because the cpu can handle 64-bit types 813 /// Complains loudly if invoked because the cpu can handle 64-bit types
802 /// natively. 814 /// natively.
803 template <typename T = Traits> 815 template <typename T = Traits>
804 typename std::enable_if<T::Is64Bit, void>::type lowerIcmp64(const InstIcmp *, 816 typename std::enable_if<T::Is64Bit, void>::type lowerIcmp64(const InstIcmp *,
805 const Inst *) { 817 const Inst *) {
806 llvm::report_fatal_error( 818 llvm::report_fatal_error(
807 "Hey, yo! This is x86-64. Watcha doin'? (lowerIcmp64)"); 819 "Hey, yo! This is x86-64. Watcha doin'? (lowerIcmp64)");
808 } 820 }
809 /// x86lowerIcmp64 handles 64-bit icmp lowering. 821 /// x86lowerIcmp64 handles 64-bit icmp lowering.
810 template <typename T = Traits> 822 template <typename T = Traits>
811 typename std::enable_if<!T::Is64Bit, void>::type 823 typename std::enable_if<!T::Is64Bit, void>::type
812 lowerIcmp64(const InstIcmp *Icmp, const Inst *Consumer); 824 lowerIcmp64(const InstIcmp *Icmp, const Inst *Consumer);
813 825
814 BoolFolding FoldingInfo; 826 BoolFolding FoldingInfo;
827
828 static FixupKind PcRelFixup;
829 static FixupKind AbsFixup;
815 }; 830 };
816 } // end of namespace X86Internal 831 } // end of namespace X86Internal
817 } // end of namespace Ice 832 } // end of namespace Ice
818 833
819 #include "IceTargetLoweringX86BaseImpl.h" 834 #include "IceTargetLoweringX86BaseImpl.h"
820 835
821 #endif // SUBZERO_SRC_ICETARGETLOWERINGX86BASE_H 836 #endif // SUBZERO_SRC_ICETARGETLOWERINGX86BASE_H
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698