| OLD | NEW |
| 1 //===- subzero/src/IceTargetLoweringX8632.cpp - x86-32 lowering -----------===// | 1 //===- subzero/src/IceTargetLoweringX8632.cpp - x86-32 lowering -----------===// |
| 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 implements the TargetLoweringX8632 class, which | 10 // This file implements the TargetLoweringX8632 class, which |
| 11 // consists almost entirely of the lowering sequence for each | 11 // consists almost entirely of the lowering sequence for each |
| 12 // high-level instruction. It also implements | 12 // high-level instruction. It also implements |
| 13 // TargetX8632Fast::postLower() which does the simplest possible | 13 // TargetX8632Fast::postLower() which does the simplest possible |
| 14 // register allocation for the "fast" target. | 14 // register allocation for the "fast" target. |
| 15 // | 15 // |
| 16 //===----------------------------------------------------------------------===// | 16 //===----------------------------------------------------------------------===// |
| 17 | 17 |
| 18 #include "IceDefs.h" | 18 #include "IceDefs.h" |
| 19 #include "IceCfg.h" | 19 #include "IceCfg.h" |
| 20 #include "IceCfgNode.h" | 20 #include "IceCfgNode.h" |
| 21 #include "IceClFlags.h" | 21 #include "IceClFlags.h" |
| 22 #include "IceInstX8632.h" | 22 #include "IceInstX8632.h" |
| 23 #include "IceOperand.h" | 23 #include "IceOperand.h" |
| 24 #include "IceRegistersX8632.h" | 24 #include "IceRegistersX8632.h" |
| 25 #include "IceTargetLoweringX8632.def" | 25 #include "IceTargetLoweringX8632.def" |
| 26 #include "IceTargetLoweringX8632.h" | 26 #include "IceTargetLoweringX8632.h" |
| 27 #include "IceUtils.h" |
| 27 #include "llvm/ADT/DenseMap.h" | 28 #include "llvm/ADT/DenseMap.h" |
| 28 #include "llvm/Support/MathExtras.h" | 29 #include "llvm/Support/MathExtras.h" |
| 29 #include "llvm/Support/CommandLine.h" | 30 #include "llvm/Support/CommandLine.h" |
| 30 | 31 |
| 31 namespace Ice { | 32 namespace Ice { |
| 32 | 33 |
| 33 namespace { | 34 namespace { |
| 34 | 35 |
| 35 // The following table summarizes the logic for lowering the fcmp | 36 // The following table summarizes the logic for lowering the fcmp |
| 36 // instruction. There is one table entry for each of the 16 conditions. | 37 // instruction. There is one table entry for each of the 16 conditions. |
| (...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 521 if (!hasFramePointer()) | 522 if (!hasFramePointer()) |
| 522 Offset += getStackAdjustment(); | 523 Offset += getStackAdjustment(); |
| 523 if (Offset) { | 524 if (Offset) { |
| 524 if (Offset > 0) | 525 if (Offset > 0) |
| 525 Str << "+"; | 526 Str << "+"; |
| 526 Str << Offset; | 527 Str << Offset; |
| 527 } | 528 } |
| 528 Str << "]"; | 529 Str << "]"; |
| 529 } | 530 } |
| 530 | 531 |
| 532 x86::Address TargetX8632::stackVarToAsmOperand(const Variable *Var) const { |
| 533 assert(!Var->hasReg()); |
| 534 int32_t Offset = Var->getStackOffset(); |
| 535 if (!hasFramePointer()) |
| 536 Offset += getStackAdjustment(); |
| 537 return x86::Address(RegX8632::getEncodedGPR(getFrameOrStackReg()), Offset); |
| 538 } |
| 539 |
| 531 void TargetX8632::lowerArguments() { | 540 void TargetX8632::lowerArguments() { |
| 532 VarList &Args = Func->getArgs(); | 541 VarList &Args = Func->getArgs(); |
| 533 // The first four arguments of vector type, regardless of their | 542 // The first four arguments of vector type, regardless of their |
| 534 // position relative to the other arguments in the argument list, are | 543 // position relative to the other arguments in the argument list, are |
| 535 // passed in registers xmm0 - xmm3. | 544 // passed in registers xmm0 - xmm3. |
| 536 unsigned NumXmmArgs = 0; | 545 unsigned NumXmmArgs = 0; |
| 537 | 546 |
| 538 Context.init(Func->getEntryNode()); | 547 Context.init(Func->getEntryNode()); |
| 539 Context.setInsertPoint(Context.getCur()); | 548 Context.setInsertPoint(Context.getCur()); |
| 540 | 549 |
| (...skipping 3162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3703 llvm::dyn_cast<Variable>(ArithInst->getSrc(0))) { | 3712 llvm::dyn_cast<Variable>(ArithInst->getSrc(0))) { |
| 3704 Var = VariableOperand; | 3713 Var = VariableOperand; |
| 3705 Const = llvm::dyn_cast<ConstantInteger32>(ArithInst->getSrc(1)); | 3714 Const = llvm::dyn_cast<ConstantInteger32>(ArithInst->getSrc(1)); |
| 3706 } else if (IsAdd) { | 3715 } else if (IsAdd) { |
| 3707 Const = llvm::dyn_cast<ConstantInteger32>(ArithInst->getSrc(0)); | 3716 Const = llvm::dyn_cast<ConstantInteger32>(ArithInst->getSrc(0)); |
| 3708 Var = llvm::dyn_cast<Variable>(ArithInst->getSrc(1)); | 3717 Var = llvm::dyn_cast<Variable>(ArithInst->getSrc(1)); |
| 3709 } | 3718 } |
| 3710 if (Var == NULL || Const == NULL || VMetadata->isMultiDef(Var)) | 3719 if (Var == NULL || Const == NULL || VMetadata->isMultiDef(Var)) |
| 3711 return false; | 3720 return false; |
| 3712 int32_t MoreOffset = IsAdd ? Const->getValue() : -Const->getValue(); | 3721 int32_t MoreOffset = IsAdd ? Const->getValue() : -Const->getValue(); |
| 3713 if (WouldOverflowAdd(Offset, MoreOffset)) | 3722 if (Utils::WouldOverflowAdd(Offset, MoreOffset)) |
| 3714 return false; | 3723 return false; |
| 3715 Base = Var; | 3724 Base = Var; |
| 3716 Offset += MoreOffset; | 3725 Offset += MoreOffset; |
| 3717 Reason = BaseInst; | 3726 Reason = BaseInst; |
| 3718 return true; | 3727 return true; |
| 3719 } | 3728 } |
| 3720 return false; | 3729 return false; |
| 3721 } | 3730 } |
| 3722 | 3731 |
| 3723 void computeAddressOpt(Cfg *Func, const Inst *Instr, Variable *&Base, | 3732 void computeAddressOpt(Cfg *Func, const Inst *Instr, Variable *&Base, |
| (...skipping 827 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4551 Str << "\t.align\t" << Align << "\n"; | 4560 Str << "\t.align\t" << Align << "\n"; |
| 4552 Str << MangledName << ":\n"; | 4561 Str << MangledName << ":\n"; |
| 4553 for (SizeT i = 0; i < Size; ++i) { | 4562 for (SizeT i = 0; i < Size; ++i) { |
| 4554 Str << "\t.byte\t" << (((unsigned)Data[i]) & 0xff) << "\n"; | 4563 Str << "\t.byte\t" << (((unsigned)Data[i]) & 0xff) << "\n"; |
| 4555 } | 4564 } |
| 4556 Str << "\t.size\t" << MangledName << ", " << Size << "\n"; | 4565 Str << "\t.size\t" << MangledName << ", " << Size << "\n"; |
| 4557 } | 4566 } |
| 4558 } | 4567 } |
| 4559 | 4568 |
| 4560 } // end of namespace Ice | 4569 } // end of namespace Ice |
| OLD | NEW |