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

Side by Side Diff: src/IceTargetLoweringX8632.cpp

Issue 597003004: Subzero: Automatically infer regalloc preferences and overlap. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Remove manual specification of prefer/overlap. Created 6 years, 2 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
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 // Validate the live range computations. Do it outside the timing 375 // Validate the live range computations. Do it outside the timing
376 // code. TODO: Put this under a flag. 376 // code. TODO: Put this under a flag.
377 bool ValidLiveness = Func->validateLiveness(); 377 bool ValidLiveness = Func->validateLiveness();
378 assert(ValidLiveness); 378 assert(ValidLiveness);
379 (void)ValidLiveness; // used only in assert() 379 (void)ValidLiveness; // used only in assert()
380 ComputedLiveRanges = true; 380 ComputedLiveRanges = true;
381 // The post-codegen dump is done here, after liveness analysis and 381 // The post-codegen dump is done here, after liveness analysis and
382 // associated cleanup, to make the dump cleaner and more useful. 382 // associated cleanup, to make the dump cleaner and more useful.
383 Func->dump("After initial x8632 codegen"); 383 Func->dump("After initial x8632 codegen");
384 Timer T_regAlloc; 384 Timer T_regAlloc;
385 Func->getVMetadata()->init();
jvoung (off chromium) 2014/09/25 16:42:11 Does the Func->liveness() already initialize VMeta
Jim Stichnoth 2014/09/25 18:13:55 It's true that liveness initializes VMetadata. Ho
385 regAlloc(); 386 regAlloc();
386 if (Func->hasError()) 387 if (Func->hasError())
387 return; 388 return;
388 T_regAlloc.printElapsedUs(Context, "regAlloc()"); 389 T_regAlloc.printElapsedUs(Context, "regAlloc()");
389 Func->dump("After linear scan regalloc"); 390 Func->dump("After linear scan regalloc");
390 391
391 // Stack frame mapping. 392 // Stack frame mapping.
392 Timer T_genFrame; 393 Timer T_genFrame;
393 Func->genFrame(); 394 Func->genFrame();
394 if (Func->hasError()) 395 if (Func->hasError())
(...skipping 1188 matching lines...) Expand 10 before | Expand all | Expand 10 after
1583 if (Dest->getType() == IceType_i8) 1584 if (Dest->getType() == IceType_i8)
1584 _mov(T, Src0, RegX8632::Reg_eax); 1585 _mov(T, Src0, RegX8632::Reg_eax);
1585 else 1586 else
1586 _mov(T, Src0); 1587 _mov(T, Src0);
1587 _imul(T, Src1); 1588 _imul(T, Src1);
1588 _mov(Dest, T); 1589 _mov(Dest, T);
1589 break; 1590 break;
1590 case InstArithmetic::Shl: 1591 case InstArithmetic::Shl:
1591 _mov(T, Src0); 1592 _mov(T, Src0);
1592 if (!llvm::isa<Constant>(Src1)) 1593 if (!llvm::isa<Constant>(Src1))
1593 Src1 = legalizeToVar(Src1, false, RegX8632::Reg_ecx); 1594 Src1 = legalizeToVar(Src1, RegX8632::Reg_ecx);
1594 _shl(T, Src1); 1595 _shl(T, Src1);
1595 _mov(Dest, T); 1596 _mov(Dest, T);
1596 break; 1597 break;
1597 case InstArithmetic::Lshr: 1598 case InstArithmetic::Lshr:
1598 _mov(T, Src0); 1599 _mov(T, Src0);
1599 if (!llvm::isa<Constant>(Src1)) 1600 if (!llvm::isa<Constant>(Src1))
1600 Src1 = legalizeToVar(Src1, false, RegX8632::Reg_ecx); 1601 Src1 = legalizeToVar(Src1, RegX8632::Reg_ecx);
1601 _shr(T, Src1); 1602 _shr(T, Src1);
1602 _mov(Dest, T); 1603 _mov(Dest, T);
1603 break; 1604 break;
1604 case InstArithmetic::Ashr: 1605 case InstArithmetic::Ashr:
1605 _mov(T, Src0); 1606 _mov(T, Src0);
1606 if (!llvm::isa<Constant>(Src1)) 1607 if (!llvm::isa<Constant>(Src1))
1607 Src1 = legalizeToVar(Src1, false, RegX8632::Reg_ecx); 1608 Src1 = legalizeToVar(Src1, RegX8632::Reg_ecx);
1608 _sar(T, Src1); 1609 _sar(T, Src1);
1609 _mov(Dest, T); 1610 _mov(Dest, T);
1610 break; 1611 break;
1611 case InstArithmetic::Udiv: 1612 case InstArithmetic::Udiv:
1612 // div and idiv are the few arithmetic operators that do not allow 1613 // div and idiv are the few arithmetic operators that do not allow
1613 // immediates as the operand. 1614 // immediates as the operand.
1614 Src1 = legalize(Src1, Legal_Reg | Legal_Mem); 1615 Src1 = legalize(Src1, Legal_Reg | Legal_Mem);
1615 if (Dest->getType() == IceType_i8) { 1616 if (Dest->getType() == IceType_i8) {
1616 Variable *T_ah = NULL; 1617 Variable *T_ah = NULL;
1617 Constant *Zero = Ctx->getConstantZero(IceType_i8); 1618 Constant *Zero = Ctx->getConstantZero(IceType_i8);
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
1718 Operand *Src0Lo = loOperand(Src0); 1719 Operand *Src0Lo = loOperand(Src0);
1719 Operand *Src0Hi = hiOperand(Src0); 1720 Operand *Src0Hi = hiOperand(Src0);
1720 Variable *DestLo = llvm::cast<Variable>(loOperand(Dest)); 1721 Variable *DestLo = llvm::cast<Variable>(loOperand(Dest));
1721 Variable *DestHi = llvm::cast<Variable>(hiOperand(Dest)); 1722 Variable *DestHi = llvm::cast<Variable>(hiOperand(Dest));
1722 Variable *T_Lo = NULL, *T_Hi = NULL; 1723 Variable *T_Lo = NULL, *T_Hi = NULL;
1723 _mov(T_Lo, Src0Lo); 1724 _mov(T_Lo, Src0Lo);
1724 _mov(DestLo, T_Lo); 1725 _mov(DestLo, T_Lo);
1725 _mov(T_Hi, Src0Hi); 1726 _mov(T_Hi, Src0Hi);
1726 _mov(DestHi, T_Hi); 1727 _mov(DestHi, T_Hi);
1727 } else { 1728 } else {
1728 const bool AllowOverlap = true;
1729 // RI is either a physical register or an immediate. 1729 // RI is either a physical register or an immediate.
1730 Operand *RI = legalize(Src0, Legal_Reg | Legal_Imm, AllowOverlap); 1730 Operand *RI = legalize(Src0, Legal_Reg | Legal_Imm);
1731 if (isVectorType(Dest->getType())) 1731 if (isVectorType(Dest->getType()))
1732 _movp(Dest, RI); 1732 _movp(Dest, RI);
1733 else 1733 else
1734 _mov(Dest, RI); 1734 _mov(Dest, RI);
1735 } 1735 }
1736 } 1736 }
1737 1737
1738 void TargetX8632::lowerBr(const InstBr *Inst) { 1738 void TargetX8632::lowerBr(const InstBr *Inst) {
1739 if (Inst->isUnconditional()) { 1739 if (Inst->isUnconditional()) {
1740 _br(Inst->getTargetUnconditional()); 1740 _br(Inst->getTargetUnconditional());
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
1823 // Copy arguments to be passed in registers to the appropriate 1823 // Copy arguments to be passed in registers to the appropriate
1824 // registers. 1824 // registers.
1825 // TODO: Investigate the impact of lowering arguments passed in 1825 // TODO: Investigate the impact of lowering arguments passed in
1826 // registers after lowering stack arguments as opposed to the other 1826 // registers after lowering stack arguments as opposed to the other
1827 // way around. Lowering register arguments after stack arguments may 1827 // way around. Lowering register arguments after stack arguments may
1828 // reduce register pressure. On the other hand, lowering register 1828 // reduce register pressure. On the other hand, lowering register
1829 // arguments first (before stack arguments) may result in more compact 1829 // arguments first (before stack arguments) may result in more compact
1830 // code, as the memory operand displacements may end up being smaller 1830 // code, as the memory operand displacements may end up being smaller
1831 // before any stack adjustment is done. 1831 // before any stack adjustment is done.
1832 for (SizeT i = 0, NumXmmArgs = XmmArgs.size(); i < NumXmmArgs; ++i) { 1832 for (SizeT i = 0, NumXmmArgs = XmmArgs.size(); i < NumXmmArgs; ++i) {
1833 Variable *Reg = legalizeToVar(XmmArgs[i], false, RegX8632::Reg_xmm0 + i); 1833 Variable *Reg = legalizeToVar(XmmArgs[i], RegX8632::Reg_xmm0 + i);
1834 // Generate a FakeUse of register arguments so that they do not get 1834 // Generate a FakeUse of register arguments so that they do not get
1835 // dead code eliminated as a result of the FakeKill of scratch 1835 // dead code eliminated as a result of the FakeKill of scratch
1836 // registers after the call. 1836 // registers after the call.
1837 Context.insert(InstFakeUse::create(Func, Reg)); 1837 Context.insert(InstFakeUse::create(Func, Reg));
1838 } 1838 }
1839 // Generate the call instruction. Assign its result to a temporary 1839 // Generate the call instruction. Assign its result to a temporary
1840 // with high register allocation weight. 1840 // with high register allocation weight.
1841 Variable *Dest = Instr->getDest(); 1841 Variable *Dest = Instr->getDest();
1842 // ReturnReg doubles as ReturnRegLo as necessary. 1842 // ReturnReg doubles as ReturnRegLo as necessary.
1843 Variable *ReturnReg = NULL; 1843 Variable *ReturnReg = NULL;
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
1907 if (!Dest) 1907 if (!Dest)
1908 return; 1908 return;
1909 1909
1910 // Assign the result of the call to Dest. 1910 // Assign the result of the call to Dest.
1911 if (ReturnReg) { 1911 if (ReturnReg) {
1912 if (ReturnRegHi) { 1912 if (ReturnRegHi) {
1913 assert(Dest->getType() == IceType_i64); 1913 assert(Dest->getType() == IceType_i64);
1914 split64(Dest); 1914 split64(Dest);
1915 Variable *DestLo = Dest->getLo(); 1915 Variable *DestLo = Dest->getLo();
1916 Variable *DestHi = Dest->getHi(); 1916 Variable *DestHi = Dest->getHi();
1917 DestLo->setPreferredRegister(ReturnReg, false);
1918 DestHi->setPreferredRegister(ReturnRegHi, false);
1919 _mov(DestLo, ReturnReg); 1917 _mov(DestLo, ReturnReg);
1920 _mov(DestHi, ReturnRegHi); 1918 _mov(DestHi, ReturnRegHi);
1921 } else { 1919 } else {
1922 assert(Dest->getType() == IceType_i32 || Dest->getType() == IceType_i16 || 1920 assert(Dest->getType() == IceType_i32 || Dest->getType() == IceType_i16 ||
1923 Dest->getType() == IceType_i8 || Dest->getType() == IceType_i1 || 1921 Dest->getType() == IceType_i8 || Dest->getType() == IceType_i1 ||
1924 isVectorType(Dest->getType())); 1922 isVectorType(Dest->getType()));
1925 Dest->setPreferredRegister(ReturnReg, false);
1926 if (isVectorType(Dest->getType())) { 1923 if (isVectorType(Dest->getType())) {
1927 _movp(Dest, ReturnReg); 1924 _movp(Dest, ReturnReg);
1928 } else { 1925 } else {
1929 _mov(Dest, ReturnReg); 1926 _mov(Dest, ReturnReg);
1930 } 1927 }
1931 } 1928 }
1932 } else if (Dest->getType() == IceType_f32 || Dest->getType() == IceType_f64) { 1929 } else if (Dest->getType() == IceType_f32 || Dest->getType() == IceType_f64) {
1933 // Special treatment for an FP function which returns its result in 1930 // Special treatment for an FP function which returns its result in
1934 // st(0). 1931 // st(0).
1935 // If Dest ends up being a physical xmm register, the fstp emit code 1932 // If Dest ends up being a physical xmm register, the fstp emit code
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
2130 } else { 2127 } else {
2131 Operand *Src0RM = legalize(Inst->getSrc(0), Legal_Reg | Legal_Mem); 2128 Operand *Src0RM = legalize(Inst->getSrc(0), Legal_Reg | Legal_Mem);
2132 // t1.i32 = cvt Src0RM; t2.dest_type = t1; Dest = t2.dest_type 2129 // t1.i32 = cvt Src0RM; t2.dest_type = t1; Dest = t2.dest_type
2133 Variable *T_1 = makeReg(IceType_i32); 2130 Variable *T_1 = makeReg(IceType_i32);
2134 Variable *T_2 = makeReg(Dest->getType()); 2131 Variable *T_2 = makeReg(Dest->getType());
2135 _cvtt(T_1, Src0RM); 2132 _cvtt(T_1, Src0RM);
2136 _mov(T_2, T_1); // T_1 and T_2 may have different integer types 2133 _mov(T_2, T_1); // T_1 and T_2 may have different integer types
2137 if (Dest->getType() == IceType_i1) 2134 if (Dest->getType() == IceType_i1)
2138 _and(T_2, Ctx->getConstantInt32(IceType_i1, 1)); 2135 _and(T_2, Ctx->getConstantInt32(IceType_i1, 1));
2139 _mov(Dest, T_2); 2136 _mov(Dest, T_2);
2140 T_2->setPreferredRegister(T_1, true);
2141 } 2137 }
2142 break; 2138 break;
2143 case InstCast::Fptoui: 2139 case InstCast::Fptoui:
2144 if (isVectorType(Dest->getType())) { 2140 if (isVectorType(Dest->getType())) {
2145 assert(Dest->getType() == IceType_v4i32 && 2141 assert(Dest->getType() == IceType_v4i32 &&
2146 Inst->getSrc(0)->getType() == IceType_v4f32); 2142 Inst->getSrc(0)->getType() == IceType_v4f32);
2147 const SizeT MaxSrcs = 1; 2143 const SizeT MaxSrcs = 1;
2148 InstCall *Call = makeHelperCall("Sz_fptoui_v4f32", Dest, MaxSrcs); 2144 InstCall *Call = makeHelperCall("Sz_fptoui_v4f32", Dest, MaxSrcs);
2149 Call->addArg(Inst->getSrc(0)); 2145 Call->addArg(Inst->getSrc(0));
2150 lowerCall(Call); 2146 lowerCall(Call);
(...skipping 16 matching lines...) Expand all
2167 } else { 2163 } else {
2168 Operand *Src0RM = legalize(Inst->getSrc(0), Legal_Reg | Legal_Mem); 2164 Operand *Src0RM = legalize(Inst->getSrc(0), Legal_Reg | Legal_Mem);
2169 // t1.i32 = cvt Src0RM; t2.dest_type = t1; Dest = t2.dest_type 2165 // t1.i32 = cvt Src0RM; t2.dest_type = t1; Dest = t2.dest_type
2170 Variable *T_1 = makeReg(IceType_i32); 2166 Variable *T_1 = makeReg(IceType_i32);
2171 Variable *T_2 = makeReg(Dest->getType()); 2167 Variable *T_2 = makeReg(Dest->getType());
2172 _cvtt(T_1, Src0RM); 2168 _cvtt(T_1, Src0RM);
2173 _mov(T_2, T_1); // T_1 and T_2 may have different integer types 2169 _mov(T_2, T_1); // T_1 and T_2 may have different integer types
2174 if (Dest->getType() == IceType_i1) 2170 if (Dest->getType() == IceType_i1)
2175 _and(T_2, Ctx->getConstantInt32(IceType_i1, 1)); 2171 _and(T_2, Ctx->getConstantInt32(IceType_i1, 1));
2176 _mov(Dest, T_2); 2172 _mov(Dest, T_2);
2177 T_2->setPreferredRegister(T_1, true);
2178 } 2173 }
2179 break; 2174 break;
2180 case InstCast::Sitofp: 2175 case InstCast::Sitofp:
2181 if (isVectorType(Dest->getType())) { 2176 if (isVectorType(Dest->getType())) {
2182 assert(Dest->getType() == IceType_v4f32 && 2177 assert(Dest->getType() == IceType_v4f32 &&
2183 Inst->getSrc(0)->getType() == IceType_v4i32); 2178 Inst->getSrc(0)->getType() == IceType_v4i32);
2184 Operand *Src0RM = legalize(Inst->getSrc(0), Legal_Reg | Legal_Mem); 2179 Operand *Src0RM = legalize(Inst->getSrc(0), Legal_Reg | Legal_Mem);
2185 Variable *T = makeReg(Dest->getType()); 2180 Variable *T = makeReg(Dest->getType());
2186 _cvt(T, Src0RM); 2181 _cvt(T, Src0RM);
2187 _movp(Dest, T); 2182 _movp(Dest, T);
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after
2679 IsSrc1ImmOrReg = true; 2674 IsSrc1ImmOrReg = true;
2680 } 2675 }
2681 2676
2682 // Try to fuse a compare immediately followed by a conditional branch. This 2677 // Try to fuse a compare immediately followed by a conditional branch. This
2683 // is possible when the compare dest and the branch source operands are the 2678 // is possible when the compare dest and the branch source operands are the
2684 // same, and are their only uses. TODO: implement this optimization for i64. 2679 // same, and are their only uses. TODO: implement this optimization for i64.
2685 if (InstBr *NextBr = llvm::dyn_cast_or_null<InstBr>(Context.getNextInst())) { 2680 if (InstBr *NextBr = llvm::dyn_cast_or_null<InstBr>(Context.getNextInst())) {
2686 if (Src0->getType() != IceType_i64 && !NextBr->isUnconditional() && 2681 if (Src0->getType() != IceType_i64 && !NextBr->isUnconditional() &&
2687 Dest == NextBr->getSrc(0) && NextBr->isLastUse(Dest)) { 2682 Dest == NextBr->getSrc(0) && NextBr->isLastUse(Dest)) {
2688 NextBr->setDeleted(); 2683 NextBr->setDeleted();
2689 Operand *Src0RM = legalize( 2684 Operand *Src0RM =
2690 Src0, IsSrc1ImmOrReg ? (Legal_Reg | Legal_Mem) : Legal_Reg, true); 2685 legalize(Src0, IsSrc1ImmOrReg ? (Legal_Reg | Legal_Mem) : Legal_Reg);
2691 _cmp(Src0RM, Src1); 2686 _cmp(Src0RM, Src1);
2692 _br(getIcmp32Mapping(Inst->getCondition()), NextBr->getTargetTrue(), 2687 _br(getIcmp32Mapping(Inst->getCondition()), NextBr->getTargetTrue(),
2693 NextBr->getTargetFalse()); 2688 NextBr->getTargetFalse());
2694 // Skip over the following branch instruction. 2689 // Skip over the following branch instruction.
2695 Context.advanceNext(); 2690 Context.advanceNext();
2696 return; 2691 return;
2697 } 2692 }
2698 } 2693 }
2699 2694
2700 // a=icmp cond, b, c ==> cmp b,c; a=1; br cond,L1; FakeUse(a); a=0; L1: 2695 // a=icmp cond, b, c ==> cmp b,c; a=1; br cond,L1; FakeUse(a); a=0; L1:
(...skipping 28 matching lines...) Expand all
2729 _br(TableIcmp64[Index].C3, LabelTrue); 2724 _br(TableIcmp64[Index].C3, LabelTrue);
2730 Context.insert(LabelFalse); 2725 Context.insert(LabelFalse);
2731 Context.insert(InstFakeUse::create(Func, Dest)); 2726 Context.insert(InstFakeUse::create(Func, Dest));
2732 _mov(Dest, Zero); 2727 _mov(Dest, Zero);
2733 Context.insert(LabelTrue); 2728 Context.insert(LabelTrue);
2734 } 2729 }
2735 return; 2730 return;
2736 } 2731 }
2737 2732
2738 // cmp b, c 2733 // cmp b, c
2739 Operand *Src0RM = legalize( 2734 Operand *Src0RM =
2740 Src0, IsSrc1ImmOrReg ? (Legal_Reg | Legal_Mem) : Legal_Reg, true); 2735 legalize(Src0, IsSrc1ImmOrReg ? (Legal_Reg | Legal_Mem) : Legal_Reg);
2741 InstX8632Label *Label = InstX8632Label::create(Func, this); 2736 InstX8632Label *Label = InstX8632Label::create(Func, this);
2742 _cmp(Src0RM, Src1); 2737 _cmp(Src0RM, Src1);
2743 _mov(Dest, One); 2738 _mov(Dest, One);
2744 _br(getIcmp32Mapping(Inst->getCondition()), Label); 2739 _br(getIcmp32Mapping(Inst->getCondition()), Label);
2745 Context.insert(InstFakeUse::create(Func, Dest)); 2740 Context.insert(InstFakeUse::create(Func, Dest));
2746 _mov(Dest, Zero); 2741 _mov(Dest, Zero);
2747 Context.insert(Label); 2742 Context.insert(Label);
2748 } 2743 }
2749 2744
2750 void TargetX8632::lowerInsertElement(const InstInsertElement *Inst) { 2745 void TargetX8632::lowerInsertElement(const InstInsertElement *Inst) {
(...skipping 830 matching lines...) Expand 10 before | Expand all | Expand 10 after
3581 Str << "<null>"; 3576 Str << "<null>";
3582 Str << ", Shift=" << Shift << ", Offset=" << Offset << "\n"; 3577 Str << ", Shift=" << Shift << ", Offset=" << Offset << "\n";
3583 } 3578 }
3584 3579
3585 bool matchTransitiveAssign(const VariablesMetadata *VMetadata, Variable *&Var, 3580 bool matchTransitiveAssign(const VariablesMetadata *VMetadata, Variable *&Var,
3586 const Inst *&Reason) { 3581 const Inst *&Reason) {
3587 // Var originates from Var=SrcVar ==> 3582 // Var originates from Var=SrcVar ==>
3588 // set Var:=SrcVar 3583 // set Var:=SrcVar
3589 if (Var == NULL) 3584 if (Var == NULL)
3590 return false; 3585 return false;
3591 if (const Inst *VarAssign = VMetadata->getDefinition(Var)) { 3586 if (VMetadata->isMultiDef(Var))
jvoung (off chromium) 2014/09/25 16:42:11 Might be able to just check that the result of get
Jim Stichnoth 2014/09/25 18:13:55 Done. (But left the equivalent asserts in place j
3587 return false;
3588 if (const Inst *VarAssign = VMetadata->getSingleDefinition(Var)) {
3592 if (llvm::isa<InstAssign>(VarAssign)) { 3589 if (llvm::isa<InstAssign>(VarAssign)) {
3593 Operand *SrcOp = VarAssign->getSrc(0); 3590 Operand *SrcOp = VarAssign->getSrc(0);
3594 assert(SrcOp); 3591 assert(SrcOp);
3595 if (Variable *SrcVar = llvm::dyn_cast<Variable>(SrcOp)) { 3592 if (Variable *SrcVar = llvm::dyn_cast<Variable>(SrcOp)) {
3596 if (!VMetadata->isMultiDef(SrcVar) && 3593 if (!VMetadata->isMultiDef(SrcVar) &&
3597 // TODO: ensure SrcVar stays single-BB 3594 // TODO: ensure SrcVar stays single-BB
3598 true) { 3595 true) {
3599 Var = SrcVar; 3596 Var = SrcVar;
3600 Reason = VarAssign; 3597 Reason = VarAssign;
3601 return true; 3598 return true;
3602 } 3599 }
3603 } 3600 }
3604 } 3601 }
3605 } 3602 }
3606 return false; 3603 return false;
3607 } 3604 }
3608 3605
3609 bool matchCombinedBaseIndex(const VariablesMetadata *VMetadata, Variable *&Base, 3606 bool matchCombinedBaseIndex(const VariablesMetadata *VMetadata, Variable *&Base,
3610 Variable *&Index, uint16_t &Shift, 3607 Variable *&Index, uint16_t &Shift,
3611 const Inst *&Reason) { 3608 const Inst *&Reason) {
3612 // Index==NULL && Base is Base=Var1+Var2 ==> 3609 // Index==NULL && Base is Base=Var1+Var2 ==>
3613 // set Base=Var1, Index=Var2, Shift=0 3610 // set Base=Var1, Index=Var2, Shift=0
3614 if (Base == NULL) 3611 if (Base == NULL)
3615 return false; 3612 return false;
3616 if (Index != NULL) 3613 if (Index != NULL)
3617 return false; 3614 return false;
3618 const Inst *BaseInst = VMetadata->getDefinition(Base); 3615 if (VMetadata->isMultiDef(Base))
3616 return false;
3617 const Inst *BaseInst = VMetadata->getSingleDefinition(Base);
3619 if (BaseInst == NULL) 3618 if (BaseInst == NULL)
3620 return false; 3619 return false;
3621 if (BaseInst->getSrcSize() < 2) 3620 if (BaseInst->getSrcSize() < 2)
3622 return false; 3621 return false;
3623 if (Variable *Var1 = llvm::dyn_cast<Variable>(BaseInst->getSrc(0))) { 3622 if (Variable *Var1 = llvm::dyn_cast<Variable>(BaseInst->getSrc(0))) {
3624 if (VMetadata->isMultiDef(Var1)) 3623 if (VMetadata->isMultiDef(Var1))
3625 return false; 3624 return false;
3626 if (Variable *Var2 = llvm::dyn_cast<Variable>(BaseInst->getSrc(1))) { 3625 if (Variable *Var2 = llvm::dyn_cast<Variable>(BaseInst->getSrc(1))) {
3627 if (VMetadata->isMultiDef(Var2)) 3626 if (VMetadata->isMultiDef(Var2))
3628 return false; 3627 return false;
(...skipping 10 matching lines...) Expand all
3639 } 3638 }
3640 return false; 3639 return false;
3641 } 3640 }
3642 3641
3643 bool matchShiftedIndex(const VariablesMetadata *VMetadata, Variable *&Index, 3642 bool matchShiftedIndex(const VariablesMetadata *VMetadata, Variable *&Index,
3644 uint16_t &Shift, const Inst *&Reason) { 3643 uint16_t &Shift, const Inst *&Reason) {
3645 // Index is Index=Var*Const && log2(Const)+Shift<=3 ==> 3644 // Index is Index=Var*Const && log2(Const)+Shift<=3 ==>
3646 // Index=Var, Shift+=log2(Const) 3645 // Index=Var, Shift+=log2(Const)
3647 if (Index == NULL) 3646 if (Index == NULL)
3648 return false; 3647 return false;
3649 const Inst *IndexInst = VMetadata->getDefinition(Index); 3648 if (VMetadata->isMultiDef(Index))
3649 return false;
3650 const Inst *IndexInst = VMetadata->getSingleDefinition(Index);
3650 if (IndexInst == NULL) 3651 if (IndexInst == NULL)
3651 return false; 3652 return false;
3652 if (IndexInst->getSrcSize() < 2) 3653 if (IndexInst->getSrcSize() < 2)
3653 return false; 3654 return false;
3654 if (const InstArithmetic *ArithInst = 3655 if (const InstArithmetic *ArithInst =
3655 llvm::dyn_cast<InstArithmetic>(IndexInst)) { 3656 llvm::dyn_cast<InstArithmetic>(IndexInst)) {
3656 if (Variable *Var = llvm::dyn_cast<Variable>(ArithInst->getSrc(0))) { 3657 if (Variable *Var = llvm::dyn_cast<Variable>(ArithInst->getSrc(0))) {
3657 if (ConstantInteger32 *Const = 3658 if (ConstantInteger32 *Const =
3658 llvm::dyn_cast<ConstantInteger32>(ArithInst->getSrc(1))) { 3659 llvm::dyn_cast<ConstantInteger32>(ArithInst->getSrc(1))) {
3659 if (ArithInst->getOp() == InstArithmetic::Mul && 3660 if (ArithInst->getOp() == InstArithmetic::Mul &&
(...skipping 30 matching lines...) Expand all
3690 } 3691 }
3691 3692
3692 bool matchOffsetBase(const VariablesMetadata *VMetadata, Variable *&Base, 3693 bool matchOffsetBase(const VariablesMetadata *VMetadata, Variable *&Base,
3693 int32_t &Offset, const Inst *&Reason) { 3694 int32_t &Offset, const Inst *&Reason) {
3694 // Base is Base=Var+Const || Base is Base=Const+Var ==> 3695 // Base is Base=Var+Const || Base is Base=Const+Var ==>
3695 // set Base=Var, Offset+=Const 3696 // set Base=Var, Offset+=Const
3696 // Base is Base=Var-Const ==> 3697 // Base is Base=Var-Const ==>
3697 // set Base=Var, Offset-=Const 3698 // set Base=Var, Offset-=Const
3698 if (Base == NULL) 3699 if (Base == NULL)
3699 return false; 3700 return false;
3700 const Inst *BaseInst = VMetadata->getDefinition(Base); 3701 if (VMetadata->isMultiDef(Base))
3702 return false;
3703 const Inst *BaseInst = VMetadata->getSingleDefinition(Base);
3701 if (BaseInst == NULL) 3704 if (BaseInst == NULL)
3702 return false; 3705 return false;
3703 if (const InstArithmetic *ArithInst = 3706 if (const InstArithmetic *ArithInst =
3704 llvm::dyn_cast<const InstArithmetic>(BaseInst)) { 3707 llvm::dyn_cast<const InstArithmetic>(BaseInst)) {
3705 if (ArithInst->getOp() != InstArithmetic::Add && 3708 if (ArithInst->getOp() != InstArithmetic::Add &&
3706 ArithInst->getOp() != InstArithmetic::Sub) 3709 ArithInst->getOp() != InstArithmetic::Sub)
3707 return false; 3710 return false;
3708 bool IsAdd = ArithInst->getOp() == InstArithmetic::Add; 3711 bool IsAdd = ArithInst->getOp() == InstArithmetic::Add;
3709 Variable *Var = NULL; 3712 Variable *Var = NULL;
3710 ConstantInteger32 *Const = NULL; 3713 ConstantInteger32 *Const = NULL;
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
3871 3874
3872 void TargetX8632::lowerPhi(const InstPhi * /*Inst*/) { 3875 void TargetX8632::lowerPhi(const InstPhi * /*Inst*/) {
3873 Func->setError("Phi found in regular instruction list"); 3876 Func->setError("Phi found in regular instruction list");
3874 } 3877 }
3875 3878
3876 void TargetX8632::lowerRet(const InstRet *Inst) { 3879 void TargetX8632::lowerRet(const InstRet *Inst) {
3877 Variable *Reg = NULL; 3880 Variable *Reg = NULL;
3878 if (Inst->hasRetValue()) { 3881 if (Inst->hasRetValue()) {
3879 Operand *Src0 = legalize(Inst->getRetValue()); 3882 Operand *Src0 = legalize(Inst->getRetValue());
3880 if (Src0->getType() == IceType_i64) { 3883 if (Src0->getType() == IceType_i64) {
3881 Variable *eax = legalizeToVar(loOperand(Src0), false, RegX8632::Reg_eax); 3884 Variable *eax = legalizeToVar(loOperand(Src0), RegX8632::Reg_eax);
3882 Variable *edx = legalizeToVar(hiOperand(Src0), false, RegX8632::Reg_edx); 3885 Variable *edx = legalizeToVar(hiOperand(Src0), RegX8632::Reg_edx);
3883 Reg = eax; 3886 Reg = eax;
3884 Context.insert(InstFakeUse::create(Func, edx)); 3887 Context.insert(InstFakeUse::create(Func, edx));
3885 } else if (Src0->getType() == IceType_f32 || 3888 } else if (Src0->getType() == IceType_f32 ||
3886 Src0->getType() == IceType_f64) { 3889 Src0->getType() == IceType_f64) {
3887 _fld(Src0); 3890 _fld(Src0);
3888 } else if (isVectorType(Src0->getType())) { 3891 } else if (isVectorType(Src0->getType())) {
3889 Reg = legalizeToVar(Src0, false, RegX8632::Reg_xmm0); 3892 Reg = legalizeToVar(Src0, RegX8632::Reg_xmm0);
3890 } else { 3893 } else {
3891 _mov(Reg, Src0, RegX8632::Reg_eax); 3894 _mov(Reg, Src0, RegX8632::Reg_eax);
3892 } 3895 }
3893 } 3896 }
3894 _ret(Reg); 3897 _ret(Reg);
3895 // Add a fake use of esp to make sure esp stays alive for the entire 3898 // Add a fake use of esp to make sure esp stays alive for the entire
3896 // function. Otherwise post-call esp adjustments get dead-code 3899 // function. Otherwise post-call esp adjustments get dead-code
3897 // eliminated. TODO: Are there more places where the fake use 3900 // eliminated. TODO: Are there more places where the fake use
3898 // should be inserted? E.g. "void f(int n){while(1) g(n);}" may not 3901 // should be inserted? E.g. "void f(int n){while(1) g(n);}" may not
3899 // have a ret instruction. 3902 // have a ret instruction.
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
3966 } 3969 }
3967 3970
3968 // a=d?b:c ==> cmp d,0; a=b; jne L1; FakeUse(a); a=c; L1: 3971 // a=d?b:c ==> cmp d,0; a=b; jne L1; FakeUse(a); a=c; L1:
3969 Operand *ConditionRM = legalize(Condition, Legal_Reg | Legal_Mem); 3972 Operand *ConditionRM = legalize(Condition, Legal_Reg | Legal_Mem);
3970 Constant *Zero = Ctx->getConstantZero(IceType_i32); 3973 Constant *Zero = Ctx->getConstantZero(IceType_i32);
3971 InstX8632Label *Label = InstX8632Label::create(Func, this); 3974 InstX8632Label *Label = InstX8632Label::create(Func, this);
3972 3975
3973 if (Dest->getType() == IceType_i64) { 3976 if (Dest->getType() == IceType_i64) {
3974 Variable *DestLo = llvm::cast<Variable>(loOperand(Dest)); 3977 Variable *DestLo = llvm::cast<Variable>(loOperand(Dest));
3975 Variable *DestHi = llvm::cast<Variable>(hiOperand(Dest)); 3978 Variable *DestHi = llvm::cast<Variable>(hiOperand(Dest));
3976 Operand *SrcLoRI = legalize(loOperand(SrcT), Legal_Reg | Legal_Imm, true); 3979 Operand *SrcLoRI = legalize(loOperand(SrcT), Legal_Reg | Legal_Imm);
3977 Operand *SrcHiRI = legalize(hiOperand(SrcT), Legal_Reg | Legal_Imm, true); 3980 Operand *SrcHiRI = legalize(hiOperand(SrcT), Legal_Reg | Legal_Imm);
3978 _cmp(ConditionRM, Zero); 3981 _cmp(ConditionRM, Zero);
3979 _mov(DestLo, SrcLoRI); 3982 _mov(DestLo, SrcLoRI);
3980 _mov(DestHi, SrcHiRI); 3983 _mov(DestHi, SrcHiRI);
3981 _br(CondX86::Br_ne, Label); 3984 _br(CondX86::Br_ne, Label);
3982 Context.insert(InstFakeUse::create(Func, DestLo)); 3985 Context.insert(InstFakeUse::create(Func, DestLo));
3983 Context.insert(InstFakeUse::create(Func, DestHi)); 3986 Context.insert(InstFakeUse::create(Func, DestHi));
3984 Operand *SrcFLo = loOperand(SrcF); 3987 Operand *SrcFLo = loOperand(SrcF);
3985 Operand *SrcFHi = hiOperand(SrcF); 3988 Operand *SrcFHi = hiOperand(SrcF);
3986 SrcLoRI = legalize(SrcFLo, Legal_Reg | Legal_Imm, true); 3989 SrcLoRI = legalize(SrcFLo, Legal_Reg | Legal_Imm);
3987 SrcHiRI = legalize(SrcFHi, Legal_Reg | Legal_Imm, true); 3990 SrcHiRI = legalize(SrcFHi, Legal_Reg | Legal_Imm);
3988 _mov(DestLo, SrcLoRI); 3991 _mov(DestLo, SrcLoRI);
3989 _mov(DestHi, SrcHiRI); 3992 _mov(DestHi, SrcHiRI);
3990 } else { 3993 } else {
3991 _cmp(ConditionRM, Zero); 3994 _cmp(ConditionRM, Zero);
3992 SrcT = legalize(SrcT, Legal_Reg | Legal_Imm, true); 3995 SrcT = legalize(SrcT, Legal_Reg | Legal_Imm);
3993 _mov(Dest, SrcT); 3996 _mov(Dest, SrcT);
3994 _br(CondX86::Br_ne, Label); 3997 _br(CondX86::Br_ne, Label);
3995 Context.insert(InstFakeUse::create(Func, Dest)); 3998 Context.insert(InstFakeUse::create(Func, Dest));
3996 SrcF = legalize(SrcF, Legal_Reg | Legal_Imm, true); 3999 SrcF = legalize(SrcF, Legal_Reg | Legal_Imm);
3997 _mov(Dest, SrcF); 4000 _mov(Dest, SrcF);
3998 } 4001 }
3999 4002
4000 Context.insert(Label); 4003 Context.insert(Label);
4001 } 4004 }
4002 4005
4003 void TargetX8632::lowerStore(const InstStore *Inst) { 4006 void TargetX8632::lowerStore(const InstStore *Inst) {
4004 Operand *Value = Inst->getData(); 4007 Operand *Value = Inst->getData();
4005 Operand *Addr = Inst->getAddr(); 4008 Operand *Addr = Inst->getAddr();
4006 OperandX8632Mem *NewAddr = FormMemoryOperand(Addr, Value->getType()); 4009 OperandX8632Mem *NewAddr = FormMemoryOperand(Addr, Value->getType());
4007 Type Ty = NewAddr->getType(); 4010 Type Ty = NewAddr->getType();
4008 4011
4009 if (Ty == IceType_i64) { 4012 if (Ty == IceType_i64) {
4010 Value = legalize(Value); 4013 Value = legalize(Value);
4011 Operand *ValueHi = legalize(hiOperand(Value), Legal_Reg | Legal_Imm, true); 4014 Operand *ValueHi = legalize(hiOperand(Value), Legal_Reg | Legal_Imm);
4012 Operand *ValueLo = legalize(loOperand(Value), Legal_Reg | Legal_Imm, true); 4015 Operand *ValueLo = legalize(loOperand(Value), Legal_Reg | Legal_Imm);
4013 _store(ValueHi, llvm::cast<OperandX8632Mem>(hiOperand(NewAddr))); 4016 _store(ValueHi, llvm::cast<OperandX8632Mem>(hiOperand(NewAddr)));
4014 _store(ValueLo, llvm::cast<OperandX8632Mem>(loOperand(NewAddr))); 4017 _store(ValueLo, llvm::cast<OperandX8632Mem>(loOperand(NewAddr)));
4015 } else if (isVectorType(Ty)) { 4018 } else if (isVectorType(Ty)) {
4016 _storep(legalizeToVar(Value), NewAddr); 4019 _storep(legalizeToVar(Value), NewAddr);
4017 } else { 4020 } else {
4018 Value = legalize(Value, Legal_Reg | Legal_Imm, true); 4021 Value = legalize(Value, Legal_Reg | Legal_Imm);
4019 _store(Value, NewAddr); 4022 _store(Value, NewAddr);
4020 } 4023 }
4021 } 4024 }
4022 4025
4023 void TargetX8632::doAddressOptStore() { 4026 void TargetX8632::doAddressOptStore() {
4024 InstStore *Inst = llvm::cast<InstStore>(*Context.getCur()); 4027 InstStore *Inst = llvm::cast<InstStore>(*Context.getCur());
4025 Operand *Data = Inst->getData(); 4028 Operand *Data = Inst->getData();
4026 Operand *Addr = Inst->getAddr(); 4029 Operand *Addr = Inst->getAddr();
4027 Variable *Index = NULL; 4030 Variable *Index = NULL;
4028 uint16_t Shift = 0; 4031 uint16_t Shift = 0;
(...skipping 18 matching lines...) Expand all
4047 void TargetX8632::lowerSwitch(const InstSwitch *Inst) { 4050 void TargetX8632::lowerSwitch(const InstSwitch *Inst) {
4048 // This implements the most naive possible lowering. 4051 // This implements the most naive possible lowering.
4049 // cmp a,val[0]; jeq label[0]; cmp a,val[1]; jeq label[1]; ... jmp default 4052 // cmp a,val[0]; jeq label[0]; cmp a,val[1]; jeq label[1]; ... jmp default
4050 Operand *Src0 = Inst->getComparison(); 4053 Operand *Src0 = Inst->getComparison();
4051 SizeT NumCases = Inst->getNumCases(); 4054 SizeT NumCases = Inst->getNumCases();
4052 // OK, we'll be slightly less naive by forcing Src into a physical 4055 // OK, we'll be slightly less naive by forcing Src into a physical
4053 // register if there are 2 or more uses. 4056 // register if there are 2 or more uses.
4054 if (NumCases >= 2) 4057 if (NumCases >= 2)
4055 Src0 = legalizeToVar(Src0, true); 4058 Src0 = legalizeToVar(Src0, true);
4056 else 4059 else
4057 Src0 = legalize(Src0, Legal_Reg | Legal_Mem, true); 4060 Src0 = legalize(Src0, Legal_Reg | Legal_Mem);
4058 for (SizeT I = 0; I < NumCases; ++I) { 4061 for (SizeT I = 0; I < NumCases; ++I) {
4059 // TODO(stichnot): Correct lowering for IceType_i64. 4062 // TODO(stichnot): Correct lowering for IceType_i64.
4060 Constant *Value = Ctx->getConstantInt32(IceType_i32, Inst->getValue(I)); 4063 Constant *Value = Ctx->getConstantInt32(IceType_i32, Inst->getValue(I));
4061 _cmp(Src0, Value); 4064 _cmp(Src0, Value);
4062 _br(CondX86::Br_e, Inst->getLabel(I)); 4065 _br(CondX86::Br_e, Inst->getLabel(I));
4063 } 4066 }
4064 4067
4065 _br(Inst->getLabelDefault()); 4068 _br(Inst->getLabelDefault());
4066 } 4069 }
4067 4070
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
4202 Variable *Reg = makeReg(Ty, RegNum); 4205 Variable *Reg = makeReg(Ty, RegNum);
4203 if (isVectorType(Ty)) { 4206 if (isVectorType(Ty)) {
4204 _movp(Reg, Src); 4207 _movp(Reg, Src);
4205 } else { 4208 } else {
4206 _mov(Reg, Src); 4209 _mov(Reg, Src);
4207 } 4210 }
4208 return Reg; 4211 return Reg;
4209 } 4212 }
4210 4213
4211 Operand *TargetX8632::legalize(Operand *From, LegalMask Allowed, 4214 Operand *TargetX8632::legalize(Operand *From, LegalMask Allowed,
4212 bool AllowOverlap, int32_t RegNum) { 4215 int32_t RegNum) {
jvoung (off chromium) 2014/09/25 16:42:11 yay +1!
Jim Stichnoth 2014/09/25 18:13:55 Indeed. :)
4213 // Assert that a physical register is allowed. To date, all calls 4216 // Assert that a physical register is allowed. To date, all calls
4214 // to legalize() allow a physical register. If a physical register 4217 // to legalize() allow a physical register. If a physical register
4215 // needs to be explicitly disallowed, then new code will need to be 4218 // needs to be explicitly disallowed, then new code will need to be
4216 // written to force a spill. 4219 // written to force a spill.
4217 assert(Allowed & Legal_Reg); 4220 assert(Allowed & Legal_Reg);
4218 // If we're asking for a specific physical register, make sure we're 4221 // If we're asking for a specific physical register, make sure we're
4219 // not allowing any other operand kinds. (This could be future 4222 // not allowing any other operand kinds. (This could be future
4220 // work, e.g. allow the shl shift amount to be either an immediate 4223 // work, e.g. allow the shl shift amount to be either an immediate
4221 // or in ecx.) 4224 // or in ecx.)
4222 assert(RegNum == Variable::NoRegister || Allowed == Legal_Reg); 4225 assert(RegNum == Variable::NoRegister || Allowed == Legal_Reg);
4223 if (OperandX8632Mem *Mem = llvm::dyn_cast<OperandX8632Mem>(From)) { 4226 if (OperandX8632Mem *Mem = llvm::dyn_cast<OperandX8632Mem>(From)) {
4224 // Before doing anything with a Mem operand, we need to ensure 4227 // Before doing anything with a Mem operand, we need to ensure
4225 // that the Base and Index components are in physical registers. 4228 // that the Base and Index components are in physical registers.
4226 Variable *Base = Mem->getBase(); 4229 Variable *Base = Mem->getBase();
4227 Variable *Index = Mem->getIndex(); 4230 Variable *Index = Mem->getIndex();
4228 Variable *RegBase = NULL; 4231 Variable *RegBase = NULL;
4229 Variable *RegIndex = NULL; 4232 Variable *RegIndex = NULL;
4230 if (Base) { 4233 if (Base) {
4231 RegBase = legalizeToVar(Base, true); 4234 RegBase = legalizeToVar(Base);
4232 } 4235 }
4233 if (Index) { 4236 if (Index) {
4234 RegIndex = legalizeToVar(Index, true); 4237 RegIndex = legalizeToVar(Index);
4235 } 4238 }
4236 if (Base != RegBase || Index != RegIndex) { 4239 if (Base != RegBase || Index != RegIndex) {
4237 From = OperandX8632Mem::create( 4240 From = OperandX8632Mem::create(
4238 Func, Mem->getType(), RegBase, Mem->getOffset(), RegIndex, 4241 Func, Mem->getType(), RegBase, Mem->getOffset(), RegIndex,
4239 Mem->getShift(), Mem->getSegmentRegister()); 4242 Mem->getShift(), Mem->getSegmentRegister());
4240 } 4243 }
4241 4244
4242 if (!(Allowed & Legal_Mem)) { 4245 if (!(Allowed & Legal_Mem)) {
4243 From = copyToReg(From, RegNum); 4246 From = copyToReg(From, RegNum);
4244 } 4247 }
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
4286 // can happen either when the variable is pre-colored or when it is 4289 // can happen either when the variable is pre-colored or when it is
4287 // assigned infinite weight. 4290 // assigned infinite weight.
4288 bool MustHaveRegister = 4291 bool MustHaveRegister =
4289 (Var->hasReg() || Var->getWeight() == RegWeight::Inf); 4292 (Var->hasReg() || Var->getWeight() == RegWeight::Inf);
4290 // We need a new physical register for the operand if: 4293 // We need a new physical register for the operand if:
4291 // Mem is not allowed and Var isn't guaranteed a physical 4294 // Mem is not allowed and Var isn't guaranteed a physical
4292 // register, or 4295 // register, or
4293 // RegNum is required and Var->getRegNum() doesn't match. 4296 // RegNum is required and Var->getRegNum() doesn't match.
4294 if ((!(Allowed & Legal_Mem) && !MustHaveRegister) || 4297 if ((!(Allowed & Legal_Mem) && !MustHaveRegister) ||
4295 (RegNum != Variable::NoRegister && RegNum != Var->getRegNum())) { 4298 (RegNum != Variable::NoRegister && RegNum != Var->getRegNum())) {
4296 Variable *Reg = copyToReg(From, RegNum); 4299 From = copyToReg(From, RegNum);
4297 if (RegNum == Variable::NoRegister) {
4298 Reg->setPreferredRegister(Var, AllowOverlap);
4299 }
4300 From = Reg;
4301 } 4300 }
4302 return From; 4301 return From;
4303 } 4302 }
4304 llvm_unreachable("Unhandled operand kind in legalize()"); 4303 llvm_unreachable("Unhandled operand kind in legalize()");
4305 return From; 4304 return From;
4306 } 4305 }
4307 4306
4308 // Provide a trivial wrapper to legalize() for this common usage. 4307 // Provide a trivial wrapper to legalize() for this common usage.
4309 Variable *TargetX8632::legalizeToVar(Operand *From, bool AllowOverlap, 4308 Variable *TargetX8632::legalizeToVar(Operand *From, int32_t RegNum) {
4310 int32_t RegNum) { 4309 return llvm::cast<Variable>(legalize(From, Legal_Reg, RegNum));
4311 return llvm::cast<Variable>(legalize(From, Legal_Reg, AllowOverlap, RegNum));
4312 } 4310 }
4313 4311
4314 OperandX8632Mem *TargetX8632::FormMemoryOperand(Operand *Operand, Type Ty) { 4312 OperandX8632Mem *TargetX8632::FormMemoryOperand(Operand *Operand, Type Ty) {
4315 OperandX8632Mem *Mem = llvm::dyn_cast<OperandX8632Mem>(Operand); 4313 OperandX8632Mem *Mem = llvm::dyn_cast<OperandX8632Mem>(Operand);
4316 // It may be the case that address mode optimization already creates 4314 // It may be the case that address mode optimization already creates
4317 // an OperandX8632Mem, so in that case it wouldn't need another level 4315 // an OperandX8632Mem, so in that case it wouldn't need another level
4318 // of transformation. 4316 // of transformation.
4319 if (!Mem) { 4317 if (!Mem) {
4320 Variable *Base = llvm::dyn_cast<Variable>(Operand); 4318 Variable *Base = llvm::dyn_cast<Variable>(Operand);
4321 Constant *Offset = llvm::dyn_cast<Constant>(Operand); 4319 Constant *Offset = llvm::dyn_cast<Constant>(Operand);
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
4560 Str << "\t.align\t" << Align << "\n"; 4558 Str << "\t.align\t" << Align << "\n";
4561 Str << MangledName << ":\n"; 4559 Str << MangledName << ":\n";
4562 for (SizeT i = 0; i < Size; ++i) { 4560 for (SizeT i = 0; i < Size; ++i) {
4563 Str << "\t.byte\t" << (((unsigned)Data[i]) & 0xff) << "\n"; 4561 Str << "\t.byte\t" << (((unsigned)Data[i]) & 0xff) << "\n";
4564 } 4562 }
4565 Str << "\t.size\t" << MangledName << ", " << Size << "\n"; 4563 Str << "\t.size\t" << MangledName << ", " << Size << "\n";
4566 } 4564 }
4567 } 4565 }
4568 4566
4569 } // end of namespace Ice 4567 } // end of namespace Ice
OLDNEW
« src/IceRegAlloc.cpp ('K') | « src/IceTargetLoweringX8632.h ('k') | src/llvm2ice.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698