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

Side by Side Diff: src/IceTargetLoweringX8632.cpp

Issue 574133002: Add initial integrated assembler w/ some Xmm ops. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: more cleanup Created 6 years, 3 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/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 482 matching lines...) Expand 10 before | Expand all | Expand 10 after
519 if (!hasFramePointer()) 520 if (!hasFramePointer())
520 Offset += getStackAdjustment(); 521 Offset += getStackAdjustment();
521 if (Offset) { 522 if (Offset) {
522 if (Offset > 0) 523 if (Offset > 0)
523 Str << "+"; 524 Str << "+";
524 Str << Offset; 525 Str << Offset;
525 } 526 }
526 Str << "]"; 527 Str << "]";
527 } 528 }
528 529
530 x86::Address TargetX8632::stackVarToAsmOperand(const Variable *Var) const {
531 assert(!Var->hasReg());
532 int32_t Offset = Var->getStackOffset();
533 if (!hasFramePointer())
534 Offset += getStackAdjustment();
535 return x86::Address(RegX8632::getEncodedGPR(getFrameOrStackReg()), Offset);
536 }
537
529 void TargetX8632::lowerArguments() { 538 void TargetX8632::lowerArguments() {
530 VarList &Args = Func->getArgs(); 539 VarList &Args = Func->getArgs();
531 // The first four arguments of vector type, regardless of their 540 // The first four arguments of vector type, regardless of their
532 // position relative to the other arguments in the argument list, are 541 // position relative to the other arguments in the argument list, are
533 // passed in registers xmm0 - xmm3. 542 // passed in registers xmm0 - xmm3.
534 unsigned NumXmmArgs = 0; 543 unsigned NumXmmArgs = 0;
535 544
536 Context.init(Func->getEntryNode()); 545 Context.init(Func->getEntryNode());
537 Context.setInsertPoint(Context.getCur()); 546 Context.setInsertPoint(Context.getCur());
538 547
(...skipping 3162 matching lines...) Expand 10 before | Expand all | Expand 10 after
3701 llvm::dyn_cast<Variable>(ArithInst->getSrc(0))) { 3710 llvm::dyn_cast<Variable>(ArithInst->getSrc(0))) {
3702 Var = VariableOperand; 3711 Var = VariableOperand;
3703 Const = llvm::dyn_cast<ConstantInteger32>(ArithInst->getSrc(1)); 3712 Const = llvm::dyn_cast<ConstantInteger32>(ArithInst->getSrc(1));
3704 } else if (IsAdd) { 3713 } else if (IsAdd) {
3705 Const = llvm::dyn_cast<ConstantInteger32>(ArithInst->getSrc(0)); 3714 Const = llvm::dyn_cast<ConstantInteger32>(ArithInst->getSrc(0));
3706 Var = llvm::dyn_cast<Variable>(ArithInst->getSrc(1)); 3715 Var = llvm::dyn_cast<Variable>(ArithInst->getSrc(1));
3707 } 3716 }
3708 if (Var == NULL || Const == NULL || Var->getIsMultidef()) 3717 if (Var == NULL || Const == NULL || Var->getIsMultidef())
3709 return false; 3718 return false;
3710 int32_t MoreOffset = IsAdd ? Const->getValue() : -Const->getValue(); 3719 int32_t MoreOffset = IsAdd ? Const->getValue() : -Const->getValue();
3711 if (WouldOverflowAdd(Offset, MoreOffset)) 3720 if (Utils::WouldOverflowAdd(Offset, MoreOffset))
3712 return false; 3721 return false;
3713 Base = Var; 3722 Base = Var;
3714 Offset += MoreOffset; 3723 Offset += MoreOffset;
3715 Reason = BaseInst; 3724 Reason = BaseInst;
3716 return true; 3725 return true;
3717 } 3726 }
3718 return false; 3727 return false;
3719 } 3728 }
3720 3729
3721 void computeAddressOpt(Cfg *Func, const Inst *Instr, Variable *&Base, 3730 void computeAddressOpt(Cfg *Func, const Inst *Instr, Variable *&Base,
(...skipping 826 matching lines...) Expand 10 before | Expand all | Expand 10 after
4548 Str << "\t.align\t" << Align << "\n"; 4557 Str << "\t.align\t" << Align << "\n";
4549 Str << MangledName << ":\n"; 4558 Str << MangledName << ":\n";
4550 for (SizeT i = 0; i < Size; ++i) { 4559 for (SizeT i = 0; i < Size; ++i) {
4551 Str << "\t.byte\t" << (((unsigned)Data[i]) & 0xff) << "\n"; 4560 Str << "\t.byte\t" << (((unsigned)Data[i]) & 0xff) << "\n";
4552 } 4561 }
4553 Str << "\t.size\t" << MangledName << ", " << Size << "\n"; 4562 Str << "\t.size\t" << MangledName << ", " << Size << "\n";
4554 } 4563 }
4555 } 4564 }
4556 4565
4557 } // end of namespace Ice 4566 } // end of namespace Ice
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698