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

Side by Side Diff: src/IceTargetLoweringX86Base.h

Issue 1216033004: Move X8632-specific Assembler stuff to Machine Traits. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Addresses comments. Created 5 years, 5 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/IceTargetLoweringX8632Traits.h ('k') | src/IceTargetLoweringX86BaseImpl.h » ('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/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 // This file declares the TargetLoweringX86 template class, which 10 // This file declares the TargetLoweringX86 template class, which
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 using Machine::regAlloc; 100 using Machine::regAlloc;
101 using Machine::resetStackAdjustment; 101 using Machine::resetStackAdjustment;
102 102
103 static TargetX86Base *create(Cfg *Func) { return new TargetX86Base(Func); } 103 static TargetX86Base *create(Cfg *Func) { return new TargetX86Base(Func); }
104 104
105 void translateOm1() override; 105 void translateOm1() override;
106 void translateO2() override; 106 void translateO2() override;
107 void doLoadOpt(); 107 void doLoadOpt();
108 bool doBranchOpt(Inst *I, const CfgNode *NextNode) override; 108 bool doBranchOpt(Inst *I, const CfgNode *NextNode) override;
109 109
110 SizeT getNumRegisters() const override { return RegX8632::Reg_NUM; } 110 SizeT getNumRegisters() const override {
111 return Traits::RegisterSet::Reg_NUM;
112 }
111 Variable *getPhysicalRegister(SizeT RegNum, Type Ty = IceType_void) override; 113 Variable *getPhysicalRegister(SizeT RegNum, Type Ty = IceType_void) override;
112 IceString getRegName(SizeT RegNum, Type Ty) const override; 114 IceString getRegName(SizeT RegNum, Type Ty) const override;
113 llvm::SmallBitVector getRegisterSet(RegSetMask Include, 115 llvm::SmallBitVector getRegisterSet(RegSetMask Include,
114 RegSetMask Exclude) const override; 116 RegSetMask Exclude) const override;
115 const llvm::SmallBitVector &getRegisterSetForType(Type Ty) const override { 117 const llvm::SmallBitVector &getRegisterSetForType(Type Ty) const override {
116 return TypeToRegisterSet[Ty]; 118 return TypeToRegisterSet[Ty];
117 } 119 }
118 bool hasFramePointer() const override { return IsEbpBasedFrame; } 120 bool hasFramePointer() const override { return IsEbpBasedFrame; }
119 SizeT getFrameOrStackReg() const override { 121 SizeT getFrameOrStackReg() const override {
120 return IsEbpBasedFrame ? RegX8632::Reg_ebp : RegX8632::Reg_esp; 122 return IsEbpBasedFrame ? Traits::RegisterSet::Reg_ebp
123 : Traits::RegisterSet::Reg_esp;
121 } 124 }
122 size_t typeWidthInBytesOnStack(Type Ty) const override { 125 size_t typeWidthInBytesOnStack(Type Ty) const override {
123 // Round up to the next multiple of 4 bytes. In particular, i1, 126 // Round up to the next multiple of 4 bytes. In particular, i1,
124 // i8, and i16 are rounded up to 4 bytes. 127 // i8, and i16 are rounded up to 4 bytes.
125 return (typeWidthInBytes(Ty) + 3) & ~3; 128 return (typeWidthInBytes(Ty) + 3) & ~3;
126 } 129 }
127 130
128 void emitVariable(const Variable *Var) const override; 131 void emitVariable(const Variable *Var) const override;
129 132
130 const char *getConstantPrefix() const final { return "$"; } 133 const char *getConstantPrefix() const final { return "$"; }
(...skipping 10 matching lines...) Expand all
141 // Ensure that a 64-bit Variable has been split into 2 32-bit 144 // Ensure that a 64-bit Variable has been split into 2 32-bit
142 // Variables, creating them if necessary. This is needed for all 145 // Variables, creating them if necessary. This is needed for all
143 // I64 operations, and it is needed for pushing F64 arguments for 146 // I64 operations, and it is needed for pushing F64 arguments for
144 // function calls using the 32-bit push instruction (though the 147 // function calls using the 32-bit push instruction (though the
145 // latter could be done by directly writing to the stack). 148 // latter could be done by directly writing to the stack).
146 void split64(Variable *Var); 149 void split64(Variable *Var);
147 Operand *loOperand(Operand *Operand); 150 Operand *loOperand(Operand *Operand);
148 Operand *hiOperand(Operand *Operand); 151 Operand *hiOperand(Operand *Operand);
149 void finishArgumentLowering(Variable *Arg, Variable *FramePtr, 152 void finishArgumentLowering(Variable *Arg, Variable *FramePtr,
150 size_t BasicFrameOffset, size_t &InArgsSizeBytes); 153 size_t BasicFrameOffset, size_t &InArgsSizeBytes);
151 X8632::Address stackVarToAsmOperand(const Variable *Var) const final; 154 typename Traits::Address
155 stackVarToAsmOperand(const Variable *Var) const final;
152 156
153 typename Traits::InstructionSet getInstructionSet() const final { 157 typename Traits::InstructionSet getInstructionSet() const final {
154 return InstructionSet; 158 return InstructionSet;
155 } 159 }
156 160
157 protected: 161 protected:
158 explicit TargetX86Base(Cfg *Func); 162 explicit TargetX86Base(Cfg *Func);
159 163
160 void postLower() override; 164 void postLower() override;
161 165
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 int32_t RegNum = Variable::NoRegister); 252 int32_t RegNum = Variable::NoRegister);
249 253
250 // Return a memory operand corresponding to a stack allocated Variable. 254 // Return a memory operand corresponding to a stack allocated Variable.
251 OperandX8632Mem *getMemoryOperandForStackSlot(Type Ty, Variable *Slot, 255 OperandX8632Mem *getMemoryOperandForStackSlot(Type Ty, Variable *Slot,
252 uint32_t Offset = 0); 256 uint32_t Offset = 0);
253 257
254 void makeRandomRegisterPermutation( 258 void makeRandomRegisterPermutation(
255 llvm::SmallVectorImpl<int32_t> &Permutation, 259 llvm::SmallVectorImpl<int32_t> &Permutation,
256 const llvm::SmallBitVector &ExcludeRegisters) const override; 260 const llvm::SmallBitVector &ExcludeRegisters) const override;
257 261
262 // TODO(jpp): move the helper methods below to the MachineTraits.
258 // The following are helpers that insert lowered x86 instructions 263 // The following are helpers that insert lowered x86 instructions
259 // with minimal syntactic overhead, so that the lowering code can 264 // with minimal syntactic overhead, so that the lowering code can
260 // look as close to assembly as practical. 265 // look as close to assembly as practical.
261 void _adc(Variable *Dest, Operand *Src0) { 266 void _adc(Variable *Dest, Operand *Src0) {
262 Context.insert(InstX8632Adc::create(Func, Dest, Src0)); 267 Context.insert(InstX8632Adc::create(Func, Dest, Src0));
263 } 268 }
264 void _adc_rmw(OperandX8632Mem *DestSrc0, Operand *Src1) { 269 void _adc_rmw(OperandX8632Mem *DestSrc0, Operand *Src1) {
265 Context.insert(InstX8632AdcRMW::create(Func, DestSrc0, Src1)); 270 Context.insert(InstX8632AdcRMW::create(Func, DestSrc0, Src1));
266 } 271 }
267 void _add(Variable *Dest, Operand *Src0) { 272 void _add(Variable *Dest, Operand *Src0) {
268 Context.insert(InstX8632Add::create(Func, Dest, Src0)); 273 Context.insert(InstX8632Add::create(Func, Dest, Src0));
269 } 274 }
270 void _add_rmw(OperandX8632Mem *DestSrc0, Operand *Src1) { 275 void _add_rmw(OperandX8632Mem *DestSrc0, Operand *Src1) {
271 Context.insert(InstX8632AddRMW::create(Func, DestSrc0, Src1)); 276 Context.insert(InstX8632AddRMW::create(Func, DestSrc0, Src1));
272 } 277 }
273 void _adjust_stack(int32_t Amount) { 278 void _adjust_stack(int32_t Amount) {
274 Context.insert(InstX8632AdjustStack::create( 279 Context.insert(InstX8632AdjustStack::create(
275 Func, Amount, getPhysicalRegister(RegX8632::Reg_esp))); 280 Func, Amount, getPhysicalRegister(Traits::RegisterSet::Reg_esp)));
276 } 281 }
277 void _addps(Variable *Dest, Operand *Src0) { 282 void _addps(Variable *Dest, Operand *Src0) {
278 Context.insert(InstX8632Addps::create(Func, Dest, Src0)); 283 Context.insert(InstX8632Addps::create(Func, Dest, Src0));
279 } 284 }
280 void _addss(Variable *Dest, Operand *Src0) { 285 void _addss(Variable *Dest, Operand *Src0) {
281 Context.insert(InstX8632Addss::create(Func, Dest, Src0)); 286 Context.insert(InstX8632Addss::create(Func, Dest, Src0));
282 } 287 }
283 void _and(Variable *Dest, Operand *Src0) { 288 void _and(Variable *Dest, Operand *Src0) {
284 Context.insert(InstX8632And::create(Func, Dest, Src0)); 289 Context.insert(InstX8632And::create(Func, Dest, Src0));
285 } 290 }
286 void _and_rmw(OperandX8632Mem *DestSrc0, Operand *Src1) { 291 void _and_rmw(OperandX8632Mem *DestSrc0, Operand *Src1) {
287 Context.insert(InstX8632AndRMW::create(Func, DestSrc0, Src1)); 292 Context.insert(InstX8632AndRMW::create(Func, DestSrc0, Src1));
288 } 293 }
289 void _blendvps(Variable *Dest, Operand *Src0, Operand *Src1) { 294 void _blendvps(Variable *Dest, Operand *Src0, Operand *Src1) {
290 Context.insert(InstX8632Blendvps::create(Func, Dest, Src0, Src1)); 295 Context.insert(InstX8632Blendvps::create(Func, Dest, Src0, Src1));
291 } 296 }
292 void _br(CondX86::BrCond Condition, CfgNode *TargetTrue, 297 void _br(typename Traits::Cond::BrCond Condition, CfgNode *TargetTrue,
293 CfgNode *TargetFalse) { 298 CfgNode *TargetFalse) {
294 Context.insert( 299 Context.insert(
295 InstX8632Br::create(Func, TargetTrue, TargetFalse, Condition)); 300 InstX8632Br::create(Func, TargetTrue, TargetFalse, Condition));
296 } 301 }
297 void _br(CfgNode *Target) { 302 void _br(CfgNode *Target) {
298 Context.insert(InstX8632Br::create(Func, Target)); 303 Context.insert(InstX8632Br::create(Func, Target));
299 } 304 }
300 void _br(CondX86::BrCond Condition, CfgNode *Target) { 305 void _br(typename Traits::Cond::BrCond Condition, CfgNode *Target) {
301 Context.insert(InstX8632Br::create(Func, Target, Condition)); 306 Context.insert(InstX8632Br::create(Func, Target, Condition));
302 } 307 }
303 void _br(CondX86::BrCond Condition, InstX8632Label *Label) { 308 void _br(typename Traits::Cond::BrCond Condition, InstX8632Label *Label) {
304 Context.insert(InstX8632Br::create(Func, Label, Condition)); 309 Context.insert(InstX8632Br::create(Func, Label, Condition));
305 } 310 }
306 void _bsf(Variable *Dest, Operand *Src0) { 311 void _bsf(Variable *Dest, Operand *Src0) {
307 Context.insert(InstX8632Bsf::create(Func, Dest, Src0)); 312 Context.insert(InstX8632Bsf::create(Func, Dest, Src0));
308 } 313 }
309 void _bsr(Variable *Dest, Operand *Src0) { 314 void _bsr(Variable *Dest, Operand *Src0) {
310 Context.insert(InstX8632Bsr::create(Func, Dest, Src0)); 315 Context.insert(InstX8632Bsr::create(Func, Dest, Src0));
311 } 316 }
312 void _bswap(Variable *SrcDest) { 317 void _bswap(Variable *SrcDest) {
313 Context.insert(InstX8632Bswap::create(Func, SrcDest)); 318 Context.insert(InstX8632Bswap::create(Func, SrcDest));
314 } 319 }
315 void _cbwdq(Variable *Dest, Operand *Src0) { 320 void _cbwdq(Variable *Dest, Operand *Src0) {
316 Context.insert(InstX8632Cbwdq::create(Func, Dest, Src0)); 321 Context.insert(InstX8632Cbwdq::create(Func, Dest, Src0));
317 } 322 }
318 void _cmov(Variable *Dest, Operand *Src0, CondX86::BrCond Condition) { 323 void _cmov(Variable *Dest, Operand *Src0,
324 typename Traits::Cond::BrCond Condition) {
319 Context.insert(InstX8632Cmov::create(Func, Dest, Src0, Condition)); 325 Context.insert(InstX8632Cmov::create(Func, Dest, Src0, Condition));
320 } 326 }
321 void _cmp(Operand *Src0, Operand *Src1) { 327 void _cmp(Operand *Src0, Operand *Src1) {
322 Context.insert(InstX8632Icmp::create(Func, Src0, Src1)); 328 Context.insert(InstX8632Icmp::create(Func, Src0, Src1));
323 } 329 }
324 void _cmpps(Variable *Dest, Operand *Src0, CondX86::CmppsCond Condition) { 330 void _cmpps(Variable *Dest, Operand *Src0,
331 typename Traits::Cond::CmppsCond Condition) {
325 Context.insert(InstX8632Cmpps::create(Func, Dest, Src0, Condition)); 332 Context.insert(InstX8632Cmpps::create(Func, Dest, Src0, Condition));
326 } 333 }
327 void _cmpxchg(Operand *DestOrAddr, Variable *Eax, Variable *Desired, 334 void _cmpxchg(Operand *DestOrAddr, Variable *Eax, Variable *Desired,
328 bool Locked) { 335 bool Locked) {
329 Context.insert( 336 Context.insert(
330 InstX8632Cmpxchg::create(Func, DestOrAddr, Eax, Desired, Locked)); 337 InstX8632Cmpxchg::create(Func, DestOrAddr, Eax, Desired, Locked));
331 // Mark eax as possibly modified by cmpxchg. 338 // Mark eax as possibly modified by cmpxchg.
332 Context.insert( 339 Context.insert(
333 InstFakeDef::create(Func, Eax, llvm::dyn_cast<Variable>(DestOrAddr))); 340 InstFakeDef::create(Func, Eax, llvm::dyn_cast<Variable>(DestOrAddr)));
334 _set_dest_nonkillable(); 341 _set_dest_nonkillable();
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 } 503 }
497 void _sar(Variable *Dest, Operand *Src0) { 504 void _sar(Variable *Dest, Operand *Src0) {
498 Context.insert(InstX8632Sar::create(Func, Dest, Src0)); 505 Context.insert(InstX8632Sar::create(Func, Dest, Src0));
499 } 506 }
500 void _sbb(Variable *Dest, Operand *Src0) { 507 void _sbb(Variable *Dest, Operand *Src0) {
501 Context.insert(InstX8632Sbb::create(Func, Dest, Src0)); 508 Context.insert(InstX8632Sbb::create(Func, Dest, Src0));
502 } 509 }
503 void _sbb_rmw(OperandX8632Mem *DestSrc0, Operand *Src1) { 510 void _sbb_rmw(OperandX8632Mem *DestSrc0, Operand *Src1) {
504 Context.insert(InstX8632SbbRMW::create(Func, DestSrc0, Src1)); 511 Context.insert(InstX8632SbbRMW::create(Func, DestSrc0, Src1));
505 } 512 }
506 void _setcc(Variable *Dest, CondX86::BrCond Condition) { 513 void _setcc(Variable *Dest, typename Traits::Cond::BrCond Condition) {
507 Context.insert(InstX8632Setcc::create(Func, Dest, Condition)); 514 Context.insert(InstX8632Setcc::create(Func, Dest, Condition));
508 } 515 }
509 void _shl(Variable *Dest, Operand *Src0) { 516 void _shl(Variable *Dest, Operand *Src0) {
510 Context.insert(InstX8632Shl::create(Func, Dest, Src0)); 517 Context.insert(InstX8632Shl::create(Func, Dest, Src0));
511 } 518 }
512 void _shld(Variable *Dest, Variable *Src0, Variable *Src1) { 519 void _shld(Variable *Dest, Variable *Src0, Variable *Src1) {
513 Context.insert(InstX8632Shld::create(Func, Dest, Src0, Src1)); 520 Context.insert(InstX8632Shld::create(Func, Dest, Src0, Src1));
514 } 521 }
515 void _shr(Variable *Dest, Operand *Src0) { 522 void _shr(Variable *Dest, Operand *Src0) {
516 Context.insert(InstX8632Shr::create(Func, Dest, Src0)); 523 Context.insert(InstX8632Shr::create(Func, Dest, Src0));
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
605 private: 612 private:
606 ~TargetX86Base() override {} 613 ~TargetX86Base() override {}
607 BoolFolding FoldingInfo; 614 BoolFolding FoldingInfo;
608 }; 615 };
609 } // end of namespace X86Internal 616 } // end of namespace X86Internal
610 } // end of namespace Ice 617 } // end of namespace Ice
611 618
612 #include "IceTargetLoweringX86BaseImpl.h" 619 #include "IceTargetLoweringX86BaseImpl.h"
613 620
614 #endif // SUBZERO_SRC_ICETARGETLOWERINGX86BASE_H 621 #endif // SUBZERO_SRC_ICETARGETLOWERINGX86BASE_H
OLDNEW
« no previous file with comments | « src/IceTargetLoweringX8632Traits.h ('k') | src/IceTargetLoweringX86BaseImpl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698