OLD | NEW |
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 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
375 X86OperandMem **findMemoryReference(T **First, Tail... Others) { | 375 X86OperandMem **findMemoryReference(T **First, Tail... Others) { |
376 if (llvm::isa<X86OperandMem>(*First)) { | 376 if (llvm::isa<X86OperandMem>(*First)) { |
377 return reinterpret_cast<X86OperandMem **>(First); | 377 return reinterpret_cast<X86OperandMem **>(First); |
378 } | 378 } |
379 return findMemoryReference(Others...); | 379 return findMemoryReference(Others...); |
380 } | 380 } |
381 | 381 |
382 X86OperandMem **findMemoryReference() { return nullptr; } | 382 X86OperandMem **findMemoryReference() { return nullptr; } |
383 | 383 |
384 public: | 384 public: |
| 385 std::unique_ptr<AutoBundle> Bundler; |
385 X86OperandMem **const MemOperand; | 386 X86OperandMem **const MemOperand; |
386 | 387 |
387 template <typename... T> | 388 template <typename... T> |
388 AutoMemorySandboxer(typename Traits::TargetLowering *Target, T... Args) | 389 AutoMemorySandboxer(typename Traits::TargetLowering *Target, T... Args) |
389 : Target(Target), | 390 : Target(Target), |
390 MemOperand( | 391 MemOperand( |
391 (!Traits::Is64Bit || !Target->Ctx->getFlags().getUseSandboxing()) | 392 (!Traits::Is64Bit || !Target->Ctx->getFlags().getUseSandboxing()) |
392 ? nullptr | 393 ? nullptr |
393 : findMemoryReference(Args...)) { | 394 : findMemoryReference(Args...)) { |
394 if (MemOperand != nullptr) { | 395 if (MemOperand != nullptr) { |
395 Target->_bundle_lock(BundleLockOpt); | 396 Bundler = makeUnique<AutoBundle>(Target, BundleLockOpt); |
396 *MemOperand = Target->_sandbox_mem_reference(*MemOperand); | 397 *MemOperand = Target->_sandbox_mem_reference(*MemOperand); |
397 } | 398 } |
398 } | 399 } |
399 | 400 |
400 ~AutoMemorySandboxer() { | 401 ~AutoMemorySandboxer() {} |
401 if (MemOperand != nullptr) { | |
402 Target->_bundle_unlock(); | |
403 } | |
404 } | |
405 }; | 402 }; |
406 | 403 |
407 /// The following are helpers that insert lowered x86 instructions with | 404 /// The following are helpers that insert lowered x86 instructions with |
408 /// minimal syntactic overhead, so that the lowering code can look as close to | 405 /// minimal syntactic overhead, so that the lowering code can look as close to |
409 /// assembly as practical. | 406 /// assembly as practical. |
410 void _adc(Variable *Dest, Operand *Src0) { | 407 void _adc(Variable *Dest, Operand *Src0) { |
411 AutoMemorySandboxer<> _(this, &Dest, &Src0); | 408 AutoMemorySandboxer<> _(this, &Dest, &Src0); |
412 Context.insert<typename Traits::Insts::Adc>(Dest, Src0); | 409 Context.insert<typename Traits::Insts::Adc>(Dest, Src0); |
413 } | 410 } |
414 void _adc_rmw(X86OperandMem *DestSrc0, Operand *Src1) { | 411 void _adc_rmw(X86OperandMem *DestSrc0, Operand *Src1) { |
(...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
999 | 996 |
1000 static FixupKind PcRelFixup; | 997 static FixupKind PcRelFixup; |
1001 static FixupKind AbsFixup; | 998 static FixupKind AbsFixup; |
1002 }; | 999 }; |
1003 } // end of namespace X86NAMESPACE | 1000 } // end of namespace X86NAMESPACE |
1004 } // end of namespace Ice | 1001 } // end of namespace Ice |
1005 | 1002 |
1006 #include "IceTargetLoweringX86BaseImpl.h" | 1003 #include "IceTargetLoweringX86BaseImpl.h" |
1007 | 1004 |
1008 #endif // SUBZERO_SRC_ICETARGETLOWERINGX86BASE_H | 1005 #endif // SUBZERO_SRC_ICETARGETLOWERINGX86BASE_H |
OLD | NEW |