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

Side by Side Diff: src/IceTargetLoweringX86Base.h

Issue 1273153002: Subzero. Native 64-bit int arithmetic on x86-64. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Addresses comments. Created 5 years, 4 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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 RegSetMask Exclude) const override; 74 RegSetMask Exclude) const override;
75 const llvm::SmallBitVector &getRegisterSetForType(Type Ty) const override { 75 const llvm::SmallBitVector &getRegisterSetForType(Type Ty) const override {
76 return TypeToRegisterSet[Ty]; 76 return TypeToRegisterSet[Ty];
77 } 77 }
78 bool hasFramePointer() const override { return IsEbpBasedFrame; } 78 bool hasFramePointer() const override { return IsEbpBasedFrame; }
79 SizeT getFrameOrStackReg() const override { 79 SizeT getFrameOrStackReg() const override {
80 return IsEbpBasedFrame ? Traits::RegisterSet::Reg_ebp 80 return IsEbpBasedFrame ? Traits::RegisterSet::Reg_ebp
81 : Traits::RegisterSet::Reg_esp; 81 : Traits::RegisterSet::Reg_esp;
82 } 82 }
83 size_t typeWidthInBytesOnStack(Type Ty) const override { 83 size_t typeWidthInBytesOnStack(Type Ty) const override {
84 // Round up to the next multiple of 4 bytes. In particular, i1, 84 // Round up to the next multiple of WordType bytes.
85 // i8, and i16 are rounded up to 4 bytes. 85 const uint32_t WordSizeInBytes = typeWidthInBytes(Traits::WordType);
86 // TODO(jpp): this needs to round to multiples of 8 bytes in x86-64. 86 return (typeWidthInBytes(Ty) + WordSizeInBytes - 1) &
Jim Stichnoth 2015/08/11 16:01:37 /lazyme wonders if there's something in Ice::Utils
John 2015/08/12 19:27:55 Done.
87 return (typeWidthInBytes(Ty) + 3) & ~3; 87 ~(WordSizeInBytes - 1);
88 } 88 }
89 89
90 SizeT getMinJumpTableSize() const override { return 4; } 90 SizeT getMinJumpTableSize() const override { return 4; }
91 91
92 void emitVariable(const Variable *Var) const override; 92 void emitVariable(const Variable *Var) const override;
93 93
94 const char *getConstantPrefix() const final { return "$"; } 94 const char *getConstantPrefix() const final { return "$"; }
95 void emit(const ConstantUndef *C) const final; 95 void emit(const ConstantUndef *C) const final;
96 void emit(const ConstantInteger32 *C) const final; 96 void emit(const ConstantInteger32 *C) const final;
97 void emit(const ConstantInteger64 *C) const final; 97 void emit(const ConstantInteger64 *C) const final;
98 void emit(const ConstantFloat *C) const final; 98 void emit(const ConstantFloat *C) const final;
99 void emit(const ConstantDouble *C) const final; 99 void emit(const ConstantDouble *C) const final;
100 100
101 void initNodeForLowering(CfgNode *Node) override; 101 void initNodeForLowering(CfgNode *Node) override;
102 /// Ensure that a 64-bit Variable has been split into 2 32-bit 102 /// x86-32: Ensure that a 64-bit Variable has been split into 2 32-bit
103 /// Variables, creating them if necessary. This is needed for all 103 /// Variables, creating them if necessary. This is needed for all
104 /// I64 operations, and it is needed for pushing F64 arguments for 104 /// I64 operations, and it is needed for pushing F64 arguments for
105 /// function calls using the 32-bit push instruction (though the 105 /// function calls using the 32-bit push instruction (though the
106 /// latter could be done by directly writing to the stack). 106 /// latter could be done by directly writing to the stack).
107 void split64(Variable *Var); 107 ///
108 Operand *loOperand(Operand *Operand); 108 /// x86-64: Complains loudly if invoked because the cpu can handle
109 Operand *hiOperand(Operand *Operand); 109 /// 64-bit types natively.
110 template <typename T = Traits>
111 typename std::enable_if<!T::Is64Bit, void>::type split64(Variable *Var);
112 template <typename T = Traits>
113 typename std::enable_if<T::Is64Bit, void>::type split64(Variable *) {
114 llvm::report_fatal_error(
115 "Hey, yo! This is x86-64. Watcha doin'? (split64)");
116 }
117
118 template <typename T = Traits>
119 typename std::enable_if<!T::Is64Bit, Operand>::type *
120 loOperand(Operand *Operand);
121 template <typename T = Traits>
122 typename std::enable_if<T::Is64Bit, Operand>::type *loOperand(Operand *) {
123 llvm::report_fatal_error(
124 "Hey, yo! This is x86-64. Watcha doin'? (loOperand)");
125 }
126
127 template <typename T = Traits>
128 typename std::enable_if<!T::Is64Bit, Operand>::type *
129 hiOperand(Operand *Operand);
130 template <typename T = Traits>
131 typename std::enable_if<T::Is64Bit, Operand>::type *hiOperand(Operand *) {
132 llvm::report_fatal_error(
133 "Hey, yo! This is x86-64. Watcha doin'? (hiOperand)");
134 }
135
110 void finishArgumentLowering(Variable *Arg, Variable *FramePtr, 136 void finishArgumentLowering(Variable *Arg, Variable *FramePtr,
111 size_t BasicFrameOffset, size_t &InArgsSizeBytes); 137 size_t BasicFrameOffset, size_t &InArgsSizeBytes);
112 typename Traits::Address stackVarToAsmOperand(const Variable *Var) const; 138 typename Traits::Address stackVarToAsmOperand(const Variable *Var) const;
113 139
114 typename Traits::InstructionSet getInstructionSet() const { 140 typename Traits::InstructionSet getInstructionSet() const {
115 return InstructionSet; 141 return InstructionSet;
116 } 142 }
117 Operand *legalizeUndef(Operand *From, int32_t RegNum = Variable::NoRegister); 143 Operand *legalizeUndef(Operand *From, int32_t RegNum = Variable::NoRegister);
118 144
119 protected: 145 protected:
120 explicit TargetX86Base(Cfg *Func); 146 explicit TargetX86Base(Cfg *Func);
121 147
122 void postLower() override; 148 void postLower() override;
123 149
124 void lowerAlloca(const InstAlloca *Inst) override; 150 void lowerAlloca(const InstAlloca *Inst) override;
125 void lowerArithmetic(const InstArithmetic *Inst) override; 151 void lowerArithmetic(const InstArithmetic *Inst) override;
126 void lowerAssign(const InstAssign *Inst) override; 152 void lowerAssign(const InstAssign *Inst) override;
127 void lowerBr(const InstBr *Inst) override; 153 void lowerBr(const InstBr *Inst) override;
128 void lowerCast(const InstCast *Inst) override; 154 void lowerCast(const InstCast *Inst) override;
129 void lowerExtractElement(const InstExtractElement *Inst) override; 155 void lowerExtractElement(const InstExtractElement *Inst) override;
130 void lowerFcmp(const InstFcmp *Inst) override; 156 void lowerFcmp(const InstFcmp *Inst) override;
131 void lowerIcmp(const InstIcmp *Inst) override; 157 void lowerIcmp(const InstIcmp *Inst) override;
158 /// Complains loudly if invoked because the cpu can handle 64-bit types
159 /// natively.
160 template <typename T = Traits>
161 typename std::enable_if<T::Is64Bit, void>::type
162 lowerIcmp64(const InstIcmp *) {
163 llvm::report_fatal_error(
164 "Hey, yo! This is x86-64. Watcha doin'? (lowerIcmp64)");
165 }
166 /// x86lowerIcmp64 handles 64-bit icmp lowering.
167 template <typename T = Traits>
168 typename std::enable_if<!T::Is64Bit, void>::type
169 lowerIcmp64(const InstIcmp *Inst);
170
132 void lowerIntrinsicCall(const InstIntrinsicCall *Inst) override; 171 void lowerIntrinsicCall(const InstIntrinsicCall *Inst) override;
133 void lowerInsertElement(const InstInsertElement *Inst) override; 172 void lowerInsertElement(const InstInsertElement *Inst) override;
134 void lowerLoad(const InstLoad *Inst) override; 173 void lowerLoad(const InstLoad *Inst) override;
135 void lowerPhi(const InstPhi *Inst) override; 174 void lowerPhi(const InstPhi *Inst) override;
136 void lowerSelect(const InstSelect *Inst) override; 175 void lowerSelect(const InstSelect *Inst) override;
137 void lowerStore(const InstStore *Inst) override; 176 void lowerStore(const InstStore *Inst) override;
138 void lowerSwitch(const InstSwitch *Inst) override; 177 void lowerSwitch(const InstSwitch *Inst) override;
139 void lowerUnreachable(const InstUnreachable *Inst) override; 178 void lowerUnreachable(const InstUnreachable *Inst) override;
140 void lowerOther(const Inst *Instr) override; 179 void lowerOther(const Inst *Instr) override;
141 void lowerRMW(const typename Traits::Insts::FakeRMW *RMW); 180 void lowerRMW(const typename Traits::Insts::FakeRMW *RMW);
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after
623 } 662 }
624 663
625 BoolFolding FoldingInfo; 664 BoolFolding FoldingInfo;
626 }; 665 };
627 } // end of namespace X86Internal 666 } // end of namespace X86Internal
628 } // end of namespace Ice 667 } // end of namespace Ice
629 668
630 #include "IceTargetLoweringX86BaseImpl.h" 669 #include "IceTargetLoweringX86BaseImpl.h"
631 670
632 #endif // SUBZERO_SRC_ICETARGETLOWERINGX86BASE_H 671 #endif // SUBZERO_SRC_ICETARGETLOWERINGX86BASE_H
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698